Replies: 1 comment 2 replies
-
UPath is a subclass of path, so should be sufficient to change that line to from typing import TYPE_CHECKING
if TYPE_CHECKING:
from _typeshed import StrPath
def generate_inputs(
root: StrPath,
...
):
if not isinstance(path, Path):
path = Path(path)
... This should make the function work with any subtype of Path (e.g. UPath), otherwise for strings etc it will coerce into a path. Then just make sure we don't use any of the old Should be easy enough to implement, are you willing? It would additionally need a test testing that both |
Beta Was this translation helpful? Give feedback.
-
Ali and I are considering using Google Cloud buckets (with a access url like "gs://path/to/file") to read and write OME_ZARR files in snakemake workflows. We would like something as follows:
while both pybids and this repo are currently depending on Python's Path class, Ali's idea is to use universal_pathlib's UPath objects as drop-in replacement for Path. For pybids, We made a fork of pybids which supports UPath and passes the unit tests of the main repository.
For this repo, after further modify the
os.path.isabs(path)
call in input_generation.py to make suregs://...
is not recognized as a local relative path, the above code seems to work.Depending on a pybids' fork is going to break dependency for other users of this repo (We are considering a PR to the main branch of pybids for UPath support. Right now, however, it's a fork and it's not finalized), but I think a commit replacing os.path.isabs() with an equivalent expression compatible with cloud storage paths is possible (so we can use a UPath compatible version of pybids in our own project if we need UPath support in snakebids). @pvandyken What do you think?
Edit: I modified input_generation.py's line 726 to use
path.absolute() != path
to test for relative path which is a workaround but I think there is probably a better way to do it.Beta Was this translation helpful? Give feedback.
All reactions