0

How to update the params on the fly?
I want to update 'input_file' param to the path present in file 'temp_file.txt'

import datetime as dt
from airflow import DAG
from airflow.providers.ssh.operators.ssh import SSHOperator
from airflow.providers.ssh.hooks.ssh import SSHHook
from airflow.models.param import Param
from airflow.providers.ssh.operators.ssh import SSHOperator
from airflow.models import DAG
with DAG(
    'tanvi_dag',
    start_date=dt.datetime(2022, 5, 16),
    schedule_interval=None,
    params={
        'input_file': Param(default='/tmp/test_input.txt', type='string'),
        'ouptut_file': Param(default='/tmp/test_output.txt', type='string'),
    }
) as dag:
        _HOOK = SSHHook(
        )
        run_task_test = SSHOperator(
        task_id='run_task',
        ssh_hook=_HOOK,
        command=
            """update_input_file=$(cat temp_file.txt) \n"""
            # how to update the params  ?
            # I want to update 'input_file' from params to one which is captured in 'update_input_file'
            # temp_file is a file which has
        )
        run_task_test

Tried updating - {{ dag_run.conf }}

  • Can you provide the context of what you are trying to accomplish? Even if it is possible, I am not sure manipulating parameters at the DAG level is the right approach as that data is suppose to be pretty static. I have a couple ideas, but I would like more info on the use case. – Tevett Goad Aug 09 '23 at 19:03

0 Answers0