You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "amoghrajesh (via GitHub)" <gi...@apache.org> on 2026/07/08 10:42:10 UTC

[PR] Making ResumableJobMixin a abstract class and its methods abstractmet… [airflow]

amoghrajesh opened a new pull request, #69607:
URL: https://github.com/apache/airflow/pull/69607

   …hods
   
    <!-- SPDX-License-Identifier: Apache-2.0
         https://www.apache.org/licenses/LICENSE-2.0 -->
   
   <!--
   Thank you for contributing!
   
   Please provide above a brief description of the changes made in this pull request.
   Write a good git commit message following this guide: http://chris.beams.io/posts/git-commit/
   
   Please make sure that your code changes are covered with tests.
   And in case of new features or big changes remember to adjust the documentation.
   
   For user-facing UI changes, please attach before/after screenshots (or a short
   screen recording) so reviewers can assess the visual impact.
   
   Feel free to ping (in general) for the review if you do not see reaction for a few days
   (72 Hours is the minimum reaction time you can expect from volunteers) - we sometimes miss notifications.
   
   In case of an existing issue, reference it using one of the following:
   
   * closes: #ISSUE
   * related: #ISSUE
   -->
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, please
   change below checkbox to `[X]` followed by the name of the tool, uncomment the "Generated-by".
   -->
   
   - [x] Yes - claude sonnet 4.6
   
   <!--
   Generated-by: [Tool Name] following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   -->
   
   ### What
   
   `ResumableJobMixin`'s six subclass-facing methods (`submit_job`, `get_job_status`, `is_job_active`, `is_job_succeeded`, `poll_until_complete`, `get_job_result`) are the entire contract a subclass must fulfill to get crash-safe execution. Today, if an implementer forgets to override one, the class still constructs fine and the mistake only surfaces as a `NotImplementedError` the first time that specific method is actually called, which can be much later than when the operator was defined.
   
   ### Current behaviour
   
   A subclass missing, say, `get_job_result` instantiates without complaint. The gap is invisible until a task actually reaches that code path, which for methods like `poll_until_complete`'s reconnect branch might only happen after a real worker crash in production, long after the operator shipped.
   
   ### Proposed change
   
   `ResumableJobMixin` now inherits from `ABC` and decorates all six methods with `@abstractmethod`. `BaseOperatorMeta` (the metaclass every `BaseOperator` subclass already uses) already inherits from `ABCMeta`, so this composes with `(ResumableJobMixin, BaseOperator)` with zero metaclass conflict.
   
   ### Why all six must be overridden
   
   - The mixin has no reasonable default for any of them and each one is where the subclass's specific external system (Databricks, Snowflake, etc.) actually gets talked to, and `execute_resumable()`'s control flow calls all six depending on which branch it takes (fresh submit, reconnect, already-succeeded, terminal failure). 
   
   - A subclass that's missing even one of them isn't "mostly correct", it has a hole in the exact contract this mixin exists to provide, and today that hole is silent until runtime. Marking them abstract moves the failure from "the first time this specific code path executes, maybe in production during an actual crash" to "the moment the class is defined," which is a strictly better place to catch it, a missing override bug should fail at parse/import time, not lie dormant until an operator's least-tested branch (e.g. reconnect-on-crash) finally runs for real.
   
   ### User implications / backcompat
   
   - No behavior change for any correctly-implemented subclass such as `DatabricksSubmitRunOperator`, `DatabricksRunNowOperator`, and `SparkSubmitOperator` (all currently shipped) already override every one of the six methods, so nothing changes for them; overriding an abstract method works identically to overriding a regular one. 
   
   ---
   
   * Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#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](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: `{pr_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments). You can add this file in a follow-up commit after the PR is created so you know the PR number.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Making ResumableJobMixin a abstract class and its methods abstractmethods [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #69607:
URL: https://github.com/apache/airflow/pull/69607#discussion_r3549266939


##########
task-sdk/src/airflow/sdk/bases/resumablejobmixin.py:
##########
@@ -218,6 +220,7 @@ def submit_job(self, context: Context) -> JsonValue:
         """
         raise NotImplementedError

Review Comment:
   These `raise NotImplementedError` are now never reached (`@abstractmethod` blocks method access from the metaclass level) and can all be removed. Leveing them here would not break anything either.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Making ResumableJobMixin a abstract class and its methods abstractmethods [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh merged PR #69607:
URL: https://github.com/apache/airflow/pull/69607


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Making ResumableJobMixin a abstract class and its methods abstractmethods [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on code in PR #69607:
URL: https://github.com/apache/airflow/pull/69607#discussion_r3549378648


##########
task-sdk/src/airflow/sdk/bases/resumablejobmixin.py:
##########
@@ -218,6 +220,7 @@ def submit_job(self, context: Context) -> JsonValue:
         """
         raise NotImplementedError

Review Comment:
   Yeah, trying to keep minimal diff and not change anything if there's no benefit to doing it. Leaving it that way



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Making ResumableJobMixin a abstract class and its methods abstractmethods [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #69607:
URL: https://github.com/apache/airflow/pull/69607#discussion_r3549266939


##########
task-sdk/src/airflow/sdk/bases/resumablejobmixin.py:
##########
@@ -218,6 +220,7 @@ def submit_job(self, context: Context) -> JsonValue:
         """
         raise NotImplementedError

Review Comment:
   These `raise NotImplementedError` are now never reached (`@abstractmethod` blocks method access from the metadata level) and can all be removed. Leveing them here would not break anything either.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org