-
Notifications
You must be signed in to change notification settings - Fork 49
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
Plan toward own pure-python udunits [DRAGON!] #446
Comments
@pp-mo I'd love to meet with you'all and talk about this topic. I already opened a few similar threads in other places, there are tons of work that could be use to achieve this quicker than starting from 0. My latest attempt, which is to leverage Pint by adding udunits units to it, is in ioos/compliance-checker#1094 Most of the discussion is happening in Ouranosinc/xclim#1788 |
Found this through #454... I see the 🐲 and I salute you 🫡! The first thing to state: the CF-conventions are currently (last time I checked) bound to the All of this said, I did a lot of work to make a I didn't asses the amount of work that follows to implement a For old-times sake, consider me interested in the progress on this issue! |
@pelson we're often battling with a tricky compromise between:
Our current solution - depending on |
There is a large amount of libraries that requires CF-like units out there that already dropped udunits2 in lieu for some pint hacks (sometimes not hacks but actual support). Some examples are cf_xarray, metpy, xclim, etc. In a way, dragons are already flying. Udunits2 is super stable, so take this with a grain of salt, but it is not well maintained. PRs languish, releases are few and far between, people hack the XML to add new units (CF ones nonetheless!) b/c it takes way too long to add them into udunits2, etc. TL;DR I don't think a pure Python implementation is a bad idea. Maybe it is what we need to unify the ecosystem. I know some folks, that are connected to the CF leadership, are working on a Rust version of udunits. IMO, that is not going to solve out problem as we are only substituting one compiled dependency for another. |
Thanks for the inputs 👍
On this particular topic, it is clear that it needs to be bigger than
Well, this would be better than the current implementation IMO. You know better than me the compatibility issues that raises, but I would guess they are less concerning than C+Cython (existing knowledge aside). But this misses the point (please feel free to pass on my regards to 🥃 😉) - my POV is that there should be a standard, not an implementation (even if it is in pure Python). If that means that the CF conventions need to define the BNF and the XML tables in the appendix, so be it. For the record, I wanted to point to the tests that exist in this project at https://github.com/SciTools/cf-units/blob/main/cf_units/tests/integration/parse/test_parse.py. They are fairly short (<400 LoC) but encode a lot of ad-hoc learning about what
I don't know how well this is working, but a quick search suggests a few years ago there was a bit of pain with the fact that the |
Working is a strong word 😬 . It is what we have and, when some units fails to parse, we add another workaround. The more we do things like this, the further away we are from solving this problem IMO. I agree that a Rust implementation is not all bad, but it is still udunits2, just with a fresh coat of paint and new maintainer. who may or may not stay for the long run. I don't want to pollute this thread with my old man bitterness, and Phil nailed all the gotchas that may happen in the comment above. With that said, I don't think the CF committee will do what needs to be done to sort this out. Also, if you all want to push for a pure Python version, count me in! And I'll try to bring others along. |
@ocefpaf - what would the first functionality that you would need from a pure Python implementation be? Unit validation, conversion, simplification, XML extensions beyond the UDUNITS2 standard XML, or something else? I have a fairly advanced proof-of-concept in https://github.com/pelson/pyudunits2/, and think that it could be interesting to refine it towards your ideas at this point. |
Unit validation and conversion first (actually check if Our main use is in the compliance-checker library. For example, this is how we validate that the user passed a valid unit for vertical coordinate. |
It has taken me a while to finish up (there were a few dragons 🐉), but I have something that seems to hold up nicely against the comparisons I have tested with Note that your linked example can be simplified now with the new
(note that the number is the order of that basis unit, so equivalent to
There is definitely still things coming out of the woodwork... for example, in the udunits2 XML file there is no mention of the plural of I suggest we can discuss this in a dedicated issue at pelson/pyudunits2#3. |
Since so many outstanding problems + request relate to builds for alternative OS or architectures
Probably main issues :
PROJ_DATA
env setting (see this Iris problem)The text was updated successfully, but these errors were encountered: