Repository navigation
[v3-4-test] Fix ORM models failing to configure in processes that skip database setup (#74642) - #74971
Merged
Conversation
…p database setup (#74642) Models name each other in string relationships, which only resolve once every model module is imported. The before_configured hook that imports them all was registered in configure_orm(), so a process that skips it (virtualenv-mode subprocesses, a task re-executed for run_as_user, non-DB tests) or configures mappers before it runs (local settings) only worked if it had already imported the right model modules. If it had not, building a model failed, for example with Team.dag_bundles unable to find DagBundleModel. Register the hook in airflow.models.base, before any model class is defined, and drop the test-only copy from the pytest plugin. Remove the orm_event_handlers test: it guarded the line that moved, and now passes whatever the code does. (cherry picked from commit d79c0b1) Co-authored-by: Kaxil Naik <kaxilnaik@gmail.com>
Contributor
|
OL compat 3.4.0 failure is expected and safe to merge past — that image/package isn't published until GA, so the 3.4.0 cell fails during beta/RC while all older versions pass. #74997 fixes it by skipping the unreleased current version from the matrix. |
Contributor
Author
|
Hi maintainer, this PR was merged without a milestone set.
|
vatsrahul1001
added a commit
that referenced
this pull request
Oct 20, 2026
…p database setup (#74642) (#74971) Models name each other in string relationships, which only resolve once every model module is imported. The before_configured hook that imports them all was registered in configure_orm(), so a process that skips it (virtualenv-mode subprocesses, a task re-executed for run_as_user, non-DB tests) or configures mappers before it runs (local settings) only worked if it had already imported the right model modules. If it had not, building a model failed, for example with Team.dag_bundles unable to find DagBundleModel. Register the hook in airflow.models.base, before any model class is defined, and drop the test-only copy from the pytest plugin. Remove the orm_event_handlers test: it guarded the line that moved, and now passes whatever the code does. (cherry picked from commit d79c0b1) Co-authored-by: Kaxil Naik <kaxilnaik@gmail.com> Co-authored-by: Rahul Vats <43964496+vatsrahul1001@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Models name each other in string relationships, which only resolve once
every model module is imported. The before_configured hook that imports
them all was registered in configure_orm(), so a process that skips it
(virtualenv-mode subprocesses, a task re-executed for run_as_user,
non-DB tests) or configures mappers before it runs (local settings)
only worked if it had already imported the right model modules. If it
had not, building a model failed, for example with Team.dag_bundles
unable to find DagBundleModel.
Register the hook in airflow.models.base, before any model class is
defined, and drop the test-only copy from the pytest plugin. Remove the
orm_event_handlers test: it guarded the line that moved, and now passes
whatever the code does.
(cherry picked from commit d79c0b1)
Co-authored-by: Kaxil Naik kaxilnaik@gmail.com