Skip to content

Commit f917ee7

Browse files
Updating has_artifact field in ADS
1 parent ead6753 commit f917ee7

File tree

12 files changed

+51
-51
lines changed

12 files changed

+51
-51
lines changed

ads/aqua/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
is_valid_ocid,
2222
load_config,
2323
)
24-
from ads.aqua.constants import UNKNOWN
24+
2525
from ads.common import oci_client as oc
2626
from ads.common.auth import default_signer
27-
from ads.common.utils import extract_region, is_path_exists
27+
from ads.common.utils import extract_region, is_path_exists , UNKNOWN
2828
from ads.config import (
2929
AQUA_TELEMETRY_BUCKET,
3030
AQUA_TELEMETRY_BUCKET_NS,

ads/aqua/common/utils.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,19 @@
5858
SUPPORTED_FILE_FORMATS,
5959
TEI_CONTAINER_DEFAULT_HOST,
6060
TGI_INFERENCE_RESTRICTED_PARAMS,
61-
UNKNOWN,
6261
UNKNOWN_JSON_STR,
6362
VLLM_INFERENCE_RESTRICTED_PARAMS,
6463
)
64+
65+
from ads.common.utils import UNKNOWN
66+
6567
from ads.aqua.data import AquaResourceIdentifier
6668
from ads.common.auth import AuthState, default_signer
6769
from ads.common.decorator.threaded import threaded
6870
from ads.common.extended_enum import ExtendedEnum
6971
from ads.common.object_storage_details import ObjectStorageDetails
7072
from ads.common.oci_resource import SEARCH_TYPE, OCIResource
71-
from ads.common.utils import copy_file, get_console_link, upload_to_os
73+
from ads.common.utils import copy_file, get_console_link, upload_to_os, read_file
7274
from ads.config import (
7375
AQUA_MODEL_DEPLOYMENT_FOLDER,
7476
AQUA_SERVICE_MODELS_BUCKET,
@@ -228,15 +230,6 @@ def get_artifact_path(custom_metadata_list: List) -> str:
228230
return UNKNOWN
229231

230232

231-
def read_file(file_path: str, **kwargs) -> str:
232-
try:
233-
with fsspec.open(file_path, "r", **kwargs.get("auth", {})) as f:
234-
return f.read()
235-
except Exception as e:
236-
logger.debug(f"Failed to read file {file_path}. {e}")
237-
return UNKNOWN
238-
239-
240233
@threaded()
241234
def load_config(file_path: str, config_file_name: str, **kwargs) -> dict:
242235
artifact_path = f"{file_path.rstrip('/')}/{config_file_name}"

ads/aqua/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
44
"""This module defines constants used in ads.aqua module."""
55

6-
UNKNOWN = ""
6+
77
UNKNOWN_VALUE = ""
88
READY_TO_IMPORT_STATUS = "TRUE"
99
UNKNOWN_DICT = {}

ads/aqua/evaluation/evaluation.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@
5252
EVALUATION_REPORT_MD,
5353
JOB_INFRASTRUCTURE_TYPE_DEFAULT_NETWORKING,
5454
LIFECYCLE_DETAILS_MISSING_JOBRUN,
55-
NB_SESSION_IDENTIFIER,
56-
UNKNOWN,
55+
NB_SESSION_IDENTIFIER
5756
)
5857
from ads.aqua.evaluation.constants import (
5958
EVAL_TERMINATION_STATE,
@@ -78,7 +77,7 @@
7877
from ads.aqua.ui import AquaContainerConfig
7978
from ads.common.auth import default_signer
8079
from ads.common.object_storage_details import ObjectStorageDetails
81-
from ads.common.utils import get_console_link, get_files, get_log_links
80+
from ads.common.utils import get_console_link, get_files, get_log_links , UNKNOWN
8281
from ads.config import (
8382
AQUA_JOB_SUBNET_ID,
8483
COMPARTMENT_OCID,

ads/aqua/finetuning/finetuning.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
DEFAULT_FT_REPLICA,
3131
DEFAULT_FT_VALIDATION_SET_SIZE,
3232
JOB_INFRASTRUCTURE_TYPE_DEFAULT_NETWORKING,
33-
UNKNOWN,
3433
UNKNOWN_DICT,
3534
)
3635
from ads.aqua.data import AquaResourceIdentifier
@@ -45,7 +44,7 @@
4544
)
4645
from ads.common.auth import default_signer
4746
from ads.common.object_storage_details import ObjectStorageDetails
48-
from ads.common.utils import get_console_link
47+
from ads.common.utils import get_console_link , UNKNOWN
4948
from ads.config import (
5049
AQUA_FINETUNING_CONTAINER_OVERRIDE_FLAG_METADATA_NAME,
5150
AQUA_JOB_SUBNET_ID,

ads/aqua/model/model.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
READY_TO_IMPORT_STATUS,
5757
TRAINING_METRICS_FINAL,
5858
TRINING_METRICS,
59-
UNKNOWN,
6059
VALIDATION_METRICS,
6160
VALIDATION_METRICS_FINAL,
6261
)
@@ -79,7 +78,7 @@
7978
from ads.aqua.ui import AquaContainerConfig, AquaContainerConfigItem
8079
from ads.common.auth import default_signer
8180
from ads.common.oci_resource import SEARCH_TYPE, OCIResource
82-
from ads.common.utils import get_console_link
81+
from ads.common.utils import get_console_link , UNKNOWN
8382
from ads.config import (
8483
AQUA_DEPLOYMENT_CONTAINER_CMD_VAR_METADATA_NAME,
8584
AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME,

ads/aqua/modeldeployment/deployment.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
AQUA_MODEL_TYPE_CUSTOM,
3131
AQUA_MODEL_TYPE_SERVICE,
3232
MODEL_BY_REFERENCE_OSS_PATH_KEY,
33-
UNKNOWN,
3433
UNKNOWN_DICT,
3534
)
3635
from ads.aqua.data import AquaResourceIdentifier
@@ -42,7 +41,7 @@
4241
)
4342
from ads.aqua.ui import ModelFormat
4443
from ads.common.object_storage_details import ObjectStorageDetails
45-
from ads.common.utils import get_log_links
44+
from ads.common.utils import get_log_links , UNKNOWN
4645
from ads.config import (
4746
AQUA_DEPLOYMENT_CONTAINER_CMD_VAR_METADATA_NAME,
4847
AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME,

ads/aqua/modeldeployment/entities.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
)
1212

1313
from ads.aqua.common.enums import Tags
14-
from ads.aqua.constants import UNKNOWN, UNKNOWN_DICT
14+
from ads.aqua.constants import UNKNOWN_DICT
1515
from ads.aqua.data import AquaResourceIdentifier
1616
from ads.common.serializer import DataClassSerializable
17-
from ads.common.utils import get_console_link
17+
from ads.common.utils import get_console_link , UNKNOWN
1818

1919

2020
@dataclass

ads/common/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
# Maximum distinct values by cardinality will be used for plotting
6565
MAX_DISPLAY_VALUES = 10
6666

67+
UNKNOWN = ""
68+
6769
# par link of the index json file.
6870
PAR_LINK = "https://objectstorage.us-ashburn-1.oraclecloud.com/p/WyjtfVIG0uda-P3-2FmAfwaLlXYQZbvPZmfX1qg0-sbkwEQO6jpwabGr2hMDBmBp/n/ociodscdev/b/service-conda-packs/o/service_pack/index.json"
6971

@@ -236,6 +238,13 @@ def random_valid_ocid(prefix="ocid1.dataflowapplication.oc1.iad"):
236238
fake = "".join([random.choice(string.ascii_lowercase) for i in range(60)])
237239
return f"{left}.{fake}"
238240

241+
def read_file(file_path: str, **kwargs) -> str:
242+
try:
243+
with fsspec.open(file_path, "r", **kwargs.get("auth", {})) as f:
244+
return f.read()
245+
except Exception as e:
246+
logger.debug(f"Failed to read file {file_path}. {e}")
247+
return UNKNOWN
239248

240249
def get_dataframe_styles(max_width=75):
241250
"""Styles used for dataframe, example usage:

ads/model/datascience_model.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,7 +2233,7 @@ def create_custom_metadata_artifact(
22332233
self,
22342234
metadata_key_name: str,
22352235
artifact_path_or_content: str,
2236-
path_type: str = utils.MetadataArtifactPathType.LOCAL,
2236+
path_type: utils.MetadataArtifactPathType = utils.MetadataArtifactPathType.LOCAL,
22372237
) -> ModelMetadataArtifactDetails:
22382238
"""Creates model custom metadata artifact for specified model.
22392239
@@ -2245,7 +2245,7 @@ def create_custom_metadata_artifact(
22452245
artifact_path_or_content: str
22462246
The model custom metadata artifact path to be upload. It can also be the actual content of the custom metadata
22472247
2248-
path_type: str
2248+
path_type: utils.MetadataArtifactPathType
22492249
Can be either of utils.MetadataArtifactPathType.LOCAL , utils.MetadataArtifactPathType.OSS , utils.MetadataArtifactPathType.CONTENT
22502250
Specifies what type of path is to be provided for metadata artifact.
22512251
Can be either local , oss or the actual content itself
@@ -2277,7 +2277,7 @@ def create_defined_metadata_artifact(
22772277
self,
22782278
metadata_key_name: str,
22792279
artifact_path_or_content: str,
2280-
path_type: str = utils.MetadataArtifactPathType.LOCAL,
2280+
path_type: utils.MetadataArtifactPathType = utils.MetadataArtifactPathType.LOCAL,
22812281
) -> ModelMetadataArtifactDetails:
22822282
"""Creates model defined metadata artifact for specified model.
22832283
@@ -2289,7 +2289,7 @@ def create_defined_metadata_artifact(
22892289
artifact_path_or_content: str
22902290
The model defined metadata artifact path to be upload. It can also be the actual content of the defined metadata
22912291
2292-
path_type: str
2292+
path_type: utils.MetadataArtifactPathType
22932293
Can be either of utils.MetadataArtifactPathType.LOCAL , utils.MetadataArtifactPathType.OSS , utils.MetadataArtifactPathType.CONTENT
22942294
Specifies what type of path is to be provided for metadata artifact.
22952295
Can be either local , oss or the actual content itself
@@ -2320,7 +2320,7 @@ def update_custom_metadata_artifact(
23202320
self,
23212321
metadata_key_name: str,
23222322
artifact_path_or_content: str,
2323-
path_type: str = utils.MetadataArtifactPathType.LOCAL,
2323+
path_type: utils.MetadataArtifactPathType = utils.MetadataArtifactPathType.LOCAL,
23242324
) -> ModelMetadataArtifactDetails:
23252325
"""Update model custom metadata artifact for specified model.
23262326
@@ -2332,7 +2332,7 @@ def update_custom_metadata_artifact(
23322332
artifact_path_or_content: str
23332333
The model custom metadata artifact path. It can also be the actual content of the custom metadata
23342334
2335-
path_type: str
2335+
path_type: utils.MetadataArtifactPathType
23362336
Can be either of utils.MetadataArtifactPathType.LOCAL , utils.MetadataArtifactPathType.OSS , utils.MetadataArtifactPathType.CONTENT
23372337
Specifies what type of path is to be provided for metadata artifact.
23382338
Can be either local , oss or the actual content itself
@@ -2364,7 +2364,7 @@ def update_defined_metadata_artifact(
23642364
self,
23652365
metadata_key_name: str,
23662366
artifact_path_or_content: str,
2367-
path_type: str = utils.MetadataArtifactPathType.LOCAL,
2367+
path_type: utils.MetadataArtifactPathType = utils.MetadataArtifactPathType.LOCAL,
23682368
) -> ModelMetadataArtifactDetails:
23692369
"""Update model defined metadata artifact for specified model.
23702370
@@ -2376,7 +2376,7 @@ def update_defined_metadata_artifact(
23762376
artifact_path_or_content: str
23772377
The model defined metadata artifact path. It can also be the actual content of the defined metadata
23782378
2379-
path_type: str
2379+
path_type: utils.MetadataArtifactPathType
23802380
Can be either of utils.MetadataArtifactPathType.LOCAL , utils.MetadataArtifactPathType.OSS , utils.MetadataArtifactPathType.CONTENT
23812381
Specifies what type of path is to be provided for metadata artifact.
23822382
Can be either local , oss or the actual content itself
@@ -2437,7 +2437,7 @@ def get_custom_metadata_artifact(
24372437

24382438
with open(artifact_file_path, "wb") as _file:
24392439
_file.write(file_content)
2440-
logger.info(f"Artifact downloaded to location - {artifact_file_path}")
2440+
logger.debug(f"Artifact downloaded to location - {artifact_file_path}")
24412441

24422442
def get_defined_metadata_artifact(
24432443
self, metadata_key_name: str, target_dir: str, override: bool = False
@@ -2472,7 +2472,7 @@ def get_defined_metadata_artifact(
24722472

24732473
with open(artifact_file_path, "wb") as _file:
24742474
_file.write(file_content)
2475-
logger.info(f"Artifact downloaded to location - {artifact_file_path}")
2475+
logger.debug(f"Artifact downloaded to location - {artifact_file_path}")
24762476

24772477
def delete_custom_metadata_artifact(
24782478
self, metadata_key_name: str

0 commit comments

Comments
 (0)