Skip to content

Commit 30f8e47

Browse files
authored
Merge branch 'main' into removing_kernal_messaging_in_aqua
2 parents a534b62 + ba8fd78 commit 30f8e47

File tree

33 files changed

+505
-454
lines changed

33 files changed

+505
-454
lines changed

.github/workflows/run-forecast-explainer-tests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ jobs:
4646
- uses: ./.github/workflows/set-dummy-conf
4747
name: "Test config setup"
4848

49+
- name: Free up disk space
50+
run: |
51+
sudo apt-get clean
52+
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
53+
df -h
54+
4955
- name: "Run Forecast Explainer Tests"
5056
timeout-minutes: 180
5157
shell: bash

ads/aqua/modeldeployment/deployment.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ def create(
189189
freeform_tags (Optional[Dict]): Freeform tags for model deployment.
190190
defined_tags (Optional[Dict]): Defined tags for model deployment.
191191
deployment_type (Optional[str]): The type of model deployment.
192+
subnet_id (Optional[str]): The custom egress for model deployment.
192193
193194
Returns
194195
-------
@@ -1150,6 +1151,7 @@ def _create_deployment(
11501151
log_group_id=create_deployment_details.log_group_id,
11511152
log_id=create_deployment_details.predict_log_id,
11521153
)
1154+
.with_subnet_id(create_deployment_details.subnet_id)
11531155
)
11541156
if (
11551157
create_deployment_details.memory_in_gbs
@@ -1209,7 +1211,10 @@ def _create_deployment(
12091211
progress_thread.start()
12101212

12111213
# we arbitrarily choose last 8 characters of OCID to identify MD in telemetry
1212-
telemetry_kwargs = {"ocid": get_ocid_substring(deployment_id, key_len=8)}
1214+
deployment_short_ocid = get_ocid_substring(deployment_id, key_len=8)
1215+
1216+
# Prepare telemetry kwargs
1217+
telemetry_kwargs = {"ocid": deployment_short_ocid}
12131218

12141219
if Tags.BASE_MODEL_CUSTOM in tags:
12151220
telemetry_kwargs["custom_base_model"] = True
@@ -1221,6 +1226,11 @@ def _create_deployment(
12211226
else:
12221227
telemetry_kwargs["deployment_type"] = DeploymentType.SINGLE
12231228

1229+
telemetry_kwargs["container"] = (
1230+
create_deployment_details.container_family
1231+
or create_deployment_details.container_image_uri
1232+
)
1233+
12241234
# tracks unique deployments that were created in the user compartment
12251235
self.telemetry.record_event_async(
12261236
category=f"aqua/{model_type}/deployment",
@@ -1234,6 +1244,7 @@ def _create_deployment(
12341244
action="shape",
12351245
detail=create_deployment_details.instance_shape,
12361246
value=model_name,
1247+
**{"ocid": deployment_short_ocid},
12371248
)
12381249

12391250
return AquaDeployment.from_oci_model_deployment(

ads/aqua/modeldeployment/entities.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ class AquaDeployment(Serializable):
132132
cmd: Optional[List[str]] = Field(
133133
default_factory=list, description="The cmd of the model deployment."
134134
)
135+
subnet_id: Optional[str] = Field(
136+
None, description="The custom egress for model deployment."
137+
)
135138

136139
@classmethod
137140
def from_oci_model_deployment(
@@ -210,6 +213,7 @@ def from_oci_model_deployment(
210213
private_endpoint_id = getattr(
211214
instance_configuration, "private_endpoint_id", UNKNOWN
212215
)
216+
subnet_id = getattr(instance_configuration, "subnet_id", UNKNOWN)
213217

214218
return AquaDeployment(
215219
id=oci_model_deployment.id,
@@ -235,6 +239,7 @@ def from_oci_model_deployment(
235239
tags=tags,
236240
environment_variables=environment_variables,
237241
cmd=cmd,
242+
subnet_id=subnet_id,
238243
)
239244

240245
class Config:
@@ -803,6 +808,9 @@ class CreateModelDeploymentDetails(ModelDeploymentDetails):
803808
deployment_type: Optional[str] = Field(
804809
None, description="The type of model deployment."
805810
)
811+
subnet_id: Optional[str] = Field(
812+
None, description="The custom egress for model deployment."
813+
)
806814

807815
@model_validator(mode="before")
808816
@classmethod

ads/aqua/server/aqua_spec.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,10 @@ components:
10921092
type: string
10931093
nullable: true
10941094
example: "private-endpoint-ocid-001"
1095+
subnet_id:
1096+
type: string
1097+
nullable: true
1098+
example: "subnet-ocid-001"
10951099
console_link:
10961100
type: string
10971101
example: "https://console.example.com/model-deployments/deployment-ocid-001"
@@ -1180,6 +1184,9 @@ components:
11801184
private_endpoint_id:
11811185
type: string
11821186
example: "ocid1.datasciencemodeldeploymentprivatendpoint.oc1..<UNIQUEID>"
1187+
subnet_id:
1188+
type: string
1189+
example: "ocid1.subnet.oc1.iad..<UNIQUEID>"
11831190
cmd_var:
11841191
type: string
11851192
example: "ocid1.compartment.oc1..<UNIQUEID>"

ads/automl/provider.py

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,33 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8; -*-
32

4-
# Copyright (c) 2020, 2023 Oracle and/or its affiliates.
3+
# Copyright (c) 2020, 2025 Oracle and/or its affiliates.
54
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
65

76
import logging
8-
import time
97
import sys
8+
import time
109
import warnings
11-
from abc import ABC, abstractmethod, abstractproperty
12-
import math
13-
import pandas as pd
10+
from abc import ABC, abstractmethod
11+
12+
import matplotlib.pyplot as plt
1413
import numpy as np
14+
import pandas as pd
1515
from sklearn import set_config
1616
from sklearn.dummy import DummyClassifier, DummyRegressor
1717

18-
import matplotlib.pyplot as plt
19-
2018
import ads
19+
from ads.common import logger, utils
20+
from ads.common.decorator.deprecate import deprecated
21+
from ads.common.decorator.runtime_dependency import (
22+
OptionalDependency,
23+
runtime_dependency,
24+
)
2125
from ads.common.utils import (
26+
is_notebook,
2227
ml_task_types,
2328
wrap_lines,
24-
is_documentation_mode,
25-
is_notebook,
2629
)
27-
from ads.common.decorator.runtime_dependency import (
28-
runtime_dependency,
29-
OptionalDependency,
30-
)
31-
from ads.common.decorator.deprecate import deprecated
3230
from ads.dataset.label_encoder import DataFrameLabelEncoder
33-
from ads.dataset.helper import is_text_data
34-
35-
from ads.common import logger, utils
3631

3732

3833
class AutoMLProvider(ABC):
@@ -141,7 +136,7 @@ def get_transformer_pipeline(self):
141136
pass
142137

143138

144-
class BaselineModel(object):
139+
class BaselineModel:
145140
"""
146141
A BaselineModel object that supports fit/predict/predict_proba/transform
147142
interface. Labels (y) are encoded using DataFrameLabelEncoder.
@@ -156,7 +151,6 @@ def __init__(self, est):
156151
self.df_label_encoder = DataFrameLabelEncoder()
157152

158153
def predict(self, X):
159-
160154
"""
161155
Runs the Baselines predict function and returns the result.
162156
@@ -174,7 +168,6 @@ def predict(self, X):
174168
return self.est.predict(X)
175169

176170
def predict_proba(self, X):
177-
178171
"""
179172
Runs the Baselines predict_proba function and returns the result.
180173
@@ -192,7 +185,6 @@ def predict_proba(self, X):
192185
return self.est.predict_proba(X)
193186

194187
def fit(self, X, y):
195-
196188
"""
197189
Fits the baseline estimator.
198190
@@ -213,7 +205,6 @@ def fit(self, X, y):
213205
return self
214206

215207
def transform(self, X):
216-
217208
"""
218209
Runs the Baselines transform function and returns the result.
219210
@@ -304,16 +295,15 @@ def decide_estimator(self, **kwargs):
304295
"""
305296
if self.est is not None:
306297
return self.est
307-
else:
308-
if self.ml_task_type == ml_task_types.REGRESSION:
309-
return BaselineModel(DummyRegressor())
310-
elif self.ml_task_type in [
311-
ml_task_types.BINARY_CLASSIFICATION,
312-
ml_task_types.MULTI_CLASS_CLASSIFICATION,
313-
ml_task_types.BINARY_TEXT_CLASSIFICATION,
314-
ml_task_types.MULTI_CLASS_TEXT_CLASSIFICATION,
315-
]:
316-
return BaselineModel(DummyClassifier())
298+
elif self.ml_task_type == ml_task_types.REGRESSION:
299+
return BaselineModel(DummyRegressor())
300+
elif self.ml_task_type in [
301+
ml_task_types.BINARY_CLASSIFICATION,
302+
ml_task_types.MULTI_CLASS_CLASSIFICATION,
303+
ml_task_types.BINARY_TEXT_CLASSIFICATION,
304+
ml_task_types.MULTI_CLASS_TEXT_CLASSIFICATION,
305+
]:
306+
return BaselineModel(DummyClassifier())
317307

318308

319309
# An installation of oracle labs automl is required only for this class
@@ -483,8 +473,11 @@ def print_summary(
483473
0, "Rank based on Performance", np.arange(2, len(sorted_summary_df) + 2)
484474
)
485475

486-
from IPython.core.display import display, HTML
476+
from IPython.display import HTML
487477

478+
from ads.common.utils import get_display
479+
480+
display = get_display()
488481
with pd.option_context(
489482
"display.max_colwidth",
490483
1000,
@@ -595,9 +588,7 @@ def _decide_estimator(self, **kwargs):
595588
if (
596589
self.ml_task_type == ml_task_types.BINARY_CLASSIFICATION
597590
or self.ml_task_type == ml_task_types.BINARY_TEXT_CLASSIFICATION
598-
):
599-
test_model_list = ["LogisticRegression"]
600-
elif (
591+
) or (
601592
self.ml_task_type == ml_task_types.MULTI_CLASS_CLASSIFICATION
602593
or self.ml_task_type == ml_task_types.MULTI_CLASS_TEXT_CLASSIFICATION
603594
):
@@ -712,7 +703,7 @@ def visualize_algorithm_selection_trials(self, ylabel=None):
712703
for f in mean_scores_ser.keys():
713704
se = scipy.stats.sem(scores_ser[f], ddof=1)
714705
y_error.append(se)
715-
if f == "{}_AS".format(self.est.selected_model_):
706+
if f == f"{self.est.selected_model_}_AS":
716707
colors.append("orange")
717708
elif mean_scores_ser[f] >= mean_scores_ser.mean():
718709
colors.append("teal")
@@ -741,7 +732,7 @@ def visualize_adaptive_sampling_trials(self):
741732
_log_visualize_no_trials("adaptive sampling")
742733
return
743734
fig, ax = plt.subplots(1, figsize=(6, 3))
744-
ax.set_title("Adaptive Sampling ({})".format(trials[0][0]))
735+
ax.set_title(f"Adaptive Sampling ({trials[0][0]})")
745736
ax.set_xlabel("Dataset sample size")
746737
ax.set_ylabel(r"Predicted model score")
747738
scores = [
@@ -882,7 +873,7 @@ def visualize_tuning_trials(self, ylabel=None):
882873
plt.show()
883874

884875

885-
class AutoMLPreprocessingTransformer(object): # pragma: no cover
876+
class AutoMLPreprocessingTransformer: # pragma: no cover
886877
@deprecated(
887878
details="Working with AutoML has moved from within ADS to working directly with the AutoMLx library. AutoMLx are preinstalled in conda pack automlx_p38_cpu_v2 and later, and can now be updated independently of ADS. AutoMLx documentation may be found at https://docs.oracle.com/en-us/iaas/tools/automlx/latest/html/multiversion/v23.1.1/index.html. Notebook examples are in Oracle's samples repository: https://github.com/oracle-samples/oci-data-science-ai-samples/tree/master/notebook_examples and a migration tutorial can be found at https://accelerated-data-science.readthedocs.io/en/latest/user_guide/model_training/automl/quick_start.html .",
888879
raise_error=True,
@@ -931,7 +922,7 @@ def __repr__(self):
931922
return self.msg
932923

933924

934-
class AutoMLFeatureSelection(object): # pragma: no cover
925+
class AutoMLFeatureSelection: # pragma: no cover
935926
@deprecated(
936927
details="Working with AutoML has moved from within ADS to working directly with the AutoMLx library. AutoMLx are preinstalled in conda pack automlx_p38_cpu_v2 and later, and can now be updated independently of ADS. AutoMLx documentation may be found at https://docs.oracle.com/en-us/iaas/tools/automlx/latest/html/multiversion/v23.1.1/index.html. Notebook examples are in Oracle's samples repository: https://github.com/oracle-samples/oci-data-science-ai-samples/tree/master/notebook_examples and a migration tutorial can be found at https://accelerated-data-science.readthedocs.io/en/latest/user_guide/model_training/automl/quick_start.html .",
937928
raise_error=True,

0 commit comments

Comments
 (0)