-
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
Replace pyke #4170
Replace pyke #4170
Conversation
@trexfeathers if you can find a moment, I'd be interested to know if you can work through what's going on here ? Especially, I'd like to think that once we're confident that behaviour is preserved, we can subsequently remove some of the scaffolding which is the legacy of "how it used to be done". So, I'm hoping at some point to run all exisiting Iris tests, with changes to run any netcdf loading via both routes, and check for identical results in all cases. The 'engine mimic' approach I'm using should enable this extensive equivalence testing, and also to focus on just replacing the 'rules' with 'actions'. |
Note: at this point [i.e. commit https://github.com//pull/4170/commits/5f18f2369b8ccc9e6844825dbf2af356abcfbf83], removing the skip on the non-Pyke testing shows quite a few anomalies. TBH, writing this test suite is taking rather longer than I had thought. |
@pp-mo this code might be of interest to the conversation here: https://github.com/informatics-lab/tiledb_netcdf/blob/master/nctotdb/data_model.py#L11. I had a go at writing a non-Pyke NetCDF Dataset "understander" recently, too... It functions, but isn't full-featured, as I thnk there are some cf-netcdf elements it still ignores. Might provide some food for thought |
Thanks! 💐 Interesting, but it goes a long way beyond what I'm trying to do here, as a lot of what it does, like classifying variables and identifying which are coords etc, is for us handled in At some point, we should probably re-consider our division of the task into the cf.py file-structure analysis and "rules", but that's not what this is about (if I can help it!). Another goal would be to split out the CF "understanding" from Iris, and make it a more generally usable solutuon. I think that would be really useful, but it means that the output of the 'build' process must be in some Iris-agnostic form. |
👀 @trexfeathers @stephenpascoe @bjlittle |
(Updated status in header, again) |
Sorry! I mistook the scope of this particular bit of work (or misremembered what the pyke rules do!)
Doing this would be super helpful! 💯 |
So, I believe the tests now at least exercise all the Pyke rules. Next up: I will progressively extend + debug the 'actions', so that they match rules behaviour in all the tests. |
N.B. the test failure is yet another link-test failure 😞 |
@pp-mo I am pretty sure that link has been fixed in |
lib/iris/tests/unit/fileformats/netcdf/load_cube/load_cube__activate/test__grid_mappings.py
Outdated
Show resolved
Hide resolved
lib/iris/tests/unit/fileformats/netcdf/load_cube/load_cube__activate/test__grid_mappings.py
Outdated
Show resolved
Hide resolved
Rebased onto master, to pick up link-check fix 🤞 |
Ok, I broke some of the other tests there by turning on the "compare all results pyke + non-pyke" option. |
That's it ! |
( Looking forward, I think this looks very hopeful for us to entirely remove Pyke within this PR 🚀 ! We should get the new code + tests reviewed as-is, Regarding the future of the new tests, I was intending to provide two TestCase classes for every set of tests, one to run against the old mechanism and one against the new (by setting the class |
iris.fileformats.netcdf.DEBUG = self.debug | ||
|
||
# Call the main translation function to load a single cube. | ||
def load_single_cube(engine): |
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.
Would this make more sense to be named load_specific_cube
? It seems like _load_cube
is already loading a 'single' cube (i.e. the result is just one cube), but this function if different in that it has already specified which cube it will load.
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.
I thin I may just call this 'translate_cube'.
It is only needed to encapsulate the "call _load_cube and record formula info" operation, as we need to do that twice.
I think this is what was wrong! |
Ok, this time it's real : |
rule_name = "fc_formula_type" | ||
(var_name,) = formula_root_fact | ||
cf_var = engine.cf_var.cf_group[var_name] | ||
# var.standard_name is a formula type (or we should never get here). |
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.
I believe this comment should refer to cf_var.standard_name
.
# Must run AFTER formula root identification. | ||
(termvar_name, rootvar_name, term_name) = formula_term_fact | ||
# The rootname is implicit : have only one per cube | ||
# TODO: change when we adopt cf-1.7 advanced grid-mping syntax |
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.
I'm guessing "grid-mping" should be "grid-mapping"
|
||
# First zap cube-data, as masked data does not compare well. | ||
def unmask_cube(cube): | ||
# preserve the original, we're going to realise.. |
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.
This comment could be clearer, I can't make out what "we're going to realise" is refering to.
Also, capitalise the first letter for consistency.
…ncluding pyke == nonpyke checks.
Rebased, now checking we are okay with all CI checks. Next I will be pulling in code from #4198, which removes Pyke and simplifies all the testing, but has not yet got more recent test additions from here. |
Basically, #4198 now replaces this. |
🚀 Pull Request
Description
Eventually, will address #3415
Technical details of approach
iris.fileformats.netcdf._load_cube
, i.e. broadly assert facts; run rules; complete cubeCurrent progress + status summary
Done
Todo:
NOTE: I'm assuming that we will have enough confidence to "simply replace", which means
Consult Iris pull request check list