Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev -> main for 3.1.2 #3406

Merged
merged 68 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
390c03a
bump to 3.2.0dev
mirpedrol Dec 20, 2024
40fa26e
[automated] Update CHANGELOG.md
nf-core-bot Dec 20, 2024
20de879
fix trailing spaces in conf/test.config
mirpedrol Dec 20, 2024
3cb8775
run pre-comit when rendering template for pipelines sync
mirpedrol Dec 20, 2024
6b43881
add newline
mirpedrol Dec 20, 2024
4bd4d23
bump to 3.1.2dev
mirpedrol Dec 20, 2024
bf3224c
Allow downloading a specific commit ID
muffato Dec 20, 2024
9dcb4a0
Added tests
fellen31 Apr 4, 2024
7b931f1
Added more tests
muffato Dec 20, 2024
c356337
Updated the changelog
muffato Dec 20, 2024
b0b9559
Added some documentation
muffato Dec 20, 2024
132d09c
Update pre-commit hook pre-commit/mirrors-mypy to v1.14.1
renovate[bot] Jan 1, 2025
6fe8f28
Update pre-commit hook astral-sh/ruff-pre-commit to v0.8.6
renovate[bot] Jan 4, 2025
340523c
Merge pull request #3370 from mirpedrol/bump-3.2.0dev
mirpedrol Jan 7, 2025
12f6e36
Merge branch 'dev' into download_commits
mirpedrol Jan 7, 2025
a335212
only append module name if it is a dir and contains main.nf
mirpedrol Jan 7, 2025
983dced
update changelog
mirpedrol Jan 7, 2025
e0d8732
Merge branch 'dev' into renovate/pre-commit-mirrors-mypy-1.x
mashehu Jan 7, 2025
069fce2
add tests for get_installed_modules() utils function
mirpedrol Jan 7, 2025
19070e5
remove type hint to make mypy pass
mashehu Jan 7, 2025
72f2ed1
Merge branch 'dev' into renovate/astral-sh-ruff-pre-commit-0.x
mashehu Jan 7, 2025
53703f4
Merge pull request #3384 from mirpedrol/modules-bump-versions
mirpedrol Jan 7, 2025
21222f4
Merge pull request #3376 from nf-core/renovate/astral-sh-ruff-pre-com…
mashehu Jan 7, 2025
73ee4a1
Merge pull request #3379 from nf-core/renovate/pre-commit-mirrors-myp…
mashehu Jan 7, 2025
011d15a
Update python:3.12-slim Docker digest to 10f3aaa (#3381)
renovate[bot] Jan 7, 2025
4a74d5b
remove required from oneOf, allOf and anyOf instances in a schema
mirpedrol Jan 8, 2025
5782edf
print complete error message from schema validation on debug
mirpedrol Jan 8, 2025
958f58e
[automated] Update CHANGELOG.md
nf-core-bot Jan 8, 2025
51fba5a
reduce code
mirpedrol Jan 8, 2025
2f2950f
handle anyOf, allOf, oneOf in top level
mirpedrol Jan 8, 2025
b1c7a8c
add tests for validate_default_params function
mirpedrol Jan 8, 2025
824fa8f
Update ci.yml
sateeshperi Jan 8, 2025
63aff6e
Merge branch 'dev' into sateeshperi-patch-1
sateeshperi Jan 8, 2025
40c77c7
Merge pull request #3388 from nf-core/sateeshperi-patch-1
maxulysse Jan 8, 2025
b685800
Merge pull request #3386 from mirpedrol/schema-allow-oneof-anyof-allof
mirpedrol Jan 9, 2025
9cc2b5b
Merge branch 'dev' into run-prettier-on-sync
mirpedrol Jan 13, 2025
80e06dc
do not run pre-commit if we are not on a git repo
mirpedrol Jan 13, 2025
d4d3f36
Merge pull request #3371 from mirpedrol/run-prettier-on-sync
mirpedrol Jan 13, 2025
a7aee9c
Factored out the commit ID
muffato Jan 13, 2025
1844f55
Not needed
muffato Jan 13, 2025
5ae7d53
Factored out the commit ID
muffato Jan 13, 2025
62c3c2b
Factored out the commit ID
muffato Jan 13, 2025
570ae2b
Merge remote-tracking branch 'origin/dev' into download_commits
muffato Jan 13, 2025
f58510f
Merge pull request #3374 from nf-core/download_commits
muffato Jan 13, 2025
16dd8d5
Reorganise download test to ensure setup and download are executed on…
MatthiasZepper Jan 8, 2025
2184cab
Add explicit container cache inspection to action.
MatthiasZepper Jan 8, 2025
737b515
Changelog.
MatthiasZepper Jan 8, 2025
65969d9
Merge pull request #3389 from MatthiasZepper/no_env_in_download_action
MatthiasZepper Jan 13, 2025
df41fc0
fix sync GHA by removing quotes from parsed branch name
mirpedrol Jan 14, 2025
ed1cbde
[automated] Update CHANGELOG.md
nf-core-bot Jan 14, 2025
4bdf77e
make rocrate no git info message a debug message to avoid seeing it e…
mirpedrol Jan 14, 2025
225b0b7
manifest.authors is not mandatory anymore
mirpedrol Jan 14, 2025
7641e5f
[automated] Update CHANGELOG.md
nf-core-bot Jan 14, 2025
6680f41
Merge pull request #3397 from mirpedrol/make-author-not-required
mirpedrol Jan 15, 2025
24e6c80
Merge branch 'dev' into fix-sync-gha
mirpedrol Jan 15, 2025
7fa5d5b
Merge pull request #3394 from mirpedrol/fix-sync-gha
mirpedrol Jan 15, 2025
cd72f97
update nf-schema version
nvnieuwk Jan 15, 2025
e62a94b
update changelog
nvnieuwk Jan 15, 2025
e6402db
Merge pull request #3401 from nvnieuwk/update-nf-schema
nvnieuwk Jan 16, 2025
bd5c641
bump version to 3.1.2
mirpedrol Jan 20, 2025
373ad61
remove jinja formatting which was deleting line breaks
mirpedrol Jan 20, 2025
4746cfd
Merge pull request #3405 from mirpedrol/fix-jinja
mirpedrol Jan 20, 2025
ce69545
Merge branch 'dev' into bump-3.1.2
mirpedrol Jan 20, 2025
c1ab12f
Merge pull request #3404 from mirpedrol/bump-3.1.2
mirpedrol Jan 20, 2025
53d0e33
changelog updates
mirpedrol Jan 20, 2025
112bf2b
Merge pull request #3407 from mirpedrol/changelog
mirpedrol Jan 20, 2025
d113f24
update release date [skip ci]
mirpedrol Jan 20, 2025
e481084
Merge pull request #3408 from mirpedrol/update-date
mirpedrol Jan 20, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:

run: |
pushd nf-core/${{ matrix.pipeline }}
defaultBranch=$(grep -B5 -A5 "nextflowVersion" nextflow.config | grep "defaultBranch" | cut -d"=" -f2)
defaultBranch=$(grep -B5 -A5 "nextflowVersion" nextflow.config | grep "defaultBranch" | cut -d"=" -f2 | sed "s/'//g")
if [ -z "$defaultBranch" ]; then
defaultBranch="master"
fi
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.2
rev: v0.8.6
mashehu marked this conversation as resolved.
Show resolved Hide resolved
hooks:
- id: ruff # linter
args: [--fix, --exit-non-zero-on-fix] # sort imports and fix
Expand All @@ -19,7 +19,7 @@ repos:
alias: ec

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.13.0"
rev: "v1.14.1"
hooks:
- id: mypy
additional_dependencies:
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# nf-core/tools: Changelog

## [v3.1.2 - Brass Boxfish Patch](https://github.com/nf-core/tools/releases/tag/3.1.2) - [2025-01-20]

### Template

- Bump nf-schema to `2.3.0` ([#3401](https://github.com/nf-core/tools/pull/3401))
- Remove jinja formatting which was deleting line breaks ([#3405](https://github.com/nf-core/tools/pull/3405))

### Download

- Allow `nf-core pipelines download -r` to download commits ([#3374](https://github.com/nf-core/tools/pull/3374))
- Fix faulty Download Test Action to ensure that setup and test run as one job and on the same runner ([#3389](https://github.com/nf-core/tools/pull/3389))

### Modules

- Fix bump-versions: only append module name if it is a dir and contains `main.nf` ([#3384](https://github.com/nf-core/tools/pull/3384))

### General

- `manifest.author` is not required anymore ([#3397](https://github.com/nf-core/tools/pull/3397))
- Parameters schema validation: allow `oneOf`, `anyOf` and `allOf` with `required` ([#3386](https://github.com/nf-core/tools/pull/3386))
- Run pre-comit when rendering template for pipelines sync ([#3371](https://github.com/nf-core/tools/pull/3371))
- Fix sync GHA by removing quotes from parsed branch name ([#3394](https://github.com/nf-core/tools/pull/3394))

## [v3.1.1 - Brass Boxfish Patch](https://github.com/nf-core/tools/releases/tag/3.1.1) - [2024-12-20]

### Template
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12-slim@sha256:2b0079146a74e23bf4ae8f6a28e1b484c6292f6fb904cbb51825b4a19812fcd8
FROM python:3.12-slim@sha256:10f3aaab98db50cba827d3b33a91f39dc9ec2d02ca9b85cbc5008220d07b17f3
LABEL authors="[email protected],[email protected]" \
description="Docker image containing requirements for nf-core/tools"

Expand Down
13 changes: 7 additions & 6 deletions nf_core/modules/modules_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,20 @@ def get_installed_modules(directory: Path, repo_type="modules") -> Tuple[List[st
local_modules = sorted([x for x in local_modules if x.endswith(".nf")])

# Get nf-core modules
if os.path.exists(nfcore_modules_dir):
for m in sorted([m for m in os.listdir(nfcore_modules_dir) if not m == "lib"]):
if not os.path.isdir(os.path.join(nfcore_modules_dir, m)):
if nfcore_modules_dir.exists():
for m in sorted([m for m in nfcore_modules_dir.iterdir() if not m == "lib"]):
if not m.is_dir():
raise ModuleExceptionError(
f"File found in '{nfcore_modules_dir}': '{m}'! This directory should only contain module directories."
)
m_content = os.listdir(os.path.join(nfcore_modules_dir, m))
m_content = [d.name for d in m.iterdir()]
# Not a module, but contains sub-modules
if "main.nf" not in m_content:
for tool in m_content:
nfcore_modules_names.append(os.path.join(m, tool))
if (m / tool).is_dir() and "main.nf" in [d.name for d in (m / tool).iterdir()]:
nfcore_modules_names.append(str(Path(m.name, tool)))
else:
nfcore_modules_names.append(m)
nfcore_modules_names.append(m.name)

# Make full (relative) file paths and create NFCoreComponent objects
if local_modules_dir:
Expand Down
2 changes: 2 additions & 0 deletions nf_core/pipeline-template/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
steps:
- name: Check out pipeline code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0

- name: Set up Nextflow
uses: nf-core/setup-nextflow@v2
Expand Down
34 changes: 19 additions & 15 deletions nf_core/pipeline-template/.github/workflows/download_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,18 @@ jobs:
REPOTITLE_LOWERCASE: ${{ steps.get_repo_properties.outputs.REPOTITLE_LOWERCASE }}
REPO_BRANCH: ${{ steps.get_repo_properties.outputs.REPO_BRANCH }}
steps:
- name: Install Nextflow{% endraw %}
- name: Get the repository name and current branch
id: get_repo_properties
run: |
echo "REPO_LOWERCASE=${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
echo "REPOTITLE_LOWERCASE=$(basename ${GITHUB_REPOSITORY,,})" >> "$GITHUB_OUTPUT"
echo "REPO_BRANCH=${{ github.event.inputs.testbranch || 'dev' }}" >> "$GITHUB_OUTPUT{% endraw %}"

download:
runs-on: ubuntu-latest
needs: configure
steps:
- name: Install Nextflow
uses: nf-core/setup-nextflow@v2

- name: Disk space cleanup
Expand All @@ -56,24 +67,13 @@ jobs:
python -m pip install --upgrade pip
pip install git+https://github.com/nf-core/tools.git@dev

- name: Get the repository name and current branch set as environment variable
id: get_repo_properties
run: |
echo "REPO_LOWERCASE=${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
echo "REPOTITLE_LOWERCASE=$(basename ${GITHUB_REPOSITORY,,})" >> "$GITHUB_OUTPUT"
echo "{% raw %}REPO_BRANCH=${{ github.event.inputs.testbranch || 'dev' }}" >> "$GITHUB_OUTPUT"

- name: Make a cache directory for the container images
run: |
mkdir -p ./singularity_container_images

download:
runs-on: ubuntu-latest
needs: configure
steps:
- name: Download the pipeline
env:
NXF_SINGULARITY_CACHEDIR: ./singularity_container_images
NXF_SINGULARITY_CACHEDIR: ./singularity_container_images{% raw %}
run: |
nf-core pipelines download ${{ needs.configure.outputs.REPO_LOWERCASE }} \
--revision ${{ needs.configure.outputs.REPO_BRANCH }} \
Expand All @@ -85,7 +85,10 @@ jobs:
--download-configuration 'yes'

- name: Inspect download
run: tree ./${{ needs.configure.outputs.REPOTITLE_LOWERCASE }}{% endraw %}{% if test_config %}{% raw %}
run: tree ./${{ needs.configure.outputs.REPOTITLE_LOWERCASE }}{% endraw %}

- name: Inspect container images
run: tree ./singularity_container_images | tee ./container_initial{% if test_config %}{% raw %}

- name: Count the downloaded number of container images
id: count_initial
Expand Down Expand Up @@ -123,7 +126,8 @@ jobs:
final_count=${{ steps.count_afterwards.outputs.IMAGE_COUNT_AFTER }}
difference=$((final_count - initial_count))
echo "$difference additional container images were \n downloaded at runtime . The pipeline has no support for offline runs!"
tree ./singularity_container_images
tree ./singularity_container_images > ./container_afterwards
diff ./container_initial ./container_afterwards
exit 1
else
echo "The pipeline can be downloaded successfully!"
Expand Down
2 changes: 1 addition & 1 deletion nf_core/pipeline-template/CITATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

{%- endif %}

{%- if multiqc %}- [MultiQC](https://pubmed.ncbi.nlm.nih.gov/27312411/)
{% if multiqc %}- [MultiQC](https://pubmed.ncbi.nlm.nih.gov/27312411/)

> Ewels P, Magnusson M, Lundin S, Käller M. MultiQC: summarize analysis results for multiple tools and samples in a single report. Bioinformatics. 2016 Oct 1;32(19):3047-8. doi: 10.1093/bioinformatics/btw354. Epub 2016 Jun 16. PubMed PMID: 27312411; PubMed Central PMCID: PMC5039924.

Expand Down
6 changes: 3 additions & 3 deletions nf_core/pipeline-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</picture>
</h1>

{%- else -%}
{% else -%}

# {{ name }}

Expand Down Expand Up @@ -54,7 +54,7 @@
## Usage

> [!NOTE]
> If you are new to Nextflow and nf-core, please refer to [this page](https://nf-co.re/docs/usage/installation) on how to set-up Nextflow. {%- if test_config %}Make sure to [test your setup](https://nf-co.re/docs/usage/introduction#how-to-run-a-pipeline) with `-profile test` before running the workflow on actual data.{% endif %}
> If you are new to Nextflow and nf-core, please refer to [this page](https://nf-co.re/docs/usage/installation) on how to set-up Nextflow. {% if test_config %}Make sure to [test your setup](https://nf-co.re/docs/usage/introduction#how-to-run-a-pipeline) with `-profile test` before running the workflow on actual data.{% endif %}

<!-- TODO nf-core: Describe the minimum required steps to execute the pipeline, e.g. how to prepare samplesheets.
Explain what rows and columns represent. For instance (please edit as appropriate):
Expand Down Expand Up @@ -120,7 +120,7 @@ For further information or help, don't hesitate to get in touch on the [Slack `#
<!-- TODO nf-core: Add citation for pipeline after first release. Uncomment lines below and update Zenodo doi and badge at the top of this file. -->
<!-- If you use {{ name }} for your analysis, please cite it using the following doi: [10.5281/zenodo.XXXXXX](https://doi.org/10.5281/zenodo.XXXXXX) -->

{%- if citations %}<!-- TODO nf-core: Add bibliography of tools and data used in your pipeline -->
{% if citations %}<!-- TODO nf-core: Add bibliography of tools and data used in your pipeline -->

An extensive list of references for the tools used by the pipeline can be found in the [`CITATIONS.md`](CITATIONS.md) file.
{%- endif %}
Expand Down
3 changes: 2 additions & 1 deletion nf_core/pipeline-template/conf/test.config
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ params {
// TODO nf-core: Give any required params for the test so that command line flags are not needed
input = params.pipelines_testdata_base_path + 'viralrecon/samplesheet/samplesheet_test_illumina_amplicon.csv'

{% if igenomes -%}
{%- if igenomes -%}

// Genome references
genome = 'R64-1-1'
{%- endif %}
Expand Down
2 changes: 1 addition & 1 deletion nf_core/pipeline-template/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ manifest {
{% if nf_schema -%}
// Nextflow plugins
plugins {
id 'nf-schema@2.1.1' // Validation of pipeline parameters and creation of an input channel from a sample sheet
id 'nf-schema@2.3.0' // Validation of pipeline parameters and creation of an input channel from a sample sheet
}

validation {
Expand Down
4 changes: 4 additions & 0 deletions nf_core/pipelines/create/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ def render_template(self) -> None:
yaml.dump(config_yml.model_dump(exclude_none=True), fh, Dumper=custom_yaml_dumper())
log.debug(f"Dumping pipeline template yml to pipeline config file '{config_fn.name}'")

# Run prettier on files for pipelines sync
log.debug("Running prettier on pipeline files")
run_prettier_on_file([str(f) for f in self.outdir.glob("**/*")])

def fix_linting(self):
"""
Updates the .nf-core.yml with linting configurations
Expand Down
17 changes: 12 additions & 5 deletions nf_core/pipelines/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,30 +374,37 @@ def prompt_revision(self) -> None:
raise AssertionError(f"No revisions of {self.pipeline} available for download.")

def get_revision_hash(self):
"""Find specified revision / branch hash"""
"""Find specified revision / branch / commit hash"""

for revision in self.revision: # revision is a list of strings, but may be of length 1
# Branch
if revision in self.wf_branches.keys():
self.wf_sha = {**self.wf_sha, revision: self.wf_branches[revision]}

# Revision
else:
# Revision
for r in self.wf_revisions:
if r["tag_name"] == revision:
self.wf_sha = {**self.wf_sha, revision: r["tag_sha"]}
break

# Can't find the revisions or branch - throw an error
else:
# Commit - full or short hash
if commit_id := nf_core.utils.get_repo_commit(self.pipeline, revision):
self.wf_sha = {**self.wf_sha, revision: commit_id}
continue

# Can't find the revisions or branch - throw an error
log.info(
"Available {} revisions: '{}'".format(
self.pipeline,
"', '".join([r["tag_name"] for r in self.wf_revisions]),
)
)
log.info("Available {} branches: '{}'".format(self.pipeline, "', '".join(self.wf_branches.keys())))
raise AssertionError(f"Not able to find revision / branch '{revision}' for {self.pipeline}")
raise AssertionError(
f"Not able to find revision / branch / commit '{revision}' for {self.pipeline}"
)

# Set the outdir
if not self.outdir:
Expand Down Expand Up @@ -1536,7 +1543,7 @@ def singularity_pull_image(

progress.remove_task(task)

def compress_download(self) -> None:
def compress_download(self):
"""Take the downloaded files and make a compressed .tar.gz archive."""
log.debug(f"Creating archive: {self.output_filename}")

Expand Down
13 changes: 11 additions & 2 deletions nf_core/pipelines/lint/files_unchanged.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import filecmp
import logging
import os
import re
import shutil
import tempfile
from pathlib import Path
Expand Down Expand Up @@ -68,7 +69,10 @@ def files_unchanged(self) -> Dict[str, Union[List[str], bool]]:
could_fix: bool = False

# Check that we have the minimum required config
required_pipeline_config = {"manifest.name", "manifest.description", "manifest.author"}
required_pipeline_config = {
"manifest.name",
"manifest.description",
} # TODO: add "manifest.contributors" when minimum nextflow version is >=24.10.0
missing_pipeline_config = required_pipeline_config.difference(self.nf_config)
if missing_pipeline_config:
return {"ignored": [f"Required pipeline config not found - {missing_pipeline_config}"]}
Expand Down Expand Up @@ -117,10 +121,15 @@ def files_unchanged(self) -> Dict[str, Union[List[str], bool]]:
tmp_dir.mkdir(parents=True)

# Create a template.yaml file for the pipeline creation
if "manifest.author" in self.nf_config:
names = self.nf_config["manifest.author"].strip("\"'")
if "manifest.contributors" in self.nf_config:
contributors = self.nf_config["manifest.contributors"]
names = ", ".join(re.findall(r"name:'([^']+)'", contributors))
template_yaml = {
"name": short_name,
"description": self.nf_config["manifest.description"].strip("\"'"),
"author": self.nf_config["manifest.author"].strip("\"'"),
"author": names,
"org": prefix,
}

Expand Down
44 changes: 29 additions & 15 deletions nf_core/pipelines/lint_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ def print_fixes(lint_obj):
)


def check_git_repo() -> bool:
"""Check if the current directory is a git repository."""
try:
subprocess.check_output(["git", "rev-parse", "--is-inside-work-tree"])
return True
except subprocess.CalledProcessError:
return False


def run_prettier_on_file(file: Union[Path, str, List[str]]) -> None:
"""Run the pre-commit hook prettier on a file.

Expand All @@ -80,28 +89,33 @@ def run_prettier_on_file(file: Union[Path, str, List[str]]) -> None:
If Prettier is not installed, a warning is logged.
"""

is_git = check_git_repo()

nf_core_pre_commit_config = Path(nf_core.__file__).parent / ".pre-commit-prettier-config.yaml"
args = ["pre-commit", "run", "--config", str(nf_core_pre_commit_config), "prettier"]
if isinstance(file, List):
args.extend(["--files", *file])
else:
args.extend(["--files", str(file)])

try:
subprocess.run(args, capture_output=True, check=True)
log.debug(f"${subprocess.STDOUT}")
except subprocess.CalledProcessError as e:
if ": SyntaxError: " in e.stdout.decode():
log.critical(f"Can't format {file} because it has a syntax error.\n{e.stdout.decode()}")
elif "files were modified by this hook" in e.stdout.decode():
all_lines = [line for line in e.stdout.decode().split("\n")]
files = "\n".join(all_lines[3:])
log.debug(f"The following files were modified by prettier:\n {files}")
else:
log.warning(
"There was an error running the prettier pre-commit hook.\n"
f"STDOUT: {e.stdout.decode()}\nSTDERR: {e.stderr.decode()}"
)
if is_git:
try:
proc = subprocess.run(args, capture_output=True, check=True)
log.debug(f"{proc.stdout.decode()}")
except subprocess.CalledProcessError as e:
if ": SyntaxError: " in e.stdout.decode():
log.critical(f"Can't format {file} because it has a syntax error.\n{e.stdout.decode()}")
elif "files were modified by this hook" in e.stdout.decode():
all_lines = [line for line in e.stdout.decode().split("\n")]
files = "\n".join(all_lines[3:])
log.debug(f"The following files were modified by prettier:\n {files}")
else:
log.warning(
"There was an error running the prettier pre-commit hook.\n"
f"STDOUT: {e.stdout.decode()}\nSTDERR: {e.stderr.decode()}"
)
else:
log.debug("Not in a git repository, skipping pre-commit hook.")


def dump_json_with_prettier(file_name, file_content):
Expand Down
2 changes: 1 addition & 1 deletion nf_core/pipelines/rocrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def add_main_authors(self, wf_file: rocrate.model.entity.Entity) -> None:
try:
git_contributors: Set[str] = set()
if self.pipeline_obj.repo is None:
log.info("No git repository found. No git contributors will be added as authors.")
log.debug("No git repository found. No git contributors will be added as authors.")
return
commits_touching_path = list(self.pipeline_obj.repo.iter_commits(paths="main.nf"))

Expand Down
Loading
Loading