From e8e781a8065046663f6ff5fb5d488ca76814f15c Mon Sep 17 00:00:00 2001 From: jvanbraekel <29703119+jvanbraekel@users.noreply.github.com> Date: Fri, 10 Nov 2023 18:16:17 +0100 Subject: [PATCH 01/16] Remove config_type from Service and ConfigFile 1) Line 156 : self.config_type = self.Config.config_type is throwing: "type object 'BaseConfig' has no attribute 'config_type'" , but is ignored by gravity. Thus config file type is not assigned for services but its silent. 2) If any exception occurs in the Service class constructor those are hidden by a not subscriptable exception. Fix 1) by removing config_type form ConfigFile and Service classes, 2) by re-throwing exception in the class constructor. --- gravity/state.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gravity/state.py b/gravity/state.py index 3879372..9a27ae8 100644 --- a/gravity/state.py +++ b/gravity/state.py @@ -40,7 +40,6 @@ class GracefulMethod(str, enum.Enum): class ConfigFile(BaseModel): - config_type: str app_config: Dict[str, Any] gravity_config_file: str galaxy_config_file: str @@ -116,8 +115,6 @@ class Service(BaseModel): settings: Dict[str, Any] - config_type: str = None - _default_environment: Dict[str, str] = {} _settings_from: Optional[str] = None @@ -151,9 +148,11 @@ def services_if_enabled(cls, config, gravity_settings=None, settings=None, servi return services def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.config_type = self.config.config_type - + try: + super().__init__(*args, **kwargs) + except Exception as ex: + gravity.io.exception("{0} init failurre: {1}".format(type(self),ex)) + @property def service_type(self): return self._service_type @@ -191,7 +190,7 @@ def command_template(self): return self._command_template def __eq__(self, other): - return self.config_type == other.config_type and self.service_type == other.service_type and self.service_name == other.service_name + return self.service_type == other.service_type and self.service_name == other.service_name def get_command_arguments(self, format_vars): """Convert settings into their command line arguments.""" From 791f8c77a0288a392e4f6af4f5066178c08481a3 Mon Sep 17 00:00:00 2001 From: jvanbraekel <29703119+jvanbraekel@users.noreply.github.com> Date: Fri, 10 Nov 2023 18:30:06 +0100 Subject: [PATCH 02/16] Fix the object not subscriptable exception Dedicated function for absolute path update, check for undefined values and use the property access. --- gravity/state.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gravity/state.py b/gravity/state.py index 9a27ae8..8a0fc30 100644 --- a/gravity/state.py +++ b/gravity/state.py @@ -448,18 +448,21 @@ class GalaxyReportsService(Service): " --config python:galaxy.web_stack.gunicorn_config" \ " {command_arguments[url_prefix]}" \ " {settings[extra_args]}" + + def _ensure_config_absolute_path(cls,v,values): + if "config_file" not in v: + gravity.io.exception("No reports config files specified.") + if not os.path.isabs(v["config_file"]): + v["config_file"] = os.path.join(os.path.dirname(values["config"].galaxy_config_file),v["config_file"]) + return None @validator("settings") def _validate_settings(cls, v, values): - reports_config_file = v["config_file"] - if not os.path.isabs(reports_config_file): - reports_config_file = os.path.join(os.path.dirname(values["config"]["galaxy_config_file"]), reports_config_file) - if not os.path.exists(reports_config_file): - gravity.io.exception(f"Reports enabled but reports config file does not exist: {reports_config_file}") - v["config_file"] = reports_config_file + GalaxyReportsService._ensure_config_absolute_path(cls,v,values) + if not os.path.exists(v["config_file"]): + gravity.io.exception("Reports enabled but reports config file does not exist: {0}".format(v["config_file"])) return v - class GalaxyStandaloneService(Service): _service_type = "standalone" service_name = "standalone" From 7c3a5cd9d9da1a06077af279e99a2fb949e1f684 Mon Sep 17 00:00:00 2001 From: jvanbraekel <29703119+jvanbraekel@users.noreply.github.com> Date: Mon, 13 Nov 2023 11:20:29 +0100 Subject: [PATCH 03/16] Remove reference to config_type from process manager --- gravity/process_manager/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gravity/process_manager/__init__.py b/gravity/process_manager/__init__.py index a26387c..b07a3aa 100644 --- a/gravity/process_manager/__init__.py +++ b/gravity/process_manager/__init__.py @@ -77,7 +77,7 @@ def _service_default_path(self): return os.environ["PATH"] def _service_program_name(self, instance_name, service): - return f"{instance_name}_{service.config_type}_{service.service_type}_{service.service_name}" + return f"{instance_name}_{service.service_type}_{service.service_name}" def _service_format_vars(self, config, service, pm_format_vars=None): pm_format_vars = pm_format_vars or {} @@ -85,7 +85,6 @@ def _service_format_vars(self, config, service, pm_format_vars=None): virtualenv_bin = shlex.quote(f'{os.path.join(virtualenv_dir, "bin")}{os.path.sep}') if virtualenv_dir else "" format_vars = { - "config_type": service.config_type, "server_name": service.service_name, "galaxy_umask": service.settings.get("umask") or config.umask, "galaxy_conf": config.galaxy_config_file, From 61dd221655e481a870ada01ae5dbe4d9c12917c6 Mon Sep 17 00:00:00 2001 From: jvanbraekel <29703119+jvanbraekel@users.noreply.github.com> Date: Mon, 13 Nov 2023 11:25:50 +0100 Subject: [PATCH 04/16] Remove config_type from supervisor process manager --- gravity/process_manager/supervisor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gravity/process_manager/supervisor.py b/gravity/process_manager/supervisor.py index 3787854..ad16936 100644 --- a/gravity/process_manager/supervisor.py +++ b/gravity/process_manager/supervisor.py @@ -105,7 +105,7 @@ def __init__(self, config, service, use_instance_name): @property def config_file_name(self): service = self.service - return f"{service.config_type}_{service.service_type}_{service.service_name}.conf" + return f"{service.service_type}_{service.service_name}.conf" @property def config_program_name(self): @@ -113,7 +113,7 @@ def config_program_name(self): service = self.service if self._use_instance_name: instance_name = self.config.instance_name - return f"{instance_name}_{service.config_type}_{service.service_type}_{service.service_name}" + return f"{instance_name}_{service.service_type}_{service.service_name}" else: return service.service_name @@ -284,7 +284,7 @@ def __process_config(self, config, force): programs = [] for service in config.services: self.__update_service(config, service, instance_conf_dir, instance_name, force) - programs.append(f"{instance_name}_{service.config_type}_{service.service_type}_{service.service_name}") + programs.append(f"{instance_name}_{service.service_type}_{service.service_name}") group_conf = os.path.join(self.supervisord_conf_dir, f"group_{instance_name}.conf") if self._use_instance_name: From 706ee493177c646a4ed1ef2c26e03672ba0f4c9b Mon Sep 17 00:00:00 2001 From: jvanbraekel <29703119+jvanbraekel@users.noreply.github.com> Date: Mon, 13 Nov 2023 11:29:53 +0100 Subject: [PATCH 05/16] Update state.py Fix typo. --- gravity/state.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity/state.py b/gravity/state.py index 8a0fc30..0f844b1 100644 --- a/gravity/state.py +++ b/gravity/state.py @@ -151,7 +151,7 @@ def __init__(self, *args, **kwargs): try: super().__init__(*args, **kwargs) except Exception as ex: - gravity.io.exception("{0} init failurre: {1}".format(type(self),ex)) + gravity.io.exception("{0} init failed: {1}".format(type(self),ex)) @property def service_type(self): From b0e98a975ffc04211fc6703a3b340e7087d25a5c Mon Sep 17 00:00:00 2001 From: jvanbraekel <29703119+jvanbraekel@users.noreply.github.com> Date: Mon, 13 Nov 2023 13:44:12 +0100 Subject: [PATCH 06/16] Remove config_type from config manager --- gravity/config_manager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/gravity/config_manager.py b/gravity/config_manager.py index 394ecb1..d202e82 100644 --- a/gravity/config_manager.py +++ b/gravity/config_manager.py @@ -170,7 +170,6 @@ def __load_config(self, gravity_config_dict, app_config): app_config_dict[app_key] = app_config[app_key] config = ConfigFile( - config_type=self.galaxy_server_config_section, app_config=app_config_dict, gravity_config_file=gravity_config_file, galaxy_config_file=galaxy_config_file, From f0998e6560963f836fd61d692e6595ed85803e17 Mon Sep 17 00:00:00 2001 From: jvanbraekel <29703119+jvanbraekel@users.noreply.github.com> Date: Mon, 13 Nov 2023 13:50:00 +0100 Subject: [PATCH 07/16] Remove config_type from instances configuration listing --- gravity/commands/cmd_list.py | 1 - 1 file changed, 1 deletion(-) diff --git a/gravity/commands/cmd_list.py b/gravity/commands/cmd_list.py index 32d8b51..aa67b59 100644 --- a/gravity/commands/cmd_list.py +++ b/gravity/commands/cmd_list.py @@ -23,7 +23,6 @@ def cli(ctx, version): click.echo(cols_str.format(*head)) for config in configs: row = [ - config.config_type, config.instance_name, config.gravity_config_file, ] From 0872138ca33ed97a8f8bf37ea51660ac106bf0b8 Mon Sep 17 00:00:00 2001 From: jvanbraekel <29703119+jvanbraekel@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:31:38 +0100 Subject: [PATCH 08/16] Remove config_type from systemd --- gravity/process_manager/systemd.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gravity/process_manager/systemd.py b/gravity/process_manager/systemd.py index d3c6a7c..322160b 100644 --- a/gravity/process_manager/systemd.py +++ b/gravity/process_manager/systemd.py @@ -82,8 +82,8 @@ def __init__(self, config, service, use_instance_name): else: description_process = "" - self.unit_prefix = f"{service.config_type}{prefix_instance_name}-{service.service_name}" - self.description = f"{config.config_type.capitalize()}{description_instance_name} {service.service_name}{description_process}" + self.unit_prefix = f"{prefix_instance_name}-{service.service_name}" + self.description = f"{description_instance_name}{service.service_name}{description_process}" @property def unit_file_name(self): @@ -161,7 +161,7 @@ def terminate(self): def __target_unit_name(self, config): instance_name = f"-{config.instance_name}" if self._use_instance_name else "" - return f"{config.config_type}{instance_name}.target" + return f"{instance_name}.target" def __unit_files_to_active_unit_names(self, unit_files): unit_names = [] @@ -205,7 +205,7 @@ def __read_gravity_config_hash_from_target(self, target_path): def _present_pm_files_for_config(self, config): unit_files = set() instance_name = f"-{config.instance_name}" if self._use_instance_name else "" - target = os.path.join(self.__systemd_unit_dir, f"{config.config_type}{instance_name}.target") + target = os.path.join(self.__systemd_unit_dir, f"{instance_name}.target") if os.path.exists(target): target_hash = self.__read_gravity_config_hash_from_target(target) if target_hash == config.path_hash: @@ -283,11 +283,11 @@ def __process_config(self, config, force): target_conf = os.path.join(self.__systemd_unit_dir, target_unit_name) format_vars = { "gravity_config_hash": config.path_hash, - "systemd_description": config.config_type.capitalize(), + "systemd_description": "Galaxy processes", "systemd_target_wants": " ".join(service_units), } if self._use_instance_name: - format_vars["systemd_description"] += f" {config.instance_name}" + format_vars["systemd_description"] = f"{config.instance_name}" contents = SYSTEMD_TARGET_TEMPLATE.format(**format_vars) if self._update_file(target_conf, contents, target_unit_name, "systemd unit", force): self.__systemctl("enable", target_conf) @@ -378,7 +378,7 @@ def shutdown(self): """ """ if self._use_instance_name: configs = self.config_manager.get_configs(process_manager=self.name) - self.__systemctl("stop", *[f"{c.config_type}-{c.instance_name}.target" for c in configs]) + self.__systemctl("stop", *[f"{c.instance_name}.target" for c in configs]) else: self.__systemctl("stop", "galaxy.target") From e2845ccfac1022eb037215d691ffa359fb82f70d Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 2 Feb 2024 15:06:10 -0500 Subject: [PATCH 09/16] Fix indentation --- gravity/state.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity/state.py b/gravity/state.py index 0f844b1..8d11551 100644 --- a/gravity/state.py +++ b/gravity/state.py @@ -150,7 +150,7 @@ def services_if_enabled(cls, config, gravity_settings=None, settings=None, servi def __init__(self, *args, **kwargs): try: super().__init__(*args, **kwargs) - except Exception as ex: + except Exception as ex: gravity.io.exception("{0} init failed: {1}".format(type(self),ex)) @property From 787bb2a691939b430d66c8793dde188548b7ca4d Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 2 Feb 2024 15:22:10 -0500 Subject: [PATCH 10/16] Restore correct behavior without config_type in systemd pm --- gravity/process_manager/systemd.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gravity/process_manager/systemd.py b/gravity/process_manager/systemd.py index 322160b..efea36d 100644 --- a/gravity/process_manager/systemd.py +++ b/gravity/process_manager/systemd.py @@ -82,8 +82,8 @@ def __init__(self, config, service, use_instance_name): else: description_process = "" - self.unit_prefix = f"{prefix_instance_name}-{service.service_name}" - self.description = f"{description_instance_name}{service.service_name}{description_process}" + self.unit_prefix = f"galaxy{prefix_instance_name}-{service.service_name}" + self.description = f"Galaxy{description_instance_name}{service.service_name}{description_process}" @property def unit_file_name(self): @@ -161,7 +161,7 @@ def terminate(self): def __target_unit_name(self, config): instance_name = f"-{config.instance_name}" if self._use_instance_name else "" - return f"{instance_name}.target" + return f"galaxy{instance_name}.target" def __unit_files_to_active_unit_names(self, unit_files): unit_names = [] @@ -205,7 +205,7 @@ def __read_gravity_config_hash_from_target(self, target_path): def _present_pm_files_for_config(self, config): unit_files = set() instance_name = f"-{config.instance_name}" if self._use_instance_name else "" - target = os.path.join(self.__systemd_unit_dir, f"{instance_name}.target") + target = os.path.join(self.__systemd_unit_dir, f"galaxy{instance_name}.target") if os.path.exists(target): target_hash = self.__read_gravity_config_hash_from_target(target) if target_hash == config.path_hash: @@ -283,11 +283,11 @@ def __process_config(self, config, force): target_conf = os.path.join(self.__systemd_unit_dir, target_unit_name) format_vars = { "gravity_config_hash": config.path_hash, - "systemd_description": "Galaxy processes", + "systemd_description": "Galaxy", "systemd_target_wants": " ".join(service_units), } if self._use_instance_name: - format_vars["systemd_description"] = f"{config.instance_name}" + format_vars["systemd_description"] += f" {config.instance_name}" contents = SYSTEMD_TARGET_TEMPLATE.format(**format_vars) if self._update_file(target_conf, contents, target_unit_name, "systemd unit", force): self.__systemctl("enable", target_conf) @@ -378,7 +378,7 @@ def shutdown(self): """ """ if self._use_instance_name: configs = self.config_manager.get_configs(process_manager=self.name) - self.__systemctl("stop", *[f"{c.instance_name}.target" for c in configs]) + self.__systemctl("stop", *[f"galaxy-{c.instance_name}.target" for c in configs]) else: self.__systemctl("stop", "galaxy.target") From 00741dfd3546e7440eaf1a23aea00a2b3f2075cc Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 2 Feb 2024 15:31:48 -0500 Subject: [PATCH 11/16] Lint and match style --- gravity/state.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/gravity/state.py b/gravity/state.py index 8d11551..80765d3 100644 --- a/gravity/state.py +++ b/gravity/state.py @@ -150,9 +150,9 @@ def services_if_enabled(cls, config, gravity_settings=None, settings=None, servi def __init__(self, *args, **kwargs): try: super().__init__(*args, **kwargs) - except Exception as ex: - gravity.io.exception("{0} init failed: {1}".format(type(self),ex)) - + except Exception as exc: + gravity.io.exception(f"{type(self)} init failed: {exc}") + @property def service_type(self): return self._service_type @@ -448,21 +448,22 @@ class GalaxyReportsService(Service): " --config python:galaxy.web_stack.gunicorn_config" \ " {command_arguments[url_prefix]}" \ " {settings[extra_args]}" - - def _ensure_config_absolute_path(cls,v,values): + + def _ensure_config_absolute_path(cls, v, values): if "config_file" not in v: gravity.io.exception("No reports config files specified.") if not os.path.isabs(v["config_file"]): - v["config_file"] = os.path.join(os.path.dirname(values["config"].galaxy_config_file),v["config_file"]) + v["config_file"] = os.path.join(os.path.dirname(values["config"].galaxy_config_file), v["config_file"]) return None @validator("settings") def _validate_settings(cls, v, values): - GalaxyReportsService._ensure_config_absolute_path(cls,v,values) + GalaxyReportsService._ensure_config_absolute_path(cls, v, values) if not os.path.exists(v["config_file"]): - gravity.io.exception("Reports enabled but reports config file does not exist: {0}".format(v["config_file"])) + gravity.io.exception(f"Reports enabled but reports config file does not exist: {v['config_file']}") return v + class GalaxyStandaloneService(Service): _service_type = "standalone" service_name = "standalone" From d7804758d200695a094dce02092d2133c7858bab Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 2 Feb 2024 15:43:35 -0500 Subject: [PATCH 12/16] Update tests for removal of config_type --- tests/test_config_manager.py | 1 - tests/test_operations.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_config_manager.py b/tests/test_config_manager.py index 2c3cab9..3598a7b 100644 --- a/tests/test_config_manager.py +++ b/tests/test_config_manager.py @@ -12,7 +12,6 @@ def test_load_defaults(galaxy_yml, galaxy_root_dir, state_dir, default_config_ma default_config_manager.load_config_file(str(galaxy_yml)) config = default_config_manager.get_config() default_settings = Settings() - assert config.config_type == 'galaxy' assert config.process_manager == 'supervisor' assert config.instance_name == default_settings.instance_name assert config.services != [] diff --git a/tests/test_operations.py b/tests/test_operations.py index 6fe44b9..3f1c6ec 100644 --- a/tests/test_operations.py +++ b/tests/test_operations.py @@ -217,7 +217,8 @@ def test_cmd_show(state_dir, galaxy_yml): result = runner.invoke(galaxyctl, ['--config-file', str(galaxy_yml), 'show']) assert result.exit_code == 0, result.output details = safe_load(result.output) - assert details['config_type'] == 'galaxy' + assert details['galaxy_config_file'] == str(galaxy_yml) + assert details['instance_name'] == '_default_' def test_cmd_list(state_dir, galaxy_yml): From c8011de3180db7572c23c73e936ac6fefe284c22 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 2 Feb 2024 17:18:34 -0500 Subject: [PATCH 13/16] Fix list command for config_type drop --- gravity/commands/cmd_list.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gravity/commands/cmd_list.py b/gravity/commands/cmd_list.py index aa67b59..8c837ef 100644 --- a/gravity/commands/cmd_list.py +++ b/gravity/commands/cmd_list.py @@ -11,11 +11,11 @@ def cli(ctx, version): aliases: configs """ - cols = ["{:<8}", "{:<18}", "{}"] - head = ["TYPE", "INSTANCE NAME", "CONFIG PATH"] + cols = ["{:<18}", "{}"] + head = ["INSTANCE NAME", "CONFIG PATH"] if version: - cols.insert(2, "{:<12}") - head.insert(2, "VERSION") + cols.insert(1, "{:<12}") + head.insert(1, "VERSION") cols_str = " ".join(cols) with config_manager.config_manager(**ctx.parent.cm_kwargs) as cm: configs = cm.get_configs() @@ -27,7 +27,7 @@ def cli(ctx, version): config.gravity_config_file, ] if version: - row.insert(2, config.galaxy_version) + row.insert(1, config.galaxy_version) click.echo(cols_str.format(*row)) else: click.echo("No configured instances") From c27391571847b1ccb4429903f04a5ae396b932f1 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 2 Feb 2024 17:25:39 -0500 Subject: [PATCH 14/16] More test fixes for dropping config_type --- tests/test_operations.py | 2 +- tests/test_process_manager.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_operations.py b/tests/test_operations.py index 3f1c6ec..9b7e312 100644 --- a/tests/test_operations.py +++ b/tests/test_operations.py @@ -225,5 +225,5 @@ def test_cmd_list(state_dir, galaxy_yml): runner = CliRunner() result = runner.invoke(galaxyctl, ['--config-file', str(galaxy_yml), 'list']) assert result.exit_code == 0, result.output - assert result.output.startswith("TYPE") + assert result.output.startswith("INSTANCE NAME") assert str(galaxy_yml) in result.output diff --git a/tests/test_process_manager.py b/tests/test_process_manager.py index 95e026e..de7acc0 100644 --- a/tests/test_process_manager.py +++ b/tests/test_process_manager.py @@ -108,7 +108,7 @@ def service_conf_dir(state_dir, process_manager_name): def service_conf_file(instance_name, process_manager_name, service_name, service_type=None): service_type = service_type or service_name if process_manager_name == 'supervisor': - return f'galaxy_{service_type}_{service_name}.conf' + return f'{service_type}_{service_name}.conf' elif process_manager_name == 'systemd': return f'galaxy-{instance_name}-{service_name}.service' raise Exception(f"Invalid process manager name: {process_manager_name}") From 474f91966de833ed96e78b98f6c4b92bf0b49db3 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 2 Feb 2024 17:40:10 -0500 Subject: [PATCH 15/16] Correct supervisor service log path in tests --- tests/test_operations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_operations.py b/tests/test_operations.py index 9b7e312..0a65c46 100644 --- a/tests/test_operations.py +++ b/tests/test_operations.py @@ -27,7 +27,7 @@ def log_for_service(state_dir, process_manager_name, start_time, service_name, i else: # could probably just glob here if instance_name is not None: - log_name = f"{instance_name}_galaxy_{service_name}_{service_name}.log" + log_name = f"{instance_name}_{service_name}_{service_name}.log" else: log_name = f"{service_name}.log" path = state_dir / "log" / log_name From 9f73ede4ebd8e2f21fd5010432aa1525887d6a26 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Tue, 6 Feb 2024 13:40:52 -0500 Subject: [PATCH 16/16] Remove trailing slash from prefix for galaxyproject/galaxy#17428 --- tests/test_operations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_operations.py b/tests/test_operations.py index 0a65c46..3b6b48a 100644 --- a/tests/test_operations.py +++ b/tests/test_operations.py @@ -203,7 +203,7 @@ def test_cmd_restart_with_update(state_dir, galaxy_yml, startup_config, free_por assert result.exit_code == 0, result.output start_instance(state_dir, galaxy_yml, free_port) # change prefix - prefix = '/galaxypf/' + prefix = '/galaxypf' startup_config['galaxy']['galaxy_url_prefix'] = prefix galaxy_yml.write(json.dumps(startup_config)) result = runner.invoke(galaxyctl, ['--config-file', str(galaxy_yml), 'restart'])