Skip to content

pims.open should handle lists of URLs #310

Open
@mrocklin

Description

I have several images on a cloud object store. I can get normal http routes to these images and I'm happy to see that pims can read these individually. However, my guess is that normal glob processing won't successfully find all of the images on the cloud object store. I'm happy to provide this list myself, but it looks like I'm unable to past a list of filenames into pims.open.

In [1]: import pims

In [2]: url = 'https://pydata.org/images/logo.png'

In [3]: pims.open(url)
Out[3]: 
<Frames>
Length: 1 frames
Frame Shape: 53 x 126
Pixel Datatype: uint8

In [4]: pims.open([url, url, url])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-4b4693a3872c> in <module>()
----> 1 pims.open([url, url, url])

~/Software/anaconda/lib/python3.6/site-packages/pims/api.py in open(sequence, **kwargs)
    147     >>> frame_shape = video.frame_shape # Pixel dimensions of video
    148     """
--> 149     files = glob.glob(sequence)
    150     if len(files) > 1:
    151         # todo: test if ImageSequence can read the image type,

~/Software/anaconda/lib/python3.6/glob.py in glob(pathname, recursive)
     18     zero or more directories and subdirectories.
     19     """
---> 20     return list(iglob(pathname, recursive=recursive))
     21 
     22 def iglob(pathname, *, recursive=False):

~/Software/anaconda/lib/python3.6/glob.py in _iglob(pathname, recursive, dironly)
     38 
     39 def _iglob(pathname, recursive, dironly):
---> 40     dirname, basename = os.path.split(pathname)
     41     if not has_magic(pathname):
     42         assert not dironly

~/Software/anaconda/lib/python3.6/posixpath.py in split(p)
    103     """Split a pathname.  Returns tuple "(head, tail)" where "tail" is
    104     everything after the final slash.  Either part may be empty."""
--> 105     p = os.fspath(p)
    106     sep = _get_sep(p)
    107     i = p.rfind(sep) + 1

TypeError: expected str, bytes or os.PathLike object, not list

Note that this behavior is currently advertised in the docstring

In [5]: pims.open?
Signature: pims.open(sequence, **kwargs)
Docstring:
Read a filename, list of filenames, or directory of image files into an
iterable that returns images as numpy arrays.

Parameters
----------
sequence : string, list of strings, or glob
    The sequence you want to load. This can be a directory containing
    images, a glob ('/path/foo*.png') pattern of images,
    a video file, or a tiff stack
kwargs :
    All keyword arguments will be passed to the reader.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions