Skip to content

Add deferrable mode to SFTPOperator#68298

Open
sunildataengineer wants to merge 5 commits into
apache:mainfrom
sunildataengineer:sftp-deferrable-clean
Open

Add deferrable mode to SFTPOperator#68298
sunildataengineer wants to merge 5 commits into
apache:mainfrom
sunildataengineer:sftp-deferrable-clean

Conversation

@sunildataengineer

Copy link
Copy Markdown

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

Adds deferrable=True parameter to SFTPOperator which allows the
operator to defer execution to SFTPOperatorTrigger, freeing the
worker slot during file transfers instead of blocking it.

- Add SFTPOperatorTrigger class in triggers/sftp.py
- Add deferrable param to SFTPOperator.__init__()
- Add defer() call in execute() when deferrable=True
- Add execute_complete() callback method
- Add unit tests for deferrable mode

Closes apache#65475
Extract SFTPOperation into constants.py to fix circular import
- Add full type annotations to SFTPOperatorTrigger
- Add remote_host, concurrency, prefetch params to trigger
- Fix directory transfer support in deferrable mode
- Replace deprecated asyncio.get_event_loop() with get_running_loop()
- Add remote_host, concurrency, prefetch to serialize()
- Remove inner imports from test methods
- Add SFTPOperatorTrigger tests: serialize roundtrip, run success, run error
@sunildataengineer

Copy link
Copy Markdown
Author

@srchilukoori @potiuk @dabla

I’m opening a new PR as a continuation/replacement for accidentally closed PR #65480. While rebasing and cleaning up the branch history against upstream/main, I mistakenly performed a reset/rebase sequence that rewrote the branch history and caused GitHub to show “0 commits,” which made the original PR impossible to reopen properly.

This was completely unintentional, and I sincerely apologize for the confusion and extra noise caused during review. Over the past couple of months, I worked extensively on this contribution — implementing deferrable support for SFTPOperator, adding async trigger support, moving transfer logic into hooks, addressing multiple rounds of review feedback, fixing CI/lint/test failures, updating docs/newsfragments, and continuously rebasing on latest main.

Thankfully, the commits were still recoverable through git reflog, so I recreated the contribution cleanly from a fresh branch based on current upstream main. This new PR contains the same intended changes and review fixes from #65480, but with a clean branch history and correct diff.

Thank you again for all the reviews, feedback, patience, and guidance throughout this process. I truly appreciate the maintainers and reviewers taking another look at the contribution 🙏

@sunildataengineer

Copy link
Copy Markdown
Author

@dabla @potiuk — the "200 changed files" in the GitHub Files tab
was showing all commits including upstream merge commits.

The actual diff vs apache:main is only 11 files:

providers/sftp/src/.../constants.py
providers/sftp/src/.../hooks/sftp.py
providers/sftp/src/.../operators/sftp.py
providers/sftp/src/.../triggers/sftp.py
providers/sftp/tests/.../test_sftp.py
providers/sftp/tests/.../test_constants.py
providers/sftp/pyproject.toml
providers/sftp/docs/index.rst
providers/sftp/newsfragments/65480.feature.rst
scripts/ci/prek/known_airflow_exceptions.txt
uv.lock
I'll squash the commits to make the PR cleaner. 🙏

@dabla

dabla commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

You could have simply renamed your old corrupt branch, and created a new branch with same name and force pushed it, that way the existing PR (with review and comments) would have been kept, which would make review for us easier.

Now the context is unfortunately lost when creating a new PR, and we reviewers, have to check back with original PR. So please take that into consideration for the future, everyone makes mistakes me included, have encountered the same myself multiple times, that’s how I know the above trick is ideal in such situations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants