-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rules/Request: Airflow DAGs checks #4421
Comments
The rules defined in https://github.com/BasPH/pylint-airflow seem to cover all those cases plus a bit more. Would a port of that Pylint plugin be a good start? |
Bas' pylint-airflow is definitely a good start, but worth noting it was designed for Airflow 1.x and we should aim to get ruff supporting Airflow 2.x, so there are likely a few changes we'll want to make. Maybe I can open a draft PR with a few of the easy rules (no duplicate DAG names, no empty DAGs, etc) to get something going, and then we can open issues for specific rules afterwards? @charliermarsh - what do you think? |
@jlaneve - Yeah, that's perfect. |
Exactly - I had seen |
https://docs.astronomer.io/learn/dag-best-practices Some opinionated options (which could certainly be contentious):
|
Some Astronomer folks might be able to help development :) |
Is there a roadmap timeline for this? |
what essentially makes the difference between ruff check vs ruff lint |
@usethia your question seems unrelated to this issue. I'll reply anyway but please open a new issue if you need more help to avoid sidetracking this issue.
To lint your project, run |
Hi, I'm a longtime user (and contributor) of Airflow, and brand new to Rust, I'd love to get my feet wet in Rust. I thought a great place to start would be to implement some rules for Airflow for Ruff. I'd love to give at least one of these a shot. Did a quick search of "airflow" in the Issues and found this. I'll try to open my first PR soon-ish for a simple Airflow rule - I'm thinking of the following: If using Taskflow Bad: # file.py
from airflow.decorators import dag, task
@dag
def my_dag():
.... Good: # file.py
from airflow.decorators import dag, task
@dag
def my_dag():
....
my_dag() Let me know if anyone objects, thanks |
@yehoshuadimarsky -- sounds great! |
We do have this that you can extend on - I started building it out but unfortunately don't have much free time! https://github.com/astral-sh/ruff/tree/main/crates/ruff_linter/src/rules/airflow |
👏 👏 `from airflow import DAG with DAG(...):
` The prior art links: https://pypi.org/project/pylint-airflow/
Use function-level imports instead of top-level imports12 (see Top level Python Code) Use jinja template syntax instead of Variable.get (see Airflow Variables) other ideas: add The jinja json variable syntax. I've seen numerous people give up and fetch multiple secrets with multiple calls instead. Not me oc. Detect code that reimplements the "connections" feature and/or using custom secrets libraries in dags that could leverage the airflow secrets backend. "This looks like it could be refactored to use the connections/secrets backend" with a code snippet and links to the docs. throw warnings about deprecated providers: https://airflow.apache.org/docs/apache-airflow-providers/core-extensions/deprecations.html I usually see low-formality, custom libraries in the dags directory. Maybe we should be using All progress here is good. 👏 |
Anyone know where in the Ruff codebase I would check for unused functions? Not sure exactly where in Getting kind of lost in what exactly all the terms mean like Bindings, Scopes, etc, any pointers where to look? I think these are Python terms but not 100% sure |
I'm not sure what you're trying to do and how it is relevant to this rule. Could you open a new issue/discussion with an explanation of what you're trying to accomplish. I might then be able to help |
Does the
Does your use case align with this issue? Looks like identifying classes and functions that exist but are not used and recommending deletion of them might not be in the ruff feature-set yet. |
There are numerous problems that could go wrong with an Airflow DAG, ex:
Seems like we might want new rules that could be used to detect these things.
The text was updated successfully, but these errors were encountered: