You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/11/16 16:58:32 UTC

[GitHub] [airflow] AnithaG-Oak edited a comment on issue #19618: Execution_date not rendering after airflow upgrade

AnithaG-Oak edited a comment on issue #19618:
URL: https://github.com/apache/airflow/issues/19618#issuecomment-970461874


   ```
   properties = SparkProperties.from_config("small")
   
   def execution_date():
       return "{{ (execution_date if execution_date.microsecond > 0 else dag.following_schedule(execution_date)).isoformat() }}"
   
   def spark_job(task_id: str,
       spark: SparkProperties,
       main_class: Optional[str],
       *args,
       py_files: Optional[str] = None,
       jars: Optional[str] = None,
       **kwargs,) -> SparkSubmitOperator:
      return SparkSubmitOperator(
           task_id=task_id,
           application=path,
           conf=spark.conf(),
           py_files=py_files,
           jars=jars,
           conn_id=spark.conn_id,
           java_class=main_class or None,
           total_executor_cores=spark.total_executor_cores,
           executor_cores=spark.executor_cores,
           executor_memory=spark.executor_memory,
           driver_memory=spark.driver_memory,
           name=task_id,
           num_executors=spark.num_executors,
           application_args=spark_args(*args, **kwargs),
           env_vars=spark.env_vars(),
       )
   
   def test1() -> SparkSubmitOperator:
       return spark_job(
           task_id=f"test_dag",
           spark=properties,
           main_class="TestSparkJob",
           execution_date=execution_date()
       )
   
   
   def test_dag(this: DAG) -> DAG:
       with this:
           (label("start") >> test1() >> label("finish"))
       return this
   
   
   with DAG(
       f"test_workflow", default_args=DEFAULT_ARGS, schedule_interval="@once", max_active_runs=1,
   ) as dag:
       (test_dag(dag))
   
   ```


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org