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

tiff-series exporter does not support empty directory kwarg on Windows #20

Open
EliotGann opened this issue Mar 21, 2019 · 3 comments
Open

Comments

@EliotGann
Copy link

Created by @mrakitin while trying suitcase-tiff exported at SST-2/RSOXS.

It is also true for all suitcases.

Current behavior:

In [14]: tiff_series.export(db[-1].documents(fill=True), file_prefix='test', directory='')
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-14-c77817249410> in <module>
----> 1 tiff_series.export(db[-1].documents(fill=True), file_prefix='test', directory='')

c:\users\greateyes\appdata\local\conda\conda\envs\collection-2019-1.2-rsoxs\lib\site-packages\suitcase\tiff_series\__init__.py in export(gen, directory, file_prefix, bigtiff, byteorder, imagej, **kwargs)
     99                     **kwargs) as serializer:
    100         for item in gen:
--> 101             serializer(*item)
    102
    103     return serializer.artifacts

c:\users\greateyes\appdata\local\conda\conda\envs\collection-2019-1.2-rsoxs\lib\site-packages\event_model\__init__.py in __call__(self, name, doc, validate)
     69             instance as doc, a copy of doc, or a different dict altogether.
     70         """
---> 71         output_doc = getattr(self, name)(doc)
     72         if validate:
     73             jsonschema.validate(output_doc,

c:\users\greateyes\appdata\local\conda\conda\envs\collection-2019-1.2-rsoxs\lib\site-packages\suitcase\tiff_series\__init__.py in event(self, doc)
    223                 filename = (f'{self._templated_file_prefix}'
    224                             f'{streamname}-{field}-{num}.tiff')
--> 225                 file = self._manager.open('stream_data', filename, 'xb')
    226                 tw = TiffWriter(file, **self._init_kwargs)
    227                 self._tiff_writers[streamname][field+f'-{num}'] = tw

c:\users\greateyes\appdata\local\conda\conda\envs\collection-2019-1.2-rsoxs\lib\site-packages\suitcase\utils\__init__.py in open(self, label, postfix, mode, encoding, errors)
    121                 f'to be one of {self._allowed_modes}')
    122         filepath = self.reserve_name(label, postfix)
--> 123         os.makedirs(os.path.dirname(filepath), exist_ok=True)
    124         f = open(filepath, mode=mode, encoding=encoding, errors=errors)
    125         self._files.append(f)

c:\users\greateyes\appdata\local\conda\conda\envs\collection-2019-1.2-rsoxs\lib\os.py in makedirs(name, mode, exist_ok)
    218             return
    219     try:
--> 220         mkdir(name, mode)
    221     except OSError:
    222         # Cannot rely on checking for EEXIST, since the operating system

FileNotFoundError: [WinError 3] The system cannot find the path specified: ''

In [15]: tiff_series.export(db[-1].documents(fill=True), file_prefix='test', directory='')

Expected behavior:

If the directory kwarg is '' or '.', it should properly recognize it and convert to current directory, as it does it on Linux (with e.g. os.getcwd()).

@danielballan
Copy link
Member

Thanks for the report. I think the simplest fix here would be to change the default value of directory to '.', if that works. I was actually surprised that '' works on Linux; it seems improper or at least unusual. Can you confirm that directory='.' works on Windows --- i.e. that it resolves to the current working directory?

@mrakitin
Copy link
Member

mrakitin commented Mar 24, 2019

No, it does not work on Windows. We tested multiple scenarios, and the only thing which worked was os.getcwd().

@danielballan
Copy link
Member

Interesting. On Windows, CPython sets os.path.curdir to '.' so I would expect '.' to work. Maybe it doesn't join properly with the rest of the path. Can we see the traceback when you try to use '.', @EliotGann? (The example above just shows ''.)

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