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

Multiscales metadata API: only support datasets as lists of dictionaries #165

Merged
merged 3 commits into from
Feb 7, 2022

Conversation

sbesson
Copy link
Member

@sbesson sbesson commented Feb 4, 2022

Follow-up of the discussion in #162, this PR primarily the write_multiscales_metadata API introduced in #149 to only work on datasets passed as list of dictionaries. The writer unit tests are all adjusted for different version of the OME-NGFF format.

Additional unit tests are also added testing various combinations of valid and invalid coordinateTransformations. The transformations validation method is updated to add a few extra checks on the presence of mandatory keys.

@sbesson sbesson requested a review from will-moore February 4, 2022 07:10
@codecov
Copy link

codecov bot commented Feb 4, 2022

Codecov Report

Merging #165 (f2e1341) into master (3e3327c) will increase coverage by 0.40%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #165      +/-   ##
==========================================
+ Coverage   83.53%   83.93%   +0.40%     
==========================================
  Files          12       12              
  Lines        1354     1357       +3     
==========================================
+ Hits         1131     1139       +8     
+ Misses        223      218       -5     
Impacted Files Coverage Δ
ome_zarr/format.py 98.17% <100.00%> (+1.35%) ⬆️
ome_zarr/writer.py 98.11% <100.00%> (+1.79%) ⬆️

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 3e3327c...f2e1341. Read the comment docs.

Copy link
Member

@joshmoore joshmoore left a comment

Choose a reason for hiding this comment

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

I missed most of the overarching discussion, but barring one minor comment, lgtm.

if isinstance(dataset, str):
validated_datasets.append({"path": dataset})
elif isinstance(dataset, dict):
if isinstance(dataset, dict):
Copy link
Member

Choose a reason for hiding this comment

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

This might have been simpler as assert isinstance(dataset, dict)

Copy link
Member

Choose a reason for hiding this comment

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

Now I'm pondering if there's some generic assertion or validation module that one could use to skip for loops where something isn't valid without just throwing a ValueError.

Copy link
Member Author

Choose a reason for hiding this comment

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

No strong opinion on using assert vs conditional and a custom error like ValueError. If we collectively agree on the former version for now, I can quickly go over the codebase after this PR.

My mid-term hope is to replace this internal validation code by a generic validation framework based on schemas/constraints. I expect this should also bring typical features like being able to collect all validation errors like the Validator.iter_errors() API of the jsonschema module.

Copy link
Member

Choose a reason for hiding this comment

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

Exactly. No strong opinion on assert isinstance especially if we'll be reviewing soon anyway.

@sbesson sbesson merged commit b5f07e4 into ome:master Feb 7, 2022
@sbesson sbesson deleted the write_multiscales_datasets_dict branch February 7, 2022 13:16
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