Skip to content

Commit

Permalink
prettify template and printing .nf-core.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mirpedrol committed Dec 16, 2024
1 parent 1fbd011 commit 2b2b435
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ body:
- [nf-core website: troubleshooting](https://nf-co.re/usage/troubleshooting)
- [{{ name }} pipeline documentation](https://nf-co.re/{{ short_name }}/usage)
{%- endif %}

- type: textarea
id: description
attributes:
Expand Down
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion nf_core/pipeline-template/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ validation {
command = "nextflow run {{ name }} -profile <docker/singularity/.../institute> --input samplesheet.csv --outdir <OUTDIR>"
fullParameter = "help_full"
showHiddenParameter = "show_hidden"
{% if is_nfcore -%}
{%- if is_nfcore %}
beforeText = """
-\033[2m----------------------------------------------------\033[0m-
\033[0;32m,--.\033[0;30m/\033[0;32m,-.\033[0m
Expand Down
4 changes: 2 additions & 2 deletions nf_core/pipelines/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import nf_core.utils
from nf_core.pipelines.rocrate import ROCrate
from nf_core.utils import Pipeline
from nf_core.utils import Pipeline, custom_yaml_dumper

log = logging.getLogger(__name__)
stderr = rich.console.Console(stderr=True, force_terminal=nf_core.utils.rich_force_colors())
Expand Down Expand Up @@ -257,7 +257,7 @@ def update_yaml_file(fn: Path, patterns: List[Tuple[str, str]], yaml_key: List[s
if new_value != current_value:
target[last_key] = new_value
with open(fn, "w") as file:
yaml.dump(yaml_content, file)
yaml.dump(yaml_content, file, Dumper=custom_yaml_dumper())
log.info(f"Updated version in YAML file '{fn}'")
log_change(str(current_value), str(new_value))
except KeyError as e:
Expand Down
6 changes: 3 additions & 3 deletions nf_core/pipelines/create/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from nf_core.pipelines.create_logo import create_logo
from nf_core.pipelines.lint_utils import run_prettier_on_file
from nf_core.pipelines.rocrate import ROCrate
from nf_core.utils import NFCoreTemplateConfig, NFCoreYamlLintConfig
from nf_core.utils import NFCoreTemplateConfig, NFCoreYamlLintConfig, custom_yaml_dumper

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -380,7 +380,7 @@ def render_template(self) -> None:
if config_fn is not None and config_yml is not None:
with open(str(config_fn), "w") as fh:
config_yml.template = NFCoreTemplateConfig(**self.config.model_dump(exclude_none=True))
yaml.safe_dump(config_yml.model_dump(exclude_none=True), fh)
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}'")

def fix_linting(self):
Expand Down Expand Up @@ -410,7 +410,7 @@ def fix_linting(self):
if config_fn is not None and nf_core_yml is not None:
nf_core_yml.lint = NFCoreYamlLintConfig(**lint_config)
with open(self.outdir / config_fn, "w") as fh:
yaml.dump(nf_core_yml.model_dump(exclude_none=True), fh, default_flow_style=False, sort_keys=False)
yaml.dump(nf_core_yml.model_dump(exclude_none=True), fh, Dumper=custom_yaml_dumper())

def make_pipeline_logo(self):
"""Fetch a logo for the new pipeline from the nf-core website"""
Expand Down
4 changes: 2 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import nf_core.modules
import nf_core.pipelines.create.create
from nf_core import __version__
from nf_core.utils import NFCoreTemplateConfig, NFCoreYamlConfig
from nf_core.utils import NFCoreTemplateConfig, NFCoreYamlConfig, custom_yaml_dumper

TEST_DATA_DIR = Path(__file__).parent / "data"
OLD_TRIMGALORE_SHA = "9b7a3bdefeaad5d42324aa7dd50f87bea1b04386"
Expand Down Expand Up @@ -136,7 +136,7 @@ def create_tmp_pipeline(no_git: bool = False) -> Tuple[Path, Path, str, Path]:
bump_version=None,
)
with open(str(Path(pipeline_dir, ".nf-core.yml")), "w") as fh:
yaml.dump(nf_core_yml.model_dump(), fh)
yaml.dump(nf_core_yml.model_dump(), fh, Dumper=custom_yaml_dumper())

nf_core.pipelines.create.create.PipelineCreate(
pipeline_name, "it is mine", "me", no_git=no_git, outdir=pipeline_dir, force=True
Expand Down

0 comments on commit 2b2b435

Please sign in to comment.