From 5a52a04fc1337cba4a1780d1c0e08c6305bc9b91 Mon Sep 17 00:00:00 2001 From: Sveinung Gundersen Date: Thu, 8 Dec 2022 10:24:06 +0100 Subject: [PATCH 1/6] Added configuration of gx-it-proxy to support path-based proxying --- gravity/state.py | 9 ++++++++- tests/conftest.py | 2 ++ tests/test_process_manager.py | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gravity/state.py b/gravity/state.py index 1d8e5e2..1d1d1eb 100644 --- a/gravity/state.py +++ b/gravity/state.py @@ -393,12 +393,19 @@ class GalaxyGxItProxyService(Service): _command_template = "{virtualenv_bin}npx gx-it-proxy --ip {settings[ip]} --port {settings[port]}" \ " --sessions {settings[sessions]} {command_arguments[verbose]}" \ " {command_arguments[forward_ip]} {command_arguments[forward_port]}" \ - " {command_arguments[reverse_proxy]}" + " {command_arguments[reverse_proxy]} {command_arguments[proxy_path_prefix]}" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # override from Galaxy config if set self.settings["sessions"] = self.config.app_config.get("interactivetools_map", self.settings["sessions"]) + # this can only be set in Galaxy config + it_base_path = self.config.app_config.get("interactivetools_base_path") + if it_base_path is not None: + it_prefix = app_config.get("interactivetools_prefix", "interactivetool") + self.settings["proxy_path_prefix"] = f"/{it_base_path.strip('/')}/{it_prefix}/access/interactivetoolentrypoint" + else: + self.settings["proxy_path_prefix"] = None @validator("settings") def _validate_settings(cls, v, values): diff --git a/tests/conftest.py b/tests/conftest.py index 42a26fc..19ed58c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -31,6 +31,8 @@ galaxy_infrastructure_url: http://localhost:{gx_port} interactivetools_upstream_proxy: false interactivetools_proxy_host: localhost:{gxit_port} + interactivetools_base_path: / + interactivetools_prefix: interactivetool """ diff --git a/tests/test_process_manager.py b/tests/test_process_manager.py index 61b12dd..cff1a9b 100644 --- a/tests/test_process_manager.py +++ b/tests/test_process_manager.py @@ -326,8 +326,11 @@ def test_gxit_handler(default_config_manager, galaxy_yml, gxit_config, process_m gxit_config_path = service_conf_path(state_dir, process_manager_name, 'gx-it-proxy') assert gxit_config_path.exists() gxit_port = gxit_config["gravity"]["gx_it_proxy"]["port"] + gxit_base_path = gxit_config["galaxy"]["interactivetools_base_path"] + gxit_prefix = gxit_config["galaxy"]["interactivetools_prefix"] sessions = "database/interactivetools_map.sqlite" - assert f'npx gx-it-proxy --ip localhost --port {gxit_port} --sessions {sessions}' in gxit_config_path.read_text() + proxy_path_prefix = f'{gxit_base_path}{gxit_prefix}/access/interactivetoolentrypoint' + assert f'npx gx-it-proxy --ip localhost --port {gxit_port} --sessions {sessions} --proxyPathPrefix {proxy_path_prefix}' in gxit_config_path.read_text() @pytest.mark.parametrize('process_manager_name', ['supervisor', 'systemd']) From aba9e634b6928ca41deb8ce2b3a7b9426120c469 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Mon, 13 Feb 2023 17:42:39 -0500 Subject: [PATCH 2/6] gx-it-proxy path prefix changes for Gravity 1.0 (and my mistakes in merging) --- gravity/config_manager.py | 9 ++++++++- gravity/state.py | 6 ++++-- tests/conftest.py | 2 -- tests/test_process_manager.py | 20 +++++++++++++++++--- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/gravity/config_manager.py b/gravity/config_manager.py index 6db21d7..8ab5c03 100644 --- a/gravity/config_manager.py +++ b/gravity/config_manager.py @@ -26,6 +26,13 @@ if "XDG_CONFIG_HOME" in os.environ: DEFAULT_STATE_DIR = os.path.join(os.environ["XDG_CONFIG_HOME"], "galaxy-gravity") +OPTIONAL_APP_KEYS = ( + "interactivetools_map", + "interactivetools_base_path", + "interactivetools_prefix", + "galaxy_url_prefix", +) + @contextlib.contextmanager def config_manager(config_file=None, state_dir=None): @@ -158,7 +165,7 @@ def __load_config(self, gravity_config_dict, app_config): } # some things should only be included if set - for app_key in ("interactivetools_map", "galaxy_url_prefix"): + for app_key in OPTIONAL_APP_KEYS: if app_key in app_config: app_config_dict[app_key] = app_config[app_key] diff --git a/gravity/state.py b/gravity/state.py index 1d1d1eb..a991abd 100644 --- a/gravity/state.py +++ b/gravity/state.py @@ -389,6 +389,7 @@ class GalaxyGxItProxyService(Service): "forward_ip": "--forwardIP {settings[forward_ip]}", "forward_port": "--forwardPort {settings[forward_port]}", "reverse_proxy": "--reverseProxy", + "proxy_path_prefix": "--proxyPathPrefix {settings[proxy_path_prefix]}", } _command_template = "{virtualenv_bin}npx gx-it-proxy --ip {settings[ip]} --port {settings[port]}" \ " --sessions {settings[sessions]} {command_arguments[verbose]}" \ @@ -402,8 +403,9 @@ def __init__(self, *args, **kwargs): # this can only be set in Galaxy config it_base_path = self.config.app_config.get("interactivetools_base_path") if it_base_path is not None: - it_prefix = app_config.get("interactivetools_prefix", "interactivetool") - self.settings["proxy_path_prefix"] = f"/{it_base_path.strip('/')}/{it_prefix}/access/interactivetoolentrypoint" + it_base_path = "/" + f"/{it_base_path.strip('/')}/".lstrip("/") + it_prefix = self.config.app_config.get("interactivetools_prefix", "interactivetool") + self.settings["proxy_path_prefix"] = f"{it_base_path}{it_prefix}/access/interactivetoolentrypoint" else: self.settings["proxy_path_prefix"] = None diff --git a/tests/conftest.py b/tests/conftest.py index 19ed58c..42a26fc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -31,8 +31,6 @@ galaxy_infrastructure_url: http://localhost:{gx_port} interactivetools_upstream_proxy: false interactivetools_proxy_host: localhost:{gxit_port} - interactivetools_base_path: / - interactivetools_prefix: interactivetool """ diff --git a/tests/test_process_manager.py b/tests/test_process_manager.py index cff1a9b..71daa19 100644 --- a/tests/test_process_manager.py +++ b/tests/test_process_manager.py @@ -326,11 +326,25 @@ def test_gxit_handler(default_config_manager, galaxy_yml, gxit_config, process_m gxit_config_path = service_conf_path(state_dir, process_manager_name, 'gx-it-proxy') assert gxit_config_path.exists() gxit_port = gxit_config["gravity"]["gx_it_proxy"]["port"] - gxit_base_path = gxit_config["galaxy"]["interactivetools_base_path"] - gxit_prefix = gxit_config["galaxy"]["interactivetools_prefix"] sessions = "database/interactivetools_map.sqlite" + gxit_config_contents = gxit_config_path.read_text() + assert f'npx gx-it-proxy --ip localhost --port {gxit_port} --sessions {sessions}' in gxit_config_contents + assert '--proxyPathPrefix' not in gxit_config_contents + + +@pytest.mark.parametrize('process_manager_name', ['supervisor', 'systemd']) +def test_gxit_handler_path_prefix(default_config_manager, galaxy_yml, gxit_config, process_manager_name): + state_dir = default_config_manager.state_dir + gxit_base_path = gxit_config["galaxy"]["interactivetools_base_path"] = "/foo/" + gxit_prefix = gxit_config["galaxy"]["interactivetools_prefix"] = "bar" + galaxy_yml.write(json.dumps(gxit_config)) + default_config_manager.load_config_file(str(galaxy_yml)) + with process_manager.process_manager(config_manager=default_config_manager) as pm: + pm.update() + gxit_config_path = service_conf_path(state_dir, process_manager_name, 'gx-it-proxy') + assert gxit_config_path.exists() proxy_path_prefix = f'{gxit_base_path}{gxit_prefix}/access/interactivetoolentrypoint' - assert f'npx gx-it-proxy --ip localhost --port {gxit_port} --sessions {sessions} --proxyPathPrefix {proxy_path_prefix}' in gxit_config_path.read_text() + assert f'--proxyPathPrefix {proxy_path_prefix}' in gxit_config_path.read_text() @pytest.mark.parametrize('process_manager_name', ['supervisor', 'systemd']) From ea932b2e041526e874da2d0c53c1f32a9c900de6 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 10 Mar 2023 10:25:34 -0500 Subject: [PATCH 3/6] Always set gxit proxy path prefix --- gravity/state.py | 11 ++++------- tests/test_process_manager.py | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/gravity/state.py b/gravity/state.py index a991abd..b6c8aa1 100644 --- a/gravity/state.py +++ b/gravity/state.py @@ -401,13 +401,10 @@ def __init__(self, *args, **kwargs): # override from Galaxy config if set self.settings["sessions"] = self.config.app_config.get("interactivetools_map", self.settings["sessions"]) # this can only be set in Galaxy config - it_base_path = self.config.app_config.get("interactivetools_base_path") - if it_base_path is not None: - it_base_path = "/" + f"/{it_base_path.strip('/')}/".lstrip("/") - it_prefix = self.config.app_config.get("interactivetools_prefix", "interactivetool") - self.settings["proxy_path_prefix"] = f"{it_base_path}{it_prefix}/access/interactivetoolentrypoint" - else: - self.settings["proxy_path_prefix"] = None + it_base_path = self.config.app_config.get("interactivetools_base_path", "/") + it_base_path = "/" + f"/{it_base_path.strip('/')}/".lstrip("/") + it_prefix = self.config.app_config.get("interactivetools_prefix", "interactivetool") + self.settings["proxy_path_prefix"] = f"{it_base_path}{it_prefix}/access/interactivetoolentrypoint" @validator("settings") def _validate_settings(cls, v, values): diff --git a/tests/test_process_manager.py b/tests/test_process_manager.py index 71daa19..6de6fed 100644 --- a/tests/test_process_manager.py +++ b/tests/test_process_manager.py @@ -329,7 +329,7 @@ def test_gxit_handler(default_config_manager, galaxy_yml, gxit_config, process_m sessions = "database/interactivetools_map.sqlite" gxit_config_contents = gxit_config_path.read_text() assert f'npx gx-it-proxy --ip localhost --port {gxit_port} --sessions {sessions}' in gxit_config_contents - assert '--proxyPathPrefix' not in gxit_config_contents + assert '--proxyPathPrefix /' in gxit_config_contents @pytest.mark.parametrize('process_manager_name', ['supervisor', 'systemd']) From 7531ae075e9693eb02ec93463b3beec6b401ec8c Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 10 Mar 2023 11:07:49 -0500 Subject: [PATCH 4/6] Correct default GxIT path test --- tests/test_process_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_process_manager.py b/tests/test_process_manager.py index 6de6fed..e615f11 100644 --- a/tests/test_process_manager.py +++ b/tests/test_process_manager.py @@ -329,7 +329,7 @@ def test_gxit_handler(default_config_manager, galaxy_yml, gxit_config, process_m sessions = "database/interactivetools_map.sqlite" gxit_config_contents = gxit_config_path.read_text() assert f'npx gx-it-proxy --ip localhost --port {gxit_port} --sessions {sessions}' in gxit_config_contents - assert '--proxyPathPrefix /' in gxit_config_contents + assert '--proxyPathPrefix /interactivetool/access/interactivetoolentrypoint' in gxit_config_contents @pytest.mark.parametrize('process_manager_name', ['supervisor', 'systemd']) From 30a28d59129c0b2b99f9cfd929c578b7cee314a8 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 10 Mar 2023 14:22:47 -0500 Subject: [PATCH 5/6] Attempt to set a test timeout for tests that aren't finishing for unknown reasons --- pyproject.toml | 1 + tox.ini | 1 + 2 files changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 911626a..61595e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,3 +3,4 @@ line-length = 160 [tool.pytest.ini_options] norecursedirs = "tests/galaxy.git/* tests/galaxy_venv" +timeout = 300 diff --git a/tox.ini b/tox.ini index 1e88aff..8ac6e5a 100644 --- a/tox.ini +++ b/tox.ini @@ -14,6 +14,7 @@ commands = deps = lint: flake8 test: pytest + test: pytest-timeout test: coverage test: requests passenv = From 6e2342151fdc32175105f190c33a1944b34f153b Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Mon, 13 Mar 2023 13:04:51 -0400 Subject: [PATCH 6/6] Exclude py3.10/release_22.01 from the matrix --- .github/workflows/test.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4d369c0..b6b975f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -12,6 +12,10 @@ jobs: matrix: python-version: ['3.7', '3.10'] galaxy-branch: ['release_22.01', 'dev'] + exclude: + # this results in lengthy and expensive numpy wheel builds + - python-version: '3.10' + galaxy-branch: 'release_22.01' steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v2