themitigater commented on issue #36567:
URL: https://github.com/apache/airflow/issues/36567#issuecomment-1875911494
This is my DAG File
```python
from airflow.models import DAG
from utils.helpers import analytical_pipeline_params, dataflow_request,
dag_start_date
from operators.dataflow_staging import (
DataflowStartFlexTemplateOperator,
)
from airflow.hooks.base_hook import BaseHook
from hooks.failure_hook import failure_hook
name = "some-"
env = "staging"
ENV_PREFIX = ""
if env != "prod":
ENV_PREFIX = f"{env}-"
JOB_NAME_SUFFIX = (
"{{macros.ds_format(data_interval_start,'%Y-%m-%dT%H:%M:%S%z','%Y%m%d-%H%M%S')}}"
)
JOB_NAME_SUFFIX += "-" + "{{task_instance.try_number}}"
params = analytical_pipeline_params(ENV_PREFIX, BaseHook, 30, 0, 0, env)
request_params = dataflow_request(ENV_PREFIX, name, JOB_NAME_SUFFIX)
body = request_params["body"]
default_args = {"start_date": dag_start_date(days=2)}
with DAG(
f"dataflow_dag-{ENV_PREFIX}{name}",
params=params,
default_args=default_args,
is_paused_upon_creation=True,
tags=[env, "AssistedVideo", "VS", "Analytical", "Hourly"],
schedule_interval="5,35 4-15 * * 1-5",
on_failure_callback=failure_hook,
) as dag:
parameters = {
"clickhouseURL": "{{params.clickhouseURL}}",
"minutes": "{{ params.minutes }}",
"hours": "{{ params.hours }}",
"days": "{{ params.days }}",
"startTime": "{{ data_interval_start - macros.timedelta(minutes=5)
if dag_run.run_type != 'manual' else params.startTime }}",
}
body["launchParameter"]["parameters"] = parameters
start_template_job = DataflowStartFlexTemplateOperator(
task_id=f"dataflow_operator-{ENV_PREFIX}{name}",
project_id=request_params["project"],
location=request_params["region"],
body=body,
wait_until_finished=True,
dag=dag,
do_xcom_push=False,
)
if __name__ == "__main__":
dag.test()
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]