Open jdavcs opened 2 years ago
Running test/unit/data/model/test_mapping.py
with the SQLALCHEMY_WARN_20=1
flag triggers 1561 RemovedIn20Warning warnings. It is likely not as problematic as it looks: the set of root causes that account for these warnings is, I'm sure, much smaller and, therefore, manageable. However, I think it makes sense to address these by enabling the flag manually for each test run: otherwise the warnings would pollute normal output.
So, we are switching to Alembic before this can be completed. I tried fixing the bound metadata issue (one of the "things" that are removed in 2.0), and that appears to be not possible with our current migration provider (e.g. a bound engine is assumed when SA Migrate executes Column.create()
. So, Alembic comes first.
In 2.0 there will be no backref/back-populates cascading of child objects into the session (ref). In particular: "In 2.0, the default behavior will be that “cascade_backrefs” is False, and additionally there will be no “True” behavior as this is not generally a desirable behavior." This, potentially could wreak havoc on a running Galaxy. To address this, I will try adding an explicit cascade_backref=False
to all relationships with back_populates
and address any issues on a case-by-case basis.
Once we get to Step Four and enable the future=True
flag on the Session
, I'll remove these attributes. I think this is the safest way to do it (and manageable too).
This builds on #10892 (SQLAlchemy 1.4 compatibility) and details the specific steps required for preparing Galaxy's codebase for migrating to SQLAlchemy's upcoming 2.0 release. The steps are documented here.
First Prerequisite, step one:
First Prerequisite, step two:
Migration to 2.0 Step One:
Migration to 2.0 Step Two Prerequisites (Galaxy-specific)
Migration to 2.0 Step Two - Use RemovedIn20Warnings (ref)(#13171) (To enable warnings, set
GALAXY_CONFIG_SQLALCHEMY_WARN_20=1
)Migration to 2.0 Step Three - Resolve all RemovedIn20Warnings (ref) (Helpful documentation on how to filter warnings: sqlalchemy, pytest, python)
Migration to 2.0 Step Four - Use the future flag on Engine (ref)
future=True
flag to thecreate_engine()
function (there are multiple places where we call that function: check entire code base: lib/, scripts/, test/)connection.commit()
where applicableMigration to 2.0 Step Four - Use the future flag on Session (ref)
future=True
flag to Session wherever we are creating an instance (direct instantiation of Session or calling the sessionmaker factory)Once all of the above is complete and no RemovedIn20Warning are emitted:
Enable SA 2.0:
pyproject.toml
, relevant packages (setup.cfg
files)Cleanup:
Next steps:
UPDATE: Keeping track of fixing RemovedIn20Warnings:
Number of distinct warnings per github workflow (each may be triggered multiple times by different tests): (last updated/corrected: Dec 11, 2023)
UPDATE: Keeping track of fixing test failures on the SQLAlchemy-2.0 PR (#17180):
(last updated/corrected: Feb 23, 2024)