A plugin for Apache Airflow that allows you to edit DAGs in browser
A plugin for Apache Airflow that allows you to edit DAGs in browser. It provides a file managing interface within specified directories and it can be used to edit, upload, and download your files. If git support is enabled, the DAGs are stored in a Git repository. You may use it to view Git history, review local changes and commit.
For the ease of deployment, use the production-ready reference container image. The image is based on the reference images for Apache Airflow.
You can find the following images there:
pip install airflow-code-editor
black - Black Python code formatter
isort - A Python utility/library to sort imports
fs-s3fs - S3FS Amazon S3 Filesystem
fs-gcsfs - Google Cloud Storage Filesystem
... other filesystems supported by PyFilesystem - see https://www.pyfilesystem.org/page/index-of-filesystems/
pip install black isort fs-s3fs fs-gcsfs
Restart the Airflow Web Server
Open Admin - DAGs Code Editor
You can set options editing the Airflow's configuration file or setting environment variables. You can edit your airflow.cfg adding any of the following settings in the [code_editor] section. All the settings are optional.
[code_editor]
enabled = True
git_enabled = True
git_cmd = /usr/bin/git
git_default_args = -c color.ui=true
git_init_repo = False
root_directory = /home/airflow/dags
line_length = 88
string_normalization = False
mount = name=data,path=/home/airflow/data
mount1 = name=logs,path=/home/airflow/logs
mount2 = name=data,path=s3://example
Mount Options:
Example:
You can also set options with the following environment variables:
Example:
export AIRFLOW__CODE_EDITOR__STRING_NORMALIZATION=True
export AIRFLOW__CODE_EDITOR__MOUNT='name=data,path=/home/airflow/data'
export AIRFLOW__CODE_EDITOR__MOUNT1='name=logs,path=/home/airflow/logs'
export AIRFLOW__CODE_EDITOR__MOUNT2='name=tmp,path=/tmp'
Airflow Code Editor provides a REST API. Through this API, users can interact with the application programmatically, enabling automation, data retrieval, and integration with other software.
For detailed information on how to use each endpoint, refer to the API documentation.
The API authentication is inherited from the Apache Airflow.
If you want to check which auth backend is currently set, you can use
airflow config get-value api auth_backends
command as in the example below.
$ airflow config get-value api auth_backends
airflow.api.auth.backend.basic_auth
For details on configuring the authentication, see API Authorization.
Fork the repo
Clone it on the local machine
git clone https://github.com/andreax79/airflow-code-editor.git
cd airflow-code-editor
make dev-image
nvm use
make npm-build
make webserver
make test
Commit and push changes
Create pull request to the original repo