-
Notifications
You must be signed in to change notification settings - Fork 60
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
Allow to specify units #445
Conversation
@tmadlener - can you let me know whether you'd agree with this? I needed some break from genreflex work and did this long-standing item on my wish list. |
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 think this is a good idea. It is not yet clear to me if/how this will affect the generated code. That might have quite an impact on the size of this feature.
Would it mainly be an addition in the docstring, or would it actually enter in the generated c++ code. If the latter, which base units do we use, or do we leave that choice to the users (and if so, how)? Would we try to make this rather strict and introduce a proper units library to do all the conversions for us (there is a propoal for c++29 to have this in the standard library)?
For the moment it is for documentation purposes. And I want to have a detection in the schema evolution in case it changes. I do not think we should use a units library unless being asked for explicitly. |
OK. That sounds reasonable to achieve then. Then the main comment/question I have is whether we also need this for the components? |
Obviously :-) |
Just for completeness, could we add this to the generated code (docstring), so that it also shows up in some way in the c++ code. podio/python/podio/generator_utils.py Lines 153 to 168 in e0cb135
|
Does this already work for components as well? If so, I think this could be merged. |
Yes it does. The test case covers |
Ah right, sorry I missed that because it also has a description. Then more specifically does this also work with components that do not have a description, e.g. the |
Sure. The description is default initialized as empty string ( |
I was wondering more about the yaml parsing side here. IIRC I special cased the components there to not require a description, and I am not sure if this already covers that special case |
The combined regex would give a |
OK. IIUC, everything should work from the parsing side and nothing breaks if I add units, e.g. here: Lines 13 to 17 in dbf9425
However, I think in the current implementation these units would also not end up in a docstring, because they are never passed to the |
@tmadlener - I addressed your comment with a fix. Indeed units were not handled correctly there. |
It looks like the |
The clang12 nightlies no longer exist |
@hegner could you rebase this onto the latest master (or merge that in), so that we pick up a completely working CI again. After that finishes successfully, I would merge this. |
@tmadlener - seems all green now :-) |
BEGINRELEASENOTES
ENDRELEASENOTES
This WIP is to allow the explicit inclusion of units into the datamodel definition.