Skip to content

Making the dependency engine more flexible - #261

Merged
mistercrunch merged 4 commits into
masterfrom
dep_rule
Aug 25, 2015
Merged

mistercrunch merged 4 commits into
masterfrom
dep_rule

Conversation

@mistercrunch

Copy link
Copy Markdown
Member

New BaseOperator parameter enables task triggers beyond "all directly upstream tasks succeeded", here are the new options:

:param trigger_rule: defines the rule by which dependencies are applied
        for the task to get triggered. Options are:
        ``{ all_success | all_failed | all_done | one_success |
        one_failed | dummy}``
        default is ``all_success``. Options can be set as string or
        using the constants defined in the static class
        ``airflow.utils.TriggerRule``
    :type trigger_rule: str

@azaroth42

Copy link
Copy Markdown

All of them are more specific than all_done, correct? E.g. one_success wouldn't fire off the task as soon as the first upstream tasks completes successfully, but only after all are completed and at least one completed successfully?

@mistercrunch

Copy link
Copy Markdown
Member Author

it all refers to directly upstream task (direct parents)

Comment thread airflow/models.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Each func.sum(...) statement should be wrapped in func.coalesce(func.sum(...), 0) for Py3 compatibility. Otherwise func.sum() can return None if there are no rows, and that might create type errors because these results are treated as ints later.

@jlowin

jlowin commented Aug 21, 2015

Copy link
Copy Markdown
Member

I think this functionality is great -- it adds so much versatility.

@azaroth42 makes a good point. If a task has two upstream tasks and the trigger is ONE_SUCCESS, wouldn't it fire as soon as the first upstream task finishes, even if the second upstream task is still running? I'm not sure if that's expected -- if I set up a dependency between two tasks, don't I expect the downstream task to wait for the upstream task to finish, even if my trigger_rule was already satisfied?

(Aside -- maybe ANY_SUCCESS and ANY_FAILED are more self-explanatory than ONE_SUCCESS and ONE_FAILED?)

@mistercrunch

Copy link
Copy Markdown
Member Author

I rebased and addressed the coalesce py3 issue

@mistercrunch

Copy link
Copy Markdown
Member Author

one_success may be as clear (or as confusing) as any_success, any may be implying that it may wait for all parent tasks to be done. Anyhow both names are arguably as confusing, so I'll take the approach or clarifying the docs.

mistercrunch added a commit that referenced this pull request Aug 25, 2015
Making the dependency engine more flexible
@mistercrunch
mistercrunch merged commit 5332ebf into master Aug 25, 2015
@mistercrunch
mistercrunch deleted the dep_rule branch August 25, 2015 06:29
@mistercrunch
mistercrunch restored the dep_rule branch September 3, 2015 06:30
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.

3 participants