Skip to content

Commit 06ce342

Browse files
committed
Gets the default value for the config timeout from the env variables.
1 parent b9caf91 commit 06ce342

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

ads/aqua/common/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@
3333
from ads.common.object_storage_details import ObjectStorageDetails
3434
from ads.common.oci_resource import SEARCH_TYPE, OCIResource
3535
from ads.common.utils import copy_file, get_console_link, upload_to_os
36-
from ads.config import AQUA_SERVICE_MODELS_BUCKET, CONDA_BUCKET_NS, TENANCY_OCID
36+
from ads.config import (
37+
AQUA_SERVICE_MODELS_BUCKET,
38+
CONDA_BUCKET_NS,
39+
TENANCY_OCID,
40+
THREADED_DEFAULT_TIMEOUT,
41+
)
3742
from ads.model import DataScienceModel, ModelVersionSet
3843

3944
logger = logging.getLogger("ads.aqua")
@@ -196,7 +201,7 @@ def read_file(file_path: str, **kwargs) -> str:
196201
return UNKNOWN
197202

198203

199-
@threaded(timeout=5)
204+
@threaded(timeout=THREADED_DEFAULT_TIMEOUT)
200205
def load_config(file_path: str, config_file_name: str, **kwargs) -> dict:
201206
artifact_path = f"{file_path.rstrip('/')}/{config_file_name}"
202207
if artifact_path.startswith("oci://"):

ads/common/decorator/threaded.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
from git import Optional
1414

15+
from ads.config import THREADED_DEFAULT_TIMEOUT
16+
1517
logger = logging.getLogger(__name__)
1618

1719
# Create a global thread pool with a maximum of 10 threads
@@ -81,7 +83,7 @@ def wrapper(*args, **kwargs):
8183
"""
8284
future = thread_pool.submit(func, *args, **kwargs)
8385
try:
84-
return future.result(timeout=timeout)
86+
return future.result(timeout=timeout or THREADED_DEFAULT_TIMEOUT)
8587
except concurrent.futures.TimeoutError as ex:
8688
logger.debug(
8789
f"The function '{func.__name__}' "

ads/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import inspect
99
import os
1010
from typing import Dict, Optional
11+
1112
from ads.common.config import DEFAULT_CONFIG_PATH, DEFAULT_CONFIG_PROFILE, Config, Mode
1213

1314
OCI_ODSC_SERVICE_ENDPOINT = os.environ.get("OCI_ODSC_SERVICE_ENDPOINT")
@@ -85,6 +86,8 @@
8586
AQUA_SERVICE_NAME = "aqua"
8687
DATA_SCIENCE_SERVICE_NAME = "data-science"
8788

89+
THREADED_DEFAULT_TIMEOUT = os.environ.get("THREADED_DEFAULT_TIMEOUT", 5)
90+
8891

8992
def export(
9093
uri: Optional[str] = DEFAULT_CONFIG_PATH,

0 commit comments

Comments
 (0)