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

When loading OptoDAS data with truncated files, the routine crashes instead of giving a warning #27

Closed
speleos opened this issue Dec 11, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@speleos
Copy link

speleos commented Dec 11, 2024

The expected behaviour when dealing with truncated files would be to warn the user and ignore them.

iterator = as_completed(futures)

File ~/anaconda3/envs/simpledas/lib/python3.11/site-packages/xdas/core/routines.py:338, in open_mfdataarray(paths, dim, tolerance, squeeze, engine, verbose, **kwargs)
336 else:
337 iterator = as_completed(futures)
--> 338 objs = [future.result() for future in iterator]
339 return combine_by_coords(objs, dim, tolerance, squeeze, None, verbose)

File ~/anaconda3/envs/simpledas/lib/python3.11/site-packages/xdas/core/routines.py:338, in (.0)
336 else:
337 iterator = as_completed(futures)
--> 338 objs = [future.result() for future in iterator]
339 return combine_by_coords(objs, dim, tolerance, squeeze, None, verbose)

File ~/anaconda3/envs/simpledas/lib/python3.11/concurrent/futures/_base.py:449, in Future.result(self, timeout)
447 raise CancelledError()
448 elif self._state == FINISHED:
--> 449 return self.__get_result()
451 self._condition.wait(timeout)
453 if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:

File ~/anaconda3/envs/simpledas/lib/python3.11/concurrent/futures/_base.py:401, in Future.__get_result(self)
399 if self._exception:
400 try:
--> 401 raise self._exception
402 finally:
403 # Break a reference cycle with the exception in self._exception
404 self = None

OSError: Unable to synchronously open file (truncated file: eof = 5738496, sblock->base_addr = 0, stored_eof = 114278280)

@atrabattoni
Copy link
Contributor

Thank you for reporting this. Indeed this routine fails when any of the file is corrupted/cannot be opened for any reason. A more user friendly solution would be to warn the user of the file that could not be opened. I will try to work on this in the next days.

@atrabattoni atrabattoni self-assigned this Dec 11, 2024
@atrabattoni atrabattoni added the enhancement New feature or request label Dec 11, 2024
@atrabattoni
Copy link
Contributor

In the meantime, the workaround is to pass a list of file instead of a wildcard string being sure to exclude corrupted files from that list. Python glob module can be useful here.

@atrabattoni
Copy link
Contributor

Please see the the related PR #29.

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

When branches are created from issues, their pull requests are automatically linked.

2 participants