aoelvp94 commented on pull request #19248:
URL: https://github.com/apache/airflow/pull/19248#issuecomment-1070762748


   
![image](https://user-images.githubusercontent.com/14033798/158788866-499b2201-8966-4ba0-a1c6-b50810add30f.png)
   I removed the main python file on purpose.
   
   ```python
   def get_week_ago(dt):
       bd = dt + relativedelta(days=-7)
       return bd.strftime('%Y-%m-%d')
   
   dag = DAG(
           dag_id=f"{table_name}_table_v4",
           ...
           user_defined_macros={'week_ago': get_week_ago}
       )
   
   
   create_batch = DataprocCreateBatchOperator(
           task_id="create_batch",
           project_id=project_id,
           region=f"{{{{ var.value.region_{environment} }}}}",
           batch=Batch(pyspark_batch=PySparkBatch(
           main_python_file_uri=main_python_file_uri,
           python_file_uris=files,
           args=[
               "--start-date",
               "{{ week_ago(execution_date) }}", # it doesn't work
               "--end-date",
               "{{ ds }}", # it doesn't work
               "--table",
               table_name,
               "--source-bucket",
               source_bucket,
               "--source-prefix",
               source_prefix,
               "--output-path",
               f"{output_path}/{table_name}/",
           ],
       ), 
runtime_config=RuntimeConfig(container_image="gcr.io/company/image_name:1.0.1")),
           batch_id=f"pyspark-table-{table_name.replace('_','-')}-{{{{ 
ds_nodash }}}}",
           retry=DEFAULT,
           timeout=500,
       )
   ```


-- 
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]


Reply via email to