Skip to content

Commit

Permalink
Gets the default value for the config timeout from the env variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrDzurb committed Jun 10, 2024
1 parent b9caf91 commit 06ce342
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
9 changes: 7 additions & 2 deletions ads/aqua/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
from ads.common.object_storage_details import ObjectStorageDetails
from ads.common.oci_resource import SEARCH_TYPE, OCIResource
from ads.common.utils import copy_file, get_console_link, upload_to_os
from ads.config import AQUA_SERVICE_MODELS_BUCKET, CONDA_BUCKET_NS, TENANCY_OCID
from ads.config import (
AQUA_SERVICE_MODELS_BUCKET,
CONDA_BUCKET_NS,
TENANCY_OCID,
THREADED_DEFAULT_TIMEOUT,
)
from ads.model import DataScienceModel, ModelVersionSet

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


@threaded(timeout=5)
@threaded(timeout=THREADED_DEFAULT_TIMEOUT)
def load_config(file_path: str, config_file_name: str, **kwargs) -> dict:
artifact_path = f"{file_path.rstrip('/')}/{config_file_name}"
if artifact_path.startswith("oci://"):
Expand Down
4 changes: 3 additions & 1 deletion ads/common/decorator/threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

from git import Optional

from ads.config import THREADED_DEFAULT_TIMEOUT

logger = logging.getLogger(__name__)

# Create a global thread pool with a maximum of 10 threads
Expand Down Expand Up @@ -81,7 +83,7 @@ def wrapper(*args, **kwargs):
"""
future = thread_pool.submit(func, *args, **kwargs)
try:
return future.result(timeout=timeout)
return future.result(timeout=timeout or THREADED_DEFAULT_TIMEOUT)
except concurrent.futures.TimeoutError as ex:
logger.debug(
f"The function '{func.__name__}' "
Expand Down
3 changes: 3 additions & 0 deletions ads/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import inspect
import os
from typing import Dict, Optional

from ads.common.config import DEFAULT_CONFIG_PATH, DEFAULT_CONFIG_PROFILE, Config, Mode

OCI_ODSC_SERVICE_ENDPOINT = os.environ.get("OCI_ODSC_SERVICE_ENDPOINT")
Expand Down Expand Up @@ -85,6 +86,8 @@
AQUA_SERVICE_NAME = "aqua"
DATA_SCIENCE_SERVICE_NAME = "data-science"

THREADED_DEFAULT_TIMEOUT = os.environ.get("THREADED_DEFAULT_TIMEOUT", 5)


def export(
uri: Optional[str] = DEFAULT_CONFIG_PATH,
Expand Down

0 comments on commit 06ce342

Please sign in to comment.