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/08/04 07:20:48 UTC

[GitHub] [airflow] shlomi-viz opened a new issue #17404: Path to dags folder in incorrect while using DagBag

shlomi-viz opened a new issue #17404:
URL: https://github.com/apache/airflow/issues/17404


   <!--
   
   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**:
   `apache-airflow==2.1.2`
   
   **Kubernetes version (if you are using kubernetes)** (use `kubectl version`):
   
   **Environment**:
   
   - **Cloud provider or hardware configuration**:
   - **OS** (e.g. from /etc/os-release):
   - **Kernel** (e.g. `uname -a`):
   - **Install tools**:
   - **Others**:
   Local on Mac
   **What happened**:
   While running tests, with `pytest` I'm getting import errors (in my case). 
   ```python 
   ModuleNotFoundError: No module named 'encryption'
   ````
   <!-- (please include exact error messages if you can) -->
   
   **What you expected to happen**:
   Dag should be imported without errors.
   <!-- 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**:
   When I'm running the UI I use `AIRFLOW_HOME` to indicate where is the `airflow` folder, in the tests I have: 
   ```python
   import sys
   from airflow.models import DagBag
   
   from decouple import config
   AIRFLOW_HOME = config('AIRFLOW_HOME')
   
   class Test(object):
       @classmethod
       def setup_class(cls):
           cls.dagbag = DagBag(f'{AIRFLOW_HOME}/dags/', include_examples=False)
           print(cls.dagbag.dags)
   
       def test_dag_loaded(self):
           dag = self.dagbag.get_dag(dag_id='test_dag')
           assert self.dagbag.import_errors == {}
           assert dag is not None
           assert len(dag.tasks) == 1
   
   ```
   
   note that I had to add
   
   ```python 
           sys.path.append(f'{AIRFLOW_HOME}/dags/')
   ````
   to fix the above error
   
   <!--
   
   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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

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



[GitHub] [airflow] shlomi-viz commented on issue #17404: Path to dags folder in incorrect while using DagBag

Posted by GitBox <gi...@apache.org>.
shlomi-viz commented on issue #17404:
URL: https://github.com/apache/airflow/issues/17404#issuecomment-892516465






-- 
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] boring-cyborg[bot] commented on issue #17404: Path to dags folder in incorrect while using DagBag

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #17404:
URL: https://github.com/apache/airflow/issues/17404#issuecomment-892427418


   Thanks for opening your first issue here! Be sure to follow the issue template!
   


-- 
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] potiuk closed issue #17404: Path to dags folder in incorrect while using DagBag

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


   


-- 
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] potiuk commented on issue #17404: Path to dags folder in incorrect while using DagBag

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


   Check your AIRFLOW_HOME settings. Just debug what are your settings when you run Test and fix it. Not sure how you are running yout tests and what settings you have but this is something that is definitely on your environment side, not Airflow. 


-- 
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] potiuk commented on issue #17404: Path to dags folder in incorrect while using DagBag

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


   This is expected behaviour. DAGs folder is expected to be in the system path  if you need to import something from there in your 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



[GitHub] [airflow] potiuk commented on issue #17404: Path to dags folder in incorrect while using DagBag

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


   Check your AIRFLOW_HOME settings. Just debug what are your settings when you run Test and fix it. Not sure how you are running yout tests and what settings you have but this is something that is definitely on your environment side, not Airflow. 


-- 
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] shlomi-viz commented on issue #17404: Path to dags folder in incorrect while using DagBag

Posted by GitBox <gi...@apache.org>.
shlomi-viz commented on issue #17404:
URL: https://github.com/apache/airflow/issues/17404#issuecomment-892638640


   Thanks, the problem was in my code, I used https://pypi.org/project/python-decouple/ to load the env var but it doesn't add them into `os.environ`


-- 
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] potiuk commented on issue #17404: Path to dags folder in incorrect while using DagBag

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


   See also here: https://airflow.apache.org/docs/apache-airflow/stable/modules_management.html#additional-modules-in-airflow - DAGS folder is explicitly added by the path and if  your tests are going to simulate airfow\s behaviour, they have to do the same.


-- 
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] shlomi-viz commented on issue #17404: Path to dags folder in incorrect while using DagBag

Posted by GitBox <gi...@apache.org>.
shlomi-viz commented on issue #17404:
URL: https://github.com/apache/airflow/issues/17404#issuecomment-892516465


   Looking at the above link I see 
   
   > Config folder: It is configured by setting AIRFLOW_HOME variable ({AIRFLOW_HOME}/config) by default. 
   but if I ran my tests without 
   ```python
   sys.path.append(f'{AIRFLOW_HOME}/dags/')
   ```
   those are the paths I see in `sys.path`
   ```bash
   '/Users/USERNAME/airflow/dags', '/Users/USERNAME/airflow/config', '/Users/USERNAME/airflow/plugins'
   ```
   instead of:
   ```bash
   '/Users/USERNAME/workspace/PROJECT_NAME/airflow/dags', '/Users/USERNAME/workspace/PROJECT_NAME/airflow/config', '/Users/USERNAME/workspace/PROJECT_NAME/airflow/plugins'
   ````
   
   What I'm doing wrong? 


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