Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
drpatelh authored and fabianegli committed May 12, 2022
1 parent de5dcb7 commit 19f3728
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Add an empty line to `modules.json`, `params.json` and `nextflow-schema.json` when dumping them to avoid prettier errors.
- Add actions workflow to respond to `@nf-core-bot fix linting` comments on nf-core/tools PRs
- Linting: Don't allow a `.nf-core.yaml` file, should be `.yml` ([#1515](https://github.com/nf-core/tools/pull/1515)).
- Not all definitions in JSON schema have a "properties", leading to an error ([#1419](https://github.com/nf-core/tools/issues/1419))

### Modules

Expand Down
25 changes: 25 additions & 0 deletions nf_core/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,29 @@ def get_wf_params(self):
)
)

def remove_schema_empty_definitions(self):
"""
Go through top-level schema remove definitions that don't have
any property attributes
"""
# Make copy of schema
schema_no_empty_definitions = copy.deepcopy(self.schema)

## Identify and remove empty definitions from the schema
empty_definitions = []
for d_key, d_schema in list(schema_no_empty_definitions.get("definitions", {}).items()):
if not d_schema['properties']:
del schema_no_empty_definitions["definitions"][d_key]
empty_definitions.append(d_key)

# Remove "allOf" group with empty definitions from the schema
for d_key in empty_definitions:
allOf = {'$ref': "#/definitions/{}".format(d_key)}
if allOf in schema_no_empty_definitions["allOf"]:
schema_no_empty_definitions["allOf"].remove(allOf)

self.schema = schema_no_empty_definitions

def remove_schema_notfound_configs(self):
"""
Go through top-level schema and all definitions sub-schemas to remove
Expand All @@ -625,6 +648,8 @@ def remove_schema_notfound_configs(self):
cleaned_schema, p_removed = self.remove_schema_notfound_configs_single_schema(definition)
self.schema["definitions"][d_key] = cleaned_schema
params_removed.extend(p_removed)
self.remove_schema_empty_definitions()

return params_removed

def remove_schema_notfound_configs_single_schema(self, schema):
Expand Down

0 comments on commit 19f3728

Please sign in to comment.