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 2020/12/06 23:32:43 UTC
[GitHub] [airflow] humbledude commented on issue #12081: PapermillOperator does not take user defined macros
humbledude commented on issue #12081:
URL: https://github.com/apache/airflow/issues/12081#issuecomment-739584766
Hi, @rootcss.
I wrote DAG like this:
```
from airflow.utils import timezone
from airflow.operators.papermill_operator import PapermillOperator
from airflow import DAG
from common.macros import seoul_date
dag = DAG(
dag_id='papermill-test2',
start_date=timezone.datetime(2019, 9, 1),
schedule_interval='0 15 * * *',
catchup=False,
user_defined_macros={
'seoul_date': seoul_date
}
)
with dag:
t1 = PapermillOperator(
task_id='papermill-task',
input_nb='s3://test/papermill_test.ipynb',
output_nb='s3://test/papermill_test_result.ipynb',
parameters={
'a': '{{ seoul_date(execution_date) }}',
'b': 'test',
}
)
```
`seoul_date` is defined as:
```
KST = pendulum.timezone('Asia/Seoul')
def seoul_date(execution_date, years=0, months=0, days=0, hours=0, fmt="%Y%m%d"):
return KST.convert(pendulum.instance(execution_date)).add(years=years, months=months, days=days, hours=hours).strftime(fmt)
```
This DAG does not work because of `seoul_date`.
Error log says, `'seoul_date' is undefined`
If I remove using `seoul_date` on parameters, then DAG works fine.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org