Skip to content

Reduce number of store queries in open(mode='a'). #611

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

Merged
merged 1 commit into from
Oct 2, 2020

Conversation

Carreau
Copy link
Contributor

@Carreau Carreau commented Sep 18, 2020

In case where 'shape' is passed as argument, this will avoid calling
"contains_array" which does store queries, as well as avoid testign if
the array contains a group as anyway this is what we were going to do in
the else case.

This does change behavior in edge case:

  • if shape is passed and the key is a group, we'll try to open as array
    instead of groups.
  • if contains_array or contains_group would have raise we might skip
    over those checks.

Though both of the above case should not be found in user code and
are bugs AFAICT, and would just fail differently.


Let's see if this triggers any test failure.

TODO:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/tutorial.rst
  • Changes documented in docs/release.rst
  • AppVeyor and Travis CI passes
  • Test coverage is 100% (Coveralls passes)

In case where 'shape' is passed as argument, this will avoid calling
"contains_array" which does store queries, as well as avoid testign if
the array contains a group as anyway this is what we were going to do in
the else case.

This does change behavior in edge case:
 - if shape is passed and the key is a group, we'll try to open as array
 instead of groups.
 - if contains_array or contains_group would have raise we might skip
 over those checks.

Though both of the above case should not be found in user code and
are bugs AFAICT, and would just fail differently.
return open_group(store, mode=mode, **kwargs)
elif 'shape' in kwargs:
elif mode == "a":
if "shape" in kwargs or contains_array(store, path):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
if "shape" in kwargs or contains_array(store, path):
if ("shape" in kwargs) or contains_array(store, path):

@alimanfoo alimanfoo added this to the v2.5 milestone Sep 23, 2020
@alimanfoo alimanfoo mentioned this pull request Sep 24, 2020
@Carreau Carreau merged commit d145e0b into zarr-developers:master Oct 2, 2020
@Carreau Carreau deleted the conv-open-a branch October 2, 2020 16:17
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.

3 participants