Kulasangar
Kulasangar

Reputation: 9434

How to capture values returned from a Python Class in Airflow Dag Script?

I have a python class which actually returns a set of values ( two strings and a list ). I'd need to capture these values in Airflow Dag Script and populate the values into a dictionary later. It'd be great to know If anyone has come across a way to store the values returned from a Python class in Airflow?

For Eg I have a class X() and it has a method Y() which returns those 3 values. So can I do something like below to capture those values in Airflow?

x = X() 
val1, val2, val3 = x.Y() # to capture the values

Also what sort of an Airflow operator should I be using in order to achieve this ( like either Bash or Python operator )?

Upvotes: 0

Views: 271

Answers (1)

balderman
balderman

Reputation: 23815

Use AirFlow Varaible

d = {'x':'y'}
Variable.set('my_data_key',json.dumps(d))

Upvotes: 1

Related Questions