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 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 1d8e5e2..b6c8aa1 100644 --- a/gravity/state.py +++ b/gravity/state.py @@ -389,16 +389,22 @@ 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]}" \ " {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", "/") + 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/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/tests/test_process_manager.py b/tests/test_process_manager.py index 61b12dd..e615f11 100644 --- a/tests/test_process_manager.py +++ b/tests/test_process_manager.py @@ -327,7 +327,24 @@ def test_gxit_handler(default_config_manager, galaxy_yml, gxit_config, process_m assert gxit_config_path.exists() gxit_port = gxit_config["gravity"]["gx_it_proxy"]["port"] sessions = "database/interactivetools_map.sqlite" - assert f'npx gx-it-proxy --ip localhost --port {gxit_port} --sessions {sessions}' in gxit_config_path.read_text() + 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 /interactivetool/access/interactivetoolentrypoint' 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'--proxyPathPrefix {proxy_path_prefix}' in gxit_config_path.read_text() @pytest.mark.parametrize('process_manager_name', ['supervisor', 'systemd']) 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 =