1 Star 0 Fork 0

caoshiwei / airflow

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
CONTRIBUTORS_QUICK_START_PYCHARM.rst 4.37 KB
一键复制 编辑 原始数据 按行查看 历史

Setup your project

  1. Open your IDE or source code editor and select the option to clone the repository

    Cloning github fork to Pycharm
  2. Paste the repository link in the URL field and submit.

    Cloning github fork to Pycharm

Setting up debugging

It requires "airflow-env" virtual environment configured locally.

  1. Configuring Airflow database connection
  • Airflow is by default configured to use SQLite database. Configuration can be seen on local machine ~/airflow/airflow.cfg under sql_alchemy_conn.

  • Installing required dependency for MySQL connection in airflow-env on local machine.

    $ pyenv activate airflow-env
    $ pip install PyMySQL
    
  • Now set sql_alchemy_conn = mysql+pymysql://root:@127.0.0.1:23306/airflow?charset=utf8mb4 in file ~/airflow/airflow.cfg on local machine.

  1. Debugging an example DAG
  • Add Interpreter to PyCharm pointing interpreter path to ~/.pyenv/versions/airflow-env/bin/python, which is virtual environment airflow-env created with pyenv earlier. For adding an Interpreter go to File -> Setting -> Project: airflow -> Python Interpreter.

    Adding existing interpreter
  • In PyCharm IDE open airflow project, directory /files/dags of local machine is by default mounted to docker machine when breeze airflow is started. So any DAG file present in this directory will be picked automatically by scheduler running in docker machine and same can be seen on http://127.0.0.1:28080.

  • Copy any example DAG present in the /airflow/example_dags directory to /files/dags/.

  • Add a __main__ block at the end of your DAG file to make it runnable. It will run a back_fill job:

    if __name__ == "__main__":
        dag.clear()
        dag.run()
    
  • Add AIRFLOW__CORE__EXECUTOR=DebugExecutor to Environment variable of Run Configuration.

    • Click on Add configuration

      Add Configuration pycharm
    • Add Script Path and Environment Variable to new Python configuration

      Add environment variable pycharm
  • Now Debug an example dag and view the entries in tables such as dag_run, xcom etc in MySQL Workbench.

Creating a branch

  1. Click on the branch symbol in the status bar

    Creating a new branch
  2. Give a name to a branch and checkout

    Giving a name to a branch

Follow the Quick start for typical development tasks.

Python
1
https://gitee.com/mingganci/apache-airflow.git
git@gitee.com:mingganci/apache-airflow.git
mingganci
apache-airflow
airflow
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891