15
15
DataTransferImportJobSchema ,
16
16
DataTransferExportJobSchema ,
17
17
)
18
- from azure .ai .ml .constants ._component import NodeType , ExternalDataType , DataTransferTaskType
18
+ from azure .ai .ml .constants ._component import (
19
+ NodeType ,
20
+ ExternalDataType ,
21
+ DataTransferTaskType ,
22
+ )
19
23
from azure .ai .ml .entities ._component .datatransfer_component import (
20
24
DataTransferCopyComponent ,
21
25
DataTransferImportComponent ,
30
34
DataTransferExportJob ,
31
35
)
32
36
from azure .ai .ml .constants ._common import BASE_PATH_CONTEXT_KEY , AssetTypes
33
- from azure .ai .ml .exceptions import ErrorCategory , ErrorTarget , ValidationErrorType , ValidationException
37
+ from azure .ai .ml .exceptions import (
38
+ ErrorCategory ,
39
+ ErrorTarget ,
40
+ ValidationErrorType ,
41
+ ValidationException ,
42
+ )
34
43
from azure .ai .ml .entities ._inputs_outputs .external_data import Database , FileSystem
35
44
36
45
@@ -53,17 +62,23 @@ def _build_source_sink(io_dict: Union[Dict, Database, FileSystem]):
53
62
component_io = io_dict
54
63
else :
55
64
if isinstance (io_dict , dict ):
56
- data_type = io_dict .get ("type" , None )
65
+ data_type = io_dict .pop ("type" , None )
57
66
if data_type == ExternalDataType .DATABASE :
58
67
component_io = Database (** io_dict )
59
68
elif data_type == ExternalDataType .FILE_SYSTEM :
60
69
component_io = FileSystem (** io_dict )
61
70
else :
62
71
msg = "Type in source or sink only support {} and {}, currently got {}."
63
72
raise ValidationException (
64
- message = msg .format (ExternalDataType .DATABASE , ExternalDataType .FILE_SYSTEM , data_type ),
73
+ message = msg .format (
74
+ ExternalDataType .DATABASE ,
75
+ ExternalDataType .FILE_SYSTEM ,
76
+ data_type ,
77
+ ),
65
78
no_personal_data_message = msg .format (
66
- ExternalDataType .DATABASE , ExternalDataType .FILE_SYSTEM , "data_type"
79
+ ExternalDataType .DATABASE ,
80
+ ExternalDataType .FILE_SYSTEM ,
81
+ "data_type" ,
67
82
),
68
83
target = ErrorTarget .DATA_TRANSFER_JOB ,
69
84
error_category = ErrorCategory .USER_ERROR ,
@@ -157,8 +172,6 @@ class DataTransferCopy(DataTransfer):
157
172
:type experiment_name: str
158
173
:param compute: The compute target the job runs on.
159
174
:type compute: str
160
- :param task: task type in data transfer component, possible value is "copy_data".
161
- :type task: str
162
175
:param data_copy_mode: data copy mode in copy task, possible value is "merge_with_overwrite", "fail_if_conflict".
163
176
:type data_copy_mode: str
164
177
:raises ~azure.ai.ml.exceptions.ValidationException: Raised if DataTransferCopy cannot be successfully validated.
@@ -173,7 +186,6 @@ def __init__(
173
186
compute : Optional [str ] = None ,
174
187
inputs : Optional [Dict [str , Union [NodeOutput , Input , str ]]] = None ,
175
188
outputs : Optional [Dict [str , Union [str , Output ]]] = None ,
176
- task : Optional [str ] = DataTransferTaskType .COPY_DATA ,
177
189
data_copy_mode : Optional [str ] = None ,
178
190
** kwargs ,
179
191
):
@@ -188,7 +200,7 @@ def __init__(
188
200
)
189
201
# init mark for _AttrDict
190
202
self ._init = True
191
- self .task = task
203
+ self .task = DataTransferTaskType . COPY_DATA
192
204
self .data_copy_mode = data_copy_mode
193
205
is_component = isinstance (component , DataTransferCopyComponent )
194
206
if is_component :
@@ -214,7 +226,10 @@ def _picked_fields_from_dict_to_rest_object(cls) -> List[str]:
214
226
215
227
def _to_rest_object (self , ** kwargs ) -> dict :
216
228
rest_obj = super ()._to_rest_object (** kwargs )
217
- for key , value in {"componentId" : self ._get_component_id (), "data_copy_mode" : self .data_copy_mode }.items ():
229
+ for key , value in {
230
+ "componentId" : self ._get_component_id (),
231
+ "data_copy_mode" : self .data_copy_mode ,
232
+ }.items ():
218
233
if value is not None :
219
234
rest_obj [key ] = value
220
235
return convert_ordered_dict_to_dict (rest_obj )
@@ -240,7 +255,6 @@ def _to_job(self) -> DataTransferCopyJob:
240
255
outputs = self ._job_outputs ,
241
256
services = self .services ,
242
257
compute = self .compute ,
243
- task = self .task ,
244
258
data_copy_mode = self .data_copy_mode ,
245
259
)
246
260
@@ -301,8 +315,6 @@ class DataTransferImport(DataTransfer):
301
315
:type experiment_name: str
302
316
:param compute: The compute target the job runs on.
303
317
:type compute: str
304
- :param task: task type in data transfer component, possible value is "import_data".
305
- :type task: str
306
318
:raises ~azure.ai.ml.exceptions.ValidationException: Raised if DataTransferImport cannot be successfully validated.
307
319
Details will be provided in the error message.
308
320
"""
@@ -315,7 +327,6 @@ def __init__(
315
327
compute : Optional [str ] = None ,
316
328
source : Optional [Union [Dict , Database , FileSystem ]] = None ,
317
329
outputs : Optional [Dict [str , Union [str , Output ]]] = None ,
318
- task : Optional [str ] = DataTransferTaskType .IMPORT_DATA ,
319
330
** kwargs ,
320
331
):
321
332
# validate init params are valid type
@@ -328,7 +339,7 @@ def __init__(
328
339
)
329
340
# init mark for _AttrDict
330
341
self ._init = True
331
- self .task = task
342
+ self .task = DataTransferTaskType . IMPORT_DATA
332
343
is_component = isinstance (component , DataTransferImportComponent )
333
344
if is_component :
334
345
self .task = component .task or self .task
@@ -409,7 +420,6 @@ def _to_job(self) -> DataTransferImportJob:
409
420
outputs = self ._job_outputs ,
410
421
services = self .services ,
411
422
compute = self .compute ,
412
- task = self .task ,
413
423
)
414
424
415
425
@@ -438,8 +448,6 @@ class DataTransferExport(DataTransfer):
438
448
:type experiment_name: str
439
449
:param compute: The compute target the job runs on.
440
450
:type compute: str
441
- :param task: task type in data transfer component, possible value is "export_data".
442
- :type task: str
443
451
:raises ~azure.ai.ml.exceptions.ValidationException: Raised if DataTransferExport cannot be successfully validated.
444
452
Details will be provided in the error message.
445
453
"""
@@ -452,7 +460,6 @@ def __init__(
452
460
compute : Optional [str ] = None ,
453
461
sink : Optional [Union [Dict , Database , FileSystem ]] = None ,
454
462
inputs : Optional [Dict [str , Union [NodeOutput , Input , str ]]] = None ,
455
- task : Optional [str ] = DataTransferTaskType .EXPORT_DATA ,
456
463
** kwargs ,
457
464
):
458
465
# validate init params are valid type
@@ -465,7 +472,7 @@ def __init__(
465
472
)
466
473
# init mark for _AttrDict
467
474
self ._init = True
468
- self .task = task
475
+ self .task = DataTransferTaskType . EXPORT_DATA
469
476
is_component = isinstance (component , DataTransferExportComponent )
470
477
if is_component :
471
478
self .task = component .task or self .task
@@ -560,5 +567,4 @@ def _to_job(self) -> DataTransferExportJob:
560
567
inputs = self ._job_inputs ,
561
568
services = self .services ,
562
569
compute = self .compute ,
563
- task = self .task ,
564
570
)
0 commit comments