diff options
author | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
---|---|---|
committer | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
commit | 4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch) | |
tree | ee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/azure/ai/ml/_internal/entities/code.py | |
parent | cc961e04ba734dd72309fb548a2f97d67d578813 (diff) | |
download | gn-ai-master.tar.gz |
Diffstat (limited to '.venv/lib/python3.12/site-packages/azure/ai/ml/_internal/entities/code.py')
-rw-r--r-- | .venv/lib/python3.12/site-packages/azure/ai/ml/_internal/entities/code.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_internal/entities/code.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_internal/entities/code.py new file mode 100644 index 00000000..d4437663 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_internal/entities/code.py @@ -0,0 +1,35 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- +from typing import Optional + +from ...entities._assets import Code + + +class InternalCode(Code): + @property + def _upload_hash(self) -> Optional[str]: + # This property will be used to identify the uploaded content when trying to + # upload to datastore. The tracebacks will be as below: + # Traceback (most recent call last): + # _artifact_utilities._check_and_upload_path + # _artifact_utilities._upload_to_datastore + # _artifact_utilities.upload_artifact + # _blob_storage_helper.upload + # where asset id will be calculated based on the upload hash. + + if self._is_anonymous is True: + # Name of an anonymous internal code is the same as its snapshot id + # in ml-component, use it as the upload hash to avoid duplicate hash + # calculation with _asset_utils.get_object_hash. + return self.name + + return getattr(super(InternalCode, self), "_upload_hash") + + def __setattr__(self, key, value): + if key == "name" and hasattr(self, key) and self._is_anonymous is True and value != self.name: + raise AttributeError( + "InternalCode name are calculated based on its content and cannot " + "be changed: current name is {} and new value is {}".format(self.name, value) + ) + super().__setattr__(key, value) |