Skip to content

Commit 809a519

Browse files
committed
Updated pr.
1 parent af0213f commit 809a519

File tree

3 files changed

+34
-26
lines changed

3 files changed

+34
-26
lines changed

ads/jobs/builders/infrastructure/dsc_file_system.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
66
import ads
77
import oci
8-
import copy
98
import ipaddress
109

1110
from ads.common import utils
@@ -35,7 +34,7 @@ def update_to_dsc_model(self) -> dict:
3534
return self.to_dict()
3635

3736
@classmethod
38-
def update_from_dsc_model(cls, dsc_model: dict) -> "DSCFileSystem":
37+
def update_from_dsc_model(cls, dsc_model: oci.data_science.models.JobStorageMountConfigurationDetails) -> "DSCFileSystem":
3938
return cls.from_dict(dsc_model)
4039

4140

@@ -156,37 +155,42 @@ def _get_resource(self, ip: str) -> oci.resource_search.models.ResourceSummary:
156155
return resource[-1]
157156

158157
@classmethod
159-
def update_from_dsc_model(cls, dsc_model: dict) -> DSCFileSystem:
158+
def update_from_dsc_model(cls, dsc_model: oci.data_science.models.JobStorageMountConfigurationDetails) -> DSCFileSystem:
160159
"""Updates arguments and builds DSCFileSystem object from dsc model.
161160
162161
Parameters
163162
----------
164-
dsc_model: dict
165-
A dictionary of arguments from dsc model.
163+
dsc_model: oci.data_science.models.JobStorageMountConfigurationDetails
164+
An instance of oci.data_science.models.JobStorageMountConfigurationDetails.
166165
167166
Returns
168167
-------
169168
DSCFileSystem
170169
An instance of DSCFileSystem.
171170
"""
172-
argument = copy.deepcopy(dsc_model)
171+
argument = {
172+
"storageType": dsc_model.storage_type,
173+
"mountTargetId": dsc_model.mount_target_id,
174+
"exportId": dsc_model.export_id,
175+
"destinationDirectoryName": dsc_model.destination_directory_name
176+
}
173177

174178
file_storage_client = oci.file_storage.FileStorageClient(
175179
**ads.auth.default_signer()
176180
)
177-
if "mountTargetId" not in argument:
181+
if not dsc_model.mount_target_id:
178182
raise ValueError(
179-
"Missing parameter `mountTargetId` from service. Check service log to see the error."
183+
"Missing parameter `mount_target_id` from service. Check service log to see the error."
180184
)
181185
argument["mountTarget"] = file_storage_client.get_mount_target(
182-
mount_target_id=argument.get("mountTargetId")
186+
mount_target_id=dsc_model.mount_target_id
183187
).data.display_name
184-
if "exportId" not in argument:
188+
if not dsc_model.export_id:
185189
raise ValueError(
186-
"Missing parameter `exportId` from service. Check service log to see the error."
190+
"Missing parameter `export_id` from service. Check service log to see the error."
187191
)
188192
argument["exportPath"] = file_storage_client.get_export(
189-
export_id=argument.get("exportId")
193+
export_id=dsc_model.export_id
190194
).data.path
191195

192196
return super().from_dict(argument)

ads/jobs/builders/infrastructure/dsc_job.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,10 +1375,10 @@ def _update_storage_mount_from_dsc_model(
13751375
if storage_mount_list:
13761376
storage_mount = [
13771377
self.storage_mount_type_dict[
1378-
file_system["storageType"]
1378+
file_system.storage_type
13791379
].update_from_dsc_model(file_system)
13801380
for file_system in storage_mount_list
1381-
if file_system["storageType"] in self.storage_mount_type_dict
1381+
if file_system.storage_type in self.storage_mount_type_dict
13821382
]
13831383
if overwrite or not self.get_spec(self.CONST_STORAGE_MOUNT):
13841384
self.set_spec(self.CONST_STORAGE_MOUNT, storage_mount)

tests/unitary/default_setup/jobs/test_jobs_mount_file_system.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,22 @@
4444
},
4545
),
4646
job_storage_mount_configuration_details_list=[
47-
{
48-
"destinationDirectoryName": "test_destination_directory_name_from_dsc",
49-
"exportId": "export_id_from_dsc",
50-
"mountTargetId": "mount_target_id_from_dsc",
51-
"storageType": "FILE_STORAGE",
52-
},
53-
{
54-
"destinationDirectoryName": "test_destination_directory_name_from_dsc",
55-
"exportId": "export_id_from_dsc",
56-
"mountTargetId": "mount_target_id_from_dsc",
57-
"storageType": "FILE_STORAGE",
58-
},
47+
oci.data_science.models.FileStorageMountConfigurationDetails(
48+
**{
49+
"destination_directory_name": "test_destination_directory_name_from_dsc",
50+
"export_id": "export_id_from_dsc",
51+
"mount_target_id": "mount_target_id_from_dsc",
52+
"storage_type": "FILE_STORAGE",
53+
},
54+
),
55+
oci.data_science.models.FileStorageMountConfigurationDetails(
56+
**{
57+
"destination_directory_name": "test_destination_directory_name_from_dsc",
58+
"export_id": "export_id_from_dsc",
59+
"mount_target_id": "mount_target_id_from_dsc",
60+
"storage_type": "FILE_STORAGE",
61+
}
62+
)
5963
],
6064
lifecycle_details="ACTIVE",
6165
lifecycle_state="STATE",

0 commit comments

Comments
 (0)