Make checking function accessible from python interpreter#33
Conversation
|
Pascal, this is maybe related to these functions which already exist in the quality checker The code is becoming hard to maintain as copies and forks are proliferating to be able to tweak the default hard-coded behaviour. A flexible central code that others can just invoke with different parameters would be simpler |
|
Ah yes indeed, I didn't see that. |
|
@aulemahal Pascal, many thanks, mate! As noted above, this is the source repo for the CMIP7 repack checker, but it's not where it's being used by ESGF; your implementation makes sense in order to add a bit more reach via Python API, and I support it, but I am also CCing my colleagues @davidhassell and @zequihg50 that are the actual developers of the package - I am devops, and from my packaging/operational PoV it's fine, but we'd need a few more tests from you 🍺 |
|
ping @davidhassell and @zequihg50 gents, what say you about this implement? |
Hi all!
Maybe I should have opened an issue before pushing a PR ? Anyway, this took me only a few minutes.
In a goal of running
check_cmip7_packingfrom inside a python script without having to make a system call and parse the result, I suggest here taking the core checking functionality and making it a standalone function that can be imported.Reading errors are still managed externally and parsing errors are passed along using a custom error class. The function returns a boolean and a string detailing the reason for the result.
I'm not sure if this was needed, but without this change the
check_cmip7_packingscript was usable even ifcmip7_repackwas not installed in a python environment. I tried to preserve this possibility here with a try..except when importing.Tested by running one two files (one passing and one failing) from inside an interpreter:
and from the CLI. Also ran the same "tests" from the CLI outside the environment (pyfive available, but
cmip7_repacknot installed).For my use case, this is the minimal importable stuff I need, but it could be interesting to also have access to the functions in
cmip7_repackthat compute the metadata blocksize and chunksizes, etc. I could maybe suggest another PR if there's interest.What do you guys think ? Is this useful ?