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

More typing in SchedulerJob and TaskInstance #24912

Merged
merged 10 commits into from
Jul 12, 2022
Merged

Conversation

jedcunningham
Copy link
Member

I noticed these were missing some typing. This doesn't bring us to complete coverage in TaskInstance, but gets all the easy ones out of the way.

@boring-cyborg boring-cyborg bot added the area:Scheduler including HA (high availability) scheduler label Jul 8, 2022
Copy link
Member Author

@jedcunningham jedcunningham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the only runtime changes in this PR, and even then they should be functionally identical.

Comment on lines +452 to +453
TI.dag_id == dag_id, TI.state == TaskInstanceState.SCHEDULED
).update({TI.state: TaskInstanceState.FAILED}, synchronize_session='fetch')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically just a typing change, but we were using the wrong one.

@@ -790,7 +794,7 @@ def _update_dag_run_state_for_paused_dags(self):
dag = SerializedDagModel.get_dag(dag_id)
if dag is None:
continue
dag_runs = DagRun.find(dag_id=dag_id, state=State.RUNNING)
dag_runs = DagRun.find(dag_id=dag_id, state=DagRunState.RUNNING)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, using the wrong one.

airflow/models/taskinstance.py Show resolved Hide resolved
airflow/jobs/scheduler_job.py Outdated Show resolved Hide resolved
airflow/models/taskinstance.py Outdated Show resolved Hide resolved
airflow/models/taskinstance.py Show resolved Hide resolved
jedcunningham and others added 3 commits July 7, 2022 22:36
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
@@ -197,7 +199,7 @@ def clear_task_instances(
if dag and dag.has_task(task_id):
task = dag.get_task(task_id)
ti.refresh_from_task(task)
task_retries = task.retries
task_retries = task.retries or 0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also had to add this, as task.retries is Optional[int]. Not sure it would have worked if it was None, but I'll look closer tomorrow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wouldn’t work, and honestly I don’t even know what None means here. I think this is exposing a more fundamental bug…

@uranusjr
Copy link
Member

uranusjr commented Jul 8, 2022

I just pushed a commit to remove unnecessary provide_session decorators.

@potiuk
Copy link
Member

potiuk commented Jul 12, 2022

Conflicts need to be resolved.

@jedcunningham jedcunningham reopened this Jul 12, 2022
@potiuk potiuk merged commit 2c2b827 into apache:main Jul 12, 2022
@ephraimbuddy ephraimbuddy deleted the more_typing branch July 15, 2022 06:03
@ephraimbuddy ephraimbuddy added the type:improvement Changelog: Improvements label Aug 12, 2022
@ephraimbuddy ephraimbuddy added this to the Airflow 2.4.0 milestone Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Scheduler including HA (high availability) scheduler type:improvement Changelog: Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants