Skip to content

Commit a46bc76

Browse files
committed
Update dsc_job.py to add comment for customizing run() method.
1 parent e94a2b7 commit a46bc76

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

ads/jobs/builders/infrastructure/dsc_job.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@
3535
from ads.jobs.builders.runtimes.container_runtime import ContainerRuntime
3636
from ads.jobs.builders.runtimes.python_runtime import GitPythonRuntime
3737

38-
from ads.common.dsc_file_system import OCIFileStorage, DSCFileSystemManager, OCIObjectStorage
38+
from ads.common.dsc_file_system import (
39+
OCIFileStorage,
40+
DSCFileSystemManager,
41+
OCIObjectStorage,
42+
)
3943

4044
logger = logging.getLogger(__name__)
4145

@@ -1454,11 +1458,14 @@ def _update_job_infra(self, dsc_job: DSCJob) -> DataScienceJob:
14541458
if value:
14551459
dsc_job.job_infrastructure_configuration_details[camel_attr] = value
14561460

1457-
if (
1458-
not dsc_job.job_infrastructure_configuration_details.get("shapeName", "").endswith("Flex")
1459-
and dsc_job.job_infrastructure_configuration_details.get("jobShapeConfigDetails")
1461+
if not dsc_job.job_infrastructure_configuration_details.get(
1462+
"shapeName", ""
1463+
).endswith("Flex") and dsc_job.job_infrastructure_configuration_details.get(
1464+
"jobShapeConfigDetails"
14601465
):
1461-
raise ValueError("Shape config is not required for non flex shape from user end.")
1466+
raise ValueError(
1467+
"Shape config is not required for non flex shape from user end."
1468+
)
14621469

14631470
if dsc_job.job_infrastructure_configuration_details.get("subnetId"):
14641471
dsc_job.job_infrastructure_configuration_details[
@@ -1495,7 +1502,10 @@ def init(self) -> DataScienceJob:
14951502
self.build()
14961503
.with_compartment_id(self.compartment_id or "{Provide a compartment OCID}")
14971504
.with_project_id(self.project_id or "{Provide a project OCID}")
1498-
.with_subnet_id(self.subnet_id or "{Provide a subnet OCID or remove this field if you use a default networking}")
1505+
.with_subnet_id(
1506+
self.subnet_id
1507+
or "{Provide a subnet OCID or remove this field if you use a default networking}"
1508+
)
14991509
)
15001510

15011511
def create(self, runtime, **kwargs) -> DataScienceJob:
@@ -1552,7 +1562,7 @@ def run(
15521562
freeform_tags=None,
15531563
defined_tags=None,
15541564
wait=False,
1555-
**kwargs
1565+
**kwargs,
15561566
) -> DataScienceJobRun:
15571567
"""Runs a job on OCI Data Science job
15581568
@@ -1610,8 +1620,11 @@ def run(
16101620
freeform_tags=freeform_tags,
16111621
defined_tags=defined_tags,
16121622
wait=wait,
1613-
**kwargs
1623+
**kwargs,
16141624
)
1625+
# A Runtime class may define customized run() method.
1626+
# Use the customized method if the run() method is defined by the runtime.
1627+
# Otherwise, use the default run() method defined in this class.
16151628
if hasattr(self.runtime, "run"):
16161629
return self.runtime.run(self.dsc_job, **kwargs)
16171630
return self.dsc_job.run(**kwargs)

0 commit comments

Comments
 (0)