Skip to content

Commit 9087625

Browse files
authored
Merge branch 'develop' into develop
2 parents d7c2e27 + a995293 commit 9087625

File tree

13 files changed

+549
-509
lines changed

13 files changed

+549
-509
lines changed

ads/jobs/builders/infrastructure/dataflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def _load_default_properties() -> dict:
436436
nb_session = dsc_client.get_notebook_session(
437437
os.environ["NB_SESSION_OCID"]
438438
).data
439-
nb_config = nb_session.notebook_session_configuration_details
439+
nb_config = nb_session.notebook_session_config_details
440440
defaults["driver_shape"] = nb_config.shape
441441
logger.debug(f"Set driver shape to {nb_config.shape}")
442442
defaults["executor_shape"] = nb_config.shape

ads/jobs/extension.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8; -*-
33

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

77

8-
import os
9-
import tempfile
108
import json
9+
import os
1110
import shlex
11+
import tempfile
12+
import warnings
1213
from getopt import gnu_getopt
1314

14-
from ads.opctl.constants import (
15-
ADS_DATAFLOW_CONFIG_FILE_NAME,
16-
DEFAULT_ADS_CONFIG_FOLDER,
17-
)
18-
from ads.jobs import Job, DataFlow, DataFlowRuntime, DataFlowRun
15+
from ads.common.decorator.runtime_dependency import (OptionalDependency,
16+
runtime_dependency)
17+
from ads.jobs import DataFlow, DataFlowRun, DataFlowRuntime, Job
1918
from ads.jobs.utils import get_dataflow_config
20-
from ads.common.decorator.runtime_dependency import (
21-
runtime_dependency,
22-
OptionalDependency,
23-
)
19+
from ads.opctl.constants import (ADS_DATAFLOW_CONFIG_FILE_NAME,
20+
DEFAULT_ADS_CONFIG_FOLDER)
2421

2522

2623
def dataflow(line, cell=None):
@@ -91,6 +88,8 @@ def dataflow_run(options, args, cell):
9188
archive_name = options["-a"]
9289
elif "--archive" in options:
9390
archive_name = options["--archive"]
91+
elif hasattr(dataflow_config, "archive_uri") and dataflow_config.archive_uri:
92+
archive_name = dataflow_config.archive_uri
9493
else:
9594
archive_name = None
9695
with tempfile.TemporaryDirectory() as td:
@@ -105,7 +104,11 @@ def dataflow_run(options, args, cell):
105104
rt_spec["args"] = args[1:]
106105
if archive_name:
107106
rt_spec["archiveUri"] = archive_name
108-
rt_spec["archiveBucket"] = dataflow_config.pop("archive_bucket")
107+
rt_spec["archiveBucket"] = dataflow_config.pop("archive_bucket", None)
108+
if not archive_name.startswith("oci://") and not rt_spec["archiveBucket"]:
109+
raise ValueError(
110+
"`archiveBucket` has to be set in the config if `archive` is a local path."
111+
)
109112
rt = DataFlowRuntime(rt_spec)
110113
infra = DataFlow(spec=dataflow_config)
111114
if "-o" in options or "--overwrite" in options:

ads/jobs/utils.py

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

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

77

@@ -43,7 +43,7 @@ def get_dataflow_config(path=None, oci_profile=None):
4343
)
4444
return config
4545
else:
46-
logger.error(f"{dataflow_config_file_path} not found.")
46+
logger.warning(f"{dataflow_config_file_path} not found. Follow this link https://accelerated-data-science.readthedocs.io/en/latest/user_guide/apachespark/dataflow.html to set up the config.")
4747
return {}
4848

4949

ads/model/deployment/model_deployment.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,9 +1532,15 @@ def _build_model_deployment_configuration_details(self) -> Dict:
15321532
infrastructure.CONST_MEMORY_IN_GBS: infrastructure.shape_config_details.get(
15331533
"memory_in_gbs", None
15341534
)
1535+
or infrastructure.shape_config_details.get(
1536+
"memoryInGBs", None
1537+
)
15351538
or MODEL_DEPLOYMENT_INSTANCE_MEMORY_IN_GBS,
15361539
}
15371540

1541+
if infrastructure.subnet_id:
1542+
instance_configuration[infrastructure.CONST_SUBNET_ID] = infrastructure.subnet_id
1543+
15381544
scaling_policy = {
15391545
infrastructure.CONST_POLICY_TYPE: "FIXED_SIZE",
15401546
infrastructure.CONST_INSTANCE_COUNT: infrastructure.replica

ads/model/deployment/model_deployment_infrastructure.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class ModelDeploymentInfrastructure(Builder):
3939
The access and predict log id of model deployment
4040
web_concurrency: int
4141
The web concurrency of model deployment
42+
subnet_id: str
43+
The subnet id of model deployment
4244
4345
Methods
4446
-------
@@ -64,6 +66,8 @@ class ModelDeploymentInfrastructure(Builder):
6466
Sets the access and predict log id of model deployment
6567
with_web_concurrency(web_concurrency)
6668
Sets the web concurrency of model deployment
69+
with_subnet_id(subnet_id)
70+
Sets the subnet id of model deployment
6771
6872
Example
6973
-------
@@ -79,6 +83,7 @@ class ModelDeploymentInfrastructure(Builder):
7983
... .with_replica(1)
8084
... .with_bandwidth_mbps(10)
8185
... .with_web_concurrency(10)
86+
... .with_subnet_id(<subnet_id>)
8287
... .with_access_log(
8388
... log_group_id=<log_group_id>,
8489
... log_id=<log_id>
@@ -121,6 +126,7 @@ class ModelDeploymentInfrastructure(Builder):
121126
CONST_LOG_GROUP_ID = "logGroupId"
122127
CONST_WEB_CONCURRENCY = "webConcurrency"
123128
CONST_STREAM_CONFIG_DETAILS = "streamConfigurationDetails"
129+
CONST_SUBNET_ID = "subnetId"
124130

125131
attribute_map = {
126132
CONST_PROJECT_ID: "project_id",
@@ -136,6 +142,7 @@ class ModelDeploymentInfrastructure(Builder):
136142
CONST_LOG_ID: "log_id",
137143
CONST_LOG_GROUP_ID: "log_group_id",
138144
CONST_WEB_CONCURRENCY: "web_concurrency",
145+
CONST_SUBNET_ID: "subnet_id"
139146
}
140147

141148
shape_config_details_attribute_map = {
@@ -162,6 +169,7 @@ class ModelDeploymentInfrastructure(Builder):
162169
CONST_COMPARTMENT_ID: "compartment_id",
163170
CONST_SHAPE_NAME: f"{MODEL_CONFIG_DETAILS_PATH}.instance_configuration.instance_shape_name",
164171
CONST_SHAPE_CONFIG_DETAILS: f"{MODEL_CONFIG_DETAILS_PATH}.instance_configuration.model_deployment_instance_shape_config_details",
172+
CONST_SUBNET_ID: f"{MODEL_CONFIG_DETAILS_PATH}.instance_configuration.subnet_id",
165173
CONST_REPLICA: f"{MODEL_CONFIG_DETAILS_PATH}.scaling_policy.instance_count",
166174
CONST_BANDWIDTH_MBPS: f"{MODEL_CONFIG_DETAILS_PATH}.bandwidth_mbps",
167175
CONST_ACCESS_LOG: "category_log_details.access",
@@ -518,3 +526,29 @@ def with_web_concurrency(
518526
The ModelDeploymentInfrastructure instance (self).
519527
"""
520528
return self.set_spec(self.CONST_WEB_CONCURRENCY, web_concurrency)
529+
530+
def with_subnet_id(self, subnet_id: str) -> "ModelDeploymentInfrastructure":
531+
"""Sets the subnet id of model deployment.
532+
533+
Parameters
534+
----------
535+
subnet_id : str
536+
The subnet id of model deployment.
537+
538+
Returns
539+
-------
540+
ModelDeploymentInfrastructure
541+
The ModelDeploymentInfrastructure instance (self).
542+
"""
543+
return self.set_spec(self.CONST_SUBNET_ID, subnet_id)
544+
545+
@property
546+
def subnet_id(self) -> str:
547+
"""The model deployment subnet id.
548+
549+
Returns
550+
-------
551+
str
552+
The model deployment subnet id.
553+
"""
554+
return self.get_spec(self.CONST_SUBNET_ID, None)

ads/model/generic_model.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,6 +1902,7 @@ def deploy(
19021902
display_name: Optional[str] = None,
19031903
description: Optional[str] = None,
19041904
deployment_instance_shape: Optional[str] = None,
1905+
deployment_instance_subnet_id: Optional[str] = None,
19051906
deployment_instance_count: Optional[int] = None,
19061907
deployment_bandwidth_mbps: Optional[int] = None,
19071908
deployment_log_group_id: Optional[str] = None,
@@ -1950,6 +1951,8 @@ def deploy(
19501951
The description of the model.
19511952
deployment_instance_shape: (str, optional). Default to `VM.Standard2.1`.
19521953
The shape of the instance used for deployment.
1954+
deployment_instance_subnet_id: (str, optional). Default to None.
1955+
The subnet id of the instance used for deployment.
19531956
deployment_instance_count: (int, optional). Defaults to 1.
19541957
The number of instance used for deployment.
19551958
deployment_bandwidth_mbps: (int, optional). Defaults to 10.
@@ -2084,6 +2087,10 @@ def deploy(
20842087
self.properties.deployment_instance_shape
20852088
or existing_infrastructure.shape_name
20862089
)
2090+
.with_subnet_id(
2091+
self.properties.deployment_instance_subnet_id
2092+
or existing_infrastructure.subnet_id
2093+
)
20872094
.with_replica(
20882095
self.properties.deployment_instance_count
20892096
or existing_infrastructure.replica
@@ -2253,6 +2260,7 @@ def prepare_save_deploy(
22532260
deployment_display_name: Optional[str] = None,
22542261
deployment_description: Optional[str] = None,
22552262
deployment_instance_shape: Optional[str] = None,
2263+
deployment_instance_subnet_id: Optional[str] = None,
22562264
deployment_instance_count: Optional[int] = None,
22572265
deployment_bandwidth_mbps: Optional[int] = None,
22582266
deployment_log_group_id: Optional[str] = None,
@@ -2340,6 +2348,8 @@ def prepare_save_deploy(
23402348
The description of the model.
23412349
deployment_instance_shape: (str, optional). Default to `VM.Standard2.1`.
23422350
The shape of the instance used for deployment.
2351+
deployment_instance_subnet_id: (str, optional). Default to None.
2352+
The subnet id of the instance used for deployment.
23432353
deployment_instance_count: (int, optional). Defaults to 1.
23442354
The number of instance used for deployment.
23452355
deployment_bandwidth_mbps: (int, optional). Defaults to 10.
@@ -2481,6 +2491,7 @@ def prepare_save_deploy(
24812491
display_name=deployment_display_name,
24822492
description=deployment_description,
24832493
deployment_instance_shape=self.properties.deployment_instance_shape,
2494+
deployment_instance_subnet_id=self.properties.deployment_instance_subnet_id,
24842495
deployment_instance_count=self.properties.deployment_instance_count,
24852496
deployment_bandwidth_mbps=self.properties.deployment_bandwidth_mbps,
24862497
deployment_log_group_id=self.properties.deployment_log_group_id,

ads/model/model_properties.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class ModelProperties(BaseProperties):
2828
remove_existing_artifact: bool = None
2929
overwrite_existing_artifact: bool = None
3030
deployment_instance_shape: str = None
31+
deployment_instance_subnet_id: str = None
3132
deployment_instance_count: int = None
3233
deployment_bandwidth_mbps: int = None
3334
deployment_log_group_id: str = None

0 commit comments

Comments
 (0)