From dcbc39edd34fec4aff6da04eaa9c8fadfefd98ed Mon Sep 17 00:00:00 2001 From: Alex Ioannidis Date: Wed, 5 Jun 2024 07:40:48 +0200 Subject: [PATCH] config: fix missing "instance_path" usage --- invenio_cli/commands/services.py | 8 +++++--- invenio_cli/helpers/cli_config.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/invenio_cli/commands/services.py b/invenio_cli/commands/services.py index 49ada81..13dd8ee 100644 --- a/invenio_cli/commands/services.py +++ b/invenio_cli/commands/services.py @@ -35,10 +35,12 @@ def ensure_containers_running(self): """Ensures containers are running.""" project_shortname = self.cli_config.get_project_shortname() - instance_path = self.cli_config.get_instance_path() + cmd_env = {} + instance_path = self.cli_config.get_instance_path(throw=False) + if instance_path: + cmd_env = {"INSTANCE_PATH": str(instance_path)} # Set environment variable for the instance path, it might be needed by docker services - with env(INSTANCE_PATH=str(instance_path)): - + with env(**cmd_env): self.docker_helper.start_containers() services = ["redis", self.cli_config.get_db_type(), "search"] diff --git a/invenio_cli/helpers/cli_config.py b/invenio_cli/helpers/cli_config.py index 9ccb45d..7829674 100644 --- a/invenio_cli/helpers/cli_config.py +++ b/invenio_cli/helpers/cli_config.py @@ -64,7 +64,7 @@ def get_project_dir(self): """Returns path to project directory.""" return self.config_path.parent.resolve() - def get_instance_path(self): + def get_instance_path(self, throw=True): """Returns path to application instance directory. If not set yet, raises an InvenioCLIConfigError. @@ -72,7 +72,7 @@ def get_instance_path(self): path = self.private_config[CLIConfig.CLI_SECTION].get("instance_path") if path: return Path(path) - else: + elif throw: raise InvenioCLIConfigError("Accessing unset 'instance_path'") def update_instance_path(self, new_instance_path):