@@ -54,37 +54,22 @@ class InputArtifacts(AutonamedDict):
54
54
def __setitem__ (self , key , value ):
55
55
assert isinstance (value , InputArtifact )
56
56
super ().__setitem__ (key , value )
57
- if (config ["save_path_as_parameter" ] or
58
- config ["save_path_as_artifact" ]) and self .template is not None :
57
+ if config ["save_path_as_parameter" ] and self .template is not None :
59
58
if isinstance (value .source , S3Artifact ):
60
- self .template .inputs .parameters [
61
- "dflow_%s_path_list" % key ] = InputParameter (
62
- value = value .source .path_list ,
63
- save_as_artifact = config ["save_path_as_artifact" ],
64
- optional = True , save_type = False )
65
- elif config ["save_path_as_artifact" ]:
66
- self .template .inputs .parameters [
67
- "dflow_%s_path_list" % key ] = InputParameter (
68
- optional = True , save_as_artifact = True )
59
+ self .template .inputs .parameters ["dflow_%s_path_list" % key ] = \
60
+ InputParameter (value = value .source .path_list )
69
61
else :
70
- self .template .inputs .parameters [
71
- "dflow_%s_path_list" % key ] = InputParameter (
72
- value = [])
62
+ self .template .inputs .parameters ["dflow_%s_path_list" % key ] = \
63
+ InputParameter (value = [])
73
64
74
65
def set_template (self , template ):
75
66
super ().set_template (template )
76
- if config ["save_path_as_parameter" ] or config [ "save_path_as_artifact" ] :
67
+ if config ["save_path_as_parameter" ]:
77
68
for name , art in self .items ():
78
69
if isinstance (art .source , S3Artifact ):
79
70
self .template .inputs .parameters ["dflow_%s_path_list"
80
71
% name ] = InputParameter (
81
- value = art .source .path_list ,
82
- save_as_artifact = config ["save_path_as_artifact" ],
83
- optional = True , save_type = False )
84
- elif config ["save_path_as_artifact" ]:
85
- self .template .inputs .parameters ["dflow_%s_path_list"
86
- % name ] = InputParameter (
87
- optional = True , save_as_artifact = True )
72
+ value = art .source .path_list )
88
73
else :
89
74
self .template .inputs .parameters ["dflow_%s_path_list"
90
75
% name ] = InputParameter (
@@ -101,22 +86,17 @@ class OutputArtifacts(AutonamedDict):
101
86
def __setitem__ (self , key , value ):
102
87
assert isinstance (value , OutputArtifact )
103
88
super ().__setitem__ (key , value )
104
- if (config ["save_path_as_parameter" ] or
105
- config ["save_path_as_artifact" ]) and self .template is not None :
89
+ if config ["save_path_as_parameter" ] and self .template is not None :
106
90
self .template .outputs .parameters ["dflow_%s_path_list" % key ] = \
107
- OutputParameter (
108
- value = [], optional = True ,
109
- save_as_artifact = config ["save_path_as_artifact" ])
91
+ OutputParameter (value = [])
110
92
value .handle_path_list ()
111
93
112
94
def set_template (self , template ):
113
95
super ().set_template (template )
114
- if config ["save_path_as_parameter" ] or config [ "save_path_as_artifact" ] :
96
+ if config ["save_path_as_parameter" ]:
115
97
for name , art in self .items ():
116
98
self .template .outputs .parameters ["dflow_%s_path_list" % name ]\
117
- = OutputParameter (
118
- value = [], optional = True ,
119
- save_as_artifact = config ["save_path_as_artifact" ])
99
+ = OutputParameter (value = [])
120
100
art .handle_path_list ()
121
101
122
102
@@ -246,8 +226,6 @@ def __init__(
246
226
path : str = None ,
247
227
source : Union ["InputArtifact" ,
248
228
"OutputArtifact" , S3Artifact ] = None ,
249
- optional : bool = None ,
250
- save_type : bool = True ,
251
229
** kwargs ,
252
230
) -> None :
253
231
self .name = name
@@ -259,8 +237,6 @@ def __init__(
259
237
self .save_as_artifact = save_as_artifact
260
238
self .path = path
261
239
self .source = source
262
- self .optional = optional
263
- self .save_type = save_type
264
240
265
241
def __getattr__ (self , key ):
266
242
if key == "expr" :
@@ -323,8 +299,7 @@ def convert_to_argo(self):
323
299
InputArtifact , OutputArtifact )):
324
300
return V1alpha1Artifact (name = "dflow_bigpar_" + self .name ,
325
301
path = self .path ,
326
- _from = str (self .value ),
327
- optional = self .optional )
302
+ _from = str (self .value ))
328
303
else :
329
304
with tempfile .TemporaryDirectory () as tmpdir :
330
305
content = {}
@@ -336,23 +311,18 @@ def convert_to_argo(self):
336
311
content ["type" ] = str (self .type )
337
312
path = tmpdir + "/" + self .name
338
313
with open (path , "w" ) as f :
339
- if self .save_type :
340
- f .write (jsonpickle .dumps (content ))
341
- else :
342
- f .write (content ["value" ])
314
+ f .write (jsonpickle .dumps (content ))
343
315
key = upload_s3 (path )
344
316
s3 = S3Artifact (key = key )
345
317
return V1alpha1Artifact (name = "dflow_bigpar_" + self .name ,
346
- path = self .path , s3 = s3 ,
347
- optional = self .optional )
318
+ path = self .path , s3 = s3 )
348
319
elif isinstance (self .source , (InputParameter , OutputParameter ,
349
320
InputArtifact , OutputArtifact )):
350
321
return V1alpha1Artifact (name = "dflow_bigpar_" + self .name ,
351
- path = self .path , _from = str (self .source ),
352
- optional = self .optional )
322
+ path = self .path , _from = str (self .source ))
353
323
else :
354
324
return V1alpha1Artifact (name = "dflow_bigpar_" + self .name ,
355
- path = self .path , optional = self . optional )
325
+ path = self .path )
356
326
357
327
if not hasattr (self , "value" ):
358
328
return V1alpha1Parameter (name = self .name , description = description )
@@ -456,11 +426,9 @@ def convert_to_argo(self):
456
426
_from = str (self .source ), sub_path = sub_path ,
457
427
mode = self .mode )
458
428
elif isinstance (self .source , S3Artifact ):
459
- sub_path = self .sub_path if self .sub_path is not None else \
460
- self .source ._sub_path
461
429
return V1alpha1Artifact (name = self .name , path = self .path ,
462
430
optional = self .optional , s3 = self .source ,
463
- sub_path = sub_path , mode = self .mode )
431
+ sub_path = self . sub_path , mode = self .mode )
464
432
elif isinstance (self .source , str ):
465
433
return V1alpha1Artifact (name = self .name , path = self .path ,
466
434
optional = self .optional ,
@@ -499,8 +467,6 @@ def __init__(
499
467
global_name : str = None ,
500
468
value_from_expression : Union [str , IfExpression ] = None ,
501
469
save_as_artifact : bool = False ,
502
- optional : bool = None ,
503
- save : List [Union [PVC , S3Artifact ]] = None ,
504
470
** kwargs ,
505
471
) -> None :
506
472
self .value_from_path = value_from_path
@@ -516,18 +482,9 @@ def __init__(
516
482
self .default = kwargs ["default" ]
517
483
if "value" in kwargs :
518
484
self .value = kwargs ["value" ]
519
- self .optional = optional
520
- if save is None :
521
- save = []
522
- elif not isinstance (save , list ):
523
- save = [save ]
524
- self .save = save
525
- self .redirect = None
526
485
527
486
def __getattr__ (self , key ):
528
487
if key == "expr" :
529
- if self .redirect is not None :
530
- return self .redirect .expr
531
488
if self .save_as_artifact :
532
489
if self .name is not None :
533
490
if self .step is not None :
@@ -566,8 +523,6 @@ def __setattr__(self, key, value):
566
523
return super ().__setattr__ (key , value )
567
524
568
525
def __repr__ (self ):
569
- if self .redirect is not None :
570
- return str (self .redirect )
571
526
if self .save_as_artifact :
572
527
if self .name is not None :
573
528
if self .step is not None :
@@ -597,35 +552,24 @@ def convert_to_argo(self):
597
552
description = jsonpickle .dumps ({"type" : str (self .type )})
598
553
599
554
if self .save_as_artifact :
600
- s3 = None
601
- for save in self .save :
602
- if isinstance (save , S3Artifact ):
603
- s3 = deepcopy (save )
604
- if s3 ._sub_path is not None :
605
- if s3 .key [- 1 ] != "/" :
606
- s3 .key += "/"
607
- s3 .key += s3 ._sub_path
608
-
609
555
if self .value_from_path is not None :
610
556
return V1alpha1Artifact (
611
557
name = "dflow_bigpar_" + self .name ,
612
- path = self .value_from_path , global_name = self . global_name ,
613
- s3 = s3 , archive = V1alpha1ArchiveStrategy (_none = {}),
614
- optional = self .optional )
558
+ path = self .value_from_path ,
559
+ archive = V1alpha1ArchiveStrategy (_none = {}),
560
+ global_name = self .global_name )
615
561
elif self .value_from_parameter is not None :
616
562
return V1alpha1Artifact (
617
563
name = "dflow_bigpar_" + self .name ,
618
564
_from = str (self .value_from_parameter ),
619
- global_name = self .global_name ,
620
- s3 = s3 , archive = V1alpha1ArchiveStrategy (_none = {}),
621
- optional = self .optional )
565
+ archive = V1alpha1ArchiveStrategy (_none = {}),
566
+ global_name = self .global_name )
622
567
elif self .value_from_expression is not None :
623
568
return V1alpha1Artifact (
624
569
name = "dflow_bigpar_" + self .name ,
625
570
from_expression = str (self .value_from_expression ),
626
- global_name = self .global_name , s3 = s3 ,
627
571
archive = V1alpha1ArchiveStrategy (_none = {}),
628
- optional = self .optional )
572
+ global_name = self .global_name )
629
573
else :
630
574
raise RuntimeError ("Not supported." )
631
575
@@ -682,7 +626,6 @@ class OutputArtifact(ArgoVar):
682
626
archive: compress format of the artifact, None for no compression
683
627
global_name: global name of the artifact within the workflow
684
628
from_expression: the artifact is from an expression
685
- optional: optional artifact or not
686
629
"""
687
630
688
631
def __init__ (
@@ -697,7 +640,6 @@ def __init__(
697
640
archive : str = "default" ,
698
641
global_name : str = None ,
699
642
from_expression : Union [IfExpression , str ] = None ,
700
- optional : bool = None ,
701
643
** kwargs ,
702
644
) -> None :
703
645
self .path = path
@@ -718,7 +660,6 @@ def __init__(
718
660
self .from_expression = from_expression
719
661
self .redirect = None
720
662
self ._from = _from
721
- self .optional = optional
722
663
723
664
def sub_path (self , path ):
724
665
artifact = deepcopy (self )
@@ -745,9 +686,8 @@ def __getattr__(self, key):
745
686
746
687
def __setattr__ (self , key , value ):
747
688
super ().__setattr__ (key , value )
748
- if (config ["save_path_as_parameter" ] or
749
- config ["save_path_as_artifact" ]) \
750
- and key in ["_from" , "from_expression" ]:
689
+ if config ["save_path_as_parameter" ] and key in ["_from" ,
690
+ "from_expression" ]:
751
691
self .handle_path_list ()
752
692
753
693
def handle_path_list (self ):
@@ -805,27 +745,20 @@ def convert_to_argo(self):
805
745
s3 = None
806
746
for save in self .save :
807
747
if isinstance (save , S3Artifact ):
808
- s3 = deepcopy (save )
809
- if s3 ._sub_path is not None :
810
- if s3 .key [- 1 ] != "/" :
811
- s3 .key += "/"
812
- s3 .key += s3 ._sub_path
748
+ s3 = save
813
749
814
750
if self .path is not None :
815
751
return V1alpha1Artifact (name = self .name , path = self .path ,
816
752
archive = archive , s3 = s3 ,
817
- global_name = self .global_name ,
818
- optional = self .optional )
753
+ global_name = self .global_name )
819
754
elif self ._from is not None :
820
755
return V1alpha1Artifact (name = self .name , _from = str (self ._from ),
821
756
archive = archive , s3 = s3 ,
822
- global_name = self .global_name ,
823
- optional = self .optional )
757
+ global_name = self .global_name )
824
758
elif self .from_expression is not None :
825
759
return V1alpha1Artifact (
826
760
name = self .name , from_expression = str (self .from_expression ),
827
- archive = archive , s3 = s3 , global_name = self .global_name ,
828
- optional = self .optional )
761
+ archive = archive , s3 = s3 , global_name = self .global_name )
829
762
else :
830
763
raise RuntimeError ("Output artifact %s is not specified" % self )
831
764
0 commit comments