-
Notifications
You must be signed in to change notification settings - Fork 283
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
Python3 grib fixes #1774
Python3 grib fixes #1774
Conversation
GRIB does not handle integral types correctly on Python 3.
For some reason, the file seems to read in 4K chunks, even if I disable buffering. So simply re-seek to the location of the end of the message after reading one.
These both seem like genuine bugs. Have you raised them upstream? |
Do you know what the performance impact is of the extra seeks? |
I don't think ECMWF support gribapi on Python 3 anyway do they? Are you using the SciTools conda package for gribapi on Python 3? It looks like that applies a patch for Python 3 compatibility, so could that be a potential location of Python 3 problems too? |
I'm aware of the patch; I wrote it. 😉 I put the changes in here because it's easier to iterate than rebuilding the conda package, and I'd like some advice (though I probably should have explained that earlier.) For For the seeking though, I really have no idea what's causing it. Whenever GRIB reads something, no matter the size, the file pointer always advances by 4K. I thought maybe Python 3's |
My concern is that this fix will go in for compatibility against a patched gribapi version, and will remain in our code base even if/when Python 3 is actually supported by gribapi. |
I can update the patched GRIB for the first commit easily (though it doesn't really hurt to be more explicit there.) However, I was really hoping someone might be able to come up with a better workaround or fix for the second commit's issue. |
Could we just leave GRIB unsupported in Python 3 for now? (e.g. Skip the relevant tests, perhaps add a warning when using it?) |
The first commit I have no issue with, it is more the second one. I'm tempted to say that we should leave GRIB support out of the Python 3 version initially until this has been thought through some more and we come up with a good solution (although it pains me to say that as I mostly work with GRIB data...). |
We could leave GRIB unsupported, but it would require added the relevant skips, so I'm against it on account of laziness 😉. To go forward though, the best method is either for GRIB to provide an open/close function to get the |
NB. I'm experimenting with making GRIB an optional dependency - it's something I've wanted to do for a long time. |
Huge 👍 |
See #1789. |
And it's done! Thanks to #1789 GRIB is now officially optional. 😀 |
If I read their description correctly, the |
I'm aiming to get some time to get Iris to move over to ecCodes. If claims are to be believed, it will be a simple piece of work to deliver once I get started; we shall see. I will use this work to investigate with ECMWF the limitations on Python version and raise issues with them. Hopefully we'll get things moving there. If we can hit v1.9 by making GRIB py3 optional (or already have done) then that's a fine solution from my point of view |
So... what do we want to do? Close this PR and remove the Py3 builds from conda (and conda-recipes-scitools)? |
that sounds like a sensible approach to me |
I think so, although we might want to keep the first commit from this PR to save it from having to be rediscovered at a later time when Python 3 support is available for gribapi. We also need to add a note to the what's new entry for Python 3 support stating that GRIB is not supported in Iris on Python 3. |
I've pushed up a PR on Iris to add a what's new entry, indicating that GRIB is unsupported for Python 3 Is that enough to close this PR, or to take it out of the 1.9 milestone?
I think we can push this information into an issue, would that be all right? Do we need to pull things out of conda-recipes? I thought we could leave them in there; GRIB is an optional dependency now, so I'd have thought this would be all right cheers |
np.array(np.round(lon_values), dtype=np.int64)) | ||
gribapi.grib_set_array(grib, 'latitudes', | ||
np.array(np.round(lat_values), dtype=np.int64)) | ||
gribapi.grib_set_long_array(grib, 'longitudes', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be incorporated into Iris?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be incorporated into Iris?
my belief: not until Python3 is adopted
@QuLogic does this sound all right to you? |
Sounds good to me. |
A couple of small fixes for GRIB parsing. Probably a more permanent fix should be put in GRIB itself, but I was lazy and some stuff was not making sense so I wasn't sure of the best fix anyway.