Skip to content

Commit 3e43b62

Browse files
resolve merge conflicts
2 parents 73b4e7b + 9de7a5c commit 3e43b62

File tree

12 files changed

+162
-39
lines changed

12 files changed

+162
-39
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ on:
44
workflow_dispatch:
55
pull_request:
66
branches: [ "main" ]
7+
paths:
8+
- "ads/**"
9+
- "!ads/opctl/operator/**"
10+
- "!ads/feature_store/**"
11+
- "pyproject.toml"
12+
713

814
# Cancel in progress workflows on pull_requests.
915
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ on:
44
workflow_dispatch:
55
pull_request:
66
branches: [ "main" ]
7+
paths:
8+
- "ads/**"
9+
- "!ads/opctl/operator/**"
10+
- "!ads/feature_store/**"
11+
- "pyproject.toml"
712

813
# Cancel in progress workflows on pull_requests.
914
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ name: "[Py3.9][Py3.10] - tests/unitary/**"
33
on:
44
workflow_dispatch:
55
pull_request:
6+
branches: [ "main" ]
7+
paths:
8+
- "ads/**"
9+
- "!ads/opctl/operator/**"
10+
- "!ads/feature_store/**"
11+
- "pyproject.toml"
612

713
# Cancel in progress workflows on pull_requests.
814
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value

ads/aqua/evaluation.py

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -833,13 +833,13 @@ def get(self, eval_id) -> AquaEvaluationDetail:
833833
logger.info(f"Fetching evaluation: {eval_id} details ...")
834834

835835
resource = utils.query_resource(eval_id)
836-
model_provenance = self.ds_client.get_model_provenance(eval_id).data
837-
838836
if not resource:
839837
raise AquaRuntimeError(
840838
f"Failed to retrieve evalution {eval_id}."
841839
"Please check if the OCID is correct."
842840
)
841+
model_provenance = self.ds_client.get_model_provenance(eval_id).data
842+
843843
jobrun_id = model_provenance.training_id
844844
job_run_details = self._fetch_jobrun(
845845
resource, use_rqs=False, jobrun_id=jobrun_id
@@ -1038,14 +1038,14 @@ def get_status(self, eval_id: str) -> dict:
10381038
"""
10391039
eval = utils.query_resource(eval_id)
10401040

1041-
# TODO: add job_run_id as input param to skip the query below
1042-
model_provenance = self.ds_client.get_model_provenance(eval_id).data
1043-
10441041
if not eval:
10451042
raise AquaRuntimeError(
10461043
f"Failed to retrieve evalution {eval_id}."
10471044
"Please check if the OCID is correct."
10481045
)
1046+
1047+
model_provenance = self.ds_client.get_model_provenance(eval_id).data
1048+
10491049
jobrun_id = model_provenance.training_id
10501050
job_run_details = self._fetch_jobrun(eval, use_rqs=False, jobrun_id=jobrun_id)
10511051

@@ -1295,7 +1295,10 @@ def cancel(self, eval_id) -> dict:
12951295
raise AquaRuntimeError(
12961296
f"Failed to get evaluation details for model {eval_id}"
12971297
)
1298-
job_run_id = model.provenance_metadata.training_id
1298+
1299+
job_run_id = (
1300+
model.provenance_metadata.training_id if model.provenance_metadata else None
1301+
)
12991302
if not job_run_id:
13001303
raise AquaMissingKeyError(
13011304
"Model provenance is missing job run training_id key"
@@ -1358,7 +1361,7 @@ def delete(self, eval_id):
13581361
job_id = model.custom_metadata_list.get(
13591362
EvaluationCustomMetadata.EVALUATION_JOB_ID.value
13601363
).value
1361-
except ValueError:
1364+
except Exception:
13621365
raise AquaMissingKeyError(
13631366
f"Custom metadata is missing {EvaluationCustomMetadata.EVALUATION_JOB_ID.value} key"
13641367
)
@@ -1390,7 +1393,7 @@ def _delete_job_and_model(job, model):
13901393
)
13911394

13921395
def load_evaluation_config(self, eval_id):
1393-
# TODO
1396+
"""Loads evaluation config."""
13941397
return {
13951398
"model_params": {
13961399
"max_tokens": 500,
@@ -1568,20 +1571,6 @@ def _build_resource_identifier(
15681571
)
15691572
return AquaResourceIdentifier()
15701573

1571-
def _get_jobrun(
1572-
self, model: oci.resource_search.models.ResourceSummary, mapping: dict = {}
1573-
) -> Union[
1574-
oci.resource_search.models.ResourceSummary, oci.data_science.models.JobRun
1575-
]:
1576-
jobrun_id = self._get_attribute_from_model_metadata(
1577-
model, EvaluationCustomMetadata.EVALUATION_JOB_RUN_ID.value
1578-
)
1579-
job_run = mapping.get(jobrun_id)
1580-
1581-
if not job_run:
1582-
job_run = self._fetch_jobrun(model, use_rqs=True, jobrun_id=jobrun_id)
1583-
return job_run
1584-
15851574
def _fetch_jobrun(
15861575
self,
15871576
resource: oci.resource_search.models.ResourceSummary,
@@ -1758,7 +1747,7 @@ def _extract_job_lifecycle_details(self, lifecycle_details: str) -> str:
17581747
Examples
17591748
--------
17601749
>>> _extract_job_lifecycle_details("Job run artifact execution failed with exit code 16")
1761-
'The evaluation configuration is invalid due to content validation errors.'
1750+
'Validation errors in the evaluation config. Exit code: 16.'
17621751
17631752
>>> _extract_job_lifecycle_details("Job completed successfully.")
17641753
'Job completed successfully.'

ads/aqua/extension/common_handler.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from ads.aqua.decorator import handle_exceptions
1111
from ads.aqua.exception import AquaResourceAccessError
1212
from ads.aqua.extension.base_handler import AquaAPIhandler
13+
from ads.aqua.utils import known_realm
1314

1415

1516
class ADSVersionHandler(AquaAPIhandler):
@@ -25,8 +26,23 @@ class CompatibilityCheckHandler(AquaAPIhandler):
2526

2627
@handle_exceptions
2728
def get(self):
29+
"""This method provides the availability status of Aqua. If ODSC_MODEL_COMPARTMENT_OCID environment variable
30+
is set, then status `ok` is returned. For regions where Aqua is available but the environment variable is not
31+
set due to accesses/policies, we return the `compatible` status to indicate that the extension can be enabled
32+
for the selected notebook session.
33+
34+
Returns
35+
-------
36+
status dict:
37+
ok or compatible
38+
Raises:
39+
AquaResourceAccessError: raised when aqua is not accessible in the given session/region.
40+
41+
"""
2842
if ODSC_MODEL_COMPARTMENT_OCID:
2943
return self.finish(dict(status="ok"))
44+
elif known_realm():
45+
return self.finish(dict(status="compatible"))
3046
else:
3147
raise AquaResourceAccessError(
3248
f"The AI Quick actions extension is not compatible in the given region."

ads/aqua/finetune.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
UpdateModelProvenanceDetails,
1616
)
1717

18+
from ads.aqua import ODSC_MODEL_COMPARTMENT_OCID
1819
from ads.aqua.base import AquaApp
1920
from ads.aqua.data import AquaResourceIdentifier, Resource, Tags
2021
from ads.aqua.exception import AquaFileExistsError, AquaValueError
@@ -195,12 +196,11 @@ def create(
195196
)
196197

197198
source = self.get_source(create_fine_tuning_details.ft_source_id)
198-
# TODO: add the following validation for fine tuning aqua service model. Revisit it when all service models are available
199-
# if source.compartment_id != ODSC_MODEL_COMPARTMENT_OCID:
200-
# raise AquaValueError(
201-
# f"Fine tuning is only supported for Aqua service models in {ODSC_MODEL_COMPARTMENT_OCID}. "
202-
# "Use a valid Aqua service model id instead."
203-
# )
199+
if source.compartment_id != ODSC_MODEL_COMPARTMENT_OCID:
200+
raise AquaValueError(
201+
f"Fine tuning is only supported for Aqua service models in {ODSC_MODEL_COMPARTMENT_OCID}. "
202+
"Use a valid Aqua service model id instead."
203+
)
204204

205205
target_compartment = (
206206
create_fine_tuning_details.compartment_id or COMPARTMENT_OCID

ads/aqua/utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
LIFECYCLE_DETAILS_MISSING_JOBRUN = "The asscociated JobRun resource has been deleted."
8080
READY_TO_DEPLOY_STATUS = "ACTIVE"
8181
READY_TO_FINE_TUNE_STATUS = "TRUE"
82+
AQUA_GA_LIST = ["id19sfcrra6z"]
8283

8384

8485
class LifecycleStatus(Enum):
@@ -733,3 +734,14 @@ def _is_valid_mvs(mvs: ModelVersionSet, target_tag: str) -> bool:
733734
return False
734735

735736
return target_tag in mvs.freeform_tags
737+
738+
739+
def known_realm():
740+
"""This helper function returns True if the Aqua service is available by default in the given namespace.
741+
Returns
742+
-------
743+
bool:
744+
Return True if aqua service is available.
745+
746+
"""
747+
return os.environ.get("CONDA_BUCKET_NS") in AQUA_GA_LIST

docs/source/release_notes.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ Release Notes
44

55
2.11.7
66
------
7-
Release date: April 8, 2024
7+
Release date: April 18, 2024
88

9-
* Fixed bugs and introduced enhancements following our recent release, which included internal adjustments for future features and updates for the Jupyter Lab 3 upgrade.
9+
* Fixed the bug in ``ADSDataset.show_in_notebook()``.
10+
* Updated langchain version.
1011

1112

1213
2.11.6
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*--
3+
4+
# Copyright (c) 2024 Oracle and/or its affiliates.
5+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
6+
7+
import os
8+
import json
9+
from importlib import reload
10+
from tornado.web import Application
11+
from tornado.testing import AsyncHTTPTestCase
12+
13+
import ads.config
14+
import ads.aqua
15+
from ads.aqua.utils import AQUA_GA_LIST
16+
from ads.aqua.extension.common_handler import CompatibilityCheckHandler
17+
18+
19+
class TestDataset:
20+
SERVICE_COMPARTMENT_ID = "ocid1.compartment.oc1..<OCID>"
21+
22+
23+
class TestYourHandler(AsyncHTTPTestCase):
24+
def get_app(self):
25+
return Application([(r"/hello", CompatibilityCheckHandler)])
26+
27+
def setUp(self):
28+
super().setUp()
29+
os.environ["ODSC_MODEL_COMPARTMENT_OCID"] = TestDataset.SERVICE_COMPARTMENT_ID
30+
reload(ads.config)
31+
reload(ads.aqua)
32+
reload(ads.aqua.extension.common_handler)
33+
34+
def tearDown(self):
35+
super().tearDown()
36+
os.environ.pop("ODSC_MODEL_COMPARTMENT_OCID", None)
37+
reload(ads.config)
38+
reload(ads.aqua)
39+
reload(ads.aqua.extension.common_handler)
40+
41+
def test_get_ok(self):
42+
response = self.fetch("/hello", method="GET")
43+
assert json.loads(response.body)["status"] == "ok"
44+
45+
def test_get_compatible_status(self):
46+
os.environ["ODSC_MODEL_COMPARTMENT_OCID"] = ""
47+
os.environ["CONDA_BUCKET_NS"] = AQUA_GA_LIST[0]
48+
reload(ads.common)
49+
reload(ads.aqua)
50+
reload(ads.aqua.extension.common_handler)
51+
response = self.fetch("/hello", method="GET")
52+
assert json.loads(response.body)["status"] == "compatible"
53+
54+
def test_raise_not_compatible_error(self):
55+
os.environ["ODSC_MODEL_COMPARTMENT_OCID"] = ""
56+
os.environ["CONDA_BUCKET_NS"] = "test-namespace"
57+
reload(ads.common)
58+
reload(ads.aqua)
59+
reload(ads.aqua.extension.common_handler)
60+
response = self.fetch("/hello", method="GET")
61+
body = json.loads(response.body)
62+
assert body["status"] == 404
63+
assert (
64+
body["reason"]
65+
== "The AI Quick actions extension is not compatible in the given region."
66+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
This is a sample evaluation report.html.
2+
Standard deviation (σ)

0 commit comments

Comments
 (0)