Skip to content

Commit f9f5d2b

Browse files
Feature/aqua v1.0.4 (#943)
2 parents 8cf0d7c + c5b5921 commit f9f5d2b

30 files changed

+1453
-244
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,6 @@ logs/
163163

164164
# Python Wheel
165165
*.whl
166+
167+
# The demo folder
168+
.demo

THIRD_PARTY_LICENSES.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,19 @@ mlforecast
459459
* Source code: https://github.com/Nixtla/mlforecast
460460
* Project home: https://github.com/Nixtla/mlforecast
461461

462+
pydantic
463+
* Copyright (c) 2017 to present Pydantic Services Inc. and individual contributors.
464+
* License: The MIT License (MIT)
465+
* Source code: https://github.com/pydantic/pydantic
466+
* Project home: https://docs.pydantic.dev/latest/
467+
462468
rrcf
463469
* Copyright 2018 kLabUM
464470
* License: MIT License
465471
* Source code: https://github.com/kLabUM/rrcf
466472
* Project home: https://github.com/kLabUM/rrcf
467473

468-
=======
474+
469475
=============================== Licenses ===============================
470476
------------------------------------------------------------------------
471477

ads/aqua/common/utils.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
)
5959
from ads.aqua.data import AquaResourceIdentifier
6060
from ads.common.auth import AuthState, default_signer
61+
from ads.common.decorator.threaded import threaded
6162
from ads.common.extended_enum import ExtendedEnumMeta
6263
from ads.common.object_storage_details import ObjectStorageDetails
6364
from ads.common.oci_resource import SEARCH_TYPE, OCIResource
@@ -225,6 +226,7 @@ def read_file(file_path: str, **kwargs) -> str:
225226
return UNKNOWN
226227

227228

229+
@threaded()
228230
def load_config(file_path: str, config_file_name: str, **kwargs) -> dict:
229231
artifact_path = f"{file_path.rstrip('/')}/{config_file_name}"
230232
signer = default_signer() if artifact_path.startswith("oci://") else {}
@@ -536,14 +538,14 @@ def _build_job_identifier(
536538
return AquaResourceIdentifier()
537539

538540

539-
def container_config_path():
541+
def service_config_path():
540542
return f"oci://{AQUA_SERVICE_MODELS_BUCKET}@{CONDA_BUCKET_NS}/service_models/config"
541543

542544

543545
@cached(cache=TTLCache(maxsize=1, ttl=timedelta(hours=5), timer=datetime.now))
544546
def get_container_config():
545547
config = load_config(
546-
file_path=container_config_path(),
548+
file_path=service_config_path(),
547549
config_file_name=CONTAINER_INDEX,
548550
)
549551

@@ -568,7 +570,7 @@ def get_container_image(
568570
"""
569571

570572
config = config_file_name or get_container_config()
571-
config_file_name = container_config_path()
573+
config_file_name = service_config_path()
572574

573575
if container_type not in config:
574576
raise AquaValueError(
@@ -1062,3 +1064,18 @@ def get_hf_model_info(repo_id: str) -> ModelInfo:
10621064
return HfApi().model_info(repo_id=repo_id)
10631065
except HfHubHTTPError as err:
10641066
raise format_hf_custom_error_message(err) from err
1067+
1068+
1069+
@cached(cache=TTLCache(maxsize=1, ttl=timedelta(hours=5), timer=datetime.now))
1070+
def list_hf_models(query: str) -> List[str]:
1071+
try:
1072+
models = HfApi().list_models(
1073+
model_name=query,
1074+
task="text-generation",
1075+
sort="downloads",
1076+
direction=-1,
1077+
limit=20,
1078+
)
1079+
return [model.id for model in models if model.disabled is None]
1080+
except HfHubHTTPError as err:
1081+
raise format_hf_custom_error_message(err) from err

ads/aqua/config/__init__.py

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

ads/aqua/config/config.py

+28
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,34 @@
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
44

55

6+
from typing import Optional
7+
8+
from ads.aqua.common.entities import ContainerSpec
9+
from ads.aqua.common.utils import get_container_config
10+
from ads.aqua.config.evaluation.evaluation_service_config import EvaluationServiceConfig
11+
12+
DEFAULT_EVALUATION_CONTAINER = "odsc-llm-evaluate"
13+
14+
15+
def get_evaluation_service_config(
16+
container: Optional[str] = DEFAULT_EVALUATION_CONTAINER,
17+
) -> EvaluationServiceConfig:
18+
"""
19+
Retrieves the common evaluation configuration.
20+
21+
Returns
22+
-------
23+
EvaluationServiceConfig: The evaluation common config.
24+
"""
25+
26+
container = container or DEFAULT_EVALUATION_CONTAINER
27+
return EvaluationServiceConfig(
28+
**get_container_config()
29+
.get(ContainerSpec.CONTAINER_SPEC, {})
30+
.get(container, {})
31+
)
32+
33+
634
# TODO: move this to global config.json in object storage
735
def get_finetuning_config_defaults():
836
"""Generate and return the fine-tuning default configuration dictionary."""
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright (c) 2024 Oracle and/or its affiliates.
4+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

0 commit comments

Comments
 (0)