diff --git a/lib/galaxy/app_unittest_utils/tools_support.py b/lib/galaxy/app_unittest_utils/tools_support.py index 9342f80c2b3..e87f70c9f82 100644 --- a/lib/galaxy/app_unittest_utils/tools_support.py +++ b/lib/galaxy/app_unittest_utils/tools_support.py @@ -130,7 +130,6 @@ class MockContext: self.flushed = False self.model_objects = model_objects or defaultdict(dict) self.created_objects = [] - self.current = self def expunge_all(self): self.expunged_all = True diff --git a/lib/galaxy/model/base.py b/lib/galaxy/model/base.py index b9e81bdfe01..eedebec8005 100644 --- a/lib/galaxy/model/base.py +++ b/lib/galaxy/model/base.py @@ -59,9 +59,6 @@ class ModelMapping(Bunch): self._SessionLocal = sessionmaker(autoflush=False) versioned_session(self._SessionLocal) context = scoped_session(self._SessionLocal, scopefunc=self.request_scopefunc) - # For backward compatibility with "context.current" - # deprecated? - context.current = context self.session = context self.scoped_registry = context.registry diff --git a/lib/tool_shed/managers/repositories.py b/lib/tool_shed/managers/repositories.py index 2a9b0e36e27..5e21ba86267 100644 --- a/lib/tool_shed/managers/repositories.py +++ b/lib/tool_shed/managers/repositories.py @@ -211,7 +211,7 @@ def index_tool_ids(app: ToolShedApp, tool_ids: List[str]) -> Dict[str, Any]: owner = repository.user.username name = repository.name assert name - repository = _get_repository_by_name_and_owner(app.model.session().current, name, owner, app.model.User) + repository = _get_repository_by_name_and_owner(app.model.session, name, owner, app.model.User) if not repository: log.warning(f"Repository {owner}/{name} does not exist, skipping") continue diff --git a/scripts/cleanup_datasets/cleanup_datasets.py b/scripts/cleanup_datasets/cleanup_datasets.py index 5cd7330ea7e..4a04f2ad90f 100755 --- a/scripts/cleanup_datasets/cleanup_datasets.py +++ b/scripts/cleanup_datasets/cleanup_datasets.py @@ -706,7 +706,7 @@ class CleanupDatasetsApplication: session from the threadlocal session context, but this is provided to allow migration toward a more SQLAlchemy 0.4 style of use. """ - return self.model.context.current + return self.model.context def shutdown(self): self.object_store.shutdown() diff --git a/scripts/grt/export.py b/scripts/grt/export.py index aaa0da2d502..12a11777793 100644 --- a/scripts/grt/export.py +++ b/scripts/grt/export.py @@ -124,7 +124,7 @@ def main(argv): # Galaxy overrides our logging level. logging.getLogger().setLevel(getattr(logging, args.loglevel.upper())) - sa_session = model.context.current + sa_session = model.context annotate("galaxy_end") # Fetch jobs COMPLETED with status OK that have not yet been sent. diff --git a/scripts/set_dataset_sizes.py b/scripts/set_dataset_sizes.py index 0e235af24e1..169e70aec97 100644 --- a/scripts/set_dataset_sizes.py +++ b/scripts/set_dataset_sizes.py @@ -31,7 +31,7 @@ def init(): if __name__ == "__main__": print("Loading Galaxy model...") model, object_store = init() - sa_session = model.context.current + sa_session = model.context session = sa_session() set = 0 diff --git a/scripts/set_user_disk_usage.py b/scripts/set_user_disk_usage.py index da42f7a5590..43c1f2a9fe0 100755 --- a/scripts/set_user_disk_usage.py +++ b/scripts/set_user_disk_usage.py @@ -70,7 +70,7 @@ def quotacheck(sa_session, users, engine, object_store): if __name__ == "__main__": print("Loading Galaxy model...") model, object_store, engine = init() - sa_session = model.context.current + sa_session = model.context if not args.username and not args.email: user_count = sa_session.query(model.User).count() diff --git a/scripts/tool_shed/deprecate_repositories_without_metadata.py b/scripts/tool_shed/deprecate_repositories_without_metadata.py index badb49ad372..c5112411670 100644 --- a/scripts/tool_shed/deprecate_repositories_without_metadata.py +++ b/scripts/tool_shed/deprecate_repositories_without_metadata.py @@ -205,7 +205,7 @@ class DeprecateRepositoriesApplication: session from the threadlocal session context, but this is provided to allow migration toward a more SQLAlchemy 0.4 style of use. """ - return self.model.context.current + return self.model.context def shutdown(self): pass diff --git a/test/integration/test_save_job_id_on_datasets.py b/test/integration/test_save_job_id_on_datasets.py index 99685b4ed03..12d681e3fb6 100644 --- a/test/integration/test_save_job_id_on_datasets.py +++ b/test/integration/test_save_job_id_on_datasets.py @@ -39,7 +39,7 @@ def test_driver(): @pytest.mark.parametrize("tool_id", TEST_TOOL_IDS) def test_tool_datasets(tool_id, test_driver): test_driver.run_tool_test(tool_id) - session = test_driver.app.model.context.current + session = test_driver.app.model.context job = session.scalars(select(model.Job).order_by(model.Job.id.desc()).limit(1)).first() datasets = session.scalars(select(model.Dataset).filter(model.Dataset.job_id == job.id)).all()