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

How to avoid StopIteration Error? #34

Closed
meteoDaniel opened this Issue Nov 22, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@meteoDaniel
Copy link

meteoDaniel commented Nov 22, 2018

Dear all,
in the last time i often receive the following Error:

  File "/app/src/modules/decoder/grib_decoder.py", line 18, in __init__
    self._data = xarray_store.open_dataset(str(file_name))
  File "/usr/local/lib/python3.6/site-packages/cfgrib/xarray_store.py", line 47, in open_dataset
    store = cfgrib_.CfGribDataStore(path, **real_backend_kwargs)
  File "/usr/local/lib/python3.6/site-packages/cfgrib/cfgrib_.py", line 78, in __init__
    self.ds = cfgrib.open_file(filename, mode='r', **backend_kwargs)
  File "/usr/local/lib/python3.6/site-packages/cfgrib/dataset.py", line 452, in open_file
    return Dataset.from_path(path, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/cfgrib/dataset.py", line 447, in from_path
    return cls(*build_dataset_components(stream, **flavour_kwargs))
  File "/usr/local/lib/python3.6/site-packages/cfgrib/dataset.py", line 395, in build_dataset_components
    index = stream.index(ALL_KEYS).subindex(filter_by_keys)
  File "/usr/local/lib/python3.6/site-packages/cfgrib/messages.py", line 211, in index
    return FileIndex.from_filestream(filestream=self, index_keys=index_keys)
  File "/usr/local/lib/python3.6/site-packages/cfgrib/messages.py", line 228, in from_filestream
    schema = make_message_schema(filestream.first(), index_keys)
  File "/usr/local/lib/python3.6/site-packages/cfgrib/messages.py", line 208, in first
    return next(iter(self))
StopIteration

Why cfgrib raise StopIteration Error? Whats wrong?

@alexamici

This comment has been minimized.

Copy link
Collaborator

alexamici commented Nov 30, 2018

@meteoDaniel I think you attempted to open a file with no valid GRIB message in it and I agree that the error is totally confusing. I'm considering it a bug and fixing it in master. Thanks for reporting!

alexamici added a commit that referenced this issue Nov 30, 2018

alexamici added a commit that referenced this issue Nov 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.