Skip to content

Add autouse fixture to clear SQLAlchemy engine map between tests#19402

Merged
harupy merged 2 commits intomlflow:masterfrom
harupy:clear-sqlalchemy-engine-map-in-tests
Dec 16, 2025
Merged

Add autouse fixture to clear SQLAlchemy engine map between tests#19402
harupy merged 2 commits intomlflow:masterfrom
harupy:clear-sqlalchemy-engine-map-in-tests

Conversation

@harupy
Copy link
Member

@harupy harupy commented Dec 15, 2025

Related Issues/PRs

N/A

What changes are proposed in this pull request?

Add an autouse fixture that clears SqlAlchemyStore._db_uri_sql_alchemy_engine_map between tests to prevent test pollution from cached SQLAlchemy engine connections.

This fixes the following error where a cached engine points to a temporary database file that no longer exists:

https://github.com/mlflow/mlflow/actions/runs/20225403229/job/58055633634

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file
FAILED tests/tracking/_tracking_service/test_utils.py::test_tracking_scheme_without_existing_mlruns

How is this PR tested?

  • Existing unit/integration tests

Does this PR require documentation update?

  • No. You can skip the rest of this section.

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/build: Build and test infrastructure for MLflow

How should the PR be classified in the release notes? Choose one:

  • rn/none - No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" section

Should this PR be included in the next patch release?

  • Yes (this PR will be cherry-picked and included in the next patch release)
  • No (this PR will be included in the next minor release)

🤖 Generated with Claude Code

Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 15, 2025 11:51
@github-actions
Copy link
Contributor

@harupy Thank you for the contribution! Could you fix the following issue(s)?

⚠ Invalid PR template

This PR does not appear to have been filed using the MLflow PR template. Please copy the PR template from here and fill it out.

@github-actions github-actions bot added area/build Build and test infrastructure for MLflow rn/none List under Small Changes in Changelogs. labels Dec 15, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an autouse fixture to clear the SQLAlchemy engine map between tests to prevent test pollution from cached database connections.

Key Changes

  • Adds a new clear_engine_map() autouse fixture that clears SqlAlchemyStore._db_uri_sql_alchemy_engine_map to prevent engine caching across tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@B-Step62 B-Step62 left a comment

Choose a reason for hiding this comment

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

LGTM!

@harupy harupy enabled auto-merge December 16, 2025 00:16
Copy link
Collaborator

@TomeHirata TomeHirata left a comment

Choose a reason for hiding this comment

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

LGTM

@harupy harupy disabled auto-merge December 16, 2025 00:18
@harupy harupy merged commit ecf11ba into mlflow:master Dec 16, 2025
41 of 52 checks passed
@harupy harupy deleted the clear-sqlalchemy-engine-map-in-tests branch December 16, 2025 00:37
WeichenXu123 pushed a commit to WeichenXu123/mlflow that referenced this pull request Dec 19, 2025
…low#19402)

Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
WeichenXu123 pushed a commit that referenced this pull request Dec 19, 2025
)

Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Build and test infrastructure for MLflow rn/none List under Small Changes in Changelogs. team-review Trigger a team review request v3.8.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants