8
8
from typing import Dict , List , Optional , Union
9
9
10
10
from cachetools import TTLCache , cached
11
- from ads .aqua .modeldeployment .constants import DEFAULT_POLL_INTERVAL , DEFAULT_WAIT_TIME
12
- from ads .common .decorator .threaded import threaded
13
- from ads .common .work_request import DataScienceWorkRequest
14
11
from oci .data_science .models import ModelDeploymentShapeSummary
15
12
from pydantic import ValidationError
16
13
49
46
AQUA_MULTI_MODEL_CONFIG ,
50
47
MODEL_BY_REFERENCE_OSS_PATH_KEY ,
51
48
MODEL_NAME_DELIMITER ,
52
- UNKNOWN_DICT
49
+ UNKNOWN_DICT ,
53
50
)
54
-
55
51
from ads .aqua .data import AquaResourceIdentifier
56
52
from ads .aqua .model import AquaModelApp
57
53
from ads .aqua .model .constants import AquaModelMetadataKeys , ModelCustomMetadataFields
58
54
from ads .aqua .model .utils import (
59
55
extract_base_model_from_ft ,
60
56
extract_fine_tune_artifacts_path ,
61
57
)
58
+ from ads .aqua .modeldeployment .constants import DEFAULT_POLL_INTERVAL , DEFAULT_WAIT_TIME
62
59
from ads .aqua .modeldeployment .entities import (
63
60
AquaDeployment ,
64
61
AquaDeploymentConfig ,
69
66
ModelDeploymentConfigSummary ,
70
67
)
71
68
from ads .aqua .modeldeployment .utils import MultiModelDeploymentConfigLoader
69
+ from ads .common .decorator .threaded import thread_pool
72
70
from ads .common .object_storage_details import ObjectStorageDetails
73
71
from ads .common .utils import UNKNOWN , get_log_links
72
+ from ads .common .work_request import DataScienceWorkRequest
74
73
from ads .config import (
75
74
AQUA_DEPLOYMENT_CONTAINER_CMD_VAR_METADATA_NAME ,
76
75
AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME ,
85
84
ModelDeploymentInfrastructure ,
86
85
ModelDeploymentMode ,
87
86
)
88
-
89
87
from ads .model .model_metadata import ModelCustomMetadataItem
90
88
from ads .telemetry import telemetry
91
- from ads . common . decorator . threaded import thread_pool
89
+
92
90
93
91
class AquaDeploymentApp (AquaApp ):
94
92
"""Provides a suite of APIs to interact with Aqua model deployments within the Oracle
@@ -795,11 +793,13 @@ def _create_deployment(
795
793
logger .info (
796
794
f"Aqua model deployment { deployment_id } created for model { aqua_model_id } . Work request Id is { deployment .dsc_model_deployment .workflow_req_id } "
797
795
)
798
-
799
- thread_pool .submit ( self .get_deployment_status ,
800
- deployment_id ,
796
+
797
+ thread_pool .submit (
798
+ self .get_deployment_status ,
799
+ deployment_id ,
801
800
deployment .dsc_model_deployment .workflow_req_id ,
802
- model_type )
801
+ model_type ,
802
+ )
803
803
804
804
# we arbitrarily choose last 8 characters of OCID to identify MD in telemetry
805
805
telemetry_kwargs = {"ocid" : get_ocid_substring (deployment_id , key_len = 8 )}
@@ -1324,12 +1324,14 @@ def list_shapes(self, **kwargs) -> List[ComputeShapeSummary]:
1324
1324
for oci_shape in oci_shapes
1325
1325
]
1326
1326
1327
- def get_deployment_status (self ,model_deployment_id : str , work_request_id : str , model_type : str ) -> None :
1327
+ def get_deployment_status (
1328
+ self , model_deployment_id : str , work_request_id : str , model_type : str
1329
+ ) -> None :
1328
1330
"""Waits for the data science model deployment to be completed and log its status in telemetry.
1329
1331
1330
1332
Parameters
1331
1333
----------
1332
-
1334
+
1333
1335
model_deployment_id: str
1334
1336
The id of the deployed aqua model.
1335
1337
work_request_id: str
@@ -1342,29 +1344,33 @@ def get_deployment_status(self,model_deployment_id: str, work_request_id : str,
1342
1344
AquaDeployment
1343
1345
An Aqua deployment instance.
1344
1346
"""
1345
- telemetry_kwargs = {"ocid" : get_ocid_substring (model_deployment_id , key_len = 8 )}
1347
+ ocid = get_ocid_substring (model_deployment_id , key_len = 8 )
1348
+ telemetry_kwargs = {"ocid" : ocid }
1349
+
1350
+ data_science_work_request : DataScienceWorkRequest = DataScienceWorkRequest (
1351
+ work_request_id
1352
+ )
1346
1353
1347
- data_science_work_request :DataScienceWorkRequest = DataScienceWorkRequest (work_request_id )
1348
-
1349
1354
try :
1350
1355
data_science_work_request .wait_work_request (
1351
1356
progress_bar_description = "Creating model deployment" ,
1352
- max_wait_time = DEFAULT_WAIT_TIME ,
1353
- poll_interval = DEFAULT_POLL_INTERVAL
1357
+ max_wait_time = DEFAULT_WAIT_TIME ,
1358
+ poll_interval = DEFAULT_POLL_INTERVAL ,
1354
1359
)
1355
1360
except Exception as e :
1356
- logger .error (
1357
- "Error while trying to create model deployment: " + str (e )
1358
- )
1361
+ logger .error ("Error while trying to create model deployment: " + str (e ))
1362
+ print ("Error while trying to create model deployment: " + str (e ))
1359
1363
self .telemetry .record_event_async (
1360
1364
category = f"aqua/{ model_type } /deployment/status" ,
1361
1365
action = "FAILED" ,
1362
- detail = data_science_work_request ._error_message
1363
- ** telemetry_kwargs
1366
+ detail = data_science_work_request ._error_message ,
1367
+ value = ocid ,
1368
+ ** telemetry_kwargs ,
1364
1369
)
1365
- else :
1370
+ else :
1366
1371
self .telemetry .record_event_async (
1367
- category = f"aqua/{ model_type } /deployment/status" ,
1368
- action = "SUCCEEDED" ,
1369
- ** telemetry_kwargs
1370
- )
1372
+ category = f"aqua/{ model_type } /deployment/status" ,
1373
+ action = "SUCCEEDED" ,
1374
+ value = ocid ,
1375
+ ** telemetry_kwargs ,
1376
+ )
0 commit comments