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

Autogenerate schema element titles #304

Merged
merged 4 commits into from
Dec 8, 2020
Merged

Autogenerate schema element titles #304

merged 4 commits into from
Dec 8, 2020

Conversation

jwodder
Copy link
Member

@jwodder jwodder commented Dec 3, 2020

Closes #301.

Note that there doesn't seem to be a way to apply this to enum types.

@codecov
Copy link

codecov bot commented Dec 3, 2020

Codecov Report

Merging #304 (bc6f43c) into master (1fd015f) will increase coverage by 0.22%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #304      +/-   ##
==========================================
+ Coverage   81.80%   82.03%   +0.22%     
==========================================
  Files          54       54              
  Lines        4886     5014     +128     
==========================================
+ Hits         3997     4113     +116     
- Misses        889      901      +12     
Flag Coverage Δ
unittests 82.03% <100.00%> (+0.22%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
dandi/models.py 81.81% <100.00%> (+0.56%) ⬆️
dandi/tests/test_models.py 100.00% <100.00%> (ø)
dandi/tests/test_utils.py 100.00% <100.00%> (ø)
dandi/utils.py 77.00% <100.00%> (+1.53%) ⬆️
dandi/upload.py 75.58% <0.00%> (+4.45%) ⬆️

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 1fd015f...bc6f43c. Read the comment docs.

@jwodder jwodder added the patch Increment the patch version when merged label Dec 4, 2020
Copy link
Member

@yarikoptic yarikoptic left a comment

Choose a reason for hiding this comment

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

just asking for a simple unittest. Otherwise looks great to me, thank you @jwodder !

May be @satra could have a peek as well

schema["title"] = name2title(schema["title"])
for name, prop in schema.get("properties", {}).items():
if prop.get("title") is None or prop["title"] == name.title():
prop["title"] = name2title(name)
Copy link
Member

Choose a reason for hiding this comment

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

we need a test for this. Please add a little test which would pretty much do what dandi/tools/pubschemata.py does and ensure that we do get title set as expected in at least one record

Copy link
Member Author

Choose a reason for hiding this comment

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

Test added.

@satra
Copy link
Member

satra commented Dec 7, 2020

LGTM - can we check that the generated json schema has the titles (especially for the enumerated types like License)?

@jwodder
Copy link
Member Author

jwodder commented Dec 7, 2020

@satra As I said above, there doesn't seem to be a way to autogenerate titles for enum types.

)
license: List[LicenseType] = Field(description="License of item.", nskey="schema")
Copy link
Member

Choose a reason for hiding this comment

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

@jwodder - then we should not remove the title field that was added to enum types. There are a few of these.

AccessType = create_enum(AccessTypeDict)
RoleType = create_enum(RoleTypeDict)
RelationType = create_enum(RelationTypeDict)
LicenseType = create_enum(LicenseTypeDict)
IdentifierType = create_enum(IdentifierTypeDict)
DigestType = create_enum(DigestTypeDict)

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, you mean the enum fields! No, those titles are autogenerated fine. It's the enum entries in the definitions section that don't get titles.

Copy link
Member

@yarikoptic yarikoptic left a comment

Choose a reason for hiding this comment

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

thank you @jwodder , looks good to me. @satra -- if enum issue is "settled" , feel welcome to click Merge ;)

@yarikoptic
Copy link
Member

Let's proceed, and if anything -- fixup after! ;) "release is cheap" these days (and we do not need a release for this anyways) but it would avoid possible conflicts happen we decide to tune the schema

@yarikoptic yarikoptic merged commit da3b7a7 into master Dec 8, 2020
@yarikoptic yarikoptic deleted the gh-301 branch December 8, 2020 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically mint "title" for entities in json schema if not explicitly given
3 participants