Skip to content

Commit

Permalink
reduce code
Browse files Browse the repository at this point in the history
  • Loading branch information
mirpedrol committed Jan 8, 2025
1 parent 958f58e commit 51fba5a
Showing 1 changed file with 10 additions and 27 deletions.
37 changes: 10 additions & 27 deletions nf_core/pipelines/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,33 +330,16 @@ def validate_default_params(self):
for group_key, group in schema_no_required.get(self.defs_notation, {}).items():
if "required" in group:
schema_no_required[self.defs_notation][group_key].pop("required")
if "allOf" in group:
for all_of in group["allOf"]:
if "required" in all_of:
schema_no_required[self.defs_notation][group_key]["allOf"].pop("required")
schema_no_required[self.defs_notation][group_key]["allOf"] = [
all_of for all_of in group["allOf"] if all_of
]
if not group["allOf"]:
schema_no_required[self.defs_notation][group_key].pop("allOf")
if "anyOf" in group:
for any_of in group["anyOf"]:
if "required" in any_of:
schema_no_required[self.defs_notation][group_key]["anyOf"].pop("required")
schema_no_required[self.defs_notation][group_key]["anyOf"] = [
any_of for any_of in group["anyOf"] if any_of
]
if not group["anyOf"]:
schema_no_required[self.defs_notation][group_key].pop("anyOf")
if "oneOf" in group:
for i, one_of in enumerate(group["oneOf"]):
if "required" in one_of:
schema_no_required[self.defs_notation][group_key]["oneOf"][i].pop("required")
schema_no_required[self.defs_notation][group_key]["oneOf"] = [
one_of for one_of in group["oneOf"] if one_of
]
if not group["oneOf"]:
schema_no_required[self.defs_notation][group_key].pop("oneOf")
for keyword in ["allOf", "anyOf", "oneOf"]:
if keyword in group:
for i, kw_content in enumerate(group[keyword]):
if "required" in kw_content:
schema_no_required[self.defs_notation][group_key][keyword][i].pop("required")
schema_no_required[self.defs_notation][group_key][keyword] = [
kw_content for kw_content in group[keyword] if kw_content
]
if not group[keyword]:
schema_no_required[self.defs_notation][group_key].pop(keyword)
jsonschema.validate(self.schema_defaults, schema_no_required)
except jsonschema.exceptions.ValidationError as e:
log.debug(f"Complete error message:\n{e}")
Expand Down

0 comments on commit 51fba5a

Please sign in to comment.