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

Support ExternalTaskSensor execution_date_fn and execution_delta #354

Merged
merged 5 commits into from
Jan 10, 2025

Conversation

tatiana
Copy link
Collaborator

@tatiana tatiana commented Jan 10, 2025

Previously, users who attempted to run a DAG with the following configuration:

example_external_task_sensor_dag_factory_consumer2:
  default_args:
    start_date: 2025-01-02
    schedule_interval: "@daily"
  tasks:
    wait_for_producer_task:
      operator: airflow.sensors.external_task_sensor.ExternalTaskSensor
      external_dag_id: example_external_task_sensor_dag_factory_producer
      external_task_id: producer_task
      execution_date_fn: sample.one_day_ago
    consumer_task:
      operator: airflow.operators.empty.EmptyOperator

Would face the error:

"TypeError: 'sample.one_day_ago' is not a callable object"

And if they attempted to run a DAG with this other configuration:

example_external_task_sensor_dag_factory_consumer3:
  default_args:
    start_date: 2025-01-03
    schedule_interval: "@daily"
  tasks:
    wait_for_producer_task:
      operator: airflow.sensors.external_task_sensor.ExternalTaskSensor
      external_dag_id: example_external_task_sensor_dag_factory_producer
      external_task_id: producer_task
      execution_delta: 1 days,
    consumer_task:
      operator: airflow.operators.empty.EmptyOperator

It would fail with:

TypeError: unsupported operand type(s) for -: 'DateTime' and 'dict'/'str'

Now both examples work.

Closes: #226

@tatiana tatiana requested a review from a team as a code owner January 10, 2025 00:02
@tatiana tatiana changed the title Support ExternalTaskSensor execution_date_fn and execution_delta Support ExternalTaskSensor execution_date_fn and execution_delta Jan 10, 2025
@tatiana tatiana added this to the DAG Factory 0.22.0 milestone Jan 10, 2025
Copy link
Contributor

@pankajkoti pankajkoti left a comment

Choose a reason for hiding this comment

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

LGTM. Happy to merge once CI is green. Just a quick question to discuss in-line.

dagfactory/dagbuilder.py Show resolved Hide resolved
Previously, users who attempted to run a DAG with the following configuration:

```
example_external_task_sensor_dag_factory_consumer2:
  default_args:
    start_date: 2025-01-02
    schedule_interval: "@daily"
  tasks:
    wait_for_producer_task:
      operator: airflow.sensors.external_task_sensor.ExternalTaskSensor
      external_dag_id: example_external_task_sensor_dag_factory_producer
      external_task_id: producer_task
      execution_date_fn: sample.one_day_ago
    consumer_task:
      operator: airflow.operators.empty.EmptyOperator
```

Would face the error:

```
"TypeError: 'sample.one_day_ago' is not a callable object"
```

And if they attempted to run a DAG with this other configuration:

```
example_external_task_sensor_dag_factory_consumer3:
  default_args:
    start_date: 2025-01-03
    schedule_interval: "@daily"
  tasks:
    wait_for_producer_task:
      operator: airflow.sensors.external_task_sensor.ExternalTaskSensor
      external_dag_id: example_external_task_sensor_dag_factory_producer
      external_task_id: producer_task
      execution_delta: 1 days,
    consumer_task:
      operator: airflow.operators.empty.EmptyOperator
```

It would fail with:

```
TypeError: unsupported operand type(s) for -: 'DateTime' and 'dict'/'str'
```

Now both examples work.

Closes: #226
Co-authored-by: Pankaj Singh <98807258+pankajastro@users.noreply.github.com>
@pankajkoti pankajkoti mentioned this pull request Jan 10, 2025
@codecov-commenter
Copy link

codecov-commenter commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.62%. Comparing base (f314bed) to head (1b8c0e4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #354      +/-   ##
==========================================
- Coverage   93.69%   93.62%   -0.08%     
==========================================
  Files          10       10              
  Lines         777      784       +7     
==========================================
+ Hits          728      734       +6     
- Misses         49       50       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tatiana tatiana merged commit 48e5575 into main Jan 10, 2025
68 checks passed
@tatiana tatiana deleted the issue-226 branch January 10, 2025 12:30
tatiana pushed a commit that referenced this pull request Jan 10, 2025
### Added

- Propagate provided dag_display_name to built dag by @pankajkoti in
#326
- Add incipient documentation tooling by @tatiana in #328
- Support loading `default_args` from shared `defaults.yml` by
@pankajastro in #330
- Add security policy by @tatiana in #339
- Add Robust Support for Callbacks at Task and TaskGroup Level by
@@jroach-astronomer in #322
- Support `ExternalTaskSensor` `execution_date_fn` and `execution_delta`
by @tatiana in #354
- Refactor and add support for schedule conditions in DAG configuration
by @ErickSeo in #320

### Fixed

- Handle gracefully exceptions during telemetry collection by @tatiana
in #335
- Adjust `markdownlint` configuration to enforce 4-space indentation for
proper `mkdocs` rendering by @pankajkoti in #345

### Docs

- Create initial documentation index by @tatiana in #325
- Use absolute URLs for failing links in docs/index.md by @pankajkoti in
#331
- Add quick start docs by @pankajastro in #324
- Add docs comparing Python and YAML-based DAGs by @tatiana in #327
- Add docs about project contributors and their roles by @tatiana in
#341
- Add documentation to support developers by @tatiana in #343
- Add docs for configuring workflows, environment variables and defaults
by @pankajkoti in #338
- Add code of conduct for contributors and DAG factory community by
@tatiana in #340
- Document Dynamic Task Mapping feature by @pankajkoti in #344
- Fix warning message 404 in code_of_conduct docs by @pankajastro in
#346
- Update theme for documentation by @pankajastro in #348
- Fix markdownlint errors and some rendering improvements by
@pankajastro in #356
- Reword content in documentation by @yanmastin-astro in #336

### Others

- Improve integration tests scripts by @tatiana in #316
- Add Markdown pre-commit checks by @tatiana in #329
- Remove Airflow <> 2.0.0 check by @pankajastro in #334
- Reduce telemetry timeout from 5 to 1 second by @tatiana in #337
- Add GH action job to deploy docs by @pankajastro in #342
- Enable Depandabot to scan outdated Github Actions dependencies by
@tatiana in #347
- Improve docs deploy job by @pankajastro in #352
- Unify how we build dagfactory by @tatiana in #353
- Fix running make docker run when previous versions were run locally by
@tatiana in #362
- Install `jq` in `dev` container by @pankajastro in #363
- Dependabot GitHub actions version upgrades in #349, #350, #351


Closes: #306
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.

execution_delta and execution_date_fn attribute in external_task_sensor
4 participants