Skip to content

Commit 1310fb7

Browse files
authored
Merge branch 'main' into operators/auto_select_tests
2 parents f4f43fb + e1b222b commit 1310fb7

23 files changed

+790
-123
lines changed

.github/workflows/run-operators-unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
fail-fast: false
2929
matrix:
30-
python-version: ["3.8", "3.9", "3.10"]
30+
python-version: ["3.8", "3.9", "3.10", "3.11"]
3131

3232
steps:
3333
- uses: actions/checkout@v4

.github/workflows/run-unittests-default_setup.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "[Py3.8][Py3.9][Py3.10] tests/unitary/default_setup/**"
1+
name: "[Py3.8-3.11] - Default Tests"
22

33
on:
44
workflow_dispatch:
@@ -33,7 +33,7 @@ jobs:
3333
strategy:
3434
fail-fast: false
3535
matrix:
36-
python-version: ["3.8", "3.9", "3.10"]
36+
python-version: ["3.8", "3.9", "3.10", "3.11"]
3737

3838
steps:
3939
- uses: actions/checkout@v4

.github/workflows/run-unittests-py38-cov-report.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "[Py3.8][COV REPORT] tests/unitary/**"
1+
name: "[Py3.8][COV REPORT] - All Unit Tests"
22

33
on:
44
workflow_dispatch:
@@ -44,6 +44,7 @@ jobs:
4444
ignore-path: |
4545
--ignore tests/unitary/with_extras/model \
4646
--ignore tests/unitary/with_extras/feature_store \
47+
--ignore tests/unitary/with_extras/operator/feature-store \
4748
--ignore tests/unitary/with_extras/operator/forecast \
4849
--ignore tests/unitary/with_extras/hpo
4950
- name: "slow_tests"
@@ -188,6 +189,7 @@ jobs:
188189
fi
189190
190191
- name: "Add comment with cov diff to PR"
192+
continue-on-error: true
191193
uses: actions/github-script@v7
192194
if: github.event_name == 'pull_request'
193195
with:

.github/workflows/run-unittests-py39-py310.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "[Py3.9][Py3.10] - tests/unitary/**"
1+
name: "[Py3.9-3.11] - All Unit Tests"
22

33
on:
44
workflow_dispatch:
@@ -33,7 +33,7 @@ jobs:
3333
strategy:
3434
fail-fast: false
3535
matrix:
36-
python-version: ["3.9", "3.10"]
36+
python-version: ["3.9", "3.10", "3.11"]
3737
name: ["unitary", "slow_tests"]
3838
include:
3939
- name: "unitary"
@@ -46,6 +46,7 @@ jobs:
4646
ignore-path: |
4747
--ignore tests/unitary/with_extras/model \
4848
--ignore tests/unitary/with_extras/feature_store \
49+
--ignore tests/unitary/with_extras/operator/feature-store \
4950
--ignore tests/unitary/with_extras/operator/forecast \
5051
--ignore tests/unitary/with_extras/operator/pii \
5152
--ignore tests/unitary/with_extras/hpo

.github/workflows/test-env-setup/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ runs:
77
using: composite
88
steps:
99
- shell: bash
10+
env:
11+
# torch > v2.1.0 brings nvidia dependency by default, we want to install torch for cpu for tests.
12+
# Fot that --index-url https://download.pytorch.org/whl/cpu needed - https://pytorch.org/get-started/locally/.
13+
# Setting env variable here instead of flag --index-url (docs: https://pip.pypa.io/en/stable/cli/pip_install/):
14+
PIP_EXTRA_INDEX_URL: "https://download.pytorch.org/whl/cpu"
1015
run: |
1116
set -x # print commands that are executed
1217

.pre-commit-config.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
repos:
2+
# ruff
3+
- repo: https://github.com/astral-sh/ruff-pre-commit
4+
rev: v0.5.0
5+
hooks:
6+
- id: ruff
7+
types_or: [ python, pyi, jupyter ]
8+
args: [ --fix ]
9+
files: ^ads
10+
exclude: ^docs/
11+
- id: ruff-format
12+
types_or: [ python, pyi, jupyter ]
13+
exclude: ^docs/
214
# Standard hooks
315
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.4.0
16+
rev: v4.6.0
517
hooks:
618
- id: check-ast
719
exclude: ^docs/
@@ -20,12 +32,6 @@ repos:
2032
- id: trailing-whitespace
2133
args: [--markdown-linebreak-ext=md]
2234
exclude: ^docs/
23-
# Black, the code formatter, natively supports pre-commit
24-
- repo: https://github.com/psf/black
25-
rev: 23.3.0
26-
hooks:
27-
- id: black
28-
exclude: ^docs/
2935
# Regex based rst files common mistakes detector
3036
- repo: https://github.com/pre-commit/pygrep-hooks
3137
rev: v1.10.0
@@ -36,7 +42,7 @@ repos:
3642
files: ^docs/
3743
# Hardcoded secrets and ocids detector
3844
- repo: https://github.com/gitleaks/gitleaks
39-
rev: v8.17.0
45+
rev: v8.18.4
4046
hooks:
4147
- id: gitleaks
4248
exclude: .github/workflows/reusable-actions/set-dummy-conf.yml

ads/aqua/app.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,15 @@ def get_config(self, model_id: str, config_file_name: str) -> Dict:
303303
config_file_name=config_file_name,
304304
)
305305
except:
306-
pass
306+
# todo: temp fix for issue related to config load for byom models, update logic to choose the right path
307+
try:
308+
config_path = f"{artifact_path.rstrip('/')}/config/"
309+
config = load_config(
310+
config_path,
311+
config_file_name=config_file_name,
312+
)
313+
except:
314+
pass
307315

308316
if not config:
309317
logger.error(

ads/aqua/common/utils.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
from ads.aqua.constants import *
2929
from ads.aqua.data import AquaResourceIdentifier
3030
from ads.common.auth import default_signer
31+
from ads.common.decorator.threaded import threaded
3132
from ads.common.extended_enum import ExtendedEnumMeta
3233
from ads.common.object_storage_details import ObjectStorageDetails
3334
from ads.common.oci_resource import SEARCH_TYPE, OCIResource
34-
from ads.common.utils import get_console_link, upload_to_os, copy_file
35+
from ads.common.utils import copy_file, get_console_link, upload_to_os
3536
from ads.config import AQUA_SERVICE_MODELS_BUCKET, CONDA_BUCKET_NS, TENANCY_OCID
3637
from ads.model import DataScienceModel, ModelVersionSet
3738

@@ -195,6 +196,7 @@ def read_file(file_path: str, **kwargs) -> str:
195196
return UNKNOWN
196197

197198

199+
@threaded()
198200
def load_config(file_path: str, config_file_name: str, **kwargs) -> dict:
199201
artifact_path = f"{file_path.rstrip('/')}/{config_file_name}"
200202
if artifact_path.startswith("oci://"):
@@ -540,8 +542,10 @@ def get_container_image(
540542

541543

542544
def fetch_service_compartment() -> Union[str, None]:
543-
"""Loads the compartment mapping json from service bucket. This json file has a service-model-compartment key which
544-
contains a dictionary of namespaces and the compartment OCID of the service models in that namespace.
545+
"""
546+
Loads the compartment mapping json from service bucket.
547+
This json file has a service-model-compartment key which contains a dictionary of namespaces
548+
and the compartment OCID of the service models in that namespace.
545549
"""
546550
config_file_name = (
547551
f"oci://{AQUA_SERVICE_MODELS_BUCKET}@{CONDA_BUCKET_NS}/service_models/config"
@@ -554,8 +558,8 @@ def fetch_service_compartment() -> Union[str, None]:
554558
)
555559
except Exception as e:
556560
logger.debug(
557-
f"Config file {config_file_name}/{CONTAINER_INDEX} to fetch service compartment OCID could not be found. "
558-
f"\n{str(e)}."
561+
f"Config file {config_file_name}/{CONTAINER_INDEX} to fetch service compartment OCID "
562+
f"could not be found. \n{str(e)}."
559563
)
560564
return
561565
compartment_mapping = config.get(COMPARTMENT_MAPPING_KEY)
@@ -664,23 +668,26 @@ def get_model_by_reference_paths(model_file_description: dict):
664668
fine_tune_output_path = UNKNOWN
665669
models = model_file_description["models"]
666670

667-
for model in models:
668-
namespace, bucket_name, prefix = (
669-
model["namespace"],
670-
model["bucketName"],
671-
model["prefix"],
671+
if not models:
672+
raise AquaValueError(
673+
f"Model path is not available in the model json artifact. "
674+
f"Please check if the model created by reference has the correct artifact."
672675
)
673-
bucket_uri = f"oci://{bucket_name}@{namespace}/{prefix}".rstrip("/")
674-
if bucket_name == AQUA_SERVICE_MODELS_BUCKET:
675-
base_model_path = bucket_uri
676-
else:
677-
fine_tune_output_path = bucket_uri
678676

679-
if not base_model_path:
680-
raise AquaValueError(
681-
f"Base Model should come from the bucket {AQUA_SERVICE_MODELS_BUCKET}. "
682-
f"Other paths are not supported by Aqua."
677+
if len(models) > 0:
678+
# since the model_file_description json does not have a flag to identify the base model, we consider
679+
# the first instance to be the base model.
680+
base_model_artifact = models[0]
681+
base_model_path = f"oci://{base_model_artifact['bucketName']}@{base_model_artifact['namespace']}/{base_model_artifact['prefix']}".rstrip(
682+
"/"
683+
)
684+
if len(models) > 1:
685+
# second model is considered as fine-tuned model
686+
ft_model_artifact = models[1]
687+
fine_tune_output_path = f"oci://{ft_model_artifact['bucketName']}@{ft_model_artifact['namespace']}/{ft_model_artifact['prefix']}".rstrip(
688+
"/"
683689
)
690+
684691
return base_model_path, fine_tune_output_path
685692

686693

ads/aqua/finetuning/finetuning.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,13 @@ def create(
109109
)
110110

111111
source = self.get_source(create_fine_tuning_details.ft_source_id)
112-
if source.compartment_id != ODSC_MODEL_COMPARTMENT_OCID:
113-
raise AquaValueError(
114-
f"Fine tuning is only supported for Aqua service models in {ODSC_MODEL_COMPARTMENT_OCID}. "
115-
"Use a valid Aqua service model id instead."
116-
)
112+
113+
# todo: revisit validation for fine tuned models
114+
# if source.compartment_id != ODSC_MODEL_COMPARTMENT_OCID:
115+
# raise AquaValueError(
116+
# f"Fine tuning is only supported for Aqua service models in {ODSC_MODEL_COMPARTMENT_OCID}. "
117+
# "Use a valid Aqua service model id instead."
118+
# )
117119

118120
target_compartment = (
119121
create_fine_tuning_details.compartment_id or COMPARTMENT_OCID
@@ -364,6 +366,7 @@ def create(
364366
source_freeform_tags.pop(Tags.LICENSE, None)
365367
source_freeform_tags.update({Tags.READY_TO_FINE_TUNE: "false"})
366368
source_freeform_tags.update({Tags.AQUA_TAG: UNKNOWN})
369+
source_freeform_tags.pop(Tags.BASE_MODEL_CUSTOM, None)
367370

368371
self.update_model(
369372
model_id=ft_model.id,

ads/aqua/model/model.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -648,15 +648,19 @@ def _create_model_catalog_entry(
648648
copy_model_config(
649649
artifact_path=artifact_path, os_path=os_path, auth=default_signer()
650650
)
651-
652651
except:
653-
# Add artifact from user bucket
654-
metadata.add(
655-
key=MODEL_BY_REFERENCE_OSS_PATH_KEY,
656-
value=os_path,
657-
description="artifact location",
658-
category="Other",
652+
logger.debug(
653+
f"Proceeding with model registration without copying model config files at {os_path}. "
654+
f"Default configuration will be used for deployment and fine-tuning."
659655
)
656+
# Set artifact location to user bucket, and replace existing key if present.
657+
metadata.add(
658+
key=MODEL_BY_REFERENCE_OSS_PATH_KEY,
659+
value=os_path,
660+
description="artifact location",
661+
category="Other",
662+
replace=True,
663+
)
660664

661665
model = (
662666
model.with_custom_metadata_list(metadata)

0 commit comments

Comments
 (0)