-
Notifications
You must be signed in to change notification settings - Fork 55
ODSC 68580- Update Evaluation SDK to Support Multi-Model Deployment #1085
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
Merged
elizjo
merged 4 commits into
feature/multi_model_deployment
from
ODSC-68580-2/multi_model_deployment
Feb 26, 2025
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
Tags, | ||
) | ||
from ads.aqua.common.errors import ( | ||
AquaError, | ||
AquaFileExistsError, | ||
AquaFileNotFoundError, | ||
AquaMissingKeyError, | ||
|
@@ -75,6 +76,7 @@ | |
CreateAquaEvaluationDetails, | ||
) | ||
from ads.aqua.evaluation.errors import EVALUATION_JOB_EXIT_CODE_MESSAGE | ||
from ads.aqua.model.constants import ModelCustomMetadataFields | ||
from ads.aqua.ui import AquaContainerConfig | ||
from ads.common.auth import default_signer | ||
from ads.common.object_storage_details import ObjectStorageDetails | ||
|
@@ -183,6 +185,26 @@ def create( | |
evaluation_source = ModelDeployment.from_id( | ||
create_aqua_evaluation_details.evaluation_source_id | ||
) | ||
try: | ||
if Tags.MULTIMODEL_TYPE_TAG in evaluation_source.freeform_tags: | ||
multi_model_id = evaluation_source.freeform_tags.get( | ||
Tags.AQUA_MODEL_ID_TAG, UNKNOWN | ||
) | ||
|
||
if not multi_model_id: | ||
raise AquaRuntimeError( | ||
f"Invalid multi model deployment {multi_model_id}." | ||
f"Make sure the {Tags.AQUA_MODEL_ID_TAG} tag is added to the deployment." | ||
) | ||
|
||
aqua_model = DataScienceModel.from_id(multi_model_id) | ||
AquaEvaluationApp.validate_model_name( | ||
aqua_model, create_aqua_evaluation_details | ||
) | ||
|
||
except AquaError as err: | ||
raise AquaValueError(f"{err}") from err | ||
|
||
try: | ||
if ( | ||
evaluation_source.runtime.type | ||
|
@@ -550,6 +572,63 @@ def create( | |
parameters=AquaEvalParams(), | ||
) | ||
|
||
@staticmethod | ||
def validate_model_name( | ||
evaluation_source: DataScienceModel, | ||
create_aqua_evaluation_details: CreateAquaEvaluationDetails, | ||
) -> None: | ||
""" | ||
Validates the user input of the model name when creating an Aqua evaluation. | ||
|
||
Parameters | ||
---------- | ||
evaluation_source: DataScienceModel | ||
The DataScienceModel Object which contains all metadata | ||
about each model in a single and multi model deployment. | ||
create_aqua_evaluation_details: CreateAquaEvaluationDetails | ||
The CreateAquaEvaluationDetails data class which contains all | ||
required and optional fields to create the aqua evaluation. | ||
|
||
Raises | ||
------- | ||
AquaValueError: | ||
- When the user fails to specify any input for the model name. | ||
- When the user supplies a model name that does not match the model name set in the DataScienceModel metadata.""" | ||
user_model_parameters = create_aqua_evaluation_details.model_parameters | ||
|
||
custom_metadata_list = evaluation_source.custom_metadata_list | ||
user_model_name = user_model_parameters.get("model") | ||
|
||
model_group_count = int( | ||
custom_metadata_list.get( | ||
ModelCustomMetadataFields.MULTIMODEL_GROUP_COUNT | ||
).value | ||
) | ||
|
||
model_names = [ | ||
custom_metadata_list.get(f"model-name-{idx}").value | ||
for idx in range(model_group_count) | ||
] | ||
|
||
valid_model_names = ", ".join(map(str, model_names)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes- I changed it now to not include None values |
||
|
||
if "model" not in user_model_parameters: | ||
logger.debug( | ||
f"User did not input model name for multi model deployment evaluation with evaluation source ID: {create_aqua_evaluation_details.evaluation_source_id}" | ||
) | ||
raise AquaValueError( | ||
f"Provide the model name. For evaluation, a single model needs to be targeted using the name in the multi model deployment. The valid model names for this Model Deployment are {valid_model_names}." | ||
) | ||
|
||
if user_model_name not in model_names: | ||
|
||
logger.debug( | ||
f"User input for model name was {user_model_name}, expected {valid_model_names} evaluation source ID: {create_aqua_evaluation_details.evaluation_source_id}" | ||
) | ||
raise AquaValueError( | ||
f"Provide the correct model name. The valid model names for this Model Deployment are {valid_model_names}." | ||
) | ||
|
||
def _build_evaluation_runtime( | ||
self, | ||
evaluation_id: str, | ||
|
@@ -1392,7 +1471,7 @@ def _fetch_jobrun( | |
) | ||
except Exception as e: | ||
logger.debug( | ||
f"Failed to retreive job run: {jobrun_id}. " f"DEBUG INFO: {str(e)}" | ||
f"Failed to retreive job run: {jobrun_id}. DEBUG INFO: {str(e)}" | ||
) | ||
jobrun = None | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Wouldn't this fail if
ModelCustomMetadataFields.MULTIMODEL_GROUP_COUNT
is missing from the custom metadata?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.
corrected