Create fsstore from filesystem - #911

Merged
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem
May 4, 2022
Merged

Create fsstore from filesystem#911
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem

Conversation

@rabernat

@rabernatrabernat commented Dec 14, 2021

Copy link
Copy Markdown
Contributor

This PR adds a new argument to FSStore which allows one to pass an existing fsspec filesystem object from which to generate the FSStore. The need to initialize an FSStore from an existing filesystem came up in pangeo-forge/pangeo-forge-recipes#254. It seems like this is something people may want to do more generally.

Also fixes#993 by simply removing the check for list-ability when initializing an FSStore.

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
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

Comment threadzarr/storage.py
Comment threadzarr/storage.py
Comment threadzarr/tests/test_storage.py
@codecov

codecovBot commented Dec 14, 2021

Copy link
Copy Markdown

Codecov Report

Merging #911 (c1c9255) into master (d1f590d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@ Coverage Diff @@## master #911 +/- ##
=======================================
Coverage 99.94% 99.94% =======================================
Files 34 34 Lines 13719 13785 +66 =======================================
+ Hits 13712 13778 +66 
Misses 7 7 
Impacted FilesCoverage Δ
zarr/storage.py100.00% <100.00%> (ø)
zarr/tests/test_convenience.py100.00% <100.00%> (ø)
zarr/tests/test_core.py100.00% <100.00%> (ø)
zarr/tests/test_storage.py100.00% <100.00%> (ø)

@rabernat

rabernat commented Jan 31, 2022

Copy link
Copy Markdown
ContributorAuthor

I would like to revive and move forward this PR. Martin, you gave a few helpful comments and ideas above. Would you mind turning these into a more formal review in terms of what you think is needed vs interesting possibility.

What we have here is a tightly scoped and tested PR to unblock a rather serious upstream problem. If there is no major technical debt incurred by this PR, could we consider merging as is (modulo doc updates from checklist) rather than expanding scope? If not, please let us know what else would be required.

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

@rabernat
rabernat requested review from d-v-b and joshmoore and removed request for d-v-bJanuary 31, 2022 18:45
@grlee77

Copy link
Copy Markdown
Contributor

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

Thanks @rabernat, I commented above. If the __init__ signature does not change then this should be pretty easy to merge into the work there.

@joshmoore

Copy link
Copy Markdown
Member

Thanks, @grlee77. From my side, that was the only concern in terms of impact on existing work, @rabernat. @martindurant's point about the general API "burden" seems to be outstanding. Is it that a concrete alternative that doesn't break the API needs proposing from your side, @rabernat?

A side note that testing is currently blocked due to GHA weirdness. @jakirkham and I will try to get that sorted ASAP.

@joshmoore

Copy link
Copy Markdown
Member

@rabernat: would you prefer someone else to propose an alternative?

Comment threadzarr/storage.py
Comment on lines -1331 to -1312
if self.fs.exists(self.path) and not self.fs.isdir(self.path):
raise FSPathExistNotDir(url)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

To fix #993 I have simply removed this check...

Comment on lines -1251 to -1254
filepath = os.path.join(path, self.root + "foo")
with pytest.raises(ValueError):
self.create_store(path=filepath, mode='r')

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

...and its corresponding test.

This test did not do anything other than test the error above. self.create_store does not actually attempt to write any data or list the store.

With the check gone, users will now see an error from fsspec if they try to do an operation that requires listing on an unlistable FSSpec store, as they would already on a generic MutableMapping-based store.

@pep8speaks

pep8speaks commented Apr 5, 2022

Copy link
Copy Markdown

Hello @rabernat! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-05-04 11:10:02 UTC

@martindurantmartindurant left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

very little to comment

Comment threadzarr/storage.py
Comment threadzarr/tests/test_convenience.py
Comment threadzarr/tests/test_convenience.py
@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from e76a376 to cfadc1dCompareApril 7, 2022 14:46
Comment threaddocs/release.rst
Comment on lines +27 to +28
2.11.3
------

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Although 2.11.3 has been released, I noted that the docs had not been updated, so I added it here.

It seems we have skipped release 2.11.2?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Those releases are coming from the 2_11 branch. (See the related #898 (comment))

I assume you intend this for release as a 2.11.x?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Sorry I have clearly not been able to follow that discussion. After reading, I now understand the situation better. Let's discuss at today's SC meeting.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please ping this thread with any decision on which branch to merge into

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@martindurant : @rabernat seemed to think it was ok to hold off on @grlee77's upcoming v3 configuration fix, i.e. this can stay on the branch it is and be released as something >2.11.x. If it looks like we want it in a quick ~=2.11.x release, I can attempt the backport.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I will do whatever the other devs recommend here (either backport to 2.11.x or put this in 2.12.0)

I am confused about how we will maintain a consistent changelog for these two branches. So I am standing by for advice.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

From my POV, this is now complete. Would appreciate any other feedback or otherwise a merge.

@martindurant

Copy link
Copy Markdown
Member

@joshmoore , I see you have been tagged to review. I am happy to put this in, if you don't intend to look.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

This is my first Zarr PR in quite a while, so I just tagged the people I know to review. 😄

@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from 3bc0299 to 36c05edCompareApril 12, 2022 19:56
@rabernat

rabernat commented Apr 21, 2022

Copy link
Copy Markdown
ContributorAuthor

I feel confused about how to move forward with this PR in terms of how to update the changelog (see #911 (comment)). Please help me 🙏. I would love to see this merged soon as I believe it is finished. It is now starting to accumulate conflicts.

@joshmoore

Copy link
Copy Markdown
Member

Sorry for having left you hanging. I think either will be fine @rabernat. Either just add your item to unreleased or copy over from the 2 11 branch. Either way feel free to get this in and I will double check before the next release. (Of whatever branch)

@joshmoorejoshmoore left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've hopefully handled the conflicts with Greg's v3 work. Once this goes green, I'll merge and update the release notes to include previous versions.

@joshmoore

joshmoore commented May 4, 2022

Copy link
Copy Markdown
Member

It looks like the semantics of the update() method have changed with the refactoring for v3:

previous noise
pytest zarr/tests/test_convenience.py -svx -k2
...snip...
> store_to_open.update(store) # copy original store to new unlistable store
zarr/tests/test_convenience.py:305:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <zarr.storage.FSStore object at 0x1ba010970>, other = '/var/folders/z5/txc_jj6x5l5cm81r56ck1n9c0000gn/T/tmp0gy4ji7i', kwds = {}
def update(self, other=(), /, **kwds):
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v
'''
if isinstance(other, Mapping):
for key in other:
self[key] = other[key]
elif hasattr(other, "keys"):
for key in other.keys():
self[key] = other[key]
else:
> for key, value in other:
E ValueError: not enough values to unpack (expected 2, got 1)

That doesn't appear to be related to the type hierarchy:

2.11.2: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)
2.12.x: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)

Still digging in case anyone has an idea.

Edit: the problem was just that store had become a str. 🤦🏽 Fix pushed.

@joshmoore
joshmoore merged commit ab6b355 into zarr-developers:masterMay 4, 2022
@rabernat

Copy link
Copy Markdown
ContributorAuthor

Thanks for finishing this up Josh! I really appreciate it!

Sign up for freeto 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.

Cannot create FSStore for unlistable http URLs

5 participants

@rabernat@grlee77@joshmoore@pep8speaks@martindurant
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Create fsstore from filesystem - #911

Merged
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem
May 4, 2022
Merged

Create fsstore from filesystem#911
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem

Conversation

@rabernat

@rabernatrabernat commented Dec 14, 2021

Copy link
Copy Markdown
Contributor

This PR adds a new argument to FSStore which allows one to pass an existing fsspec filesystem object from which to generate the FSStore. The need to initialize an FSStore from an existing filesystem came up in pangeo-forge/pangeo-forge-recipes#254. It seems like this is something people may want to do more generally.

Also fixes#993 by simply removing the check for list-ability when initializing an FSStore.

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
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

Comment threadzarr/storage.py
Comment threadzarr/storage.py
Comment threadzarr/tests/test_storage.py
@codecov

codecovBot commented Dec 14, 2021

Copy link
Copy Markdown

Codecov Report

Merging #911 (c1c9255) into master (d1f590d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@ Coverage Diff @@## master #911 +/- ##
=======================================
Coverage 99.94% 99.94% =======================================
Files 34 34 Lines 13719 13785 +66 =======================================
+ Hits 13712 13778 +66 
Misses 7 7 
Impacted FilesCoverage Δ
zarr/storage.py100.00% <100.00%> (ø)
zarr/tests/test_convenience.py100.00% <100.00%> (ø)
zarr/tests/test_core.py100.00% <100.00%> (ø)
zarr/tests/test_storage.py100.00% <100.00%> (ø)

@rabernat

rabernat commented Jan 31, 2022

Copy link
Copy Markdown
ContributorAuthor

I would like to revive and move forward this PR. Martin, you gave a few helpful comments and ideas above. Would you mind turning these into a more formal review in terms of what you think is needed vs interesting possibility.

What we have here is a tightly scoped and tested PR to unblock a rather serious upstream problem. If there is no major technical debt incurred by this PR, could we consider merging as is (modulo doc updates from checklist) rather than expanding scope? If not, please let us know what else would be required.

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

@rabernat
rabernat requested review from d-v-b and joshmoore and removed request for d-v-bJanuary 31, 2022 18:45
@grlee77

Copy link
Copy Markdown
Contributor

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

Thanks @rabernat, I commented above. If the __init__ signature does not change then this should be pretty easy to merge into the work there.

@joshmoore

Copy link
Copy Markdown
Member

Thanks, @grlee77. From my side, that was the only concern in terms of impact on existing work, @rabernat. @martindurant's point about the general API "burden" seems to be outstanding. Is it that a concrete alternative that doesn't break the API needs proposing from your side, @rabernat?

A side note that testing is currently blocked due to GHA weirdness. @jakirkham and I will try to get that sorted ASAP.

@joshmoore

Copy link
Copy Markdown
Member

@rabernat: would you prefer someone else to propose an alternative?

Comment threadzarr/storage.py
Comment on lines -1331 to -1312
if self.fs.exists(self.path) and not self.fs.isdir(self.path):
raise FSPathExistNotDir(url)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

To fix #993 I have simply removed this check...

Comment on lines -1251 to -1254
filepath = os.path.join(path, self.root + "foo")
with pytest.raises(ValueError):
self.create_store(path=filepath, mode='r')

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

...and its corresponding test.

This test did not do anything other than test the error above. self.create_store does not actually attempt to write any data or list the store.

With the check gone, users will now see an error from fsspec if they try to do an operation that requires listing on an unlistable FSSpec store, as they would already on a generic MutableMapping-based store.

@pep8speaks

pep8speaks commented Apr 5, 2022

Copy link
Copy Markdown

Hello @rabernat! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-05-04 11:10:02 UTC

@martindurantmartindurant left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

very little to comment

Comment threadzarr/storage.py
Comment threadzarr/tests/test_convenience.py
Comment threadzarr/tests/test_convenience.py
@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from e76a376 to cfadc1dCompareApril 7, 2022 14:46
Comment threaddocs/release.rst
Comment on lines +27 to +28
2.11.3
------

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Although 2.11.3 has been released, I noted that the docs had not been updated, so I added it here.

It seems we have skipped release 2.11.2?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Those releases are coming from the 2_11 branch. (See the related #898 (comment))

I assume you intend this for release as a 2.11.x?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Sorry I have clearly not been able to follow that discussion. After reading, I now understand the situation better. Let's discuss at today's SC meeting.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please ping this thread with any decision on which branch to merge into

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@martindurant : @rabernat seemed to think it was ok to hold off on @grlee77's upcoming v3 configuration fix, i.e. this can stay on the branch it is and be released as something >2.11.x. If it looks like we want it in a quick ~=2.11.x release, I can attempt the backport.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I will do whatever the other devs recommend here (either backport to 2.11.x or put this in 2.12.0)

I am confused about how we will maintain a consistent changelog for these two branches. So I am standing by for advice.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

From my POV, this is now complete. Would appreciate any other feedback or otherwise a merge.

@martindurant

Copy link
Copy Markdown
Member

@joshmoore , I see you have been tagged to review. I am happy to put this in, if you don't intend to look.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

This is my first Zarr PR in quite a while, so I just tagged the people I know to review. 😄

@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from 3bc0299 to 36c05edCompareApril 12, 2022 19:56
@rabernat

rabernat commented Apr 21, 2022

Copy link
Copy Markdown
ContributorAuthor

I feel confused about how to move forward with this PR in terms of how to update the changelog (see #911 (comment)). Please help me 🙏. I would love to see this merged soon as I believe it is finished. It is now starting to accumulate conflicts.

@joshmoore

Copy link
Copy Markdown
Member

Sorry for having left you hanging. I think either will be fine @rabernat. Either just add your item to unreleased or copy over from the 2 11 branch. Either way feel free to get this in and I will double check before the next release. (Of whatever branch)

@joshmoorejoshmoore left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've hopefully handled the conflicts with Greg's v3 work. Once this goes green, I'll merge and update the release notes to include previous versions.

@joshmoore

joshmoore commented May 4, 2022

Copy link
Copy Markdown
Member

It looks like the semantics of the update() method have changed with the refactoring for v3:

previous noise
pytest zarr/tests/test_convenience.py -svx -k2
...snip...
> store_to_open.update(store) # copy original store to new unlistable store
zarr/tests/test_convenience.py:305:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <zarr.storage.FSStore object at 0x1ba010970>, other = '/var/folders/z5/txc_jj6x5l5cm81r56ck1n9c0000gn/T/tmp0gy4ji7i', kwds = {}
def update(self, other=(), /, **kwds):
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v
'''
if isinstance(other, Mapping):
for key in other:
self[key] = other[key]
elif hasattr(other, "keys"):
for key in other.keys():
self[key] = other[key]
else:
> for key, value in other:
E ValueError: not enough values to unpack (expected 2, got 1)

That doesn't appear to be related to the type hierarchy:

2.11.2: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)
2.12.x: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)

Still digging in case anyone has an idea.

Edit: the problem was just that store had become a str. 🤦🏽 Fix pushed.

@joshmoore
joshmoore merged commit ab6b355 into zarr-developers:masterMay 4, 2022
@rabernat

Copy link
Copy Markdown
ContributorAuthor

Thanks for finishing this up Josh! I really appreciate it!

Sign up for freeto 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.

Cannot create FSStore for unlistable http URLs

5 participants

@rabernat@grlee77@joshmoore@pep8speaks@martindurant
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Create fsstore from filesystem - #911

Merged
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem
May 4, 2022
Merged

Create fsstore from filesystem#911
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem

Conversation

@rabernat

@rabernatrabernat commented Dec 14, 2021

Copy link
Copy Markdown
Contributor

This PR adds a new argument to FSStore which allows one to pass an existing fsspec filesystem object from which to generate the FSStore. The need to initialize an FSStore from an existing filesystem came up in pangeo-forge/pangeo-forge-recipes#254. It seems like this is something people may want to do more generally.

Also fixes#993 by simply removing the check for list-ability when initializing an FSStore.

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
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

Comment threadzarr/storage.py
Comment threadzarr/storage.py
Comment threadzarr/tests/test_storage.py
@codecov

codecovBot commented Dec 14, 2021

Copy link
Copy Markdown

Codecov Report

Merging #911 (c1c9255) into master (d1f590d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@ Coverage Diff @@## master #911 +/- ##
=======================================
Coverage 99.94% 99.94% =======================================
Files 34 34 Lines 13719 13785 +66 =======================================
+ Hits 13712 13778 +66 
Misses 7 7 
Impacted FilesCoverage Δ
zarr/storage.py100.00% <100.00%> (ø)
zarr/tests/test_convenience.py100.00% <100.00%> (ø)
zarr/tests/test_core.py100.00% <100.00%> (ø)
zarr/tests/test_storage.py100.00% <100.00%> (ø)

@rabernat

rabernat commented Jan 31, 2022

Copy link
Copy Markdown
ContributorAuthor

I would like to revive and move forward this PR. Martin, you gave a few helpful comments and ideas above. Would you mind turning these into a more formal review in terms of what you think is needed vs interesting possibility.

What we have here is a tightly scoped and tested PR to unblock a rather serious upstream problem. If there is no major technical debt incurred by this PR, could we consider merging as is (modulo doc updates from checklist) rather than expanding scope? If not, please let us know what else would be required.

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

@rabernat
rabernat requested review from d-v-b and joshmoore and removed request for d-v-bJanuary 31, 2022 18:45
@grlee77

Copy link
Copy Markdown
Contributor

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

Thanks @rabernat, I commented above. If the __init__ signature does not change then this should be pretty easy to merge into the work there.

@joshmoore

Copy link
Copy Markdown
Member

Thanks, @grlee77. From my side, that was the only concern in terms of impact on existing work, @rabernat. @martindurant's point about the general API "burden" seems to be outstanding. Is it that a concrete alternative that doesn't break the API needs proposing from your side, @rabernat?

A side note that testing is currently blocked due to GHA weirdness. @jakirkham and I will try to get that sorted ASAP.

@joshmoore

Copy link
Copy Markdown
Member

@rabernat: would you prefer someone else to propose an alternative?

Comment threadzarr/storage.py
Comment on lines -1331 to -1312
if self.fs.exists(self.path) and not self.fs.isdir(self.path):
raise FSPathExistNotDir(url)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

To fix #993 I have simply removed this check...

Comment on lines -1251 to -1254
filepath = os.path.join(path, self.root + "foo")
with pytest.raises(ValueError):
self.create_store(path=filepath, mode='r')

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

...and its corresponding test.

This test did not do anything other than test the error above. self.create_store does not actually attempt to write any data or list the store.

With the check gone, users will now see an error from fsspec if they try to do an operation that requires listing on an unlistable FSSpec store, as they would already on a generic MutableMapping-based store.

@pep8speaks

pep8speaks commented Apr 5, 2022

Copy link
Copy Markdown

Hello @rabernat! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-05-04 11:10:02 UTC

@martindurantmartindurant left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

very little to comment

Comment threadzarr/storage.py
Comment threadzarr/tests/test_convenience.py
Comment threadzarr/tests/test_convenience.py
@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from e76a376 to cfadc1dCompareApril 7, 2022 14:46
Comment threaddocs/release.rst
Comment on lines +27 to +28
2.11.3
------

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Although 2.11.3 has been released, I noted that the docs had not been updated, so I added it here.

It seems we have skipped release 2.11.2?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Those releases are coming from the 2_11 branch. (See the related #898 (comment))

I assume you intend this for release as a 2.11.x?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Sorry I have clearly not been able to follow that discussion. After reading, I now understand the situation better. Let's discuss at today's SC meeting.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please ping this thread with any decision on which branch to merge into

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@martindurant : @rabernat seemed to think it was ok to hold off on @grlee77's upcoming v3 configuration fix, i.e. this can stay on the branch it is and be released as something >2.11.x. If it looks like we want it in a quick ~=2.11.x release, I can attempt the backport.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I will do whatever the other devs recommend here (either backport to 2.11.x or put this in 2.12.0)

I am confused about how we will maintain a consistent changelog for these two branches. So I am standing by for advice.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

From my POV, this is now complete. Would appreciate any other feedback or otherwise a merge.

@martindurant

Copy link
Copy Markdown
Member

@joshmoore , I see you have been tagged to review. I am happy to put this in, if you don't intend to look.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

This is my first Zarr PR in quite a while, so I just tagged the people I know to review. 😄

@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from 3bc0299 to 36c05edCompareApril 12, 2022 19:56
@rabernat

rabernat commented Apr 21, 2022

Copy link
Copy Markdown
ContributorAuthor

I feel confused about how to move forward with this PR in terms of how to update the changelog (see #911 (comment)). Please help me 🙏. I would love to see this merged soon as I believe it is finished. It is now starting to accumulate conflicts.

@joshmoore

Copy link
Copy Markdown
Member

Sorry for having left you hanging. I think either will be fine @rabernat. Either just add your item to unreleased or copy over from the 2 11 branch. Either way feel free to get this in and I will double check before the next release. (Of whatever branch)

@joshmoorejoshmoore left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've hopefully handled the conflicts with Greg's v3 work. Once this goes green, I'll merge and update the release notes to include previous versions.

@joshmoore

joshmoore commented May 4, 2022

Copy link
Copy Markdown
Member

It looks like the semantics of the update() method have changed with the refactoring for v3:

previous noise
pytest zarr/tests/test_convenience.py -svx -k2
...snip...
> store_to_open.update(store) # copy original store to new unlistable store
zarr/tests/test_convenience.py:305:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <zarr.storage.FSStore object at 0x1ba010970>, other = '/var/folders/z5/txc_jj6x5l5cm81r56ck1n9c0000gn/T/tmp0gy4ji7i', kwds = {}
def update(self, other=(), /, **kwds):
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v
'''
if isinstance(other, Mapping):
for key in other:
self[key] = other[key]
elif hasattr(other, "keys"):
for key in other.keys():
self[key] = other[key]
else:
> for key, value in other:
E ValueError: not enough values to unpack (expected 2, got 1)

That doesn't appear to be related to the type hierarchy:

2.11.2: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)
2.12.x: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)

Still digging in case anyone has an idea.

Edit: the problem was just that store had become a str. 🤦🏽 Fix pushed.

@joshmoore
joshmoore merged commit ab6b355 into zarr-developers:masterMay 4, 2022
@rabernat

Copy link
Copy Markdown
ContributorAuthor

Thanks for finishing this up Josh! I really appreciate it!

Sign up for freeto 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.

Cannot create FSStore for unlistable http URLs

5 participants

@rabernat@grlee77@joshmoore@pep8speaks@martindurant
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Create fsstore from filesystem - #911

Merged
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem
May 4, 2022
Merged

Create fsstore from filesystem#911
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem

Conversation

@rabernat

@rabernatrabernat commented Dec 14, 2021

Copy link
Copy Markdown
Contributor

This PR adds a new argument to FSStore which allows one to pass an existing fsspec filesystem object from which to generate the FSStore. The need to initialize an FSStore from an existing filesystem came up in pangeo-forge/pangeo-forge-recipes#254. It seems like this is something people may want to do more generally.

Also fixes#993 by simply removing the check for list-ability when initializing an FSStore.

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
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

Comment threadzarr/storage.py
Comment threadzarr/storage.py
Comment threadzarr/tests/test_storage.py
@codecov

codecovBot commented Dec 14, 2021

Copy link
Copy Markdown

Codecov Report

Merging #911 (c1c9255) into master (d1f590d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@ Coverage Diff @@## master #911 +/- ##
=======================================
Coverage 99.94% 99.94% =======================================
Files 34 34 Lines 13719 13785 +66 =======================================
+ Hits 13712 13778 +66 
Misses 7 7 
Impacted FilesCoverage Δ
zarr/storage.py100.00% <100.00%> (ø)
zarr/tests/test_convenience.py100.00% <100.00%> (ø)
zarr/tests/test_core.py100.00% <100.00%> (ø)
zarr/tests/test_storage.py100.00% <100.00%> (ø)

@rabernat

rabernat commented Jan 31, 2022

Copy link
Copy Markdown
ContributorAuthor

I would like to revive and move forward this PR. Martin, you gave a few helpful comments and ideas above. Would you mind turning these into a more formal review in terms of what you think is needed vs interesting possibility.

What we have here is a tightly scoped and tested PR to unblock a rather serious upstream problem. If there is no major technical debt incurred by this PR, could we consider merging as is (modulo doc updates from checklist) rather than expanding scope? If not, please let us know what else would be required.

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

@rabernat
rabernat requested review from d-v-b and joshmoore and removed request for d-v-bJanuary 31, 2022 18:45
@grlee77

Copy link
Copy Markdown
Contributor

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

Thanks @rabernat, I commented above. If the __init__ signature does not change then this should be pretty easy to merge into the work there.

@joshmoore

Copy link
Copy Markdown
Member

Thanks, @grlee77. From my side, that was the only concern in terms of impact on existing work, @rabernat. @martindurant's point about the general API "burden" seems to be outstanding. Is it that a concrete alternative that doesn't break the API needs proposing from your side, @rabernat?

A side note that testing is currently blocked due to GHA weirdness. @jakirkham and I will try to get that sorted ASAP.

@joshmoore

Copy link
Copy Markdown
Member

@rabernat: would you prefer someone else to propose an alternative?

Comment threadzarr/storage.py
Comment on lines -1331 to -1312
if self.fs.exists(self.path) and not self.fs.isdir(self.path):
raise FSPathExistNotDir(url)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

To fix #993 I have simply removed this check...

Comment on lines -1251 to -1254
filepath = os.path.join(path, self.root + "foo")
with pytest.raises(ValueError):
self.create_store(path=filepath, mode='r')

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

...and its corresponding test.

This test did not do anything other than test the error above. self.create_store does not actually attempt to write any data or list the store.

With the check gone, users will now see an error from fsspec if they try to do an operation that requires listing on an unlistable FSSpec store, as they would already on a generic MutableMapping-based store.

@pep8speaks

pep8speaks commented Apr 5, 2022

Copy link
Copy Markdown

Hello @rabernat! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-05-04 11:10:02 UTC

@martindurantmartindurant left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

very little to comment

Comment threadzarr/storage.py
Comment threadzarr/tests/test_convenience.py
Comment threadzarr/tests/test_convenience.py
@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from e76a376 to cfadc1dCompareApril 7, 2022 14:46
Comment threaddocs/release.rst
Comment on lines +27 to +28
2.11.3
------

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Although 2.11.3 has been released, I noted that the docs had not been updated, so I added it here.

It seems we have skipped release 2.11.2?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Those releases are coming from the 2_11 branch. (See the related #898 (comment))

I assume you intend this for release as a 2.11.x?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Sorry I have clearly not been able to follow that discussion. After reading, I now understand the situation better. Let's discuss at today's SC meeting.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please ping this thread with any decision on which branch to merge into

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@martindurant : @rabernat seemed to think it was ok to hold off on @grlee77's upcoming v3 configuration fix, i.e. this can stay on the branch it is and be released as something >2.11.x. If it looks like we want it in a quick ~=2.11.x release, I can attempt the backport.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I will do whatever the other devs recommend here (either backport to 2.11.x or put this in 2.12.0)

I am confused about how we will maintain a consistent changelog for these two branches. So I am standing by for advice.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

From my POV, this is now complete. Would appreciate any other feedback or otherwise a merge.

@martindurant

Copy link
Copy Markdown
Member

@joshmoore , I see you have been tagged to review. I am happy to put this in, if you don't intend to look.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

This is my first Zarr PR in quite a while, so I just tagged the people I know to review. 😄

@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from 3bc0299 to 36c05edCompareApril 12, 2022 19:56
@rabernat

rabernat commented Apr 21, 2022

Copy link
Copy Markdown
ContributorAuthor

I feel confused about how to move forward with this PR in terms of how to update the changelog (see #911 (comment)). Please help me 🙏. I would love to see this merged soon as I believe it is finished. It is now starting to accumulate conflicts.

@joshmoore

Copy link
Copy Markdown
Member

Sorry for having left you hanging. I think either will be fine @rabernat. Either just add your item to unreleased or copy over from the 2 11 branch. Either way feel free to get this in and I will double check before the next release. (Of whatever branch)

@joshmoorejoshmoore left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've hopefully handled the conflicts with Greg's v3 work. Once this goes green, I'll merge and update the release notes to include previous versions.

@joshmoore

joshmoore commented May 4, 2022

Copy link
Copy Markdown
Member

It looks like the semantics of the update() method have changed with the refactoring for v3:

previous noise
pytest zarr/tests/test_convenience.py -svx -k2
...snip...
> store_to_open.update(store) # copy original store to new unlistable store
zarr/tests/test_convenience.py:305:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <zarr.storage.FSStore object at 0x1ba010970>, other = '/var/folders/z5/txc_jj6x5l5cm81r56ck1n9c0000gn/T/tmp0gy4ji7i', kwds = {}
def update(self, other=(), /, **kwds):
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v
'''
if isinstance(other, Mapping):
for key in other:
self[key] = other[key]
elif hasattr(other, "keys"):
for key in other.keys():
self[key] = other[key]
else:
> for key, value in other:
E ValueError: not enough values to unpack (expected 2, got 1)

That doesn't appear to be related to the type hierarchy:

2.11.2: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)
2.12.x: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)

Still digging in case anyone has an idea.

Edit: the problem was just that store had become a str. 🤦🏽 Fix pushed.

@joshmoore
joshmoore merged commit ab6b355 into zarr-developers:masterMay 4, 2022
@rabernat

Copy link
Copy Markdown
ContributorAuthor

Thanks for finishing this up Josh! I really appreciate it!

Sign up for freeto 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.

Cannot create FSStore for unlistable http URLs

5 participants

@rabernat@grlee77@joshmoore@pep8speaks@martindurant
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Create fsstore from filesystem - #911

Merged
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem
May 4, 2022
Merged

Create fsstore from filesystem#911
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem

Conversation

@rabernat

@rabernatrabernat commented Dec 14, 2021

Copy link
Copy Markdown
Contributor

This PR adds a new argument to FSStore which allows one to pass an existing fsspec filesystem object from which to generate the FSStore. The need to initialize an FSStore from an existing filesystem came up in pangeo-forge/pangeo-forge-recipes#254. It seems like this is something people may want to do more generally.

Also fixes#993 by simply removing the check for list-ability when initializing an FSStore.

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
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

Comment threadzarr/storage.py
Comment threadzarr/storage.py
Comment threadzarr/tests/test_storage.py
@codecov

codecovBot commented Dec 14, 2021

Copy link
Copy Markdown

Codecov Report

Merging #911 (c1c9255) into master (d1f590d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@ Coverage Diff @@## master #911 +/- ##
=======================================
Coverage 99.94% 99.94% =======================================
Files 34 34 Lines 13719 13785 +66 =======================================
+ Hits 13712 13778 +66 
Misses 7 7 
Impacted FilesCoverage Δ
zarr/storage.py100.00% <100.00%> (ø)
zarr/tests/test_convenience.py100.00% <100.00%> (ø)
zarr/tests/test_core.py100.00% <100.00%> (ø)
zarr/tests/test_storage.py100.00% <100.00%> (ø)

@rabernat

rabernat commented Jan 31, 2022

Copy link
Copy Markdown
ContributorAuthor

I would like to revive and move forward this PR. Martin, you gave a few helpful comments and ideas above. Would you mind turning these into a more formal review in terms of what you think is needed vs interesting possibility.

What we have here is a tightly scoped and tested PR to unblock a rather serious upstream problem. If there is no major technical debt incurred by this PR, could we consider merging as is (modulo doc updates from checklist) rather than expanding scope? If not, please let us know what else would be required.

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

@rabernat
rabernat requested review from d-v-b and joshmoore and removed request for d-v-bJanuary 31, 2022 18:45
@grlee77

Copy link
Copy Markdown
Contributor

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

Thanks @rabernat, I commented above. If the __init__ signature does not change then this should be pretty easy to merge into the work there.

@joshmoore

Copy link
Copy Markdown
Member

Thanks, @grlee77. From my side, that was the only concern in terms of impact on existing work, @rabernat. @martindurant's point about the general API "burden" seems to be outstanding. Is it that a concrete alternative that doesn't break the API needs proposing from your side, @rabernat?

A side note that testing is currently blocked due to GHA weirdness. @jakirkham and I will try to get that sorted ASAP.

@joshmoore

Copy link
Copy Markdown
Member

@rabernat: would you prefer someone else to propose an alternative?

Comment threadzarr/storage.py
Comment on lines -1331 to -1312
if self.fs.exists(self.path) and not self.fs.isdir(self.path):
raise FSPathExistNotDir(url)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

To fix #993 I have simply removed this check...

Comment on lines -1251 to -1254
filepath = os.path.join(path, self.root + "foo")
with pytest.raises(ValueError):
self.create_store(path=filepath, mode='r')

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

...and its corresponding test.

This test did not do anything other than test the error above. self.create_store does not actually attempt to write any data or list the store.

With the check gone, users will now see an error from fsspec if they try to do an operation that requires listing on an unlistable FSSpec store, as they would already on a generic MutableMapping-based store.

@pep8speaks

pep8speaks commented Apr 5, 2022

Copy link
Copy Markdown

Hello @rabernat! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-05-04 11:10:02 UTC

@martindurantmartindurant left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

very little to comment

Comment threadzarr/storage.py
Comment threadzarr/tests/test_convenience.py
Comment threadzarr/tests/test_convenience.py
@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from e76a376 to cfadc1dCompareApril 7, 2022 14:46
Comment threaddocs/release.rst
Comment on lines +27 to +28
2.11.3
------

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Although 2.11.3 has been released, I noted that the docs had not been updated, so I added it here.

It seems we have skipped release 2.11.2?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Those releases are coming from the 2_11 branch. (See the related #898 (comment))

I assume you intend this for release as a 2.11.x?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Sorry I have clearly not been able to follow that discussion. After reading, I now understand the situation better. Let's discuss at today's SC meeting.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please ping this thread with any decision on which branch to merge into

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@martindurant : @rabernat seemed to think it was ok to hold off on @grlee77's upcoming v3 configuration fix, i.e. this can stay on the branch it is and be released as something >2.11.x. If it looks like we want it in a quick ~=2.11.x release, I can attempt the backport.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I will do whatever the other devs recommend here (either backport to 2.11.x or put this in 2.12.0)

I am confused about how we will maintain a consistent changelog for these two branches. So I am standing by for advice.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

From my POV, this is now complete. Would appreciate any other feedback or otherwise a merge.

@martindurant

Copy link
Copy Markdown
Member

@joshmoore , I see you have been tagged to review. I am happy to put this in, if you don't intend to look.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

This is my first Zarr PR in quite a while, so I just tagged the people I know to review. 😄

@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from 3bc0299 to 36c05edCompareApril 12, 2022 19:56
@rabernat

rabernat commented Apr 21, 2022

Copy link
Copy Markdown
ContributorAuthor

I feel confused about how to move forward with this PR in terms of how to update the changelog (see #911 (comment)). Please help me 🙏. I would love to see this merged soon as I believe it is finished. It is now starting to accumulate conflicts.

@joshmoore

Copy link
Copy Markdown
Member

Sorry for having left you hanging. I think either will be fine @rabernat. Either just add your item to unreleased or copy over from the 2 11 branch. Either way feel free to get this in and I will double check before the next release. (Of whatever branch)

@joshmoorejoshmoore left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've hopefully handled the conflicts with Greg's v3 work. Once this goes green, I'll merge and update the release notes to include previous versions.

@joshmoore

joshmoore commented May 4, 2022

Copy link
Copy Markdown
Member

It looks like the semantics of the update() method have changed with the refactoring for v3:

previous noise
pytest zarr/tests/test_convenience.py -svx -k2
...snip...
> store_to_open.update(store) # copy original store to new unlistable store
zarr/tests/test_convenience.py:305:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <zarr.storage.FSStore object at 0x1ba010970>, other = '/var/folders/z5/txc_jj6x5l5cm81r56ck1n9c0000gn/T/tmp0gy4ji7i', kwds = {}
def update(self, other=(), /, **kwds):
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v
'''
if isinstance(other, Mapping):
for key in other:
self[key] = other[key]
elif hasattr(other, "keys"):
for key in other.keys():
self[key] = other[key]
else:
> for key, value in other:
E ValueError: not enough values to unpack (expected 2, got 1)

That doesn't appear to be related to the type hierarchy:

2.11.2: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)
2.12.x: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)

Still digging in case anyone has an idea.

Edit: the problem was just that store had become a str. 🤦🏽 Fix pushed.

@joshmoore
joshmoore merged commit ab6b355 into zarr-developers:masterMay 4, 2022
@rabernat

Copy link
Copy Markdown
ContributorAuthor

Thanks for finishing this up Josh! I really appreciate it!

Sign up for freeto 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.

Cannot create FSStore for unlistable http URLs

5 participants

@rabernat@grlee77@joshmoore@pep8speaks@martindurant
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Create fsstore from filesystem - #911

Merged
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem
May 4, 2022
Merged

Create fsstore from filesystem#911
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem

Conversation

@rabernat

@rabernatrabernat commented Dec 14, 2021

Copy link
Copy Markdown
Contributor

This PR adds a new argument to FSStore which allows one to pass an existing fsspec filesystem object from which to generate the FSStore. The need to initialize an FSStore from an existing filesystem came up in pangeo-forge/pangeo-forge-recipes#254. It seems like this is something people may want to do more generally.

Also fixes#993 by simply removing the check for list-ability when initializing an FSStore.

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
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

Comment threadzarr/storage.py
Comment threadzarr/storage.py
Comment threadzarr/tests/test_storage.py
@codecov

codecovBot commented Dec 14, 2021

Copy link
Copy Markdown

Codecov Report

Merging #911 (c1c9255) into master (d1f590d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@ Coverage Diff @@## master #911 +/- ##
=======================================
Coverage 99.94% 99.94% =======================================
Files 34 34 Lines 13719 13785 +66 =======================================
+ Hits 13712 13778 +66 
Misses 7 7 
Impacted FilesCoverage Δ
zarr/storage.py100.00% <100.00%> (ø)
zarr/tests/test_convenience.py100.00% <100.00%> (ø)
zarr/tests/test_core.py100.00% <100.00%> (ø)
zarr/tests/test_storage.py100.00% <100.00%> (ø)

@rabernat

rabernat commented Jan 31, 2022

Copy link
Copy Markdown
ContributorAuthor

I would like to revive and move forward this PR. Martin, you gave a few helpful comments and ideas above. Would you mind turning these into a more formal review in terms of what you think is needed vs interesting possibility.

What we have here is a tightly scoped and tested PR to unblock a rather serious upstream problem. If there is no major technical debt incurred by this PR, could we consider merging as is (modulo doc updates from checklist) rather than expanding scope? If not, please let us know what else would be required.

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

@rabernat
rabernat requested review from d-v-b and joshmoore and removed request for d-v-bJanuary 31, 2022 18:45
@grlee77

Copy link
Copy Markdown
Contributor

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

Thanks @rabernat, I commented above. If the __init__ signature does not change then this should be pretty easy to merge into the work there.

@joshmoore

Copy link
Copy Markdown
Member

Thanks, @grlee77. From my side, that was the only concern in terms of impact on existing work, @rabernat. @martindurant's point about the general API "burden" seems to be outstanding. Is it that a concrete alternative that doesn't break the API needs proposing from your side, @rabernat?

A side note that testing is currently blocked due to GHA weirdness. @jakirkham and I will try to get that sorted ASAP.

@joshmoore

Copy link
Copy Markdown
Member

@rabernat: would you prefer someone else to propose an alternative?

Comment threadzarr/storage.py
Comment on lines -1331 to -1312
if self.fs.exists(self.path) and not self.fs.isdir(self.path):
raise FSPathExistNotDir(url)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

To fix #993 I have simply removed this check...

Comment on lines -1251 to -1254
filepath = os.path.join(path, self.root + "foo")
with pytest.raises(ValueError):
self.create_store(path=filepath, mode='r')

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

...and its corresponding test.

This test did not do anything other than test the error above. self.create_store does not actually attempt to write any data or list the store.

With the check gone, users will now see an error from fsspec if they try to do an operation that requires listing on an unlistable FSSpec store, as they would already on a generic MutableMapping-based store.

@pep8speaks

pep8speaks commented Apr 5, 2022

Copy link
Copy Markdown

Hello @rabernat! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-05-04 11:10:02 UTC

@martindurantmartindurant left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

very little to comment

Comment threadzarr/storage.py
Comment threadzarr/tests/test_convenience.py
Comment threadzarr/tests/test_convenience.py
@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from e76a376 to cfadc1dCompareApril 7, 2022 14:46
Comment threaddocs/release.rst
Comment on lines +27 to +28
2.11.3
------

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Although 2.11.3 has been released, I noted that the docs had not been updated, so I added it here.

It seems we have skipped release 2.11.2?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Those releases are coming from the 2_11 branch. (See the related #898 (comment))

I assume you intend this for release as a 2.11.x?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Sorry I have clearly not been able to follow that discussion. After reading, I now understand the situation better. Let's discuss at today's SC meeting.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please ping this thread with any decision on which branch to merge into

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@martindurant : @rabernat seemed to think it was ok to hold off on @grlee77's upcoming v3 configuration fix, i.e. this can stay on the branch it is and be released as something >2.11.x. If it looks like we want it in a quick ~=2.11.x release, I can attempt the backport.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I will do whatever the other devs recommend here (either backport to 2.11.x or put this in 2.12.0)

I am confused about how we will maintain a consistent changelog for these two branches. So I am standing by for advice.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

From my POV, this is now complete. Would appreciate any other feedback or otherwise a merge.

@martindurant

Copy link
Copy Markdown
Member

@joshmoore , I see you have been tagged to review. I am happy to put this in, if you don't intend to look.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

This is my first Zarr PR in quite a while, so I just tagged the people I know to review. 😄

@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from 3bc0299 to 36c05edCompareApril 12, 2022 19:56
@rabernat

rabernat commented Apr 21, 2022

Copy link
Copy Markdown
ContributorAuthor

I feel confused about how to move forward with this PR in terms of how to update the changelog (see #911 (comment)). Please help me 🙏. I would love to see this merged soon as I believe it is finished. It is now starting to accumulate conflicts.

@joshmoore

Copy link
Copy Markdown
Member

Sorry for having left you hanging. I think either will be fine @rabernat. Either just add your item to unreleased or copy over from the 2 11 branch. Either way feel free to get this in and I will double check before the next release. (Of whatever branch)

@joshmoorejoshmoore left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've hopefully handled the conflicts with Greg's v3 work. Once this goes green, I'll merge and update the release notes to include previous versions.

@joshmoore

joshmoore commented May 4, 2022

Copy link
Copy Markdown
Member

It looks like the semantics of the update() method have changed with the refactoring for v3:

previous noise
pytest zarr/tests/test_convenience.py -svx -k2
...snip...
> store_to_open.update(store) # copy original store to new unlistable store
zarr/tests/test_convenience.py:305:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <zarr.storage.FSStore object at 0x1ba010970>, other = '/var/folders/z5/txc_jj6x5l5cm81r56ck1n9c0000gn/T/tmp0gy4ji7i', kwds = {}
def update(self, other=(), /, **kwds):
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v
'''
if isinstance(other, Mapping):
for key in other:
self[key] = other[key]
elif hasattr(other, "keys"):
for key in other.keys():
self[key] = other[key]
else:
> for key, value in other:
E ValueError: not enough values to unpack (expected 2, got 1)

That doesn't appear to be related to the type hierarchy:

2.11.2: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)
2.12.x: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)

Still digging in case anyone has an idea.

Edit: the problem was just that store had become a str. 🤦🏽 Fix pushed.

@joshmoore
joshmoore merged commit ab6b355 into zarr-developers:masterMay 4, 2022
@rabernat

Copy link
Copy Markdown
ContributorAuthor

Thanks for finishing this up Josh! I really appreciate it!

Sign up for freeto 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.

Cannot create FSStore for unlistable http URLs

5 participants

@rabernat@grlee77@joshmoore@pep8speaks@martindurant
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Create fsstore from filesystem - #911

Merged
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem
May 4, 2022
Merged

Create fsstore from filesystem#911
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem

Conversation

@rabernat

@rabernatrabernat commented Dec 14, 2021

Copy link
Copy Markdown
Contributor

This PR adds a new argument to FSStore which allows one to pass an existing fsspec filesystem object from which to generate the FSStore. The need to initialize an FSStore from an existing filesystem came up in pangeo-forge/pangeo-forge-recipes#254. It seems like this is something people may want to do more generally.

Also fixes#993 by simply removing the check for list-ability when initializing an FSStore.

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
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

Comment threadzarr/storage.py
Comment threadzarr/storage.py
Comment threadzarr/tests/test_storage.py
@codecov

codecovBot commented Dec 14, 2021

Copy link
Copy Markdown

Codecov Report

Merging #911 (c1c9255) into master (d1f590d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@ Coverage Diff @@## master #911 +/- ##
=======================================
Coverage 99.94% 99.94% =======================================
Files 34 34 Lines 13719 13785 +66 =======================================
+ Hits 13712 13778 +66 
Misses 7 7 
Impacted FilesCoverage Δ
zarr/storage.py100.00% <100.00%> (ø)
zarr/tests/test_convenience.py100.00% <100.00%> (ø)
zarr/tests/test_core.py100.00% <100.00%> (ø)
zarr/tests/test_storage.py100.00% <100.00%> (ø)

@rabernat

rabernat commented Jan 31, 2022

Copy link
Copy Markdown
ContributorAuthor

I would like to revive and move forward this PR. Martin, you gave a few helpful comments and ideas above. Would you mind turning these into a more formal review in terms of what you think is needed vs interesting possibility.

What we have here is a tightly scoped and tested PR to unblock a rather serious upstream problem. If there is no major technical debt incurred by this PR, could we consider merging as is (modulo doc updates from checklist) rather than expanding scope? If not, please let us know what else would be required.

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

@rabernat
rabernat requested review from d-v-b and joshmoore and removed request for d-v-bJanuary 31, 2022 18:45
@grlee77

Copy link
Copy Markdown
Contributor

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

Thanks @rabernat, I commented above. If the __init__ signature does not change then this should be pretty easy to merge into the work there.

@joshmoore

Copy link
Copy Markdown
Member

Thanks, @grlee77. From my side, that was the only concern in terms of impact on existing work, @rabernat. @martindurant's point about the general API "burden" seems to be outstanding. Is it that a concrete alternative that doesn't break the API needs proposing from your side, @rabernat?

A side note that testing is currently blocked due to GHA weirdness. @jakirkham and I will try to get that sorted ASAP.

@joshmoore

Copy link
Copy Markdown
Member

@rabernat: would you prefer someone else to propose an alternative?

Comment threadzarr/storage.py
Comment on lines -1331 to -1312
if self.fs.exists(self.path) and not self.fs.isdir(self.path):
raise FSPathExistNotDir(url)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

To fix #993 I have simply removed this check...

Comment on lines -1251 to -1254
filepath = os.path.join(path, self.root + "foo")
with pytest.raises(ValueError):
self.create_store(path=filepath, mode='r')

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

...and its corresponding test.

This test did not do anything other than test the error above. self.create_store does not actually attempt to write any data or list the store.

With the check gone, users will now see an error from fsspec if they try to do an operation that requires listing on an unlistable FSSpec store, as they would already on a generic MutableMapping-based store.

@pep8speaks

pep8speaks commented Apr 5, 2022

Copy link
Copy Markdown

Hello @rabernat! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-05-04 11:10:02 UTC

@martindurantmartindurant left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

very little to comment

Comment threadzarr/storage.py
Comment threadzarr/tests/test_convenience.py
Comment threadzarr/tests/test_convenience.py
@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from e76a376 to cfadc1dCompareApril 7, 2022 14:46
Comment threaddocs/release.rst
Comment on lines +27 to +28
2.11.3
------

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Although 2.11.3 has been released, I noted that the docs had not been updated, so I added it here.

It seems we have skipped release 2.11.2?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Those releases are coming from the 2_11 branch. (See the related #898 (comment))

I assume you intend this for release as a 2.11.x?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Sorry I have clearly not been able to follow that discussion. After reading, I now understand the situation better. Let's discuss at today's SC meeting.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please ping this thread with any decision on which branch to merge into

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@martindurant : @rabernat seemed to think it was ok to hold off on @grlee77's upcoming v3 configuration fix, i.e. this can stay on the branch it is and be released as something >2.11.x. If it looks like we want it in a quick ~=2.11.x release, I can attempt the backport.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I will do whatever the other devs recommend here (either backport to 2.11.x or put this in 2.12.0)

I am confused about how we will maintain a consistent changelog for these two branches. So I am standing by for advice.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

From my POV, this is now complete. Would appreciate any other feedback or otherwise a merge.

@martindurant

Copy link
Copy Markdown
Member

@joshmoore , I see you have been tagged to review. I am happy to put this in, if you don't intend to look.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

This is my first Zarr PR in quite a while, so I just tagged the people I know to review. 😄

@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from 3bc0299 to 36c05edCompareApril 12, 2022 19:56
@rabernat

rabernat commented Apr 21, 2022

Copy link
Copy Markdown
ContributorAuthor

I feel confused about how to move forward with this PR in terms of how to update the changelog (see #911 (comment)). Please help me 🙏. I would love to see this merged soon as I believe it is finished. It is now starting to accumulate conflicts.

@joshmoore

Copy link
Copy Markdown
Member

Sorry for having left you hanging. I think either will be fine @rabernat. Either just add your item to unreleased or copy over from the 2 11 branch. Either way feel free to get this in and I will double check before the next release. (Of whatever branch)

@joshmoorejoshmoore left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've hopefully handled the conflicts with Greg's v3 work. Once this goes green, I'll merge and update the release notes to include previous versions.

@joshmoore

joshmoore commented May 4, 2022

Copy link
Copy Markdown
Member

It looks like the semantics of the update() method have changed with the refactoring for v3:

previous noise
pytest zarr/tests/test_convenience.py -svx -k2
...snip...
> store_to_open.update(store) # copy original store to new unlistable store
zarr/tests/test_convenience.py:305:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <zarr.storage.FSStore object at 0x1ba010970>, other = '/var/folders/z5/txc_jj6x5l5cm81r56ck1n9c0000gn/T/tmp0gy4ji7i', kwds = {}
def update(self, other=(), /, **kwds):
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v
'''
if isinstance(other, Mapping):
for key in other:
self[key] = other[key]
elif hasattr(other, "keys"):
for key in other.keys():
self[key] = other[key]
else:
> for key, value in other:
E ValueError: not enough values to unpack (expected 2, got 1)

That doesn't appear to be related to the type hierarchy:

2.11.2: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)
2.12.x: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)

Still digging in case anyone has an idea.

Edit: the problem was just that store had become a str. 🤦🏽 Fix pushed.

@joshmoore
joshmoore merged commit ab6b355 into zarr-developers:masterMay 4, 2022
@rabernat

Copy link
Copy Markdown
ContributorAuthor

Thanks for finishing this up Josh! I really appreciate it!

Sign up for freeto 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.

Cannot create FSStore for unlistable http URLs

5 participants

@rabernat@grlee77@joshmoore@pep8speaks@martindurant
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Create fsstore from filesystem - #911

Merged
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem
May 4, 2022
Merged

Create fsstore from filesystem#911
joshmoore merged 15 commits into
zarr-developers:masterfrom
rabernat:create-fsstore-from-filesystem

Conversation

@rabernat

@rabernatrabernat commented Dec 14, 2021

Copy link
Copy Markdown
Contributor

This PR adds a new argument to FSStore which allows one to pass an existing fsspec filesystem object from which to generate the FSStore. The need to initialize an FSStore from an existing filesystem came up in pangeo-forge/pangeo-forge-recipes#254. It seems like this is something people may want to do more generally.

Also fixes#993 by simply removing the check for list-ability when initializing an FSStore.

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
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

Comment threadzarr/storage.py
Comment threadzarr/storage.py
Comment threadzarr/tests/test_storage.py
@codecov

codecovBot commented Dec 14, 2021

Copy link
Copy Markdown

Codecov Report

Merging #911 (c1c9255) into master (d1f590d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@ Coverage Diff @@## master #911 +/- ##
=======================================
Coverage 99.94% 99.94% =======================================
Files 34 34 Lines 13719 13785 +66 =======================================
+ Hits 13712 13778 +66 
Misses 7 7 
Impacted FilesCoverage Δ
zarr/storage.py100.00% <100.00%> (ø)
zarr/tests/test_convenience.py100.00% <100.00%> (ø)
zarr/tests/test_core.py100.00% <100.00%> (ø)
zarr/tests/test_storage.py100.00% <100.00%> (ø)

@rabernat

rabernat commented Jan 31, 2022

Copy link
Copy Markdown
ContributorAuthor

I would like to revive and move forward this PR. Martin, you gave a few helpful comments and ideas above. Would you mind turning these into a more formal review in terms of what you think is needed vs interesting possibility.

What we have here is a tightly scoped and tested PR to unblock a rather serious upstream problem. If there is no major technical debt incurred by this PR, could we consider merging as is (modulo doc updates from checklist) rather than expanding scope? If not, please let us know what else would be required.

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

@rabernat
rabernat requested review from d-v-b and joshmoore and removed request for d-v-bJanuary 31, 2022 18:45
@grlee77

Copy link
Copy Markdown
Contributor

Also pinging @grlee77 and @joshmoore for potential interaction with ongoing refactor of storage classes (#789).

Thanks @rabernat, I commented above. If the __init__ signature does not change then this should be pretty easy to merge into the work there.

@joshmoore

Copy link
Copy Markdown
Member

Thanks, @grlee77. From my side, that was the only concern in terms of impact on existing work, @rabernat. @martindurant's point about the general API "burden" seems to be outstanding. Is it that a concrete alternative that doesn't break the API needs proposing from your side, @rabernat?

A side note that testing is currently blocked due to GHA weirdness. @jakirkham and I will try to get that sorted ASAP.

@joshmoore

Copy link
Copy Markdown
Member

@rabernat: would you prefer someone else to propose an alternative?

Comment threadzarr/storage.py
Comment on lines -1331 to -1312
if self.fs.exists(self.path) and not self.fs.isdir(self.path):
raise FSPathExistNotDir(url)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

To fix #993 I have simply removed this check...

Comment on lines -1251 to -1254
filepath = os.path.join(path, self.root + "foo")
with pytest.raises(ValueError):
self.create_store(path=filepath, mode='r')

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

...and its corresponding test.

This test did not do anything other than test the error above. self.create_store does not actually attempt to write any data or list the store.

With the check gone, users will now see an error from fsspec if they try to do an operation that requires listing on an unlistable FSSpec store, as they would already on a generic MutableMapping-based store.

@pep8speaks

pep8speaks commented Apr 5, 2022

Copy link
Copy Markdown

Hello @rabernat! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-05-04 11:10:02 UTC

@martindurantmartindurant left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

very little to comment

Comment threadzarr/storage.py
Comment threadzarr/tests/test_convenience.py
Comment threadzarr/tests/test_convenience.py
@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from e76a376 to cfadc1dCompareApril 7, 2022 14:46
Comment threaddocs/release.rst
Comment on lines +27 to +28
2.11.3
------

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Although 2.11.3 has been released, I noted that the docs had not been updated, so I added it here.

It seems we have skipped release 2.11.2?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Those releases are coming from the 2_11 branch. (See the related #898 (comment))

I assume you intend this for release as a 2.11.x?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Sorry I have clearly not been able to follow that discussion. After reading, I now understand the situation better. Let's discuss at today's SC meeting.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please ping this thread with any decision on which branch to merge into

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@martindurant : @rabernat seemed to think it was ok to hold off on @grlee77's upcoming v3 configuration fix, i.e. this can stay on the branch it is and be released as something >2.11.x. If it looks like we want it in a quick ~=2.11.x release, I can attempt the backport.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I will do whatever the other devs recommend here (either backport to 2.11.x or put this in 2.12.0)

I am confused about how we will maintain a consistent changelog for these two branches. So I am standing by for advice.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

From my POV, this is now complete. Would appreciate any other feedback or otherwise a merge.

@martindurant

Copy link
Copy Markdown
Member

@joshmoore , I see you have been tagged to review. I am happy to put this in, if you don't intend to look.

@rabernat

Copy link
Copy Markdown
ContributorAuthor

This is my first Zarr PR in quite a while, so I just tagged the people I know to review. 😄

@rabernat
rabernatforce-pushed the create-fsstore-from-filesystem branch from 3bc0299 to 36c05edCompareApril 12, 2022 19:56
@rabernat

rabernat commented Apr 21, 2022

Copy link
Copy Markdown
ContributorAuthor

I feel confused about how to move forward with this PR in terms of how to update the changelog (see #911 (comment)). Please help me 🙏. I would love to see this merged soon as I believe it is finished. It is now starting to accumulate conflicts.

@joshmoore

Copy link
Copy Markdown
Member

Sorry for having left you hanging. I think either will be fine @rabernat. Either just add your item to unreleased or copy over from the 2 11 branch. Either way feel free to get this in and I will double check before the next release. (Of whatever branch)

@joshmoorejoshmoore left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've hopefully handled the conflicts with Greg's v3 work. Once this goes green, I'll merge and update the release notes to include previous versions.

@joshmoore

joshmoore commented May 4, 2022

Copy link
Copy Markdown
Member

It looks like the semantics of the update() method have changed with the refactoring for v3:

previous noise
pytest zarr/tests/test_convenience.py -svx -k2
...snip...
> store_to_open.update(store) # copy original store to new unlistable store
zarr/tests/test_convenience.py:305:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <zarr.storage.FSStore object at 0x1ba010970>, other = '/var/folders/z5/txc_jj6x5l5cm81r56ck1n9c0000gn/T/tmp0gy4ji7i', kwds = {}
def update(self, other=(), /, **kwds):
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v
'''
if isinstance(other, Mapping):
for key in other:
self[key] = other[key]
elif hasattr(other, "keys"):
for key in other.keys():
self[key] = other[key]
else:
> for key, value in other:
E ValueError: not enough values to unpack (expected 2, got 1)

That doesn't appear to be related to the type hierarchy:

2.11.2: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)
2.12.x: FSStore.__mro__: (<class 'zarr.storage.FSStore'>, <class 'zarr._storage.store.Store'>, <class 'zarr._storage.store.BaseStore'>, <class 'collections.abc.MutableMapping'>, <class 'collections.abc.Mapping'>, <class 'collections.abc.Collection'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Container'>, <class 'object'>)

Still digging in case anyone has an idea.

Edit: the problem was just that store had become a str. 🤦🏽 Fix pushed.

@joshmoore
joshmoore merged commit ab6b355 into zarr-developers:masterMay 4, 2022
@rabernat

Copy link
Copy Markdown
ContributorAuthor

Thanks for finishing this up Josh! I really appreciate it!

Sign up for freeto 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.

Cannot create FSStore for unlistable http URLs

5 participants

@rabernat@grlee77@joshmoore@pep8speaks@martindurant