Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions nf_core/components/components_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import nf_core.utils
from nf_core.modules.modules_repo import ModulesRepo
from nf_core.pipelines.containers_utils import ContainerConfigs

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -279,3 +280,10 @@ def _iterate_input_output(type) -> DictWithStrAndTuple:
# If the tool name was not found in the response
log.warning(f"Could not find an EDAM ontology term for '{tool_name}'")
return None


def try_generate_container_configs(directory: str | Path, path: str):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def try_generate_container_configs(directory: str | Path, path: str):
def try_generate_container_configs(directory: Path, path: Path):

let's make this simpler

try:
ContainerConfigs(directory, path).generate_container_configs()
except UserWarning as e:
log.warning(f"Could not regenerate container configuration files: {e}")
7 changes: 2 additions & 5 deletions nf_core/components/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
from nf_core.components.components_utils import (
get_components_to_install,
prompt_component_version_sha,
try_generate_container_configs,
)
from nf_core.components.constants import (
NF_CORE_MODULES_NAME,
)
from nf_core.modules.modules_json import ModulesJson
from nf_core.modules.modules_repo import ModulesRepo
from nf_core.pipelines.containers_utils import ContainerConfigs

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -170,10 +170,7 @@ def install(self, component: str | dict[str, str], silent: bool = False) -> bool

# Regenerate container configuration files for the pipeline when modules are installed
if self.component_type == "modules":
try:
ContainerConfigs(self.directory, self.modules_repo.repo_path).generate_container_configs()
except UserWarning as e:
log.warning(f"Could not regenerate container configuration files: {e}")
try_generate_container_configs(self.directory, self.modules_repo.repo_path)

if not silent:
modules_json.load()
Expand Down
7 changes: 2 additions & 5 deletions nf_core/components/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import nf_core.utils
from nf_core.components.components_command import ComponentCommand
from nf_core.components.components_utils import try_generate_container_configs
from nf_core.modules.modules_json import ModulesJson
from nf_core.pipelines.containers_utils import ContainerConfigs

from .install import ComponentInstall

Expand Down Expand Up @@ -175,10 +175,7 @@ def remove(self, component, repo_url=None, repo_path=None, removed_by=None, remo
removed_components.append(component_name.replace("/", "_"))
# Regenerate container configuration files for the pipeline when modules are removed
if self.component_type == "modules":
try:
ContainerConfigs(self.directory, repo_path).generate_container_configs()
except UserWarning as e:
log.warning(f"Could not regenerate container configuration files: {e}")
try_generate_container_configs(self.directory, repo_path)

# print removed dependencies
if removed_components:
Expand Down
7 changes: 2 additions & 5 deletions nf_core/components/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
from nf_core.components.components_utils import (
get_components_to_install,
prompt_component_version_sha,
try_generate_container_configs,
)
from nf_core.components.install import ComponentInstall
from nf_core.components.remove import ComponentRemove
from nf_core.modules.modules_json import ModulesJson
from nf_core.modules.modules_repo import ModulesRepo
from nf_core.pipelines.containers_utils import ContainerConfigs
from nf_core.utils import plural_es, plural_s, plural_y

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -302,10 +302,7 @@ def update(self, component=None, silent=False, updated=None, check_diff_exist=Tr

# Regenerate container configuration files for the pipeline when modules are updated
if self.component_type == "modules":
try:
ContainerConfigs(self.directory, modules_repo.repo_path).generate_container_configs()
except UserWarning as e:
log.warning(f"Could not regenerate container configuration files: {e}")
try_generate_container_configs(self.directory, modules_repo.repo_path)
recursive_update = True
modules_to_update, subworkflows_to_update = self.get_components_to_update(component)
if not silent and len(modules_to_update + subworkflows_to_update) > 0:
Expand Down
63 changes: 16 additions & 47 deletions nf_core/pipelines/containers_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,53 +106,22 @@ def generate_all_container_configs(self, default_config: str) -> None:
log.warning(f"Could not find meta.yml for {module_name}")
continue

try:
containers["docker_arm64"][module_name] = meta["containers"]["docker"]["linux_arm64"]["name"]
except KeyError:
log.warning(f"Could not find docker linux_arm64 container for {module_name}")
continue
try:
containers["singularity_oras_amd64"][module_name] = meta["containers"]["singularity"]["linux_amd64"][
"name"
]
except KeyError:
log.warning(f"Could not find singularity linux_amd64 oras container for {module_name}")
continue
try:
containers["singularity_oras_arm64"][module_name] = meta["containers"]["singularity"]["linux_arm64"][
"name"
]
except KeyError:
log.warning(f"Could not find singularity linux_arm64 oras container for {module_name}")
continue
try:
containers["singularity_https_amd64"][module_name] = meta["containers"]["singularity"]["linux_amd64"][
"https"
]
except KeyError:
log.warning(f"Could not find singularity linux_amd64 https URL for {module_name}")
continue
try:
containers["singularity_https_arm64"][module_name] = meta["containers"]["singularity"]["linux_arm64"][
"https"
]
except KeyError:
log.warning(f"Could not find singularity linux_arm64 https URL for {module_name}")
continue
try:
containers["conda_amd64_lockfile"][module_name] = meta["containers"]["conda"]["linux_amd64"][
"lock_file"
]
except KeyError:
log.warning(f"Could not find conda linux_amd64 lock file for {module_name}")
continue
try:
containers["conda_arm64_lockfile"][module_name] = meta["containers"]["conda"]["linux_arm64"][
"lock_file"
]
except KeyError:
log.warning(f"Could not find conda linux_arm64 lock file for {module_name}")
continue
platforms: dict[str, list[str]] = {
"docker_arm64": ["docker", "linux_arm64", "name"],
"singularity_oras_amd64": ["singularity", "linux_amd64", "name"],
"singularity_oras_arm64": ["singularity", "linux_arm64", "name"],
"singularity_https_amd64": ["singularity", "linux_amd64", "https"],
"singularity_https_arm64": ["singularity", "linux_arm64", "https"],
"conda_amd64_lockfile": ["conda", "linux_amd64", "lock_file"],
"conda_arm64_lockfile": ["conda", "linux_arm64", "lock_file"],
}

for p_name, p_keys in platforms.items():
try:
containers[p_name][module_name] = meta["containers"][p_keys[0]][p_keys[1]][p_keys[2]]
except KeyError:
log.warning(f"Could not find {p_name} container for {module_name}")
continue

# write config files
for platform in containers.keys():
Expand Down