You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@airflow.apache.org by Tzu-ping Chung <tp...@astronomer.io.INVALID> on 2024/11/21 11:54:13 UTC

[LAZY CONSENSUS] Use Ruff as the official linter to detect Airflow 3 incompatibilities in user code

Hi all,

I am calling a LAZY CONSENSUS to officially anoint Ruff as the tool to implement lint rules that detect potential incompatibilities in existing user code (including DAG files and plugins) that may break in Airflow 3. The rationale is

* Ruff provides the best set of features for our needs according to my research, most importantly import resolution, and also a nice CLI “for free”.

* While a rule in Ruff must be implemented in Rust, which can be a hurdle to most Airflow contributors, it does not actually require a very deep understanding to Rust, but more toward the Python AST parser that Ruff provides (which is very similar to Python’s built-in ast).

* We intend to only implement lint rules, not “fixes” (which would allow Ruff to rewrite offending files automatically. This reduces the learning curve even further.

* Most Airflow contributors likely don’t know Python’s ast library very well to begin with anyway, so the learning curve would not be much flatter even if we choose a Python-based tool.

* We would not be the first Python library to use Ruff for this—Numpy also uses Ruff to detect potential incompatibilities for Numpy 2.0. We are also not the first to create Airflow rules in Ruff either—it already contains one Airflow-specific rule.

If we are to implement an auto fixer, it can still be rewritten in Python. With Ruff handling most of the user interaction (including generating proper error messages and a clear error code), the fixer can have a relatively simplistic CLI that can be more easily implemented with just argparse and print() (or a little drop of Rich if we feel fancy).

I have created a POC on generating lint errors against creating an Airflow DAG without using the 'schedule' argument correctly for Airflow 3: https://github.com/uranusjr/ruff/pull/1

If no one objects, the vote will pass three days from now, at 12:00 (noon) UTC, 24 November 2024. I intend to formally submit the rule implemented above to Ruff, and start contributing other rules to Ruff. A list of rule candidates can be found in Wei’s thread “[Discuss] Airflow 2 to 3 migration rules” sent to this list earlier.

Thanks all,
TP
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@airflow.apache.org
For additional commands, e-mail: dev-help@airflow.apache.org


Re: [LAZY CONSENSUS] Use Ruff as the official linter to detect Airflow 3 incompatibilities in user code

Posted by Jarek Potiuk <ja...@potiuk.com>.
Very cool :)

On Wed, Nov 27, 2024 at 10:46 AM Wei Lee <we...@gmail.com> wrote:

> Hi folks,
>
> If anyone plans to work on any of the rules in this list
> https://github.com/apache/airflow/issues/41641, please create an issue and
> leave a comment in that issue 41641 so that we can avoid duplicate efforts.
> I will update the issue description whenever I notice that someone has
> commented to indicate they created an issue and intend to work on it.
>
> Best,
> Wei
>
> Tzu-ping Chung <tp...@astronomer.io.invalid> 於 2024年11月25日 週一 下午12:36寫道:
>
> > The lazy consensus has passed. I am currently working on a step-by-setp
> > writeup on how to implement a Ruff rule for Airflow migration.
> >
> > Thanks all,
> > TP
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@airflow.apache.org
> > For additional commands, e-mail: dev-help@airflow.apache.org
> >
> >
>

Re: [LAZY CONSENSUS] Use Ruff as the official linter to detect Airflow 3 incompatibilities in user code

Posted by Wei Lee <we...@gmail.com>.
Hi folks,

If anyone plans to work on any of the rules in this list
https://github.com/apache/airflow/issues/41641, please create an issue and
leave a comment in that issue 41641 so that we can avoid duplicate efforts.
I will update the issue description whenever I notice that someone has
commented to indicate they created an issue and intend to work on it.

Best,
Wei

Tzu-ping Chung <tp...@astronomer.io.invalid> 於 2024年11月25日 週一 下午12:36寫道:

> The lazy consensus has passed. I am currently working on a step-by-setp
> writeup on how to implement a Ruff rule for Airflow migration.
>
> Thanks all,
> TP
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@airflow.apache.org
> For additional commands, e-mail: dev-help@airflow.apache.org
>
>

Re: [LAZY CONSENSUS] Use Ruff as the official linter to detect Airflow 3 incompatibilities in user code

Posted by Tzu-ping Chung <tp...@astronomer.io.INVALID>.
The lazy consensus has passed. I am currently working on a step-by-setp writeup on how to implement a Ruff rule for Airflow migration.

Thanks all,
TP
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@airflow.apache.org
For additional commands, e-mail: dev-help@airflow.apache.org


Re: [LAZY CONSENSUS] Use Ruff as the official linter to detect Airflow 3 incompatibilities in user code

Posted by Buğra Öztürk <oz...@gmail.com>.
It would be great to see Ruff more. It performs well too over
other linters. Plus any time we save during the migration process would be
helpful to users.

On Fri, Nov 22, 2024 at 1:27 AM Jarek Potiuk <ja...@potiuk.com> wrote:

> Agree. Very good direction!
>
> On Thu, Nov 21, 2024 at 5:00 PM Julian LaNeve <julian@astronomer.io.invalid
> >
> wrote:
>
> > This is awesome to see - I wrote the first rule in Ruff for Airflow, and
> > it was super easy to do despite not having written any Rust prior.
> >
> > The Ruff maintainers are also incredibly responsive and helpful. I think
> > Airflow’s one of the largest projects they work with, and they have us
> > listed on the Ruff README.
> >
> > > On Nov 21, 2024, at 10:44 AM, Pierre Jeambrun <pi...@gmail.com>
> > wrote:
> > >
> > > That's a nice one, looking forward to it :)
> > >
> > > On Thu, Nov 21, 2024 at 12:55 PM Tzu-ping Chung
> <tp@astronomer.io.invalid
> > >
> > > wrote:
> > >
> > >> Hi all,
> > >>
> > >> I am calling a LAZY CONSENSUS to officially anoint Ruff as the tool to
> > >> implement lint rules that detect potential incompatibilities in
> existing
> > >> user code (including DAG files and plugins) that may break in Airflow
> 3.
> > >> The rationale is
> > >>
> > >> * Ruff provides the best set of features for our needs according to my
> > >> research, most importantly import resolution, and also a nice CLI “for
> > >> free”.
> > >>
> > >> * While a rule in Ruff must be implemented in Rust, which can be a
> > hurdle
> > >> to most Airflow contributors, it does not actually require a very deep
> > >> understanding to Rust, but more toward the Python AST parser that Ruff
> > >> provides (which is very similar to Python’s built-in ast).
> > >>
> > >> * We intend to only implement lint rules, not “fixes” (which would
> allow
> > >> Ruff to rewrite offending files automatically. This reduces the
> learning
> > >> curve even further.
> > >>
> > >> * Most Airflow contributors likely don’t know Python’s ast library
> very
> > >> well to begin with anyway, so the learning curve would not be much
> > flatter
> > >> even if we choose a Python-based tool.
> > >>
> > >> * We would not be the first Python library to use Ruff for this—Numpy
> > also
> > >> uses Ruff to detect potential incompatibilities for Numpy 2.0. We are
> > also
> > >> not the first to create Airflow rules in Ruff either—it already
> contains
> > >> one Airflow-specific rule.
> > >>
> > >> If we are to implement an auto fixer, it can still be rewritten in
> > Python.
> > >> With Ruff handling most of the user interaction (including generating
> > >> proper error messages and a clear error code), the fixer can have a
> > >> relatively simplistic CLI that can be more easily implemented with
> just
> > >> argparse and print() (or a little drop of Rich if we feel fancy).
> > >>
> > >> I have created a POC on generating lint errors against creating an
> > Airflow
> > >> DAG without using the 'schedule' argument correctly for Airflow 3:
> > >> https://github.com/uranusjr/ruff/pull/1
> > >>
> > >> If no one objects, the vote will pass three days from now, at 12:00
> > (noon)
> > >> UTC, 24 November 2024. I intend to formally submit the rule
> implemented
> > >> above to Ruff, and start contributing other rules to Ruff. A list of
> > rule
> > >> candidates can be found in Wei’s thread “[Discuss] Airflow 2 to 3
> > migration
> > >> rules” sent to this list earlier.
> > >>
> > >> Thanks all,
> > >> TP
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: dev-unsubscribe@airflow.apache.org
> > >> For additional commands, e-mail: dev-help@airflow.apache.org
> > >>
> > >>
> >
> >
>


-- 
Bugra Ozturk

Re: [LAZY CONSENSUS] Use Ruff as the official linter to detect Airflow 3 incompatibilities in user code

Posted by Jarek Potiuk <ja...@potiuk.com>.
Agree. Very good direction!

On Thu, Nov 21, 2024 at 5:00 PM Julian LaNeve <ju...@astronomer.io.invalid>
wrote:

> This is awesome to see - I wrote the first rule in Ruff for Airflow, and
> it was super easy to do despite not having written any Rust prior.
>
> The Ruff maintainers are also incredibly responsive and helpful. I think
> Airflow’s one of the largest projects they work with, and they have us
> listed on the Ruff README.
>
> > On Nov 21, 2024, at 10:44 AM, Pierre Jeambrun <pi...@gmail.com>
> wrote:
> >
> > That's a nice one, looking forward to it :)
> >
> > On Thu, Nov 21, 2024 at 12:55 PM Tzu-ping Chung <tp@astronomer.io.invalid
> >
> > wrote:
> >
> >> Hi all,
> >>
> >> I am calling a LAZY CONSENSUS to officially anoint Ruff as the tool to
> >> implement lint rules that detect potential incompatibilities in existing
> >> user code (including DAG files and plugins) that may break in Airflow 3.
> >> The rationale is
> >>
> >> * Ruff provides the best set of features for our needs according to my
> >> research, most importantly import resolution, and also a nice CLI “for
> >> free”.
> >>
> >> * While a rule in Ruff must be implemented in Rust, which can be a
> hurdle
> >> to most Airflow contributors, it does not actually require a very deep
> >> understanding to Rust, but more toward the Python AST parser that Ruff
> >> provides (which is very similar to Python’s built-in ast).
> >>
> >> * We intend to only implement lint rules, not “fixes” (which would allow
> >> Ruff to rewrite offending files automatically. This reduces the learning
> >> curve even further.
> >>
> >> * Most Airflow contributors likely don’t know Python’s ast library very
> >> well to begin with anyway, so the learning curve would not be much
> flatter
> >> even if we choose a Python-based tool.
> >>
> >> * We would not be the first Python library to use Ruff for this—Numpy
> also
> >> uses Ruff to detect potential incompatibilities for Numpy 2.0. We are
> also
> >> not the first to create Airflow rules in Ruff either—it already contains
> >> one Airflow-specific rule.
> >>
> >> If we are to implement an auto fixer, it can still be rewritten in
> Python.
> >> With Ruff handling most of the user interaction (including generating
> >> proper error messages and a clear error code), the fixer can have a
> >> relatively simplistic CLI that can be more easily implemented with just
> >> argparse and print() (or a little drop of Rich if we feel fancy).
> >>
> >> I have created a POC on generating lint errors against creating an
> Airflow
> >> DAG without using the 'schedule' argument correctly for Airflow 3:
> >> https://github.com/uranusjr/ruff/pull/1
> >>
> >> If no one objects, the vote will pass three days from now, at 12:00
> (noon)
> >> UTC, 24 November 2024. I intend to formally submit the rule implemented
> >> above to Ruff, and start contributing other rules to Ruff. A list of
> rule
> >> candidates can be found in Wei’s thread “[Discuss] Airflow 2 to 3
> migration
> >> rules” sent to this list earlier.
> >>
> >> Thanks all,
> >> TP
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@airflow.apache.org
> >> For additional commands, e-mail: dev-help@airflow.apache.org
> >>
> >>
>
>

Re: [LAZY CONSENSUS] Use Ruff as the official linter to detect Airflow 3 incompatibilities in user code

Posted by Julian LaNeve <ju...@astronomer.io.INVALID>.
This is awesome to see - I wrote the first rule in Ruff for Airflow, and it was super easy to do despite not having written any Rust prior.

The Ruff maintainers are also incredibly responsive and helpful. I think Airflow’s one of the largest projects they work with, and they have us listed on the Ruff README.

> On Nov 21, 2024, at 10:44 AM, Pierre Jeambrun <pi...@gmail.com> wrote:
> 
> That's a nice one, looking forward to it :)
> 
> On Thu, Nov 21, 2024 at 12:55 PM Tzu-ping Chung <tp...@astronomer.io.invalid>
> wrote:
> 
>> Hi all,
>> 
>> I am calling a LAZY CONSENSUS to officially anoint Ruff as the tool to
>> implement lint rules that detect potential incompatibilities in existing
>> user code (including DAG files and plugins) that may break in Airflow 3.
>> The rationale is
>> 
>> * Ruff provides the best set of features for our needs according to my
>> research, most importantly import resolution, and also a nice CLI “for
>> free”.
>> 
>> * While a rule in Ruff must be implemented in Rust, which can be a hurdle
>> to most Airflow contributors, it does not actually require a very deep
>> understanding to Rust, but more toward the Python AST parser that Ruff
>> provides (which is very similar to Python’s built-in ast).
>> 
>> * We intend to only implement lint rules, not “fixes” (which would allow
>> Ruff to rewrite offending files automatically. This reduces the learning
>> curve even further.
>> 
>> * Most Airflow contributors likely don’t know Python’s ast library very
>> well to begin with anyway, so the learning curve would not be much flatter
>> even if we choose a Python-based tool.
>> 
>> * We would not be the first Python library to use Ruff for this—Numpy also
>> uses Ruff to detect potential incompatibilities for Numpy 2.0. We are also
>> not the first to create Airflow rules in Ruff either—it already contains
>> one Airflow-specific rule.
>> 
>> If we are to implement an auto fixer, it can still be rewritten in Python.
>> With Ruff handling most of the user interaction (including generating
>> proper error messages and a clear error code), the fixer can have a
>> relatively simplistic CLI that can be more easily implemented with just
>> argparse and print() (or a little drop of Rich if we feel fancy).
>> 
>> I have created a POC on generating lint errors against creating an Airflow
>> DAG without using the 'schedule' argument correctly for Airflow 3:
>> https://github.com/uranusjr/ruff/pull/1
>> 
>> If no one objects, the vote will pass three days from now, at 12:00 (noon)
>> UTC, 24 November 2024. I intend to formally submit the rule implemented
>> above to Ruff, and start contributing other rules to Ruff. A list of rule
>> candidates can be found in Wei’s thread “[Discuss] Airflow 2 to 3 migration
>> rules” sent to this list earlier.
>> 
>> Thanks all,
>> TP
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@airflow.apache.org
>> For additional commands, e-mail: dev-help@airflow.apache.org
>> 
>> 


Re: [LAZY CONSENSUS] Use Ruff as the official linter to detect Airflow 3 incompatibilities in user code

Posted by Pierre Jeambrun <pi...@gmail.com>.
That's a nice one, looking forward to it :)

On Thu, Nov 21, 2024 at 12:55 PM Tzu-ping Chung <tp...@astronomer.io.invalid>
wrote:

> Hi all,
>
> I am calling a LAZY CONSENSUS to officially anoint Ruff as the tool to
> implement lint rules that detect potential incompatibilities in existing
> user code (including DAG files and plugins) that may break in Airflow 3.
> The rationale is
>
> * Ruff provides the best set of features for our needs according to my
> research, most importantly import resolution, and also a nice CLI “for
> free”.
>
> * While a rule in Ruff must be implemented in Rust, which can be a hurdle
> to most Airflow contributors, it does not actually require a very deep
> understanding to Rust, but more toward the Python AST parser that Ruff
> provides (which is very similar to Python’s built-in ast).
>
> * We intend to only implement lint rules, not “fixes” (which would allow
> Ruff to rewrite offending files automatically. This reduces the learning
> curve even further.
>
> * Most Airflow contributors likely don’t know Python’s ast library very
> well to begin with anyway, so the learning curve would not be much flatter
> even if we choose a Python-based tool.
>
> * We would not be the first Python library to use Ruff for this—Numpy also
> uses Ruff to detect potential incompatibilities for Numpy 2.0. We are also
> not the first to create Airflow rules in Ruff either—it already contains
> one Airflow-specific rule.
>
> If we are to implement an auto fixer, it can still be rewritten in Python.
> With Ruff handling most of the user interaction (including generating
> proper error messages and a clear error code), the fixer can have a
> relatively simplistic CLI that can be more easily implemented with just
> argparse and print() (or a little drop of Rich if we feel fancy).
>
> I have created a POC on generating lint errors against creating an Airflow
> DAG without using the 'schedule' argument correctly for Airflow 3:
> https://github.com/uranusjr/ruff/pull/1
>
> If no one objects, the vote will pass three days from now, at 12:00 (noon)
> UTC, 24 November 2024. I intend to formally submit the rule implemented
> above to Ruff, and start contributing other rules to Ruff. A list of rule
> candidates can be found in Wei’s thread “[Discuss] Airflow 2 to 3 migration
> rules” sent to this list earlier.
>
> Thanks all,
> TP
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@airflow.apache.org
> For additional commands, e-mail: dev-help@airflow.apache.org
>
>