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

Not all definitions in JSON schema have a "properties", leading to an error #1521

Merged
merged 6 commits into from
May 5, 2022

Conversation

drpatelh
Copy link
Member

Closes #1419

@codecov
Copy link

codecov bot commented Apr 21, 2022

Codecov Report

Merging #1521 (a494d27) into dev (1685277) will decrease coverage by 0.01%.
The diff coverage is 57.14%.

@@            Coverage Diff             @@
##              dev    #1521      +/-   ##
==========================================
- Coverage   64.61%   64.59%   -0.02%     
==========================================
  Files          54       54              
  Lines        6178     6192      +14     
==========================================
+ Hits         3992     4000       +8     
- Misses       2186     2192       +6     
Impacted Files Coverage Δ
nf_core/schema.py 77.24% <57.14%> (-0.61%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1685277...a494d27. Read the comment docs.


# Remove "allOf" group with empty definitions from the schema
for d_key in empty_definitions:
allOf = {"$ref": "#/definitions/{}".format(d_key)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on this PR at the moment so no need to change, but FYI we are trying to slowly move everything to the new format string style in the codebase now (with a few exceptions where this old style is still clearer). Generally it's much easier to read and maintain.

So here it'd be:

Suggested change
allOf = {"$ref": "#/definitions/{}".format(d_key)}
allOf = {"$ref": f"#/definitions/{d_key}"}

Just prepend the string quotes with f and then stick the variable name into the squiggly brackets.

Copy link
Member

@ewels ewels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rewrote this whole function to use Python list comprehension so that you didn't need to use deep copies. But the code ended up being uglier so I ditched it. Then I realised that you didn't actually need deep copies with your existing code 😅

Minor cleanup, hope that's ok. LGTM now 👍🏻

Changes:

  • Added log warning
  • Use get to avoid crashes if properties or allOf keys not set
  • Moved function call out of function to remove missing config parameters
  • Added call to the function on the object returned from the web builder

@drpatelh drpatelh merged commit 9364e5b into nf-core:dev May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants