From c28f3a073a1214ed620c189a20a5f163e3cc41eb Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Wed, 23 Oct 2024 14:57:54 -0400 Subject: [PATCH] Delay conda init until a dependency install is attempted --- lib/galaxy/tool_util/deps/resolvers/conda.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/galaxy/tool_util/deps/resolvers/conda.py b/lib/galaxy/tool_util/deps/resolvers/conda.py index 450e0c1b6fdd..0a2c6893e4f5 100644 --- a/lib/galaxy/tool_util/deps/resolvers/conda.py +++ b/lib/galaxy/tool_util/deps/resolvers/conda.py @@ -149,11 +149,7 @@ def get_option(name): auto_install = _string_as_bool(get_option("auto_install")) self.auto_init = _string_as_bool(get_option("auto_init")) self.conda_context = conda_context - self.disabled = not galaxy.tool_util.deps.installable.ensure_installed( - conda_context, install_conda, self.auto_init - ) - if self.auto_init and not self.disabled: - self.conda_context.ensure_conda_build_installed_if_needed() + self.disabled = False self.auto_install = auto_install self.copy_dependencies = copy_dependencies @@ -189,6 +185,12 @@ def install_all(self, conda_targets: List[CondaTarget], env: str) -> bool: if self.read_only: return False + self.disabled = not galaxy.tool_util.deps.installable.ensure_installed( + self.conda_context, install_conda, self.auto_init + ) + if self.auto_init and not self.disabled: + self.conda_context.ensure_conda_build_installed_if_needed() + return_code = install_conda_targets(conda_targets, conda_context=self.conda_context, env_name=env) if return_code != 0: is_installed = False @@ -221,9 +223,6 @@ def resolve_all(self, requirements: ToolRequirements, **kwds) -> List[Dependency if len(requirements) == 0: return [] - if not os.path.isdir(self.conda_context.conda_prefix): - return [] - for requirement in requirements: if requirement.type != "package": return [] @@ -252,6 +251,9 @@ def resolve_all(self, requirements: ToolRequirements, **kwds) -> List[Dependency if install: is_installed = self.install_all(conda_targets, env) + if not os.path.isdir(self.conda_context.conda_prefix): + return [] + dependencies: List[Dependency] = [] if is_installed: for requirement in requirements: