@@ -384,6 +384,8 @@ class DataFlow(Infrastructure):
384
384
CONST_OCPUS = "ocpus"
385
385
CONST_ID = "id"
386
386
CONST_PRIVATE_ENDPOINT_ID = "private_endpoint_id"
387
+ CONST_FREEFORM_TAGS = "freeform_tags"
388
+ CONST_DEFINED_TAGS = "defined_tags"
387
389
388
390
attribute_map = {
389
391
CONST_COMPARTMENT_ID : "compartmentId" ,
@@ -402,6 +404,8 @@ class DataFlow(Infrastructure):
402
404
CONST_OCPUS : CONST_OCPUS ,
403
405
CONST_ID : CONST_ID ,
404
406
CONST_PRIVATE_ENDPOINT_ID : "privateEndpointId" ,
407
+ CONST_FREEFORM_TAGS : "freeformTags" ,
408
+ CONST_DEFINED_TAGS : "definedTags"
405
409
}
406
410
407
411
def __init__ (self , spec : dict = None , ** kwargs ):
@@ -414,7 +418,9 @@ def __init__(self, spec: dict = None, **kwargs):
414
418
spec = {
415
419
k : v
416
420
for k , v in spec .items ()
417
- if f"with_{ camel_to_snake (k )} " in self .__dir__ () and v is not None
421
+ if (f"with_{ camel_to_snake (k )} " in self .__dir__ ()
422
+ or (k == "defined_tags" or "freeform_tags" ))
423
+ and v is not None
418
424
}
419
425
defaults .update (spec )
420
426
super ().__init__ (defaults , ** kwargs )
@@ -775,6 +781,36 @@ def with_private_endpoint_id(self, private_endpoint_id: str) -> "DataFlow":
775
781
the Data Flow instance itself
776
782
"""
777
783
return self .set_spec (self .CONST_PRIVATE_ENDPOINT_ID , private_endpoint_id )
784
+
785
+ def with_freeform_tag (self , ** kwargs ) -> "DataFlow" :
786
+ """Sets freeform tags
787
+
788
+ Returns
789
+ -------
790
+ DataFlow
791
+ The DataFlow instance (self)
792
+ """
793
+ return self .set_spec (self .CONST_FREEFORM_TAGS , kwargs )
794
+
795
+ def with_defined_tag (self , ** kwargs ) -> "DataFlow" :
796
+ """Sets defined tags
797
+
798
+ Returns
799
+ -------
800
+ DataFlow
801
+ The DataFlow instance (self)
802
+ """
803
+ return self .set_spec (self .CONST_DEFINED_TAGS , kwargs )
804
+
805
+ @property
806
+ def freeform_tags (self ) -> dict :
807
+ """Freeform tags"""
808
+ return self .get_spec (self .CONST_FREEFORM_TAGS , {})
809
+
810
+ @property
811
+ def defined_tags (self ) -> dict :
812
+ """Defined tags"""
813
+ return self .get_spec (self .CONST_DEFINED_TAGS , {})
778
814
779
815
def __getattr__ (self , item ):
780
816
if f"with_{ item } " in self .__dir__ ():
@@ -849,7 +885,8 @@ def create(self, runtime: DataFlowRuntime, **kwargs) -> "DataFlow":
849
885
{
850
886
"display_name" : self .name ,
851
887
"file_uri" : runtime .script_uri ,
852
- "freeform_tags" : runtime .freeform_tags ,
888
+ "freeform_tags" : runtime .freeform_tags or self .freeform_tags ,
889
+ "defined_tags" : runtime .defined_tags or self .defined_tags ,
853
890
"archive_uri" : runtime .archive_uri ,
854
891
"configuration" : runtime .configuration ,
855
892
}
@@ -915,6 +952,7 @@ def run(
915
952
args : List [str ] = None ,
916
953
env_vars : Dict [str , str ] = None ,
917
954
freeform_tags : Dict [str , str ] = None ,
955
+ defined_tags : Dict [str , Dict [str , object ]] = None ,
918
956
wait : bool = False ,
919
957
** kwargs ,
920
958
) -> DataFlowRun :
@@ -932,6 +970,8 @@ def run(
932
970
dictionary of environment variables (not used for data flow)
933
971
freeform_tags: Dict[str, str], optional
934
972
freeform tags
973
+ defined_tags: Dict[str, Dict[str, object]], optional
974
+ defined tags
935
975
wait: bool, optional
936
976
whether to wait for a run to terminate
937
977
kwargs
@@ -950,7 +990,8 @@ def run(
950
990
# Set default display_name if not specified - randomly generated easy to remember name generated
951
991
payload ["display_name" ] = name if name else utils .get_random_name_for_resource ()
952
992
payload ["arguments" ] = args if args and len (args ) > 0 else None
953
- payload ["freeform_tags" ] = freeform_tags
993
+ payload ["freeform_tags" ] = freeform_tags or self .freeform_tags
994
+ payload ["defined_tags" ] = defined_tags or self .defined_tags
954
995
payload .pop ("spark_version" , None )
955
996
logger .debug (f"Creating a DataFlow Run with payload { payload } " )
956
997
run = DataFlowRun (** payload ).create ()
0 commit comments