From 80342df4e3dd99da7dc56455a058e122398543fb Mon Sep 17 00:00:00 2001 From: Sergey Golitsynskiy Date: Fri, 14 Jan 2022 16:49:49 -0500 Subject: [PATCH 1/3] Enable setting SQLALCHEMY_WARN_20 --- lib/galaxy/config/__init__.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/galaxy/config/__init__.py b/lib/galaxy/config/__init__.py index b7607fbe45ea..d5c6d94cebac 100644 --- a/lib/galaxy/config/__init__.py +++ b/lib/galaxy/config/__init__.py @@ -620,8 +620,36 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin): def __init__(self, **kwargs): super().__init__(**kwargs) self._override_tempdir(kwargs) + self._configure_sqlalchemy20_warnings(kwargs) self._process_config(kwargs) + def _configure_sqlalchemy20_warnings(self, kwargs): + """ + This method should be deleted after migration to SQLAlchemy 2.0 is complete. + To enable warnings, set `GALAXY_CONFIG_SQLALCHEMY_WARN_20=1`, + """ + warn = kwargs.get('sqlalchemy_warn_20', False) + if warn: + import sqlalchemy + sqlalchemy.util.deprecations.SQLALCHEMY_WARN_20 = True + self._setup_sqlalchemy20_warnings_filters() + + def _setup_sqlalchemy20_warnings_filters(self): + import warnings + from sqlalchemy.exc import RemovedIn20Warning + # Always display RemovedIn20Warning warnings. + warnings.filterwarnings('always', category=RemovedIn20Warning) + # Optionally, enable filters for specific warnings (raise error, or log, etc.) + # messages = [ + # r"replace with warning text to match", + # ] + # for msg in messages: + # warnings.filterwarnings('error', message=msg, category=RemovedIn20Warning) + # + # See documentation: + # https://docs.python.org/3.7/library/warnings.html#the-warnings-filter + # https://docs.sqlalchemy.org/en/14/changelog/migration_20.html#migration-to-2-0-step-three-resolve-all-removedin20warnings + def _load_schema(self): # Schemas are symlinked to the root of the galaxy-app package config_schema_path = os.path.join(os.path.dirname(__file__), os.pardir, 'config_schema.yml') From 8b6706dafe23f99416d74a7e8fcf8056862a43ca Mon Sep 17 00:00:00 2001 From: Sergey Golitsynskiy Date: Tue, 18 Jan 2022 21:51:55 -0500 Subject: [PATCH 2/3] Fix bug: use string_as_bool --- lib/galaxy/config/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/config/__init__.py b/lib/galaxy/config/__init__.py index d5c6d94cebac..b80797874d1a 100644 --- a/lib/galaxy/config/__init__.py +++ b/lib/galaxy/config/__init__.py @@ -628,7 +628,7 @@ def _configure_sqlalchemy20_warnings(self, kwargs): This method should be deleted after migration to SQLAlchemy 2.0 is complete. To enable warnings, set `GALAXY_CONFIG_SQLALCHEMY_WARN_20=1`, """ - warn = kwargs.get('sqlalchemy_warn_20', False) + warn = string_as_bool(kwargs.get('sqlalchemy_warn_20', False)) if warn: import sqlalchemy sqlalchemy.util.deprecations.SQLALCHEMY_WARN_20 = True From bd02eaff6ca0e444a3369cfe0def62ec21cd1263 Mon Sep 17 00:00:00 2001 From: Sergey Golitsynskiy Date: Tue, 18 Jan 2022 22:02:13 -0500 Subject: [PATCH 3/3] Enable SA2.0 warning on api/selenium/integration tests --- .github/workflows/api.yaml | 1 + .github/workflows/api_paste.yaml | 1 + .github/workflows/integration.yaml | 1 + .github/workflows/integration_selenium.yaml | 1 + .github/workflows/selenium.yaml | 1 + .github/workflows/selenium_beta.yaml | 1 + 6 files changed, 6 insertions(+) diff --git a/.github/workflows/api.yaml b/.github/workflows/api.yaml index 3d8d21b8e587..250ee7a1aa0c 100644 --- a/.github/workflows/api.yaml +++ b/.github/workflows/api.yaml @@ -12,6 +12,7 @@ env: GALAXY_TEST_DBURI: 'postgresql://postgres:postgres@localhost:5432/galaxy?client_encoding=utf8' GALAXY_TEST_RAISE_EXCEPTION_ON_HISTORYLESS_HDA: '1' GALAXY_DEPENDENCIES_INSTALL_WEASYPRINT: '1' + GALAXY_CONFIG_SQLALCHEMY_WARN_20: '1' concurrency: group: api-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/api_paste.yaml b/.github/workflows/api_paste.yaml index b80bfb42b4d3..99c0ebf1c7b4 100644 --- a/.github/workflows/api_paste.yaml +++ b/.github/workflows/api_paste.yaml @@ -12,6 +12,7 @@ env: GALAXY_TEST_DBURI: 'postgresql://postgres:postgres@localhost:5432/galaxy?client_encoding=utf8' GALAXY_TEST_USE_UVICORN: false GALAXY_TEST_RAISE_EXCEPTION_ON_HISTORYLESS_HDA: '1' + GALAXY_CONFIG_SQLALCHEMY_WARN_20: '1' concurrency: group: api-legacy-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index be3f983cfe2b..4bb722685e6c 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -12,6 +12,7 @@ env: GALAXY_TEST_AMQP_URL: 'amqp://localhost:5672//' GALAXY_TEST_DBURI: 'postgresql://postgres:postgres@localhost:5432/galaxy?client_encoding=utf8' GALAXY_TEST_RAISE_EXCEPTION_ON_HISTORYLESS_HDA: '1' + GALAXY_CONFIG_SQLALCHEMY_WARN_20: '1' concurrency: group: integration-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/integration_selenium.yaml b/.github/workflows/integration_selenium.yaml index 964687b862dc..6ee668d95170 100644 --- a/.github/workflows/integration_selenium.yaml +++ b/.github/workflows/integration_selenium.yaml @@ -12,6 +12,7 @@ env: GALAXY_TEST_RAISE_EXCEPTION_ON_HISTORYLESS_HDA: '1' GALAXY_TEST_SELENIUM_RETRIES: 1 YARN_INSTALL_OPTS: --frozen-lockfile + GALAXY_CONFIG_SQLALCHEMY_WARN_20: '1' concurrency: group: integration-selenium-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/selenium.yaml b/.github/workflows/selenium.yaml index d39b95d0c197..844f4cc04958 100644 --- a/.github/workflows/selenium.yaml +++ b/.github/workflows/selenium.yaml @@ -13,6 +13,7 @@ env: GALAXY_TEST_SELENIUM_RETRIES: 1 GALAXY_TEST_SKIP_FLAKEY_TESTS_ON_ERROR: 1 YARN_INSTALL_OPTS: --frozen-lockfile + GALAXY_CONFIG_SQLALCHEMY_WARN_20: '1' concurrency: group: selenium-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/selenium_beta.yaml b/.github/workflows/selenium_beta.yaml index 4177f059dc56..5eeb2a8dab3d 100644 --- a/.github/workflows/selenium_beta.yaml +++ b/.github/workflows/selenium_beta.yaml @@ -14,6 +14,7 @@ env: GALAXY_TEST_SELENIUM_BETA_HISTORY: 1 GALAXY_TEST_SKIP_FLAKEY_TESTS_ON_ERROR: 1 YARN_INSTALL_OPTS: --frozen-lockfile + GALAXY_CONFIG_SQLALCHEMY_WARN_20: '1' concurrency: group: selenium-beta-${{ github.ref }} cancel-in-progress: true