2
respostas

Erro ao executar

Olá, no final desta aula, ao tentar excutar me restornou este erro:

(Traceback (most recent call last):
  File "twitter_operator.py", line 62, in <module>
    ti.run()
  File "/home/alexis/Documentos/datapipeline/.env/lib/python3.8/site-packages/airflow/utils/db.py", line 74, in wrapper
    return func(*args, **kwargs)
  File "/home/alexis/Documentos/datapipeline/.env/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1102, in run
    self._run_raw_task(
  File "/home/alexis/Documentos/datapipeline/.env/lib/python3.8/site-packages/airflow/utils/db.py", line 70, in wrapper
    return func(*args, **kwargs)
  File "/home/alexis/Documentos/datapipeline/.env/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 984, in _run_raw_task
    result = task_copy.execute(context=context)
  File "twitter_operator.py", line 49, in execute
    for pg in hook.run():
  File "/home/alexis/Documentos/datapipeline/airflow/plugins/hooks/twitter_hook.py", line 53, in run
    session = self.get_conn()
  File "/home/alexis/Documentos/datapipeline/.env/lib/python3.8/site-packages/airflow/hooks/http_hook.py", line 62, in get_conn
    conn = self.get_connection(self.http_conn_id)
  File "/home/alexis/Documentos/datapipeline/.env/lib/python3.8/site-packages/airflow/hooks/base_hook.py", line 87, in get_connection
    conn = random.choice(list(cls.get_connections(conn_id)))
  File "/home/alexis/Documentos/datapipeline/.env/lib/python3.8/site-packages/airflow/hooks/base_hook.py", line 83, in get_connections
    return secrets.get_connections(conn_id)
  File "/home/alexis/Documentos/datapipeline/.env/lib/python3.8/site-packages/airflow/secrets/__init__.py", line 59, in get_connections
    raise AirflowException("The conn_id `{0}` isn't defined".format(conn_id))
airflow.exceptions.AirflowException: The conn_id `twitter_default` isn't defined

2 respostas

Ou ela basicamente me retorna

Traceback (most recent call last):
  File "twitter_operator.py", line 7, in <module>
    from ..hooks.twitter_hook import TwitterHook
ImportError: attempted relative import with no known parent package

Alexis, você está rodando em uma janela do terminal na qual exportou o caminho correto da pasta airflow? sempre que abrir uma nova janela do terminal vá até a sua pasta de trabalho (onde estão as pastas airflow, activate, venv, blablabla) e execute: export AIRFLOW_HOME=$(pwd)/airflow

Assim funcionou pra mim no Airflow 2