2017-05-11 3 views
5

기류 지침에 따라 here을 따르십시오.기류 플러그인을 가져올 수 없습니다.

문제 : 웹 서버에서 반환하는 다음과 같은 오류

Broken DAG: [/usr/local/airflow/dags/test_operator.py] cannot import name 
MyFirstOperator 

주 :이 디렉토리 구조는 다음과 같습니다 :

airflow_home 
├── airflow.cfg 
├── airflow.db 
├── dags 
│ └── test_operators.py 
├── plugins 
│ └── my_operators.py 
└── unittests.cfg 

내가 test_operators '에서 플러그인을 가져 시도하고있다 .py '는 다음과 같습니다.

from airflow.operators import MyFirstOperator 

코드는 모두 자습서에있는 코드와 같습니다. 그것은 다음과 같이 수행 기사에서

+0

에서 오류가 내가 전에 공기 흐름을 사용한 적이 있다는 것입니다. 그러나 pip와 함께 프로젝트 요구 사항을 설치 했습니까? – cbll

+0

@cbll - 예, 모든것이 docs에 따라 설치되었습니다 : https://airflow.incubator.apache.org/installation.html –

답변

1

:

class MyFirstPlugin(AirflowPlugin): 
    name = "my_first_plugin" 
    operators = [MyFirstOperator] 

대신 사용

또한
class MyFirstPlugin(AirflowPlugin): 
    name = "my_first_plugin" 
    operators = [MyFirstOperator] 
    # 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 = [] 

사용하지 않는 :

from airflow.operators import MyFirstOperator 

According to the airflow article on plugins, it should be:

from airflow.operators.my_first_plugin import MyFirstOperator 
,

그 시도는 작동하지 않는 경우

from airflow.operators.my_operators import MyFirstOperator 

즉, 작동 자세한 내용은 시작시 웹 서버 로그를 확인하지 않습니다.

+2

고마워, 나는 이것을 벌써 시도했다 - 가져 오기를하면 'my_first_plugin'이라는 모듈이 없다. 'my_operators'. –

+0

어떤 버전의 기류를 사용하고 있습니까? 1.7 일 경우 1.8으로 업그레이드 할 수 있습니까? – jhnclvr

+0

나는 1.8에 있습니다 - 조언 주셔서 감사합니다. –

1

웹 서버를 다시 시작하면 모든 것이 정상적으로 작동합니다. 여기

가 무슨 일이 있었 것 같아 무엇 :

  1. 내가 튜토리얼 예를 시작하기 전에, 나는 내 자신의 플러그인 및 DAG를 실행했습니다. 내가 수정 한 첫 번째 실행에서 사소한 구문 오류가 있었지만 수정 한 후에 '이름을 가져올 수 없음'오류가 발생했습니다.
  2. 플러그인 및 dag를 삭제하고 튜토리얼의 내용을 사용하여 진행 상황을 확인했습니다.

내 생각 엔 1 단계 어떻게 든 영향을 2 단계

+2

제 경험상, 플러그인을 추가/수정할 때 웹 서버를 다시 시작해야합니다. –

+0

@Daniel Lee가 여기서 좋은 지적을했습니다. 웹 서버와 스케줄러를 다시 시작해야합니다. 적어도 Airflow 1.8.2에서 저에게 잘 맞았습니다. – dorvak

관련 문제