Skip to content

Commit 2fa05bf

Browse files
committed
Updated pr.
1 parent 2c7ee57 commit 2fa05bf

File tree

5 files changed

+25
-27
lines changed

5 files changed

+25
-27
lines changed

ads/jobs/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
from ads.jobs.builders.infrastructure.dsc_job import (
2424
DataScienceJob,
2525
DataScienceJobRun,
26-
DSCFileSystem,
27-
DSCFileStorage,
26+
OCIFileStorage,
2827
)
2928
from ads.jobs.builders.infrastructure.dataflow import DataFlow, DataFlowRun
3029
except AttributeError as e:
@@ -50,6 +49,5 @@
5049
"DataFlowRun",
5150
"DataFlowRuntime",
5251
"DataFlowNotebookRuntime",
53-
"DSCFileSystem",
54-
"DSCFileStorage",
52+
"OCIFileStorage",
5553
]

ads/jobs/builders/infrastructure/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
# Copyright (c) 2021, 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/
6-
from .dsc_job import DataScienceJob, DSCFileSystem, DSCFileStorage
6+
from .dsc_job import DataScienceJob, OCIFileStorage

ads/jobs/builders/infrastructure/dsc_file_system.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ def from_dict(cls, env: dict) -> "DSCFileSystem":
2727
"""Initialize the object from a Python dictionary."""
2828
return cls(**{utils.camel_to_snake(k): v for k, v in env.items()})
2929

30-
def _update_to_dsc_model(self, **kwargs) -> dict:
30+
def update_to_dsc_model(self, **kwargs) -> dict:
3131
return self.to_dict()
3232

3333
@classmethod
34-
def _update_from_dsc_model(cls, dsc_model: dict) -> "DSCFileSystem":
34+
def update_from_dsc_model(cls, dsc_model: dict) -> "DSCFileSystem":
3535
return cls.from_dict(dsc_model)
3636

3737

3838
@dataclass
39-
class DSCFileStorage(DSCFileSystem):
39+
class OCIFileStorage(DSCFileSystem):
4040

4141
mount_target: str = None
4242
mount_target_id: str = None
@@ -60,7 +60,7 @@ def __post_init__(self):
6060
"Either parameter `export_path` or `export_id` must be provided to mount file system."
6161
)
6262

63-
def _update_to_dsc_model(self, **kwargs) -> dict:
63+
def update_to_dsc_model(self, **kwargs) -> dict:
6464
"""Updates arguments to dsc model.
6565
6666
Returns
@@ -128,7 +128,7 @@ def _update_to_dsc_model(self, **kwargs) -> dict:
128128
return arguments
129129

130130
@classmethod
131-
def _update_from_dsc_model(cls, dsc_model: dict) -> DSCFileSystem:
131+
def update_from_dsc_model(cls, dsc_model: dict) -> DSCFileSystem:
132132
"""Updates arguments and builds DSCFileSystem object from dsc model.
133133
134134
Parameters

ads/jobs/builders/infrastructure/dsc_job.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from ads.jobs.builders.runtimes.python_runtime import GitPythonRuntime
3838

3939
from ads.jobs.builders.infrastructure.dsc_file_system import (
40-
DSCFileStorage,
40+
OCIFileStorage,
4141
DSCFileSystem,
4242
)
4343

@@ -844,7 +844,7 @@ class DataScienceJob(Infrastructure):
844844
.with_block_storage_size(50)
845845
# A list of file systems to be mounted
846846
.with_storage_mount(
847-
DSCFileStorage(
847+
OCIFileStorage(
848848
destination_directory_name="test_mount",
849849
mount_target="test_mount_target",
850850
export_path="test_export_path"
@@ -907,7 +907,7 @@ class DataScienceJob(Infrastructure):
907907
v.split(".", maxsplit=1)[-1]: k for k, v in payload_attribute_map.items()
908908
}
909909

910-
storage_mount_type_dict = {FILE_STORAGE_TYPE: DSCFileStorage}
910+
storage_mount_type_dict = {FILE_STORAGE_TYPE: OCIFileStorage}
911911

912912
@staticmethod
913913
def standardize_spec(spec):
@@ -1385,7 +1385,7 @@ def _update_storage_mount_from_dsc_model(
13851385
storage_mount = [
13861386
self.storage_mount_type_dict[
13871387
file_system["storageType"]
1388-
]._update_from_dsc_model(file_system)
1388+
].update_from_dsc_model(file_system)
13891389
for file_system in storage_mount_list
13901390
if file_system["storageType"] in self.storage_mount_type_dict
13911391
]
@@ -1436,7 +1436,7 @@ def _update_job_infra(self, dsc_job: DSCJob) -> DataScienceJob:
14361436
"Storage mount hasn't been supported in the current OCI SDK installed."
14371437
)
14381438
dsc_job.job_storage_mount_configuration_details_list = [
1439-
file_system._update_to_dsc_model(compartment_id=dsc_job.compartment_id)
1439+
file_system.update_to_dsc_model(compartment_id=dsc_job.compartment_id)
14401440
for file_system in self.storage_mount
14411441
]
14421442
return self

tests/unitary/default_setup/jobs/test_jobs_mount_file_system.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pytest
1111

1212
from ads.jobs.ads_job import Job
13-
from ads.jobs.builders.infrastructure import DSCFileStorage, DataScienceJob
13+
from ads.jobs.builders.infrastructure import OCIFileStorage, DataScienceJob
1414
from ads.jobs.builders.runtimes.python_runtime import PythonRuntime
1515

1616
try:
@@ -71,7 +71,7 @@
7171
.with_shape_config_details(memory_in_gbs=16, ocpus=1)
7272
.with_block_storage_size(50)
7373
.with_storage_mount(
74-
DSCFileStorage(
74+
OCIFileStorage(
7575
destination_directory_name="test_mount_one",
7676
mount_target="test_mount_target_one",
7777
export_path="test_export_path_one",
@@ -134,14 +134,14 @@ class TestDataScienceJobMountFileSystem(unittest.TestCase):
134134
def test_data_science_job_initialize(self):
135135
assert isinstance(job.infrastructure.storage_mount, list)
136136
dsc_file_storage_one = job.infrastructure.storage_mount[0]
137-
assert isinstance(dsc_file_storage_one, DSCFileStorage)
137+
assert isinstance(dsc_file_storage_one, OCIFileStorage)
138138
assert dsc_file_storage_one.storage_type == "FILE_STORAGE"
139139
assert dsc_file_storage_one.destination_directory_name == "test_mount_one"
140140
assert dsc_file_storage_one.mount_target == "test_mount_target_one"
141141
assert dsc_file_storage_one.export_path == "test_export_path_one"
142142

143143
dsc_file_storage_two = job.infrastructure.storage_mount[1]
144-
assert isinstance(dsc_file_storage_two, DSCFileStorage)
144+
assert isinstance(dsc_file_storage_two, OCIFileStorage)
145145
assert dsc_file_storage_two.storage_type == "FILE_STORAGE"
146146
assert dsc_file_storage_two.destination_directory_name == "test_mount_two"
147147
assert dsc_file_storage_two.mount_target == "test_mount_target_two"
@@ -152,14 +152,14 @@ def test_data_science_job_from_yaml(self):
152152

153153
assert isinstance(job_from_yaml.infrastructure.storage_mount, list)
154154
dsc_file_storage_one = job_from_yaml.infrastructure.storage_mount[0]
155-
assert isinstance(dsc_file_storage_one, DSCFileStorage)
155+
assert isinstance(dsc_file_storage_one, OCIFileStorage)
156156
assert dsc_file_storage_one.storage_type == "FILE_STORAGE"
157157
assert dsc_file_storage_one.destination_directory_name == "test_mount_one"
158158
assert dsc_file_storage_one.mount_target == "test_mount_target_one"
159159
assert dsc_file_storage_one.export_path == "test_export_path_one"
160160

161161
dsc_file_storage_two = job.infrastructure.storage_mount[1]
162-
assert isinstance(dsc_file_storage_two, DSCFileStorage)
162+
assert isinstance(dsc_file_storage_two, OCIFileStorage)
163163
assert dsc_file_storage_two.storage_type == "FILE_STORAGE"
164164
assert dsc_file_storage_two.destination_directory_name == "test_mount_two"
165165
assert dsc_file_storage_two.mount_target == "test_mount_target_two"
@@ -214,7 +214,7 @@ def test_mount_file_system_failed(self):
214214
ValueError,
215215
match="Either parameter `export_path` or `export_id` must be provided to mount file system.",
216216
):
217-
DSCFileStorage(
217+
OCIFileStorage(
218218
destination_directory_name="test_mount",
219219
mount_target_id="ocid1.mounttarget.oc1.iad.xxxx",
220220
)
@@ -223,7 +223,7 @@ def test_mount_file_system_failed(self):
223223
ValueError,
224224
match="Either parameter `mount_target` or `mount_target_id` must be provided to mount file system.",
225225
):
226-
DSCFileStorage(
226+
OCIFileStorage(
227227
destination_directory_name="test_mount",
228228
export_id="ocid1.export.oc1.iad.xxxx",
229229
)
@@ -232,13 +232,13 @@ def test_mount_file_system_failed(self):
232232
ValueError,
233233
match="Parameter `destination_directory_name` must be provided to mount file system.",
234234
):
235-
DSCFileStorage(
235+
OCIFileStorage(
236236
mount_target_id="ocid1.mounttarget.oc1.iad.xxxx",
237237
export_id="ocid1.export.oc1.iad.xxxx",
238238
)
239239

240240
job_copy = copy.deepcopy(job)
241-
dsc_file_storage = DSCFileStorage(
241+
dsc_file_storage = OCIFileStorage(
242242
destination_directory_name="test_mount",
243243
mount_target="test_mount_target",
244244
export_id="ocid1.export.oc1.iad.xxxx",
@@ -305,8 +305,8 @@ def test_update_storage_mount_from_dsc_model(
305305
infrastructure._update_from_dsc_model(dsc_job_payload)
306306

307307
assert len(infrastructure.storage_mount) == 2
308-
assert isinstance(infrastructure.storage_mount[0], DSCFileStorage)
309-
assert isinstance(infrastructure.storage_mount[1], DSCFileStorage)
308+
assert isinstance(infrastructure.storage_mount[0], OCIFileStorage)
309+
assert isinstance(infrastructure.storage_mount[1], OCIFileStorage)
310310
assert infrastructure.storage_mount[0].to_dict() == {
311311
"destinationDirectoryName": "test_destination_directory_name_from_dsc",
312312
"exportId": "export_id_from_dsc",

0 commit comments

Comments
 (0)