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-209] Add scheduler tests and improve lineage handling #1568

Merged
merged 1 commit into from
Jun 3, 2016

Conversation

bolkedebruin
Copy link
Contributor

@bolkedebruin bolkedebruin commented Jun 2, 2016

Dear Airflow Maintainers,

Please accept this PR that addresses the following issues:

Reminders for contributors:

ti.state = State.REMOVED
try:
dag.get_task(ti.task_id)
except AirflowException:
Copy link
Contributor

Choose a reason for hiding this comment

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

Wonder about this logic. Is it possible to get an AirflowException for another reason, and erroneously set the state to REMOVED?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really. Removed is set when the task
Does not exist in the DAG. This exception is thrown when the task does not exist in task dictionary of the DAG.

Copy link
Member

@jlowin jlowin Jun 3, 2016

Choose a reason for hiding this comment

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

So is the guard (if self.state is not State.RUNING) against it running to protect against this situation:

  1. Task starts running
  2. While task is running, DAG is modified and task is removed
  3. We don't want to interrupt the running task, that's what this guard is for

If so do you mind just commenting the logic to clarify?

@criccomini
Copy link
Contributor

LGTM

This patch adds schedule_dag and process_dag unittests. It also
fixes some minor bugs that were caught by these tests. Some
small changes for readability.
@bolkedebruin bolkedebruin changed the title Add scheduler tests and improve lineage handling [AIRFLOW-209] Add scheduler tests and improve lineage handling Jun 3, 2016
@@ -491,3 +491,196 @@ def test_scheduler_process_check_heartrate(self):
scheduler.process_dag(dag, queue=queue)

queue.put.assert_not_called()

def test_scheduler_do_not_schedule_removed_task(self):
dag = DAG(
Copy link
Member

Choose a reason for hiding this comment

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

The DAG creation code is very repetitive and I think it will be useful for future tests. Maybe you could refactor it into a helper function?

@jlowin
Copy link
Member

jlowin commented Jun 3, 2016

+1

@asfgit asfgit merged commit fb5a3b3 into apache:master Jun 3, 2016
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.

4 participants