|
5 | 5 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
|
6 | 6 | import ads
|
7 | 7 | import oci
|
8 |
| -import copy |
9 | 8 | import ipaddress
|
10 | 9 |
|
11 | 10 | from ads.common import utils
|
@@ -35,7 +34,7 @@ def update_to_dsc_model(self) -> dict:
|
35 | 34 | return self.to_dict()
|
36 | 35 |
|
37 | 36 | @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": |
39 | 38 | return cls.from_dict(dsc_model)
|
40 | 39 |
|
41 | 40 |
|
@@ -156,37 +155,42 @@ def _get_resource(self, ip: str) -> oci.resource_search.models.ResourceSummary:
|
156 | 155 | return resource[-1]
|
157 | 156 |
|
158 | 157 | @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: |
160 | 159 | """Updates arguments and builds DSCFileSystem object from dsc model.
|
161 | 160 |
|
162 | 161 | Parameters
|
163 | 162 | ----------
|
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. |
166 | 165 |
|
167 | 166 | Returns
|
168 | 167 | -------
|
169 | 168 | DSCFileSystem
|
170 | 169 | An instance of DSCFileSystem.
|
171 | 170 | """
|
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 | + } |
173 | 177 |
|
174 | 178 | file_storage_client = oci.file_storage.FileStorageClient(
|
175 | 179 | **ads.auth.default_signer()
|
176 | 180 | )
|
177 |
| - if "mountTargetId" not in argument: |
| 181 | + if not dsc_model.mount_target_id: |
178 | 182 | 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." |
180 | 184 | )
|
181 | 185 | argument["mountTarget"] = file_storage_client.get_mount_target(
|
182 |
| - mount_target_id=argument.get("mountTargetId") |
| 186 | + mount_target_id=dsc_model.mount_target_id |
183 | 187 | ).data.display_name
|
184 |
| - if "exportId" not in argument: |
| 188 | + if not dsc_model.export_id: |
185 | 189 | 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." |
187 | 191 | )
|
188 | 192 | argument["exportPath"] = file_storage_client.get_export(
|
189 |
| - export_id=argument.get("exportId") |
| 193 | + export_id=dsc_model.export_id |
190 | 194 | ).data.path
|
191 | 195 |
|
192 | 196 | return super().from_dict(argument)
|
|
0 commit comments