Skip to content

Commit

Permalink
Feature/aqua v1.0.4 (#943)
Browse files Browse the repository at this point in the history
  • Loading branch information
VipulMascarenhas authored Sep 24, 2024
2 parents 8cf0d7c + c5b5921 commit f9f5d2b
Show file tree
Hide file tree
Showing 30 changed files with 1,453 additions and 244 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,6 @@ logs/

# Python Wheel
*.whl

# The demo folder
.demo
8 changes: 7 additions & 1 deletion THIRD_PARTY_LICENSES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -459,13 +459,19 @@ mlforecast
* Source code: https://github.com/Nixtla/mlforecast
* Project home: https://github.com/Nixtla/mlforecast

pydantic
* Copyright (c) 2017 to present Pydantic Services Inc. and individual contributors.
* License: The MIT License (MIT)
* Source code: https://github.com/pydantic/pydantic
* Project home: https://docs.pydantic.dev/latest/

rrcf
* Copyright 2018 kLabUM
* License: MIT License
* Source code: https://github.com/kLabUM/rrcf
* Project home: https://github.com/kLabUM/rrcf

=======

=============================== Licenses ===============================
------------------------------------------------------------------------

Expand Down
23 changes: 20 additions & 3 deletions ads/aqua/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
)
from ads.aqua.data import AquaResourceIdentifier
from ads.common.auth import AuthState, default_signer
from ads.common.decorator.threaded import threaded
from ads.common.extended_enum import ExtendedEnumMeta
from ads.common.object_storage_details import ObjectStorageDetails
from ads.common.oci_resource import SEARCH_TYPE, OCIResource
Expand Down Expand Up @@ -225,6 +226,7 @@ def read_file(file_path: str, **kwargs) -> str:
return UNKNOWN


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


def container_config_path():
def service_config_path():
return f"oci://{AQUA_SERVICE_MODELS_BUCKET}@{CONDA_BUCKET_NS}/service_models/config"


@cached(cache=TTLCache(maxsize=1, ttl=timedelta(hours=5), timer=datetime.now))
def get_container_config():
config = load_config(
file_path=container_config_path(),
file_path=service_config_path(),
config_file_name=CONTAINER_INDEX,
)

Expand All @@ -568,7 +570,7 @@ def get_container_image(
"""

config = config_file_name or get_container_config()
config_file_name = container_config_path()
config_file_name = service_config_path()

if container_type not in config:
raise AquaValueError(
Expand Down Expand Up @@ -1062,3 +1064,18 @@ def get_hf_model_info(repo_id: str) -> ModelInfo:
return HfApi().model_info(repo_id=repo_id)
except HfHubHTTPError as err:
raise format_hf_custom_error_message(err) from err


@cached(cache=TTLCache(maxsize=1, ttl=timedelta(hours=5), timer=datetime.now))
def list_hf_models(query: str) -> List[str]:
try:
models = HfApi().list_models(
model_name=query,
task="text-generation",
sort="downloads",
direction=-1,
limit=20,
)
return [model.id for model in models if model.disabled is None]
except HfHubHTTPError as err:
raise format_hf_custom_error_message(err) from err
4 changes: 4 additions & 0 deletions ads/aqua/config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env python

# Copyright (c) 2024 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
28 changes: 28 additions & 0 deletions ads/aqua/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,34 @@
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/


from typing import Optional

from ads.aqua.common.entities import ContainerSpec
from ads.aqua.common.utils import get_container_config
from ads.aqua.config.evaluation.evaluation_service_config import EvaluationServiceConfig

DEFAULT_EVALUATION_CONTAINER = "odsc-llm-evaluate"


def get_evaluation_service_config(
container: Optional[str] = DEFAULT_EVALUATION_CONTAINER,
) -> EvaluationServiceConfig:
"""
Retrieves the common evaluation configuration.
Returns
-------
EvaluationServiceConfig: The evaluation common config.
"""

container = container or DEFAULT_EVALUATION_CONTAINER
return EvaluationServiceConfig(
**get_container_config()
.get(ContainerSpec.CONTAINER_SPEC, {})
.get(container, {})
)


# TODO: move this to global config.json in object storage
def get_finetuning_config_defaults():
"""Generate and return the fine-tuning default configuration dictionary."""
Expand Down
4 changes: 4 additions & 0 deletions ads/aqua/config/evaluation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env python

# Copyright (c) 2024 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
Loading

0 comments on commit f9f5d2b

Please sign in to comment.