+
Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
- Fix backwards compatibility with python 3.9 in use of Enum ([#3736](https://github.com/nf-core/tools/pull/3736))
- Fix downloads: temporary files not moved and cleaned up correctly after singularity pull ([#3749](https://github.com/nf-core/tools/pull/3749))
- impr devcontainer: Add hostRequirements to run with 4CPUs and 16GB ram by default ([#3746](https://github.com/nf-core/tools/pull/3746))
- Fix Issues/3729: Remove temporary folders created from nextflow inspect during downloads ([#3750](https://github.com/nf-core/tools/pull/3750))
- Fix diff printing to terminal ([#3759](https://github.com/nf-core/tools/pull/3759))
- Add .nf-test/ to prettier ignore list ([#3776](https://github.com/nf-core/tools/pull/3776))
- Update dependency prompt_toolkit to <=3.0.52 ([#3783](https://github.com/nf-core/tools/pull/3783))
Expand Down
30 changes: 16 additions & 14 deletions nf_core/pipelines/download/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from nf_core.pipelines.download.container_fetcher import ContainerFetcher
from nf_core.pipelines.download.docker import DockerFetcher
from nf_core.pipelines.download.singularity import SINGULARITY_CACHE_DIR_ENV_VAR, SingularityFetcher
from nf_core.pipelines.download.utils import DownloadError
from nf_core.pipelines.download.utils import DownloadError, intermediate_dir_with_cd
from nf_core.pipelines.download.workflow_repo import WorkflowRepo
from nf_core.utils import (
NF_INSPECT_MIN_NF_VERSION,
Expand Down Expand Up @@ -650,19 +650,21 @@ def find_container_images(
profile_str += ",test,test_full"
profile = f"-profile {profile_str}" if self.container_system else ""

# Run nextflow inspect
executable = "nextflow"
cmd_params = f"inspect -format json {profile} {workflow_directory / entrypoint}"
cmd_out = run_cmd(executable, cmd_params)
if cmd_out is None:
raise DownloadError("Failed to run `nextflow inspect`. Please check your Nextflow installation.")

out, _ = cmd_out
out_json = json.loads(out)
# NOTE: Should we save the container name too to have more meta information?
named_containers = {proc["name"]: proc["container"] for proc in out_json["processes"]}
# We only want to process unique containers
self.containers = list(set(named_containers.values()))
working_dir = Path().absolute()
with intermediate_dir_with_cd(working_dir):
# Run nextflow inspect
executable = "nextflow"
cmd_params = f"inspect -format json {profile} {working_dir / workflow_directory / entrypoint}"
cmd_out = run_cmd(executable, cmd_params)
if cmd_out is None:
raise DownloadError("Failed to run `nextflow inspect`. Please check your Nextflow installation.")

out, _ = cmd_out
out_json = json.loads(out)
# NOTE: Should we save the container name too to have more meta information?
named_containers = {proc["name"]: proc["container"] for proc in out_json["processes"]}
# We only want to process unique containers
self.containers = list(set(named_containers.values()))

except RuntimeError as e:
log.error("Running 'nextflow inspect' failed with the following error")
Expand Down
19 changes: 19 additions & 0 deletions nf_core/pipelines/download/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import contextlib
import importlib.resources
import logging
import os
import shutil
import tempfile
from collections.abc import Generator
Expand Down Expand Up @@ -81,3 +82,21 @@ def intermediate_file_no_creation(output_path: Path) -> Generator[Path, None, No
except:
tmp.cleanup()
raise


@contextlib.contextmanager
def intermediate_dir_with_cd(original_dir: Path, base_dir: Path = Path(".")):
"""
Context manager to provide and change into a tempdir and ensure its removal and return to the
original_dir upon exceptions.
"""

if not original_dir.is_dir():
raise DownloadError(f"Unable to setup temporary dir, original_dir does not exist: {original_dir}")

tmp = tempfile.TemporaryDirectory(dir=base_dir)
try:
os.chdir(tmp.name)
yield tmp
finally:
os.chdir(original_dir)
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载