I'm trying to find a way to generalize passing parameters of a dag when triggering it from the UI itself,I know I should pass it as a key/value pair format but I don't know how to parse those parameters in the dag script itself
for example if I pass the conf pair {"dir_of_project":"root/home/project"}
what should i do inside the dag script so that I have inside it a variable called dir_of_project that equals the path above so that I can use it further in my code. I tried to do the following inside the script but obviously i'm doing it wrong :
dir of project = "{{ dag_run.conf['file_name'] }}"
for example let's say i did this:
def func(**kwargs):
file_name = kwargs['dag_run'].conf.get('dir_of_project')
return file_name
op = PythonOperator(
task_id='task',
python_callable=func,
dag=dag,
provide_context=True
)
sampling_out_parent_dir="/root/home/myfolder/sampled-vids"
file_path=os.path.join(sampling_out_parent_dir,file_name)
this would result in an undef. variable error as it's defined only in the scope of the fn and the operator and i can't used it outside like this, so how can i make it work?