-
Notifications
You must be signed in to change notification settings - Fork 43
Use path-like tools with DataTree #281
Comments
Hi @eschalkargans , thank you so much for your suggestion! This is something I have So internally datatree already uses
One thing to be clear about here is that
This would be extremely easy to allow, as often the first thing we do internally is convert the given string to a
This is an interesting idea, and neat syntax, but how exactly would this work?
We certainly could. I was not sure what to call the What do you think? |
Hi @TomNicholas , Thanks for your answer! I'm answering from my other personal account. TLDRI wrote too much text so here is a quick summary:
Details(1) As said in #205,
This is also very useful for users! I have some points to defend the exposure of this First, the package is named (2) Then, also answering the reason of why indexing a Now, some drawbacks: (3) The main drawback of rendering the Regarding:
and
(4) The design issue I can see is that the pathlib's "concrete" paths are bound to the underlying filesystem. There is only one filesystem. We don't need to indicate to pathlib that we use the current fileystem. So when we write a So, going back on |
Thanks for your engagement and suggestions here @eschalkargans / @etienneschalk !
Trying harder to match the nomenclature used for
This is a very easy fix, so I've opened #282 to add it.
This is a big difference, and I think indicates that exposing
This is possible, but would be very complicated. I tried to create a similar bi-directional linking (between In general I still don't really see a clear use case for exposing |
Closing in favour of pydata/xarray#9448 upstream. |
Hello,
I open this issue to discuss about integrating more path manipulations into the datatree library.
TLDR:
To summarize:
pathlib
-like methods for DataTreePath
objectspathlib
some path operationsDetails
This is a suggestion regarding DataTrees
Since a DataTree can be accessed with string representing unix-like paths (slash-separated strings), and since there is the
pathlib
library in Python, I wondered if the DataTree could comply with some of the "pathlib API". It's especially true for Zarr files that are persisted to literal directories into the filesystem. It seems natural to have all the tools for Path manipulation inside a DataTree.For instance, with
pathlib
we canglob
orrglob
on a directory path. Would it be possible toglob
andrglob
in DataTrees too? Currently there is amatch
function, but it introduces a new word, "match".dt.match("*/B")
ordt.glob("*/B")
would be okay, ordt.glob('**/B')
ordt.rglob('B')
.The idea is that the,
glob
andrglob
are already "standard" in thepathlib
library, and well-known by Python developers using pathlib.Also, we can imagine, to keep the path aspect separated from the datatree API, to index a datatree with a
Path
:dt[Path('/a/b/c')]
. Or, equivalent todt.rglob('B')
,dt[Path('/').rglob('B')]
. I don't know how much pathlib is tied to the underlying file-system. We could imagine being able to use it from a "virtual filesystem hierarchy" provided by the DataTree itself:(Note: i saw that the path property already exists on the DataTree object.)
The current way to iterate over all nodes is using
.subtree
For a python developer discovering datatree but already knowing well how to work with paths, we could imagine:
The text was updated successfully, but these errors were encountered: