Skip to content
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

Airflow upgrade dag schedule argument #1

Closed
wants to merge 64 commits into from

Conversation

uranusjr
Copy link
Owner

POC…

@uranusjr uranusjr force-pushed the airflow-upgrade-dag-schedule-argument branch 2 times, most recently from c5c2075 to 3803fb8 Compare November 19, 2024 10:48
@uranusjr
Copy link
Owner Author

Not sure why my resolve_qualified_name call is not working… I’ll ask somewhere.

@uranusjr uranusjr force-pushed the airflow-upgrade-dag-schedule-argument branch from 3803fb8 to 8a72a7e Compare November 19, 2024 11:34
Copy link

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+34 -0 violations, +0 -0 fixes in 2 projects; 52 projects unchanged)

apache/airflow (+34 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ airflow/models/dag.py:299:16: AIR301 DAG should have an explicit `schedule` argument
+ performance/src/performance_dags/performance_dag/performance_dag.py:244:9: AIR301 argument `schedule_interval` is deprecated; use `schedule` instead
+ providers/src/airflow/providers/arangodb/example_dags/example_arangodb.py:25:7: AIR301 DAG should have an explicit `schedule` argument
+ providers/src/airflow/providers/google/cloud/example_dags/example_cloud_task.py:41:6: AIR301 DAG should have an explicit `schedule` argument
+ providers/src/airflow/providers/google/cloud/example_dags/example_facebook_ads_to_gcs.py:61:6: AIR301 DAG should have an explicit `schedule` argument
+ providers/src/airflow/providers/google/cloud/example_dags/example_looker.py:31:6: AIR301 DAG should have an explicit `schedule` argument
+ providers/src/airflow/providers/google/cloud/example_dags/example_presto_to_gcs.py:52:6: AIR301 DAG should have an explicit `schedule` argument
+ providers/src/airflow/providers/google/cloud/example_dags/example_salesforce_to_gcs.py:47:6: AIR301 DAG should have an explicit `schedule` argument
+ providers/src/airflow/providers/google/marketing_platform/example_dags/example_display_video.py:124:6: AIR301 DAG should have an explicit `schedule` argument
+ providers/src/airflow/providers/google/marketing_platform/example_dags/example_display_video.py:172:6: AIR301 DAG should have an explicit `schedule` argument
+ providers/src/airflow/providers/google/marketing_platform/example_dags/example_display_video.py:91:6: AIR301 DAG should have an explicit `schedule` argument
+ providers/src/airflow/providers/oracle/example_dags/example_oracle.py:25:6: AIR301 DAG should have an explicit `schedule` argument
+ providers/tests/google/cloud/operators/test_looker.py:47:19: AIR301 DAG should have an explicit `schedule` argument
+ providers/tests/google/cloud/utils/airflow_util.py:54:15: AIR301 DAG should have an explicit `schedule` argument
+ providers/tests/google/cloud/utils/test_mlengine_operator_utils.py:64:12: AIR301 DAG should have an explicit `schedule` argument
+ providers/tests/integration/mongo/sensors/test_mongo.py:49:20: AIR301 DAG should have an explicit `schedule` argument
+ providers/tests/integration/qdrant/operators/test_qdrant_ingest.py:38:20: AIR301 DAG should have an explicit `schedule` argument
+ providers/tests/integration/redis/sensors/test_redis_key.py:35:20: AIR301 DAG should have an explicit `schedule` argument
+ providers/tests/integration/redis/sensors/test_redis_pub_sub.py:38:20: AIR301 DAG should have an explicit `schedule` argument
+ providers/tests/integration/ydb/operators/test_ydb.py:51:20: AIR301 DAG should have an explicit `schedule` argument
+ providers/tests/system/apache/kafka/example_dag_event_listener.py:85:6: AIR301 DAG should have an explicit `schedule` argument
+ providers/tests/system/asana/example_asana.py:49:6: AIR301 DAG should have an explicit `schedule` argument
+ providers/tests/system/google/cloud/cloud_functions/example_functions.py:81:6: AIR301 DAG should have an explicit `schedule` argument
+ task_sdk/tests/dags/super_basic.py:24:2: AIR301 DAG should have an explicit `schedule` argument
+ task_sdk/tests/defintions/test_baseoperator.py:283:23: AIR301 DAG should have an explicit `schedule` argument
+ task_sdk/tests/defintions/test_baseoperator.py:352:10: AIR301 DAG should have an explicit `schedule` argument
+ task_sdk/tests/defintions/test_baseoperator.py:359:10: AIR301 DAG should have an explicit `schedule` argument
+ task_sdk/tests/defintions/test_dag.py:296:9: AIR301 DAG should have an explicit `schedule` argument
+ task_sdk/tests/defintions/test_dag.py:339:14: AIR301 DAG should have an explicit `schedule` argument
+ task_sdk/tests/defintions/test_dag.py:345:16: AIR301 DAG should have an explicit `schedule` argument
+ tests/jobs/test_scheduler_job.py:6433:16: AIR301 DAG should have an explicit `schedule` argument
+ tests/models/test_dag.py:2858:10: AIR301 DAG should have an explicit `schedule` argument
+ tests/serialization/test_serialized_objects.py:218:47: AIR301 DAG should have an explicit `schedule` argument
+ tests/utils/test_log_handlers.py:273:15: AIR301 DAG should have an explicit `schedule` argument

python-trio/trio (+0 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview


Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
AIR301 34 34 0 0 0

MichaReiser and others added 11 commits November 19, 2024 15:24
There is an upstream bug with latest version detection
jetli/wasm-pack-action#23

This causes random flakes of the wasm build job.
I noticed this was exceedingly slow.

Reduces to 3m from 14m
Reduces Linux test CI to 1m 40s (16 core) or 2m 56s (8 core) to from 4m
25s. Times are approximate, as runner performance is pretty variable.

In uv, we use the 16 core runners.
Reduces to 3m 50s (extra large) or 6m 5s (large) vs 9m 7s (standard)
…ns (astral-sh#14422)

## Summary

closes astral-sh#14279

### Limitations of the Current Implementation
#### Incorrect Error Propagation

In the current implementation of lexicographic comparisons, if the
result of an Eq operation is Ambiguous, the comparison stops
immediately, returning a bool instance. While this may yield correct
inferences, it fails to capture unsupported-operation errors that might
occur in subsequent comparisons.
```py
class A: ...

(int_instance(), A()) < (int_instance(), A())  # should error
```

#### Weak Inference in Specific Cases

> Example: `(int_instance(), "foo") == (int_instance(), "bar")`
> Current result: `bool`
> Expected result: `Literal[False]`

`Eq` and `NotEq` have unique behavior in lexicographic comparisons
compared to other operators. Specifically:
- For `Eq`, if any non-equal pair exists within the tuples being
compared, we can immediately conclude that the tuples are not equal.
- For `NotEq`, if any equal pair exists, we can conclude that the tuples
are unequal.

```py
a = (str_instance(), int_instance(), "foo")

reveal_type(a == a)  # revealed: bool
reveal_type(a != a)  # revealed: bool

b = (str_instance(), int_instance(), "bar")

reveal_type(a == b)  # revealed: bool  # should be Literal[False]
reveal_type(a != b)  # revealed: bool  # should be Literal[True]
```
#### Incorrect Support for Non-Boolean Rich Comparisons

In CPython, aside from `==` and `!=`, tuple comparisons return a
non-boolean result as-is. Tuples do not convert the value into `bool`.

Note: If all pairwise `==` comparisons between elements in the tuples
return Truthy, the comparison then considers the tuples' lengths.
Regardless of the return type of the dunder methods, the final result
can still be a boolean.

```py
from __future__ import annotations

class A:
    def __eq__(self, o: object) -> str:
        return "hello"

    def __ne__(self, o: object) -> bytes:
        return b"world"

    def __lt__(self, o: A) -> float:
        return 3.14

a = (A(), A())

reveal_type(a == a)  # revealed: bool
reveal_type(a != a)  # revealed: bool
reveal_type(a < a)  # revealed: bool # should be: `float | Literal[False]`

```

### Key Changes
One of the major changes is that comparisons no longer end with a `bool`
result when a pairwise `Eq` result is `Ambiguous`. Instead, the function
attempts to infer all possible cases and unions the results. This
improvement allows for more robust type inference and better error
detection.

Additionally, as the function is now optimized for tuple comparisons,
the name has been changed from the more general
`infer_lexicographic_comparison` to `infer_tuple_rich_comparison`.

## Test Plan

mdtest included
…-sh#14474)

## Summary

Resolves astral-sh#13537.

## Test Plan

`cargo nextest run` and `cargo insta test`.
This is one of the slowest remaining jobs in the pull request CI. We
could use a larger runner for a trivial speed-up (in exchange for $$),
but I don't think this is going to break often enough to merit testing
on every pull request commit? It's not a required job, so I don't feel
strongly about it, but it feels like a bit of a waste of compute.

Originally added in astral-sh#11182
…stral-sh#14476)

## Summary

Similar to astral-sh/uv#9244, but we need to use
the `mkdocs.generated.yml` file because the `scripts/generate_mkdocs.py`
uses the `mkdocs.template.yml` to generate the final config.
It's not actually doing anything per pull request and it's pretty slow?
xref astral-sh#14469

It seems useful to build on `main` still to find build regressions? e.g.
astral-sh#9368
@kaxil
Copy link

kaxil commented Nov 20, 2024

Oh did you add the ecosystem thing?

AlexWaygood and others added 12 commits November 20, 2024 13:11
…stral-sh#14401)

This PR stabilizes the unsafe fix for [zip-instead-of-pairwise
(RUF007)](https://docs.astral.sh/ruff/rules/zip-instead-of-pairwise/#zip-instead-of-pairwise-ruf007),
which replaces the use of zip with that of itertools.pairwise and has
been available under preview since version 0.5.7.

There are no open issues regarding RUF007 at the time of this writing.
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
MichaReiser and others added 27 commits November 21, 2024 12:49
…uration for `unconventional-import-alias (ICN001)` (astral-sh#14477)

Co-authored-by: Micha Reiser <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: David Salvisberg <[email protected]>
## Summary

Add support for (non-generic) type aliases. The main motivation behind
this was to get rid of panics involving expressions in (generic) type
aliases. But it turned out the best way to fix it was to implement
(partial) support for type aliases.

```py
type IntOrStr = int | str

reveal_type(IntOrStr)  # revealed: typing.TypeAliasType
reveal_type(IntOrStr.__name__)  # revealed: Literal["IntOrStr"]

x: IntOrStr = 1

reveal_type(x)  # revealed: Literal[1]

def f() -> None:
    reveal_type(x)  # revealed: int | str
```

## Test Plan

- Updated corpus test allow list to reflect that we don't panic anymore.
- Added Markdown-based test for type aliases (`type_alias.md`)
## Summary

This fix addresses panics related to invalid syntax like the following
where a `break` statement is used in a nested definition inside a
loop:

```py
while True:

    def b():
        x: int

        break
```

closes astral-sh#14342

## Test Plan

* New corpus regression tests.
* New unit test to make sure we handle nested while loops correctly.
This test is passing on `main`, but can easily fail if the
`is_inside_loop` state isn't properly saved/restored.
…w-re-pattern (RUF039)` (astral-sh#14536)

This PR adds a sometimes-available, safe autofix for [unraw-re-pattern
(RUF039)](https://docs.astral.sh/ruff/rules/unraw-re-pattern/#unraw-re-pattern-ruf039),
which prepends an `r` prefix. It is used only when the string in
question has no backslahses (and also does not have a `u` prefix, since
that causes a syntax error.)

Closes astral-sh#14527

Notes: 
- Test fixture unchanged, but snapshot changed to include fix messages.
- This fix is automatically only available in preview since the rule
itself is in preview
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This PR causes the following rules to ignore stub files, on the grounds
that it is not under the author's control to appease these lints:

- `PLR0904` https://docs.astral.sh/ruff/rules/too-many-public-methods/
- `PLR0913` https://docs.astral.sh/ruff/rules/too-many-arguments/
- `PLR0917`
https://docs.astral.sh/ruff/rules/too-many-positional-arguments/
- `PLW3201` https://docs.astral.sh/ruff/rules/bad-dunder-method-name/
- `SLOT` https://docs.astral.sh/ruff/rules/#flake8-slots-slot
- `FBT` https://docs.astral.sh/ruff/rules/#flake8-boolean-trap-fbt
(except for FBT003 since that involves a function call.)

Progress towards astral-sh#14535
## Summary
Resolves astral-sh#14289
The documentation for B028 no_explicit_stacklevel is updated to be more
clear.

---------

Co-authored-by: dylwil3 <[email protected]>
… annotated function calls properly (astral-sh#14532)

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

Fix astral-sh#14525

## Test Plan

<!-- How was it tested? -->

New test cases

---------

Signed-off-by: harupy <[email protected]>
…sh#14505)

## Summary

Resolves astral-sh#12949.

## Test Plan

`cargo nextest run` and `cargo insta test`.
…-sh#14520)

## Summary

Resolves astral-sh#14519.

## Test Plan

`cargo nextest run` and `cargo insta test`.
…ots` as unsafe when there are complex comments in the sequence (`RUF022`, `RUF023`) (astral-sh#14560)
## Summary

This is just a small refactor to remove the `FormatFStringPart` as it's
only used in the case when the f-string is not implicitly concatenated
in which case the only part is going to be `FString`. In implicitly
concatenated f-strings, we use `StringLike` instead.
Airflow 3.0 changes the default of the 'schedule' argument. This causes
incompatibility if a DAG previously does not specify a schedule
explicitly. This is against best practice anyway---you should always
prefer to set a schedule explicitly.

Due to backward compatibility, Airflow 2 also possesses multiple
arguments to set the schedule. These are all being combined into
'schedule' in 3.0. Usages of those old arguments are also detected.
@uranusjr uranusjr force-pushed the airflow-upgrade-dag-schedule-argument branch from fcd7936 to 5607a2f Compare November 25, 2024 07:29
@uranusjr
Copy link
Owner Author

Submitted upstream as astral-sh#14582

@uranusjr uranusjr closed this Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.