15
15
from ads .jobs .builders .runtimes .python_runtime import PythonRuntime
16
16
17
17
try :
18
- from oci .data_science .models import JobStorageMountConfigurationDetails
19
18
from oci .data_science .models import FileStorageMountConfigurationDetails
20
19
from oci .data_science .models import ObjectStorageMountConfigurationDetails
21
20
except (ImportError , AttributeError ) as e :
50
49
FileStorageMountConfigurationDetails (
51
50
** {
52
51
"destination_directory_name" : "test_destination_directory_name_from_dsc" ,
52
+ "destination_path" : "/test_destination_path" ,
53
53
"export_id" : "export_id_from_dsc" ,
54
54
"mount_target_id" : "mount_target_id_from_dsc" ,
55
55
"storage_type" : "FILE_STORAGE" ,
58
58
FileStorageMountConfigurationDetails (
59
59
** {
60
60
"destination_directory_name" : "test_destination_directory_name_from_dsc" ,
61
+ "destination_path" : "/test_destination_path" ,
61
62
"export_id" : "export_id_from_dsc" ,
62
63
"mount_target_id" : "mount_target_id_from_dsc" ,
63
64
"storage_type" : "FILE_STORAGE" ,
80
81
.with_storage_mount (
81
82
{
82
83
"src" : "1.1.1.1:test_export_path_one" ,
83
- "dest" : "test_mount_one" ,
84
+ "dest" : "/test_path_one/ test_mount_one" ,
84
85
},
85
86
{
86
87
"src" : "2.2.2.2:test_export_path_two" ,
87
- "dest" : "test_mount_two" ,
88
+ "dest" : "/test_path_two/ test_mount_two" ,
88
89
},
89
90
{
90
91
"src" : "oci://bucket_name@namespace/synthetic/" ,
91
- "dest" : "test_mount_three" ,
92
+ "dest" : "/test_path_three/ test_mount_three" ,
92
93
}
93
94
)
94
95
)
114
115
shapeName: VM.Standard.E3.Flex
115
116
storageMount:
116
117
- src: 1.1.1.1:test_export_path_one
117
- dest: test_mount_one
118
+ dest: /test_path_one/ test_mount_one
118
119
- src: 2.2.2.2:test_export_path_two
119
- dest: test_mount_two
120
+ dest: /test_path_two/ test_mount_two
120
121
- src: oci://bucket_name@namespace/synthetic/
121
- dest: test_mount_three
122
+ dest: /test_path_three/ test_mount_three
122
123
subnetId: ocid1.subnet.oc1.iad.xxxx
123
124
type: dataScienceJob
124
125
name: My Job
@@ -142,17 +143,17 @@ def test_data_science_job_initialize(self):
142
143
dsc_file_storage_one = job .infrastructure .storage_mount [0 ]
143
144
assert isinstance (dsc_file_storage_one , dict )
144
145
assert dsc_file_storage_one ["src" ] == "1.1.1.1:test_export_path_one"
145
- assert dsc_file_storage_one ["dest" ] == "test_mount_one"
146
+ assert dsc_file_storage_one ["dest" ] == "/test_path_one/ test_mount_one"
146
147
147
148
dsc_file_storage_two = job .infrastructure .storage_mount [1 ]
148
149
assert isinstance (dsc_file_storage_two , dict )
149
150
assert dsc_file_storage_two ["src" ] == "2.2.2.2:test_export_path_two"
150
- assert dsc_file_storage_two ["dest" ] == "test_mount_two"
151
+ assert dsc_file_storage_two ["dest" ] == "/test_path_two/ test_mount_two"
151
152
152
153
dsc_object_storage = job .infrastructure .storage_mount [2 ]
153
154
assert isinstance (dsc_object_storage , dict )
154
155
assert dsc_object_storage ["src" ] == "oci://bucket_name@namespace/synthetic/"
155
- assert dsc_object_storage ["dest" ] == "test_mount_three"
156
+ assert dsc_object_storage ["dest" ] == "/test_path_three/ test_mount_three"
156
157
157
158
def test_data_science_job_from_yaml (self ):
158
159
job_from_yaml = Job .from_yaml (job_yaml_string )
@@ -161,17 +162,17 @@ def test_data_science_job_from_yaml(self):
161
162
dsc_file_storage_one = job_from_yaml .infrastructure .storage_mount [0 ]
162
163
assert isinstance (dsc_file_storage_one , dict )
163
164
assert dsc_file_storage_one ["src" ] == "1.1.1.1:test_export_path_one"
164
- assert dsc_file_storage_one ["dest" ] == "test_mount_one"
165
+ assert dsc_file_storage_one ["dest" ] == "/test_path_one/ test_mount_one"
165
166
166
167
dsc_file_storage_two = job .infrastructure .storage_mount [1 ]
167
168
assert isinstance (dsc_file_storage_two , dict )
168
169
assert dsc_file_storage_two ["src" ] == "2.2.2.2:test_export_path_two"
169
- assert dsc_file_storage_two ["dest" ] == "test_mount_two"
170
+ assert dsc_file_storage_two ["dest" ] == "/test_path_two/ test_mount_two"
170
171
171
172
dsc_object_storage = job .infrastructure .storage_mount [2 ]
172
173
assert isinstance (dsc_object_storage , dict )
173
174
assert dsc_object_storage ["src" ] == "oci://bucket_name@namespace/synthetic/"
174
- assert dsc_object_storage ["dest" ] == "test_mount_three"
175
+ assert dsc_object_storage ["dest" ] == "/test_path_three/ test_mount_three"
175
176
176
177
def test_data_science_job_to_dict (self ):
177
178
assert job .to_dict () == {
@@ -201,15 +202,15 @@ def test_data_science_job_to_dict(self):
201
202
"storageMount" : [
202
203
{
203
204
"src" : "1.1.1.1:test_export_path_one" ,
204
- "dest" : "test_mount_one" ,
205
+ "dest" : "/test_path_one/ test_mount_one" ,
205
206
},
206
207
{
207
208
"src" : "2.2.2.2:test_export_path_two" ,
208
- "dest" : "test_mount_two" ,
209
+ "dest" : "/test_path_two/ test_mount_two" ,
209
210
},
210
211
{
211
212
"src" : "oci://bucket_name@namespace/synthetic/" ,
212
- "dest" : "test_mount_three" ,
213
+ "dest" : "/test_path_three/ test_mount_three" ,
213
214
}
214
215
],
215
216
},
@@ -260,11 +261,11 @@ def test_update_storage_mount_from_dsc_model(
260
261
assert isinstance (infrastructure .storage_mount [1 ], dict )
261
262
assert infrastructure .storage_mount [0 ] == {
262
263
"src" : "mount_target_id_from_dsc:export_id_from_dsc" ,
263
- "dest" : "test_destination_directory_name_from_dsc"
264
+ "dest" : "/test_destination_path/ test_destination_directory_name_from_dsc"
264
265
}
265
266
assert infrastructure .storage_mount [1 ] == {
266
267
"src" : "mount_target_id_from_dsc:export_id_from_dsc" ,
267
- "dest" : "test_destination_directory_name_from_dsc"
268
+ "dest" : "/test_destination_path/ test_destination_directory_name_from_dsc"
268
269
}
269
270
270
271
@patch .object (OCIFileStorage , "update_to_dsc_model" )
@@ -276,6 +277,7 @@ def test_update_job_infra(
276
277
277
278
mock_update_to_dsc_model .return_value = {
278
279
"destinationDirectoryName" : "test_destination_directory_name_from_dsc" ,
280
+ "destination_path" : "/test_destination_path" ,
279
281
"exportId" : "test_export_id_one" ,
280
282
"mountTargetId" : "test_mount_target_id_one" ,
281
283
"storageType" : "FILE_STORAGE" ,
@@ -293,6 +295,7 @@ def test_update_job_infra(
293
295
0
294
296
] == {
295
297
"destinationDirectoryName" : "test_destination_directory_name_from_dsc" ,
298
+ "destination_path" : "/test_destination_path" ,
296
299
"exportId" : "test_export_id_one" ,
297
300
"mountTargetId" : "test_mount_target_id_one" ,
298
301
"storageType" : "FILE_STORAGE" ,
@@ -358,7 +361,7 @@ def test_file_manager_process_data_error(self):
358
361
def test_dsc_object_storage (self ):
359
362
object_storage = OCIObjectStorage (
360
363
src = "oci://bucket@namespace/prefix" ,
361
- dest = "test_dest" ,
364
+ dest = "/test_path/ test_dest" ,
362
365
)
363
366
364
367
result = object_storage .update_to_dsc_model ()
@@ -367,10 +370,12 @@ def test_dsc_object_storage(self):
367
370
assert result ["prefix" ] == "prefix"
368
371
assert result ["storageType" ] == "OBJECT_STORAGE"
369
372
assert result ["destinationDirectoryName" ] == "test_dest"
373
+ assert result ["destinationPath" ] == "/test_path"
370
374
371
375
dsc_model = ObjectStorageMountConfigurationDetails (
372
376
** {
373
377
"destination_directory_name" : "test_destination_directory_name_from_dsc" ,
378
+ "destination_path" : "/test_destination_path" ,
374
379
"storage_type" : "OBJECT_STORAGE" ,
375
380
"bucket" : "bucket" ,
376
381
"namespace" : "namespace" ,
@@ -380,17 +385,18 @@ def test_dsc_object_storage(self):
380
385
381
386
result = OCIObjectStorage .update_from_dsc_model (dsc_model )
382
387
assert result ["src" ] == "oci://bucket@namespace/prefix"
383
- assert result ["dest" ] == "test_destination_directory_name_from_dsc"
388
+ assert result ["dest" ] == "/test_destination_path/ test_destination_directory_name_from_dsc"
384
389
385
390
def test_dsc_object_storage_error (self ):
386
391
error_messages = {
387
392
"namespace" : "Missing parameter `namespace` from service. Check service log to see the error." ,
388
393
"bucket" : "Missing parameter `bucket` from service. Check service log to see the error." ,
389
- "destination_directory_name" : "Missing parameter `destination_directory_name` from service. Check service log to see the error."
394
+ "destination_directory_name" : "Missing parameter `destination_directory_name` from service. Check service log to see the error." ,
390
395
}
391
396
392
397
dsc_model_dict = {
393
398
"destination_directory_name" : "test_destination_directory_name_from_dsc" ,
399
+ "destination_path" : "/test_path" ,
394
400
"storage_type" : "OBJECT_STORAGE" ,
395
401
"bucket" : "bucket" ,
396
402
"namespace" : "namespace" ,
@@ -412,19 +418,20 @@ def test_dsc_object_storage_error(self):
412
418
def test_dsc_file_storage (self , mock_search_resources ):
413
419
file_storage = OCIFileStorage (
414
420
src = "ocid1.mounttarget.oc1.iad.xxxx:ocid1.export.oc1.iad.xxxx" ,
415
- dest = "test_dest" ,
421
+ dest = "/test_path/ test_dest" ,
416
422
)
417
423
file_storage = file_storage .update_to_dsc_model ()
418
424
assert file_storage == {
419
425
"destinationDirectoryName" : "test_dest" ,
426
+ "destinationPath" : "/test_path" ,
420
427
"exportId" : "ocid1.export.oc1.iad.xxxx" ,
421
428
"mountTargetId" : "ocid1.mounttarget.oc1.iad.xxxx" ,
422
429
"storageType" : "FILE_STORAGE"
423
430
}
424
431
425
432
file_storage = OCIFileStorage (
426
433
src = "1.1.1.1:/test_export" ,
427
- dest = "test_dest" ,
434
+ dest = "/test_path/ test_dest" ,
428
435
)
429
436
430
437
items = [
@@ -477,6 +484,7 @@ def test_dsc_file_storage(self, mock_search_resources):
477
484
file_storage = file_storage .update_to_dsc_model ()
478
485
assert file_storage == {
479
486
"destinationDirectoryName" : "test_dest" ,
487
+ "destinationPath" : "/test_path" ,
480
488
"exportId" : "ocid1.export.oc1.iad.xxxx" ,
481
489
"mountTargetId" : "ocid1.mounttarget.oc1.iad.xxxx" ,
482
490
"storageType" : "FILE_STORAGE"
@@ -485,24 +493,26 @@ def test_dsc_file_storage(self, mock_search_resources):
485
493
dsc_model = FileStorageMountConfigurationDetails (
486
494
** {
487
495
"destination_directory_name" : "test_dest" ,
496
+ "destination_path" : "/test_path" ,
488
497
"storage_type" : "FILE_STORAGE" ,
489
498
"export_id" : "ocid1.export.oc1.iad.xxxx" ,
490
499
"mount_target_id" : "ocid1.mounttarget.oc1.iad.xxxx"
491
500
}
492
501
)
493
502
result = OCIFileStorage .update_from_dsc_model (dsc_model )
494
503
assert result ["src" ] == "ocid1.mounttarget.oc1.iad.xxxx:ocid1.export.oc1.iad.xxxx"
495
- assert result ["dest" ] == "test_dest"
504
+ assert result ["dest" ] == "/test_path/ test_dest"
496
505
497
506
def test_dsc_file_storage_error (self ):
498
507
error_messages = {
499
508
"mount_target_id" : "Missing parameter `mount_target_id` from service. Check service log to see the error." ,
500
509
"export_id" : "Missing parameter `export_id` from service. Check service log to see the error." ,
501
- "destination_directory_name" : "Missing parameter `destination_directory_name` from service. Check service log to see the error."
510
+ "destination_directory_name" : "Missing parameter `destination_directory_name` from service. Check service log to see the error." ,
502
511
}
503
512
504
513
dsc_model_dict = {
505
514
"destination_directory_name" : "test_destination_directory_name_from_dsc" ,
515
+ "destination_path" : "/test_path" ,
506
516
"storage_type" : "FILE_STORAGE" ,
507
517
"mount_target_id" : "ocid1.mounttarget.oc1.iad.xxxx" ,
508
518
"export_id" : "ocid1.export.oc1.iad.xxxx" ,
@@ -517,4 +527,25 @@ def test_dsc_file_storage_error(self):
517
527
dsc_model_copy .pop (error )
518
528
OCIFileStorage .update_from_dsc_model (
519
529
FileStorageMountConfigurationDetails (** dsc_model_copy )
520
- )
530
+ )
531
+
532
+ def test_get_destination_path_and_name (self ):
533
+ path , directory = OCIFileStorage .get_destination_path_and_name ("abc" )
534
+
535
+ assert path == None
536
+ assert directory == "abc"
537
+
538
+ path , directory = OCIFileStorage .get_destination_path_and_name ("/abc" )
539
+
540
+ assert path == "/"
541
+ assert directory == "abc"
542
+
543
+ path , directory = OCIFileStorage .get_destination_path_and_name ("/abc/def" )
544
+
545
+ assert path == "/abc"
546
+ assert directory == "def"
547
+
548
+ path , directory = OCIFileStorage .get_destination_path_and_name ("/abc/def/ghi" )
549
+
550
+ assert path == "/abc/def"
551
+ assert directory == "ghi"
0 commit comments