Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access tiff images on Linux #5

Closed
mrakitin opened this issue May 30, 2019 · 4 comments
Closed

Access tiff images on Linux #5

mrakitin opened this issue May 30, 2019 · 4 comments

Comments

@mrakitin
Copy link
Member

The tiff images are saved on a Windows machine xf07id1-ws17 (10.7.0.217):

tiff = C(TIFFPluginWithFileStore, 'TIFF1:',
write_path_template='/mnt/zdrive/data/%Y/%m/%d/',
read_path_template='Z:\\images\\data\\%Y\\%m\\%d\\',
read_attrs=[],
root='Z:\\images\\data\\')

Even if the volume is mounted on a Linux machine with the following command:

# sudo mount -t cifs //10.7.0.217/data/ /mnt/zdrive -o user=linuxuser,pass=greateyes

it's still not possible to retrieve the data:

In [15]: imgs = list(db['0372d961'].data('Synced_saxs_image'))  # scan_id=2460
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-15-4c2934cf7df9> in <module>
----> 1 imgs = list(db['0372d961'].data('Synced_saxs_image'))  # scan_id=2460

/opt/conda_envs/collection-2019-2.1-rsoxs/lib/python3.6/site-packages/databroker/_core.py in data(self, field, stream_name, fill)
    490         for event in self.events(stream_name=stream_name,
    491                                  fields=[field],
--> 492                                  fill=fill):
    493             yield event['data'][field]
    494

/opt/conda_envs/collection-2019-2.1-rsoxs/lib/python3.6/site-packages/databroker/_core.py in events(self, stream_name, fields, fill)
    380         ev_gen = self.db.get_events([self], stream_name=stream_name,
    381                                     fields=fields, fill=fill)
--> 382         for ev in ev_gen:
    383             yield ev
    384

/opt/conda_envs/collection-2019-2.1-rsoxs/lib/python3.6/site-packages/databroker/_core.py in get_events(self, headers, stream_name, fields, fill, handler_registry)
   1509                                             stream_name=stream_name,
   1510                                             fill=fill,
-> 1511                                             handler_registry=handler_registry):
   1512             if name == 'event':
   1513                 yield doc

/opt/conda_envs/collection-2019-2.1-rsoxs/lib/python3.6/site-packages/databroker/_core.py in get_documents(self, headers, stream_name, fields, fill, handler_registry)
   1603                                                                      datum)
   1604
-> 1605                             doc = proc_gen.send(doc)
   1606
   1607                         yield name, self.prepare_hook(name, doc)

/opt/conda_envs/collection-2019-2.1-rsoxs/lib/python3.6/site-packages/databroker/_core.py in _fill_events_coro(self, descriptors, fields, inplace)
   2053                     d_id = data[dk]
   2054                     data[dk] = (registry_map[(desc_id, dk)]
-> 2055                                 .retrieve(d_id))
   2056                     filled[dk] = d_id
   2057

/opt/conda_envs/collection-2019-2.1-rsoxs/lib/python3.6/site-packages/databroker/assets/base_registry.py in retrieve(self, datum_id)
    176         return self._api.retrieve(self._datum_col, datum_id,
    177                                   self._datum_cache, self.get_spec_handler,
--> 178                                   logger)
    179
    180     def get_datum(self, datum_id):

/opt/conda_envs/collection-2019-2.1-rsoxs/lib/python3.6/site-packages/databroker/assets/core.py in retrieve(col, datum_id, datum_cache, get_spec_handler, logger)
     64     datum = _get_datum_from_datum_id(col, datum_id, datum_cache, logger)
     65     handler = get_spec_handler(datum['resource'])
---> 66     return handler(**datum['datum_kwargs'])
     67
     68

/opt/conda_envs/collection-2019-2.1-rsoxs/lib/python3.6/site-packages/databroker/assets/handlers.py in __call__(self, point_number)
    106         ret = []
    107         for fn in self._fnames_for_point(point_number):
--> 108             with tifffile.TiffFile(fn) as tif:
    109                 ret.append(tif.asarray())
    110         return np.array(ret).squeeze()

/opt/conda_envs/collection-2019-2.1-rsoxs/lib/python3.6/site-packages/tifffile/tifffile.py in __init__(self, arg, name, offset, size, multifile, multifile_close, pages, fastij, is_ome)
   1321
   1322         self._fh = FileHandle(arg, mode='rb',
-> 1323                               name=name, offset=offset, size=size)
   1324         self.offset_size = None
   1325         self.pages = []

/opt/conda_envs/collection-2019-2.1-rsoxs/lib/python3.6/site-packages/tifffile/tifffile.py in __init__(self, file, mode, name, offset, size)
   3519         self._close = True
   3520         self.is_file = False
-> 3521         self.open()
   3522
   3523     def open(self):

/opt/conda_envs/collection-2019-2.1-rsoxs/lib/python3.6/site-packages/tifffile/tifffile.py in open(self)
   3530             self._file = os.path.realpath(self._file)
   3531             self._dir, self._name = os.path.split(self._file)
-> 3532             self._fh = open(self._file, self._mode)
   3533             self._close = True
   3534             if self._offset is None:

FileNotFoundError: [Errno 2] No such file or directory: '/home/mrakitin/.ipython/profile_collection/startup/Z:\\images\\data/2019\\05\\29/72271a43-61ff-4dc7-9457_000000.tiff'

Need to figure out a way how to access the data either with the root_map as it's done at XPD, or by more sophisticated methods.

@mrakitin
Copy link
Member Author

We will check what we can do when @danielballan will come back from vacation.

@mrakitin
Copy link
Member Author

xf07id1-ca1 needed this to mount successfully:

$ sudo apt install cifs-utils

@EliotGann
Copy link
Member

right, you would need to use the write directory (the linux directory equivalent) to read it from a linux machine. the read directory is for windows. Basically it should pick the directory based on if it is running on windows or linux (for writing or reading)

@tacaswell
Copy link
Member

Interesting, at every other beamline where we have mixed windows / linux read/write paths it is in the context of a windows IOC and wanting to access from linux. We do not record the write_path in the database as that is "for the camera" where as the read_path is "for the consumer".

As @mrakitin says, the solution here is to use root_map (https://nsls-ii.github.io/databroker/configuration.html#coping-with-moved-files-or-different-mount-points ) or db.reg.set_root_map({...}), however I am not 100% sure that having a windows-style rpath and a linux-style root is going to work out of the box...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants