Skip to content

Conversation

@davidavdav
Copy link
Contributor

This small PR uses the type of a BaseOperator task, rather than its property task_type, to detect DAG dependence.

This helps in situations like described in #19582, where an operator is derived from ExternalTaskSensor. Using the task_type prevents such a sensor from being detected as a DAG dependence. This PR will allow automatic detection of derived classes.

@boring-cyborg
Copy link

boring-cyborg bot commented Nov 18, 2021

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it’s a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

Copy link
Member

Choose a reason for hiding this comment

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

Since this is done during serialization time this should be ok, however can you please add test(s)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure I'll look into how tests work in airflow, and add one, I suppose, for testing that both TriggerDagRunOperator and inherited classes give the expected result.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kaxil do you think that perhaps there should be an attribute on task sensor (like a class attribute that is set on it, and which could also be set in other implementations) that we look at (instead of the class itself) so that there could be other implementations of task-sensor-like operators which do not inherit from external task sensor but also have dag dependencies?

so that it needn't necessarily be a subclass. maybe it's a bit too magical, and just thinking aloud, but perhaps we could look at the arguments of the operator to infer whether DagDependency should be created?

@uranusjr uranusjr requested a review from kaxil November 22, 2021 02:17
Copy link
Member

@kaxil kaxil left a comment

Choose a reason for hiding this comment

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

Looks good, can you fix Static Checks please https://github.com/apache/airflow/runs/4281700481?check_suite_focus=true and rebase on latest main branch please.

@davidavdav
Copy link
Contributor Author

Is that purely formatting / style? I should be able to fix that (but so should the automatic checking I suppose?).

@davidavdav davidavdav force-pushed the dagdependence branch 2 times, most recently from 17bcf7f to 0311d86 Compare November 24, 2021 08:00
Copy link
Contributor

@dstandish dstandish left a comment

Choose a reason for hiding this comment

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

i think this looks ok but just have some naming nits

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for Trigger in [TriggerDagRunOperator, DerivedTrigger]:
for class_ in [TriggerDagRunOperator, DerivedTrigger]:

Copy link
Contributor

Choose a reason for hiding this comment

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

@kaxil do you think that perhaps there should be an attribute on task sensor (like a class attribute that is set on it, and which could also be set in other implementations) that we look at (instead of the class itself) so that there could be other implementations of task-sensor-like operators which do not inherit from external task sensor but also have dag dependencies?

so that it needn't necessarily be a subclass. maybe it's a bit too magical, and just thinking aloud, but perhaps we could look at the arguments of the operator to infer whether DagDependency should be created?

@davidavdav
Copy link
Contributor Author

bump

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Feb 14, 2022
Add tests for DAG dependency detector

Adhere to style norms

Add a line to make black happy

Don't call an Operator just Trigger

Use  `class_` for class variables

Fix static check isort imports

Simplipy test class and split into two tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:serialization stale Stale PRs per the .github/workflows/stale.yml policy file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants