Skip to content

Handle both SubDagOperator classes#1196

Merged
jlowin merged 1 commit intoapache:masterfrom
jlowin:subdag_class
Apr 1, 2016
Merged

Handle both SubDagOperator classes#1196
jlowin merged 1 commit intoapache:masterfrom
jlowin:subdag_class

Conversation

@jlowin
Copy link
Member

@jlowin jlowin commented Mar 22, 2016

As described in #1168, Airflow validates subdags against airflow.operators.SubDagOperator, which is NOT the same as airflow.operators.subdag_operator.SubDagOperator. Users who used the latter class got unexpected errors.

Since this is a piece of Airflow’s internals, we can handle both cases explicitly (with this PR), but this isn’t a good long term fix for the many other cases where users could be using either of two possible Operator/Hook classes. See #1194.

@mistercrunch
Copy link
Member

Oh interesting, I thought both would have the same identity... Should we go with obj.__class__.__name__ == 'SubDagOperator' instead ?

@jlowin
Copy link
Member Author

jlowin commented Mar 27, 2016

@mistercrunch yes, I like that! It gets around the import issue. But since it potentially includes other user-created tasks that could be called SubDagOperator I'm going to do this just to be safe.

            if (
                    task.__class__.__name__ == 'SubDagOperator'
                    and hasattr(task, 'subdag')):

`airflow.operators.SubDagOperator` and
`airflow.operators.subdag_operator.SubDagOperator` are NOT the
same. Airflow needs to check against both classes to determine
if a task is in fact a SubDagOperator. This is because of Airflow's
import machinery. It is *probably* ok to check both classes with
`isinstance()` but the behavior is surprising and to cover our bases
we check for __class__.__name__ and a `subdag` attr.

closes apache#1168
@mistercrunch
Copy link
Member

As a longer term fix there might be a way to handle it in the importing function in utils to insure the object ids are the same.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.005%) to 66.368% when pulling de0b5d144412ed10936868e248d82217cc513831 on jlowin:subdag_class into 58029df on airbnb:master.

@landscape-bot
Copy link

Code Health
Repository health decreased by 0.56% when pulling 7398dda on jlowin:subdag_class into dea40d1 on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 66.6% when pulling 7398dda on jlowin:subdag_class into dea40d1 on airbnb:master.

@jlowin jlowin merged commit 154dec0 into apache:master Apr 1, 2016
@jlowin jlowin deleted the subdag_class branch April 1, 2016 16:47
@aaur0 aaur0 mentioned this pull request Apr 27, 2016
mobuchowski added a commit to mobuchowski/airflow that referenced this pull request Jan 4, 2022
* marquez-airflow bigquery stats

Signed-off-by: Maciej Obuchowski <maciej.obuchowski@getindata.com>
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