Airflow on Docker - Path issue

≡放荡痞女 提交于 2020-01-06 08:10:45

问题


Working with airflow I try simple DAG work.

I wrote custom operators and other files that I want to import into the main file where the DAG logic is.

Here the folder's structure :

├── airflow.cfg
├── dags
│   ├── __init__.py
│   ├── dag.py
│   └── sql_statements.sql
├── docker-compose.yaml
├── environment.yml
└── plugins
    ├── __init__.py
    └── operators
        ├── __init__.py
        ├── facts_calculator.py
        ├── has_rows.py
        └── s3_to_redshift.py

I setup the volume right in the compose file since I can see them when I log into the container's terminal.

I followed some tutorials online from where I have added some __init__.py.

The 2 none empty __init__ are into

  • /plugins/operators:
from operators.facts_calculator import FactsCalculatorOperator
from operators.has_rows import HasRowsOperator
from operators.s3_to_redshift import S3ToRedshiftOperator

__all__ = [
    'FactsCalculatorOperator',
    'HasRowsOperator',
    'S3ToRedshiftOperator'
]
  • /plugins:
from airflow.plugins_manager import AirflowPlugin

import operators

# Defining the plugin class
class CustomPlugin(AirflowPlugin):
    name = "custom_plugin"
    # A list of class(es) derived from BaseOperator
    operators = [
        operators.FactsCalculatorOperator,
        operators.HasRowsOperator,
        operators.S3ToRedshiftOperator
    ]
    # A list of class(es) derived from BaseHook
    hooks = []
    # A list of class(es) derived from BaseExecutor
    executors = []
    # A list of references to inject into the macros namespace
    macros = []
    # A list of objects created from a class derived
    # from flask_admin.BaseView
    admin_views = []
    # A list of Blueprint object created from flask.Blueprint
    flask_blueprints = []
    # A list of menu links (flask_admin.base.MenuLink)
    menu_links = []

But I keep getting errors from my IDE (saying No module named operators or Unresolved reference operators inside the operator's __init__).

Since everything fails to launch on the webserver.

Any idea how to set this up ? Where I'm wrong ?

来源:https://stackoverflow.com/questions/58237543/airflow-on-docker-path-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!