Skip to content

Commit 561bb88

Browse files
committed
Merge remote-tracking branch 'origin/feature/autogen' into feature/autogen
2 parents 25083b8 + 8e87aab commit 561bb88

37 files changed

+552
-431
lines changed

ads/aqua/common/decorator.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ def inner_function(
6969
reason=error.message,
7070
service_payload=error.args[0] if error.args else None,
7171
exc_info=sys.exc_info(),
72+
aqua_api_details=dict(
73+
# __qualname__ gives information of class and name of api
74+
aqua_api_name=func.__qualname__,
75+
oci_api_name=getattr(
76+
error, "operation_name", "Unknown OCI Operation"
77+
),
78+
service_endpoint=getattr(
79+
error, "request_endpoint", "Unknown Request Endpoint"
80+
)
81+
)
7282
)
7383
except (
7484
ClientError,

ads/aqua/common/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,13 +788,14 @@ def get_ocid_substring(ocid: str, key_len: int) -> str:
788788
return ocid[-key_len:] if ocid and len(ocid) > key_len else ""
789789

790790

791-
def upload_folder(os_path: str, local_dir: str, model_name: str) -> str:
791+
def upload_folder(os_path: str, local_dir: str, model_name: str, exclude_pattern: str = None) -> str:
792792
"""Upload the local folder to the object storage
793793
794794
Args:
795795
os_path (str): object storage URI with prefix. This is the path to upload
796796
local_dir (str): Local directory where the object is downloaded
797797
model_name (str): Name of the huggingface model
798+
exclude_pattern (optional, str): The matching pattern of files to be excluded from uploading.
798799
Retuns:
799800
str: Object name inside the bucket
800801
"""
@@ -804,6 +805,8 @@ def upload_folder(os_path: str, local_dir: str, model_name: str) -> str:
804805
auth_state = AuthState()
805806
object_path = os_details.filepath.rstrip("/") + "/" + model_name + "/"
806807
command = f"oci os object bulk-upload --src-dir {local_dir} --prefix {object_path} -bn {os_details.bucket} -ns {os_details.namespace} --auth {auth_state.oci_iam_type} --profile {auth_state.oci_key_profile} --no-overwrite"
808+
if exclude_pattern:
809+
command += f" --exclude {exclude_pattern}"
807810
try:
808811
logger.info(f"Running: {command}")
809812
subprocess.check_call(shlex.split(command))

ads/aqua/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME = "_name_or_path"
3636
AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE = "model_type"
3737
AQUA_MODEL_ARTIFACT_FILE = "model_file"
38+
HF_METADATA_FOLDER = ".cache/"
3839
HF_LOGIN_DEFAULT_TIMEOUT = 2
3940

4041
TRAINING_METRICS_FINAL = "training_metrics_final"

ads/aqua/evaluation/entities.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
This module contains dataclasses for aqua evaluation.
1010
"""
1111

12+
from typing import Any, Dict, List, Optional
13+
1214
from pydantic import Field
13-
from typing import Any, Dict, List, Optional, Union
1415

15-
from ads.aqua.data import AquaResourceIdentifier
1616
from ads.aqua.config.utils.serializer import Serializable
17+
from ads.aqua.data import AquaResourceIdentifier
1718

1819

1920
class CreateAquaEvaluationDetails(Serializable):
@@ -87,6 +88,8 @@ class CreateAquaEvaluationDetails(Serializable):
8788

8889
class Config:
8990
extra = "ignore"
91+
protected_namespaces = ()
92+
9093

9194
class AquaEvalReport(Serializable):
9295
evaluation_id: str = ""
@@ -95,6 +98,7 @@ class AquaEvalReport(Serializable):
9598
class Config:
9699
extra = "ignore"
97100

101+
98102
class AquaEvalParams(Serializable):
99103
shape: str = ""
100104
dataset_path: str = ""
@@ -103,6 +107,7 @@ class AquaEvalParams(Serializable):
103107
class Config:
104108
extra = "allow"
105109

110+
106111
class AquaEvalMetric(Serializable):
107112
key: str
108113
name: str
@@ -111,6 +116,7 @@ class AquaEvalMetric(Serializable):
111116
class Config:
112117
extra = "ignore"
113118

119+
114120
class AquaEvalMetricSummary(Serializable):
115121
metric: str = ""
116122
score: str = ""
@@ -119,6 +125,7 @@ class AquaEvalMetricSummary(Serializable):
119125
class Config:
120126
extra = "ignore"
121127

128+
122129
class AquaEvalMetrics(Serializable):
123130
id: str
124131
report: str
@@ -128,6 +135,7 @@ class AquaEvalMetrics(Serializable):
128135
class Config:
129136
extra = "ignore"
130137

138+
131139
class AquaEvaluationCommands(Serializable):
132140
evaluation_id: str
133141
evaluation_target_id: str
@@ -139,6 +147,7 @@ class AquaEvaluationCommands(Serializable):
139147
class Config:
140148
extra = "ignore"
141149

150+
142151
class AquaEvaluationSummary(Serializable):
143152
"""Represents a summary of Aqua evalution."""
144153

@@ -157,6 +166,7 @@ class AquaEvaluationSummary(Serializable):
157166
class Config:
158167
extra = "ignore"
159168

169+
160170
class AquaEvaluationDetail(AquaEvaluationSummary):
161171
"""Represents a details of Aqua evalution."""
162172

ads/aqua/extension/aqua_ws_msg_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ def write_error(self, status_code, **kwargs):
7878
logger.warning(reply["message"])
7979
# telemetry may not be present if there is an error while initializing
8080
if hasattr(self, "telemetry"):
81+
aqua_api_details = kwargs.get("aqua_api_details", {})
8182
self.telemetry.record_event_async(
8283
category="aqua/error",
8384
action=str(status_code),
8485
value=reason,
86+
**aqua_api_details
8587
)
8688
response = AquaWsError(
8789
status=status_code,

ads/aqua/extension/base_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,12 @@ def write_error(self, status_code, **kwargs):
9898

9999
# telemetry may not be present if there is an error while initializing
100100
if hasattr(self, "telemetry"):
101+
aqua_api_details = kwargs.get("aqua_api_details", {})
101102
self.telemetry.record_event_async(
102103
category="aqua/error",
103104
action=str(status_code),
104105
value=reason,
106+
**aqua_api_details
105107
)
106108

107109
self.finish(json.dumps(reply))

ads/aqua/extension/model_handler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ def post(self, *args, **kwargs):
129129
str(input_data.get("download_from_hf", "false")).lower() == "true"
130130
)
131131
inference_container_uri = input_data.get("inference_container_uri")
132+
allow_patterns = input_data.get("allow_patterns")
133+
ignore_patterns = input_data.get("ignore_patterns")
132134

133135
return self.finish(
134136
AquaModelApp().register(
@@ -141,6 +143,8 @@ def post(self, *args, **kwargs):
141143
project_id=project_id,
142144
model_file=model_file,
143145
inference_container_uri=inference_container_uri,
146+
allow_patterns=allow_patterns,
147+
ignore_patterns=ignore_patterns,
144148
)
145149
)
146150

ads/aqua/finetuning/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ class FineTuneCustomMetadata(str, metaclass=ExtendedEnumMeta):
1515
SERVICE_MODEL_ARTIFACT_LOCATION = "artifact_location"
1616
SERVICE_MODEL_DEPLOYMENT_CONTAINER = "deployment-container"
1717
SERVICE_MODEL_FINE_TUNE_CONTAINER = "finetune-container"
18+
19+
20+
ENV_AQUA_FINE_TUNING_CONTAINER = "AQUA_FINE_TUNING_CONTAINER"

ads/aqua/finetuning/finetuning.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
UNKNOWN_DICT,
3232
)
3333
from ads.aqua.data import AquaResourceIdentifier
34-
from ads.aqua.finetuning.constants import *
34+
from ads.aqua.finetuning.constants import (
35+
ENV_AQUA_FINE_TUNING_CONTAINER,
36+
FineTuneCustomMetadata,
37+
)
3538
from ads.aqua.finetuning.entities import *
3639
from ads.common.auth import default_signer
3740
from ads.common.object_storage_details import ObjectStorageDetails
@@ -310,6 +313,15 @@ def create(
310313
except Exception:
311314
pass
312315

316+
if not is_custom_container and ENV_AQUA_FINE_TUNING_CONTAINER in os.environ:
317+
ft_container = os.environ[ENV_AQUA_FINE_TUNING_CONTAINER]
318+
logger.info(
319+
"Using container set by environment variable %s=%s",
320+
ENV_AQUA_FINE_TUNING_CONTAINER,
321+
ft_container,
322+
)
323+
is_custom_container = True
324+
313325
ft_parameters.batch_size = ft_parameters.batch_size or (
314326
ft_config.get("shape", UNKNOWN_DICT)
315327
.get(create_fine_tuning_details.shape_name, UNKNOWN_DICT)
@@ -559,7 +571,6 @@ def get_finetuning_config(self, model_id: str) -> Dict:
559571
Dict:
560572
A dict of allowed finetuning configs.
561573
"""
562-
563574
config = self.get_config(model_id, AQUA_MODEL_FINETUNING_CONFIG)
564575
if not config:
565576
logger.debug(

ads/aqua/model/entities.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ class ImportModelDetails(CLIBuilderMixin):
289289
project_id: Optional[str] = None
290290
model_file: Optional[str] = None
291291
inference_container_uri: Optional[str] = None
292+
allow_patterns: Optional[List[str]] = None
293+
ignore_patterns: Optional[List[str]] = None
292294

293295
def __post_init__(self):
294296
self._command = "model register"

0 commit comments

Comments
 (0)