-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Trained Models: Count tests run against trained models #212927
base: main
Are you sure you want to change the base?
[ML] Trained Models: Count tests run against trained models #212927
Conversation
Pinging @elastic/ml-ui (:ml) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR adds UI counters to track the number of tests run against trained models (both success and failure) by updating usage events and passing the MlUsageCollection dependency to various inference modules.
- Added new ML usage event constants for test events in the constants file.
- Updated the inference classes and their constructors to accept and use MlUsageCollection.
- Modified UI components and service hooks to supply the new dependency to model inference instances.
Reviewed Changes
File | Description |
---|---|
x-pack/platform/plugins/shared/ml/common/constants/usage_collection.ts | Adds new usage event constants for test counters. |
x-pack/platform/plugins/shared/ml/public/application/model_management/test_models/models/inference_base.ts | Updates runInfer method to count test events using mlUsageCollection. |
x-pack/platform/plugins/shared/ml/public/application/services/usage_collection.ts | Exports the MlUsageCollection type to support dependency injection. |
x-pack/platform/plugins/shared/ml/public/application/model_management/test_models/selected_model.tsx | Retrieves and passes mlUsageCollection to the inference model constructors. |
Other inference modules (ner, text classification, lang ident, text embedding, question answering, zero shot, text expansion, fill mask) | Their constructors are updated to receive mlUsageCollection and pass it to the superclass. |
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
x-pack/platform/plugins/shared/ml/common/constants/usage_collection.ts:15
- [nitpick] The constant name is plural (TESTED_TRAINED_MODELS) but its value is singular ('tested_trained_model'); consider aligning these for consistency.
TESTED_TRAINED_MODELS: 'tested_trained_model',
x-pack/platform/plugins/shared/ml/public/application/model_management/test_models/models/inference_base.ts:317
- Instead of using hardcoded event strings, consider using the defined constants (e.g., ML_USAGE_EVENT.TESTED_TRAINED_MODELS) to ensure consistency across the codebase.
this.mlUsageCollection.count('tested_trained_model');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR integrates UI counters for tracking the number of tests run against trained models by adding new usage event constants and wiring up usage collection calls into the inference workflows.
- Added two new usage event constants (“tested_trained_model” and “test_failed_trained_model”) to support tracking the tests.
- Injected and utilized the mlUsageCollection dependency into various inference models to record UI counter events on success and error paths.
- Updated the usage collection service to export a type for mlUsageCollection, ensuring type consistency across the plugin.
Reviewed Changes
File | Description |
---|---|
x-pack/platform/plugins/shared/ml/common/constants/usage_collection.ts | Added new usage event constants for tracking trained model tests. |
x-pack/platform/plugins/shared/ml/public/application/model_management/test_models/models/inference_base.ts | Integrated mlUsageCollection counting in the runInfer method for both success and failure scenarios. |
x-pack/platform/plugins/shared/ml/public/application/services/usage_collection.ts | Exported the MlUsageCollection type from the usage collection provider. |
x-pack/platform/plugins/shared/ml/public/application/model_management/test_models/selected_model.tsx | Updated usage context extraction and passed mlUsageCollection to inference model constructors. |
Other model files (text_embedding, ner, text_classification, lang_ident, question_answering, zero_shot_classification, text_expansion, fill_mask) | Updated constructors to accept the mlUsageCollection dependency and pass it on to their super class. |
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
@@ -84,7 +85,8 @@ export abstract class InferenceBase<TInferResponse> { | |||
protected readonly trainedModelsApi: ReturnType<typeof trainedModelsApiProvider>, | |||
protected readonly model: estypes.MlTrainedModelConfig, | |||
protected readonly inputType: INPUT_TYPE, | |||
protected readonly deploymentId: string | |||
protected readonly deploymentId: string, | |||
protected readonly mlUsageCollection: MlUsageCollection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't used in any of the derived classes and so could be private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 5704fb9
@@ -312,6 +314,8 @@ export abstract class InferenceBase<TInferResponse> { | |||
DEFAULT_INFERENCE_TIME_OUT | |||
)) as unknown as TRawInferResponse; | |||
|
|||
this.mlUsageCollection.count('tested_trained_model'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it's good to have counts for when testing has been performed. I think it would be a lot more valuable to also track additional information, such as the model type and pytorch task type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we need event-based telemetry for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After short discussion with @peteharverson, we agreed to collect EBT events with all relevant data, updated in: 5704fb9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
Page load bundle
History
cc @rbrtj |
Part of: #200725
This PR adds UI Counters for tests (success and failed) run against trained models.