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

Get name for parent path to create schema_filename #2886

Merged
merged 5 commits into from
Apr 4, 2024
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 @@ -47,6 +47,7 @@
- Update gitpod/workspace-base Docker digest to 168d78b ([#2899](https://github.com/nf-core/tools/pull/2899))
- Update pre-commit hook astral-sh/ruff-pre-commit to v0.3.4 ([#2894](https://github.com/nf-core/tools/pull/2894))
- Update GitHub Actions ([#2902](https://github.com/nf-core/tools/pull/2902))
- Get immediate parent path name for schema creation ([#2886](https://github.com/nf-core/tools/pull/2886))
- Update pre-commit hook astral-sh/ruff-pre-commit to v0.3.5 ([#2903](https://github.com/nf-core/tools/pull/2903))
- Remove old references to CUSTOMDUMPSOFTWAREVERSIONS and add linting checks ([#2897](https://github.com/nf-core/tools/pull/2897))

Expand Down
4 changes: 3 additions & 1 deletion nf_core/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,12 @@ def make_skeleton_schema(self):
loader=jinja2.PackageLoader("nf_core", "pipeline-template"), keep_trailing_newline=True
)
schema_template = env.get_template("nextflow_schema.json")

template_vars = {
"name": self.pipeline_manifest.get("name", str(Path(self.schema_filename).parent)).strip("'"),
"name": self.pipeline_manifest.get("name", Path(self.schema_filename).parent.name).strip("'"),
"description": self.pipeline_manifest.get("description", "").strip("'"),
}

self.schema = json.loads(schema_template.render(template_vars))
self.get_schema_defaults()

Expand Down
9 changes: 9 additions & 0 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,15 @@ def test_make_skeleton_schema(self):
self.schema_obj.pipeline_manifest["description"] = "Test pipeline"
self.schema_obj.make_skeleton_schema()
self.schema_obj.validate_schema(self.schema_obj.schema)
assert self.schema_obj.schema["title"] == "nf-core/test pipeline parameters"

def test_make_skeleton_schema_absent_name(self):
"""Test making a new schema skeleton"""
self.schema_obj.schema_filename = self.template_schema
self.schema_obj.pipeline_manifest["description"] = "Test pipeline"
self.schema_obj.make_skeleton_schema()
self.schema_obj.validate_schema(self.schema_obj.schema)
assert self.schema_obj.schema["title"] == "wf pipeline parameters"

def test_get_wf_params(self):
"""Test getting the workflow parameters from a pipeline"""
Expand Down
Loading