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/11/04 08:34:59 UTC

[GitHub] [airflow] humbledude opened a new issue #12081: PapermillOperator does not take user defined macros

humbledude opened a new issue #12081:
URL: https://github.com/apache/airflow/issues/12081


   <!--
   
   Welcome to Apache Airflow!  For a smooth issue process, try to answer the following questions.
   Don't worry if they're not all applicable; just try to include what you can :-)
   
   If you need to include code snippets or logs, please put them in fenced code
   blocks.  If they're super-long, please use the details tag like
   <details><summary>super-long log</summary> lots of stuff </details>
   
   Please delete these comment blocks before submitting the issue.
   
   -->
   
   <!--
   
   IMPORTANT!!!
   
   PLEASE CHECK "SIMILAR TO X EXISTING ISSUES" OPTION IF VISIBLE
   NEXT TO "SUBMIT NEW ISSUE" BUTTON!!!
   
   PLEASE CHECK IF THIS ISSUE HAS BEEN REPORTED PREVIOUSLY USING SEARCH!!!
   
   Please complete the next sections or the issue will be closed.
   These questions are the first thing we need to know to understand the context.
   
   -->
   
   **Apache Airflow version**:
   1.10.12
   
   **Kubernetes version (if you are using kubernetes)** (use `kubectl version`):
   1.15.11
   
   **Environment**:
   
   - **Cloud provider or hardware configuration**:
   - **OS** (e.g. from /etc/os-release):
   - **Kernel** (e.g. `uname -a`):
   - **Install tools**:
   - **Others**:
   
   **What happened**:
   - When initialize DAG, I defined `user_defined_macros` with my macros.
   - If I use user defined macro on PapermillOperator, it does not find user defined macros.
   
   <!-- (please include exact error messages if you can) -->
   ```
   [2020-11-04 16:35:10,822] {taskinstance.py:1150} ERROR - 'seoul_date' is undefined
   Traceback (most recent call last):
     File "/opt/pyenv/versions/3.6.8/lib/python3.6/site-packages/airflow/models/taskinstance.py", line 984, in _run_raw_task
       result = task_copy.execute(context=context)
     File "/opt/pyenv/versions/3.6.8/lib/python3.6/site-packages/airflow/operators/papermill_operator.py", line 57, in execute
       parameters=self.inlets[i].parameters,
     File "/opt/pyenv/versions/3.6.8/lib/python3.6/site-packages/airflow/lineage/datasets.py", line 69, in __getattr__
       ).render(**self.context)
     File "/opt/pyenv/versions/3.6.8/lib/python3.6/site-packages/jinja2/environment.py", line 1090, in render
       self.environment.handle_exception()
     File "/opt/pyenv/versions/3.6.8/lib/python3.6/site-packages/jinja2/environment.py", line 832, in handle_exception
       reraise(*rewrite_traceback_stack(source=source))
     File "/opt/pyenv/versions/3.6.8/lib/python3.6/site-packages/jinja2/_compat.py", line 28, in reraise
       raise value.with_traceback(tb)
     File "<template>", line 1, in top-level template code
   jinja2.exceptions.UndefinedError: 'seoul_date' is undefined
   
   ```
   
   
   **What you expected to happen**:
   PapermillOperator should find user defined macro.
   
   <!-- What do you think went wrong? -->
   
   **How to reproduce it**:
   <!---
   
   As minimally and precisely as possible. Keep in mind we do not have access to your cluster or dags.
   
   If you are using kubernetes, please attempt to recreate the issue using minikube or kind.
   
   ## Install minikube/kind
   
   - Minikube https://minikube.sigs.k8s.io/docs/start/
   - Kind https://kind.sigs.k8s.io/docs/user/quick-start/
   
   If this is a UI bug, please provide a screenshot of the bug or a link to a youtube video of the bug in action
   
   You can include images using the .md style of
   ![alt text](http://url/to/img.png)
   
   To record a screencast, mac users can use QuickTime and then create an unlisted youtube video with the resulting .mov file.
   
   --->
   
   
   **Anything else we need to know**:
   PapermillOperator uses `Notebook` class which derived from `DataSet`
   https://github.com/apache/airflow/blob/65df1e802190d262b5e18fa9bc2e055768b96e28/airflow/operators/papermill_operator.py#L27
   And `DataSet` seems not taking user defined macro from DAG.
   
   <!--
   
   How often does this problem occur? Once? Every time etc?
   
   Any relevant logs to include? Put them here in side a detail tag:
   <details><summary>x.log</summary> lots of stuff </details>
   
   -->
   


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



[GitHub] [airflow] kaxil commented on issue #12081: PapermillOperator does not take user defined macros

Posted by GitBox <gi...@apache.org>.
kaxil commented on issue #12081:
URL: https://github.com/apache/airflow/issues/12081#issuecomment-723490554


   Would you like to take a look at this one @rootcss ?


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



[GitHub] [airflow] rootcss commented on issue #12081: PapermillOperator does not take user defined macros

Posted by GitBox <gi...@apache.org>.
rootcss commented on issue #12081:
URL: https://github.com/apache/airflow/issues/12081#issuecomment-739664525


   Thanks @humbledude. Will check this and get back to you. 


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



[GitHub] [airflow] rootcss commented on issue #12081: PapermillOperator does not take user defined macros

Posted by GitBox <gi...@apache.org>.
rootcss commented on issue #12081:
URL: https://github.com/apache/airflow/issues/12081#issuecomment-723498959


   @kaxil Sure. please assign it to me.


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



[GitHub] [airflow] eladkal commented on issue #12081: PapermillOperator does not take user defined macros

Posted by GitBox <gi...@apache.org>.
eladkal commented on issue #12081:
URL: https://github.com/apache/airflow/issues/12081#issuecomment-919973794


   hi @rootcss are you still working on it?


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



[GitHub] [airflow] rootcss commented on issue #12081: PapermillOperator does not take user defined macros

Posted by GitBox <gi...@apache.org>.
rootcss commented on issue #12081:
URL: https://github.com/apache/airflow/issues/12081#issuecomment-739389387


   Hi @humbledude. This seems to be working fine for me. Could you please share a snippet of DAG object and your PapermillOperator.


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



[GitHub] [airflow] humbledude commented on issue #12081: PapermillOperator does not take user defined macros

Posted by GitBox <gi...@apache.org>.
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



[GitHub] [airflow] eladkal closed issue #12081: PapermillOperator does not take user defined macros

Posted by GitBox <gi...@apache.org>.
eladkal closed issue #12081:
URL: https://github.com/apache/airflow/issues/12081


   


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