Skip to content
Open
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
11 changes: 10 additions & 1 deletion nf_core/pipelines/download/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,17 @@ def check_and_set_implementation(self) -> None:
"""
Check if Docker is installed and set the implementation.
"""
if not shutil.which("docker"):
docker_binary = shutil.which("docker")
if not docker_binary:
raise OSError("Docker is needed to pull images, but it is not installed or not in $PATH")

try:
nf_core.utils.run_cmd(docker_binary, "info")
except RuntimeError:
raise OSError(
"Docker daemon is required to pull images, but it is not running or unavailable to the docker client"
)

self.implementation = "docker"

def gather_registries(self, workflow_directory: Path) -> set[str]:
Expand Down
44 changes: 24 additions & 20 deletions nf_core/pipelines/download/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,26 +494,30 @@ def setup_container_fetcher(self) -> None:
Create the appropriate ContainerFetcher object
"""
assert self.outdir is not None # mypy
if self.container_system == "singularity":
self.container_fetcher = SingularityFetcher(
outdir=self.outdir,
container_library=self.container_library,
registry_set=self.registry_set,
container_cache_utilisation=self.container_cache_utilisation,
container_cache_index=self.container_cache_index,
parallel=self.parallel,
hide_progress=self.hide_progress,
)
elif self.container_system == "docker":
self.container_fetcher = DockerFetcher(
outdir=self.outdir,
registry_set=self.registry_set,
container_library=self.container_library,
parallel=self.parallel,
hide_progress=self.hide_progress,
)
else:
self.container_fetcher = None
try:
if self.container_system == "singularity":
self.container_fetcher = SingularityFetcher(
Copy link
Contributor

Choose a reason for hiding this comment

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

does the SingularityFetcher raise a similar error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No singularity does not require a daemon running in the background. But there is a check for if singularity or apptainer is installed.

outdir=self.outdir,
container_library=self.container_library,
registry_set=self.registry_set,
container_cache_utilisation=self.container_cache_utilisation,
container_cache_index=self.container_cache_index,
parallel=self.parallel,
hide_progress=self.hide_progress,
)
elif self.container_system == "docker":
self.container_fetcher = DockerFetcher(
outdir=self.outdir,
registry_set=self.registry_set,
container_library=self.container_library,
parallel=self.parallel,
hide_progress=self.hide_progress,
)
else:
self.container_fetcher = None
except OSError as e:
log.error(e)
exit(1)
Copy link
Member

Choose a reason for hiding this comment

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

It is better to raise a UserWarning or LookupError, we handle these in the commands. This should be updated in the nf_core/commands_pipelines.py, you can look at other commands to see an example.

Suggested change
exit(1)
raise UserWarning


def prompt_use_singularity(self, fail_message: str) -> None:
use_singularity = questionary.confirm(
Expand Down