Add created_by field to ML resources for adoption metrics attribution#4754
Add created_by field to ML resources for adoption metrics attribution#4754dbwiddis wants to merge 9 commits intoopensearch-project:mainfrom
Conversation
PR Reviewer Guide 🔍(Review updated until commit e85bb6f)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to e85bb6f Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 31fb021
Suggestions up to commit 6b67eec
Suggestions up to commit ae4ea18
Suggestions up to commit a6d4005
Suggestions up to commit 7bf11f7
|
|
Persistent review updated to latest commit 7bf11f7 |
|
Persistent review updated to latest commit a6d4005 |
|
Persistent review updated to latest commit 31fb021 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4754 +/- ##
============================================
+ Coverage 77.36% 77.38% +0.02%
- Complexity 11895 11922 +27
============================================
Files 963 963
Lines 53304 53370 +66
Branches 6500 6520 +20
============================================
+ Hits 41240 41303 +63
- Misses 9304 9311 +7
+ Partials 2760 2756 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Adds an optional `created_by` field to MLAgent to allow plugins using the ML Client API (e.g. flow-framework) to attribute provisioned agents for adoption metrics tracking. - Add VERSION_3_6_0 and VERSION_3_7_0 constants to CommonValue - Add `created_by` field to MLAgent with version-gated serialization - Emit `created_by` tag in getTags() defaulting to "unknown" when null - Validate `created_by` in MLRegisterAgentRequest using SAFE_INPUT_PATTERN - Update all affected test files Signed-off-by: Daniel Widdis <widdis@gmail.com>
Adds an optional `created_by` field to HttpConnector, AwsConnector, AbstractConnector, the Connector interface, and MLCreateConnectorInput to allow plugins using the ML Client API to attribute provisioned connectors for adoption metrics tracking. - Add `created_by` to Connector interface (getter/setter) - Add `created_by` field to AbstractConnector via @Setter - Add `created_by` to HttpConnector builder, XContent parse/write, and version-gated stream serialization (VERSION_3_7_0) - Add `created_by` to AwsConnector builder, delegating to HttpConnector - Add `created_by` to MLCreateConnectorInput builder, XContent parse/write, and version-gated stream serialization (VERSION_3_7_0) Signed-off-by: Daniel Widdis <widdis@gmail.com>
Adds an optional `created_by` field to MLModel and MLRegisterModelInput to allow plugins using the ML Client API to attribute provisioned models for adoption metrics tracking. - Add CREATED_BY_FIELD constant and field to MLModel with toXContent, parse, and version-gated stream serialization (VERSION_3_7_0) - Add CREATED_BY_FIELD constant and field to MLRegisterModelInput with toXContent, both parse overloads, and version-gated stream serialization (VERSION_3_7_0) Signed-off-by: Daniel Widdis <widdis@gmail.com>
Add created_by to the Tags returned by getRemoteModelTags, getPreTrainedModelTags, and getCustomModelTags. Defaults to 'unknown' when createdBy is null, consistent with MLAgent. Signed-off-by: Daniel Widdis <widdis@gmail.com>
Consistent with MLRegisterAgentRequest, validate created_by as an optional safe-text field in MLCreateConnectorRequest and MLRegisterModelRequest. Signed-off-by: Daniel Widdis <widdis@gmail.com>
…n and tenantId - Centralize CREATED_BY_FIELD constant in CommonValue; remove duplicate definitions from MLAgent, MLModel, HttpConnector, MLCreateConnectorInput, and MLRegisterModelInput - Add created_by validation to MLUpdateConnectorRequest (was missing alongside MLCreateConnectorRequest) - Use human-readable labels for created_by validation across all four request classes - Fix missing tenantId in registerModelFromUrl MLModel builder in MLModelManager Signed-off-by: Daniel Widdis <widdis@gmail.com>
- MachineLearningNodeClientTest: add happy path tests verifying createdBy is passed through for registerAgent, register, and createConnector - MLRegisterAgentRequestTest: add validate_ValidCreatedBy and validate_InvalidCreatedBy - MLCreateConnectorRequestTests: add validateWithValidCreatedBy and validateWithInvalidCreatedBy - MLRegisterModelRequestTest: add validate_ValidCreatedBy and validate_InvalidCreatedBy Signed-off-by: Daniel Widdis <widdis@gmail.com>
…ror merge bug created_by is set at creation time only and is not merged by HttpConnector.update(), so validating it on update was misleading. Also fix a pre-existing bug where exception = validateFields(...) would silently discard any prior connectorId null error; now merges field errors into the existing exception via addValidationError. Signed-off-by: Daniel Widdis <widdis@gmail.com>
…d field invalid Signed-off-by: Daniel Widdis <widdis@gmail.com>
|
Persistent review updated to latest commit e85bb6f |
Description
Adds a
created_byfield to ML agents, connectors, and models to enableattribution of adoption metrics by the client that created the resource
(e.g.
flow-framework,opensearch-dashboards).This is distinct from the authenticated user (
User/FGAC) —created_byidentifies the calling client, which may differ from the user when a
workflow engine like Flow Framework creates resources on behalf of a user.
Data model
MLAgent: newcreated_byfield, version-gated serialization atVERSION_3_7_0, emitted ingetTags()(defaults to"unknown")Connector/AbstractConnector/HttpConnector:new
created_byfield, version-gated serialization atVERSION_3_7_0MLCreateConnectorInput: newcreated_byfield, flows through toconnector via XContent round-trip in
TransportCreateConnectorActionMLModel: newcreated_byfield, version-gated serialization atVERSION_3_7_0, emitted in all threegetTags()methods(
getRemoteModelTags,getPreTrainedModelTags,getCustomModelTags),defaults to
"unknown"MLRegisterModelInput: newcreated_byfield, wired through toMLModelinMLModelManager(all three builder sites, includingthe previously missing
tenantIdfix inregisterModelFromUrl)Validation
MLRegisterAgentRequest: validatescreated_byas optional safe-textfield; restructured
validate()to seed exception fromvalidateFieldsand eliminate manual error-merging loop
MLCreateConnectorRequest: validatescreated_byas optional safe-text fieldMLRegisterModelRequest: validatescreated_byas optional safe-text fieldMLUpdateConnectorRequest:created_byis intentionally not validatedhere — it is set at creation time only and is not merged by
HttpConnector.update(); also fixed a pre-existing bug wherevalidateFieldsresult overwrote any priorconnectorIdnull errorMetrics
MLStatsJobProcessorrequires no changes —created_byflows throughautomatically via
model.getTags()andagent.getTags()Versioning
CommonValue: addedVERSION_3_7_0constant;VERSION_3_6_0wasconsidered but removed as unused in production code — tests use the
existing
VERSION_3_5_0constant to represent a pre-created_bynodedeserialize
created_byasnullCREATED_BY_FIELDconstant centralized inCommonValue; duplicatelocal definitions removed from
MLAgent,MLModel,HttpConnector,MLCreateConnectorInput, andMLRegisterModelInputTesting
VERSION_3_7_0and
VERSION_3_5_0), XContent parse/write, andgetTags()emissionfor all three resource types
createdBytests added toMachineLearningNodeClientTestverifying the field is passed through for
registerAgent,register(Model),and
createConnectorMLRegisterAgentRequestTest,MLCreateConnectorRequestTests, andMLRegisterModelRequestTestRelated Issues
Resolves #4752
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.