Skip to content

Commit f3a9e9d

Browse files
committed
testing in INT
1 parent 5e84eaf commit f3a9e9d

File tree

3 files changed

+44
-36
lines changed

3 files changed

+44
-36
lines changed

ads/aqua/modeldeployment/constants.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# Copyright (c) 2024 Oracle and/or its affiliates.
2+
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
44

55
"""
@@ -8,5 +8,6 @@
88
99
This module contains constants used in Aqua Model Deployment.
1010
"""
11-
DEFAULT_WAIT_TIME = 1200
12-
DEFAULT_POLL_INTERVAL = 10
11+
12+
DEFAULT_WAIT_TIME = 120
13+
DEFAULT_POLL_INTERVAL = 10

ads/aqua/modeldeployment/deployment.py

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
from typing import Dict, List, Optional, Union
99

1010
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
1411
from oci.data_science.models import ModelDeploymentShapeSummary
1512
from pydantic import ValidationError
1613

@@ -49,16 +46,16 @@
4946
AQUA_MULTI_MODEL_CONFIG,
5047
MODEL_BY_REFERENCE_OSS_PATH_KEY,
5148
MODEL_NAME_DELIMITER,
52-
UNKNOWN_DICT
49+
UNKNOWN_DICT,
5350
)
54-
5551
from ads.aqua.data import AquaResourceIdentifier
5652
from ads.aqua.model import AquaModelApp
5753
from ads.aqua.model.constants import AquaModelMetadataKeys, ModelCustomMetadataFields
5854
from ads.aqua.model.utils import (
5955
extract_base_model_from_ft,
6056
extract_fine_tune_artifacts_path,
6157
)
58+
from ads.aqua.modeldeployment.constants import DEFAULT_POLL_INTERVAL, DEFAULT_WAIT_TIME
6259
from ads.aqua.modeldeployment.entities import (
6360
AquaDeployment,
6461
AquaDeploymentConfig,
@@ -69,8 +66,10 @@
6966
ModelDeploymentConfigSummary,
7067
)
7168
from ads.aqua.modeldeployment.utils import MultiModelDeploymentConfigLoader
69+
from ads.common.decorator.threaded import thread_pool
7270
from ads.common.object_storage_details import ObjectStorageDetails
7371
from ads.common.utils import UNKNOWN, get_log_links
72+
from ads.common.work_request import DataScienceWorkRequest
7473
from ads.config import (
7574
AQUA_DEPLOYMENT_CONTAINER_CMD_VAR_METADATA_NAME,
7675
AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME,
@@ -85,10 +84,9 @@
8584
ModelDeploymentInfrastructure,
8685
ModelDeploymentMode,
8786
)
88-
8987
from ads.model.model_metadata import ModelCustomMetadataItem
9088
from ads.telemetry import telemetry
91-
from ads.common.decorator.threaded import thread_pool
89+
9290

9391
class AquaDeploymentApp(AquaApp):
9492
"""Provides a suite of APIs to interact with Aqua model deployments within the Oracle
@@ -795,11 +793,13 @@ def _create_deployment(
795793
logger.info(
796794
f"Aqua model deployment {deployment_id} created for model {aqua_model_id}. Work request Id is {deployment.dsc_model_deployment.workflow_req_id}"
797795
)
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,
801800
deployment.dsc_model_deployment.workflow_req_id,
802-
model_type)
801+
model_type,
802+
)
803803

804804
# we arbitrarily choose last 8 characters of OCID to identify MD in telemetry
805805
telemetry_kwargs = {"ocid": get_ocid_substring(deployment_id, key_len=8)}
@@ -1324,12 +1324,14 @@ def list_shapes(self, **kwargs) -> List[ComputeShapeSummary]:
13241324
for oci_shape in oci_shapes
13251325
]
13261326

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:
13281330
"""Waits for the data science model deployment to be completed and log its status in telemetry.
13291331
13301332
Parameters
13311333
----------
1332-
1334+
13331335
model_deployment_id: str
13341336
The id of the deployed aqua model.
13351337
work_request_id: str
@@ -1342,29 +1344,33 @@ def get_deployment_status(self,model_deployment_id: str, work_request_id : str,
13421344
AquaDeployment
13431345
An Aqua deployment instance.
13441346
"""
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+
)
13461353

1347-
data_science_work_request:DataScienceWorkRequest = DataScienceWorkRequest(work_request_id)
1348-
13491354
try:
13501355
data_science_work_request.wait_work_request(
13511356
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,
13541359
)
13551360
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))
13591363
self.telemetry.record_event_async(
13601364
category=f"aqua/{model_type}/deployment/status",
13611365
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,
13641369
)
1365-
else :
1370+
else:
13661371
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+
)

ads/telemetry/client.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
44

55

6+
import concurrent.futures
67
import logging
7-
import threading
88
import traceback
99
import urllib.parse
1010
from typing import Optional
11-
import concurrent.futures
1211

1312
import oci
1413

@@ -20,6 +19,7 @@
2019
THREAD_POOL_SIZE = 16
2120
thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=THREAD_POOL_SIZE)
2221

22+
2323
class TelemetryClient(TelemetryBase):
2424
"""Represents a telemetry python client providing functions to record an event.
2525
@@ -81,7 +81,8 @@ def record_event(
8181
# Here `endpoint`` is for debugging purpose
8282
# For some federated/domain users, the `endpoint` may not be a valid URL
8383
endpoint = f"{self.service_endpoint}/n/{self.namespace}/b/{self.bucket}/o/telemetry/{category}/{action}"
84-
logger.debug(f"Sending telemetry to endpoint: {endpoint}")
84+
logger.info(f"Sending telemetry to endpoint: {endpoint}")
85+
print(f"Sending telemetry to endpoint: {endpoint}")
8586

8687
self.os_client.base_client.user_agent = self._encode_user_agent(**kwargs)
8788
try:
@@ -104,7 +105,7 @@ def record_event(
104105

105106
def record_event_async(
106107
self, category: str = None, action: str = None, detail: str = None, **kwargs
107-
)-> None:
108+
) -> None:
108109
"""Send a head request to generate an event record.
109110
110111
Parameters
@@ -119,4 +120,4 @@ def record_event_async(
119120
Thread
120121
A started thread to send a head request to generate an event record.
121122
"""
122-
thread_pool.submit(self.record_event, category, action, detail, **kwargs)
123+
thread_pool.submit(self.record_event, category, action, detail, **kwargs)

0 commit comments

Comments
 (0)