Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
67 changes: 8 additions & 59 deletions nf_core/commands_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import rich

from nf_core.pipelines.containers_utils import try_generate_container_configs
from nf_core.utils import CONTAINER_PLATFORMS, rich_force_colors

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -341,12 +340,7 @@ def modules_containers_create(ctx, module: str, directory: Path, force: bool) ->
"""
Build docker and singularity containers for linux/arm64 and linux/amd64 using wave.
"""
from rich.console import Group
from rich.live import Live
from rich.progress import BarColumn, MofNCompleteColumn, Progress, SpinnerColumn, TextColumn

from nf_core.modules.containers import ModuleContainers
from nf_core.pipelines.lint_utils import console
from nf_core.modules.containers import ModuleContainers, build_containers_with_progress

try:
manager = ModuleContainers(module=module, directory=directory, verbose=ctx.obj["verbose"])
Expand All @@ -364,60 +358,15 @@ def modules_containers_create(ctx, module: str, directory: Path, force: bool) ->
assert manager.nfcore_component is not None
components = [manager.nfcore_component]

failed_modules = []

overall_progress = Progress(
"[bold blue]{task.description}",
BarColumn(),
MofNCompleteColumn(),
console=console,
disable=ctx.obj["hide_progress"],
)
module_progress = Progress(
SpinnerColumn(finished_text="[green]✓[/green]"),
"[bold blue]{task.description}",
TextColumn("{task.fields[status]}"),
console=console,
disable=ctx.obj["hide_progress"],
failed_modules = build_containers_with_progress(
manager,
components,
directory,
force=force,
hide_progress=ctx.obj["hide_progress"],
verbose=ctx.obj["verbose"],
)

with Live(Group(overall_progress, module_progress), console=console, transient=True):
# The overall bar is only useful when processing more than one module
overall_task_id = overall_progress.add_task("modules", total=len(components), visible=len(components) > 1)
for component in components:
module_name = component.component_name
module_task_id = module_progress.add_task(
f"[cyan]{module_name}[/cyan]",
total=None,
status="building containers...",
)
try:
if manager.all_modules:
# Per-module instance, reusing the already-scanned component list
module_manager = ModuleContainers(
module=module_name,
directory=directory,
verbose=ctx.obj["verbose"],
components=manager.available_modules,
)
else:
module_manager = manager
_, success = module_manager.create(
progress_bar=module_progress, task_id=module_task_id, force=force
)
if success:
module_manager.update_containers_in_meta()
if module_manager.repo_type == "pipeline":
try_generate_container_configs(directory, module_manager.module_directory)
else:
failed_modules.append(module_name)
except (ValueError, RuntimeError, OSError) as e:
log.error(f"✗ Failed to build containers for {module_name}: {e}")
failed_modules.append(module_name)
finally:
overall_progress.advance(overall_task_id)
module_progress.remove_task(module_task_id)

if failed_modules:
if manager.all_modules:
log.warning(
Expand Down
45 changes: 29 additions & 16 deletions nf_core/components/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,37 @@ def create(self) -> bool:
run_prettier_on_file(new_files)

log.info("Created following files:\n " + "\n ".join(new_files))

if self.component_type == "modules":
self._build_seqera_containers()

return True

def _build_seqera_containers(self) -> None:
"""
Build Seqera/Wave containers for the freshly created module.
"""
from nf_core.modules.containers import ModuleContainers, build_containers_with_progress

log.info("Building Seqera containers for the module with Wave...")
try:
manager = ModuleContainers(
module=self.component_name,
directory=self.directory,
)
ModuleContainers.check_tower_token()
if manager.nfcore_component is None:
log.warning("Could not locate the new module to build Seqera containers.")
return
failed = build_containers_with_progress(manager, [manager.nfcore_component], self.directory)
if failed:
log.warning(
"Could not build all Seqera containers for the module. "
"Run `nf-core modules containers create` to retry."
)
except (ValueError, RuntimeError, OSError) as e:
log.warning(f"Could not build Seqera containers for the module: {e}")

def _get_bioconda_tool(self):
"""
Try to find a bioconda package for 'tool'
Expand Down Expand Up @@ -226,22 +255,6 @@ def _get_bioconda_tool(self):
)
break

# Try to get the container tag (only if bioconda package was found)
if self.bioconda:
try:
if self.tool_conda_name:
self.docker_container, self.singularity_container = nf_core.utils.get_biocontainer_tag(
self.tool_conda_name, version
)
else:
self.docker_container, self.singularity_container = nf_core.utils.get_biocontainer_tag(
self.component, version
)
log.info(f"Using Docker container: '{self.docker_container}'")
log.info(f"Using Singularity container: '{self.singularity_container}'")
except (ValueError, LookupError) as e:
log.info(f"Could not find a Docker/Singularity container ({e})")

def _get_module_structure_components(self):
process_label_defaults = [
"process_single",
Expand Down
Loading
Loading