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

fix: update migration code to account for missing fields #30

Merged
merged 5 commits into from
Jun 9, 2021

Conversation

satra
Copy link
Member

@satra satra commented Jun 9, 2021

I just ran through all the dandiset metadata and this code wasn't taking badly formed metadata into account.

@satra satra added patch Increment the patch version when merged release Create a release when this pr is merged labels Jun 9, 2021
@codecov
Copy link

codecov bot commented Jun 9, 2021

Codecov Report

Merging #30 (9186d30) into master (42221bb) will increase coverage by 0.22%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #30      +/-   ##
==========================================
+ Coverage   94.52%   94.74%   +0.22%     
==========================================
  Files          11       11              
  Lines         858      876      +18     
==========================================
+ Hits          811      830      +19     
+ Misses         47       46       -1     
Flag Coverage Δ
unittests 94.74% <100.00%> (+0.22%) ⬆️

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

Impacted Files Coverage Δ
dandischema/metadata.py 97.14% <100.00%> (+1.06%) ⬆️
dandischema/tests/test_metadata.py 100.00% <100.00%> (ø)
dandischema/tests/test_utils.py 100.00% <100.00%> (ø)
dandischema/utils.py 100.00% <100.00%> (ø)

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 42221bb...9186d30. Read the comment docs.

@satra satra requested a review from yarikoptic June 9, 2021 12:20
@satra
Copy link
Member Author

satra commented Jun 9, 2021

@yarikoptic - a quick review of this would be much appreciated.

regarding adding newlines. they were added to the schema from the schema precommit action when i pushed manually. i'm just adding that here as a default mechanism when we write out the schemas.

(vdir / "dandiset.json").write_text(models.Dandiset.schema_json(indent=2))
(vdir / "asset.json").write_text(models.Asset.schema_json(indent=2))
(vdir / "dandiset.json").write_text(
models.Dandiset.schema_json(indent=2).rstrip("\n") + "\n"
Copy link
Member

Choose a reason for hiding this comment

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

absent trailing new line was an issue?

we don't care about windows here, or python would magically convert line breaks to windows ones?

I would have probably came up with a helper ensure_trailing_space or alike to avoid duplication.

Copy link
Member

Choose a reason for hiding this comment

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

or better, as I have suggested before, I think we should overload schema_json and centralize all our tuneups (indent and trailing line) in there

Copy link
Member Author

Choose a reason for hiding this comment

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

python magically converts or rather both open/write_text does as far as i could tell.

Copy link
Member Author

Choose a reason for hiding this comment

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

i'm still a little hesitant on overwriting schema_json as then we would need to ensure that everything we have is derived from a common BaseModel that just overrides schema_json. doable, but hesitant.

Copy link
Member

Choose a reason for hiding this comment

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

isn't everything relevant here is a subclass of DandiBaseModel or otherwise we would have other issues (since DandiBaseModel does already to_dictrepr and unvalidated and we would fail if it didn't?). Anyways -- could be harmonized after this PR. But the question just keeps coming, so we better deal with it.... I guess next time ;)

@satra
Copy link
Member Author

satra commented Jun 9, 2021

can i merge this now?

@yarikoptic
Copy link
Member

Sure ;-) Let's see how release goes (no new release of schema but new release of library)

@yarikoptic yarikoptic merged commit 94d453a into master Jun 9, 2021
@yarikoptic yarikoptic deleted the fix/migrate branch June 9, 2021 16:17
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 release Create a release when this pr is merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants