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

alter calculation of offset #287

Merged
merged 4 commits into from
Jul 7, 2023

Conversation

david-bentley
Copy link
Contributor

These changes allow the correct calculation of the message offset on both Windows and Linux.

There are three additional test errors introduced as part of these changes (see below - only tested on Linux so far). These are all related to grib_message being a string rather than an integer - I'm not particularly familiar with GRIB, so I'm not sure if this is a peculiarity of the tests or that one would expect to encounter a message as a string when loading a file.

======================================================================
ERROR: test_reduced_proxy_args (unit.test_GribWrapper.Test_deferred_proxy_args)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/net/home/h02/dbentley/defence_applications/tda_source_code/github/iris-grib/iris_grib/tests/unit/test_GribWrapper.py", line 122, in test_reduced_proxy_args
    gw = GribWrapper(grib_message, self.grib_fh)
  File "/net/home/h02/dbentley/defence_applications/tda_source_code/github/iris-grib/iris_grib/__init__.py", line 147, in __init__
    offset = gribapi.grib_get_message_offset(grib_message)
  File "/data/users/dbentley/environments/iris-grib-dev/lib/python3.7/site-packages/gribapi/gribapi.py", line 1592, in grib_get_message_offset
    h = get_handle(msgid)
  File "/data/users/dbentley/environments/iris-grib-dev/lib/python3.7/site-packages/gribapi/gribapi.py", line 165, in get_handle
    h = ffi.cast("grib_handle*", msgid)
  File "/data/users/dbentley/environments/iris-grib-dev/lib/python3.7/site-packages/cffi/api.py", line 300, in cast
    return self._backend.cast(cdecl, source)
TypeError: an integer is required

======================================================================
ERROR: test_regular_proxy_args (unit.test_GribWrapper.Test_deferred_proxy_args)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/net/home/h02/dbentley/defence_applications/tda_source_code/github/iris-grib/iris_grib/tests/unit/test_GribWrapper.py", line 113, in test_regular_proxy_args
    gw = GribWrapper(grib_message, self.grib_fh)
  File "/net/home/h02/dbentley/defence_applications/tda_source_code/github/iris-grib/iris_grib/__init__.py", line 147, in __init__
    offset = gribapi.grib_get_message_offset(grib_message)
  File "/data/users/dbentley/environments/iris-grib-dev/lib/python3.7/site-packages/gribapi/gribapi.py", line 1592, in grib_get_message_offset
    h = get_handle(msgid)
  File "/data/users/dbentley/environments/iris-grib-dev/lib/python3.7/site-packages/gribapi/gribapi.py", line 165, in get_handle
    h = ffi.cast("grib_handle*", msgid)
  File "/data/users/dbentley/environments/iris-grib-dev/lib/python3.7/site-packages/cffi/api.py", line 300, in cast
    return self._backend.cast(cdecl, source)
TypeError: an integer is required

======================================================================
ERROR: test_edition_1 (unit.test_GribWrapper.Test_edition)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/net/home/h02/dbentley/defence_applications/tda_source_code/github/iris-grib/iris_grib/tests/unit/test_GribWrapper.py", line 74, in test_edition_1
    wrapper = GribWrapper(grib_message, grib_fh)
  File "/net/home/h02/dbentley/defence_applications/tda_source_code/github/iris-grib/iris_grib/__init__.py", line 147, in __init__
    offset = gribapi.grib_get_message_offset(grib_message)
  File "/data/users/dbentley/environments/iris-grib-dev/lib/python3.7/site-packages/gribapi/gribapi.py", line 1592, in grib_get_message_offset
    h = get_handle(msgid)
  File "/data/users/dbentley/environments/iris-grib-dev/lib/python3.7/site-packages/gribapi/gribapi.py", line 165, in get_handle
    h = ffi.cast("grib_handle*", msgid)
  File "/data/users/dbentley/environments/iris-grib-dev/lib/python3.7/site-packages/cffi/api.py", line 300, in cast
    return self._backend.cast(cdecl, source)
TypeError: an integer is required

@david-bentley
Copy link
Contributor Author

I've updated a couple of tests to mock the grib_get_message_offset function, so the number of test failures/errors matches those found in the main branch now

@wjbenfold
Copy link

Hi David, thanks for this. The cryptic message about a CLA (Contributor Licence Agreement) more more helpfully direct you here, which has information and a (quick) form that contributors to SciTools need to fill out: https://docs.google.com/forms/d/e/1FAIpQLSfd0tdE-DcJOXh8ej_7T93IizwJFYBFyRWYQOi2A8QRaKwykA/viewform

@david-bentley
Copy link
Contributor Author

Now signed the CLA

@lbdreyer
Copy link
Member

Hi @david-bentley, sometimes the cla-assistant doesn't pick up when it has been signed. I am going to close and reopen this PR to trigger it to run again

@trexfeathers
Copy link
Contributor

@david-bentley are you free to rebase / merge in the latest from main?

@trexfeathers trexfeathers self-assigned this Jul 5, 2023
@david-bentley david-bentley force-pushed the bugfix/offset-error branch from ac243eb to 69d9936 Compare July 5, 2023 10:28
@trexfeathers
Copy link
Contributor

trexfeathers commented Jul 5, 2023

I'll put something together to make iris-grib NEP 29 compliant, which should at least address the iris=repo-main failure.

EDIT: working on #339

@trexfeathers
Copy link
Contributor

@david-bentley if you bring in #339 I think this should pass the CI

@david-bentley david-bentley force-pushed the bugfix/offset-error branch from db6f2e9 to fa65b98 Compare July 6, 2023 16:32
@david-bentley
Copy link
Contributor Author

Just for reference, here are the results of the code in #286 on Windows with these changes:

669134.5234870911 669134.5234870911
offset 0
669579.7834396362 669579.7834396362
offset 3713
669659.5537185669 669659.5537185669
offset 7426
669386.830329895 669386.830329895
offset 11139
667856.9562911987 667856.9562911987
offset 14852
666605.8734893799 666605.8734893799
offset 18565
666640.6002998352 666640.6002998352
offset 22278
666665.0799751282 666665.0799751282
offset 25991
666563.8387680054 666563.8387680054
offset 29704
666692.4885749817 666692.4885749817
offset 33417
666673.7871170044 666673.7871170044
offset 37130
666599.6193885803 666599.6193885803
offset 40843
...

Which is what we expect.

Copy link
Contributor

@trexfeathers trexfeathers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@david-bentley this is great!

Thanks for your diligence, but even more thanks for your patience.

@trexfeathers trexfeathers merged commit 00a95b2 into SciTools:main Jul 7, 2023
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

Successfully merging this pull request may close these issues.

5 participants