-
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
Incorporating Julia code generation in the existing Python interface #473
Conversation
7a4eafe
to
3d970f0
Compare
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.
Hi - looks pretty good, a few comments embedded. Are the tests as extensive as the tests for the C++ rendering of the data model? It's not too exhaustive.
Also, we need to rethink the "forward declaration" solution we use too.
python/podio/generator_utils.py
Outdated
builtin_types_map = {"int": "Int32", "float": "Float32", "double": "Float64", | ||
"bool": "Bool", "long": "Int32", "unsigned int": "UInt32", | ||
"unsigned long": "UInt32", "char": "Char", "short": "Int16", | ||
"long long": "Int64", "unsigned long long": "UInt64"} |
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.
Maybe long long
should be Int128
? I am not sure though, as this would be a slow datatype in practice.
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.
long long
is 64 bits in practice at the moment (as far as the table on the integers shows). We could put in a header that encodes these "assumptions" into the c++ code, that essentially consists of static_assert
s of the form
static_assert(sizeof(long long int) == 8, "long long int is not 64 bits wide");
BTW, you also failed some |
3d970f0
to
cd44b51
Compare
I have corrected all the changes that were asked. |
Is this optional? I would say even if Julia is installed there will be cases when we'll want podio not to have the Julia interface by default. Of course if Julia is not installed then it should work as it works now, tests included |
Yes, the code generation will work regardless of whether julia is present in the system or not, as julia code for a particular datamodel is generated using jinja2 templates. And yes the tests for julia will only run if the users have julia in their system. |
Also, that's why we have introduced a new parameter --lang (-l). By default the language is cpp, but if the users want to generate julia code, they can by specifying |
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.
Hi - I think this isn't the last word on the EDM in Julia, but it works and allows us to develop from here without very painful rebases, so I am happy to merge this now.
@Ananya2003Gupta @graeme-a-stewart - I'd agree once the conflicts are resolved ;-) |
cd44b51
to
96bdc65
Compare
Yes, it's done : ) |
I got a test failure when I was running in your branch: ERROR: LoadError: ArgumentError: Package StaticArrays not found in current path.
- Run `import Pkg; Pkg.add("StaticArrays")` to install the StaticArrays package. Can you fix that one? You shouldn't make assumptions about which packages are installed in the test environment. |
I think this would just need to be put into the README as a dependency and also how to install it, right? CI seems to be configured to do that and the tests are running and succeeding. |
Actually you would have to install StaticArrays package in your system, then only it would work. |
Yes. The users need to have StaticArrays package installed in their system. Otherwise it will throw this error and ask them to install it. We can make it a dependency as suggested here: https://discourse.julialang.org/t/install-a-packages-from-a-list/30920/6 |
But you should not fail the test, we are testing the code, not the user's environment. Probably the best way is to have a For the user, document that |
Okay |
I have added a try-catch block in |
@hegner @tmadlener can you please review the PR? If there are anymore changes required I would do them. |
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 can't comment too much on the generated Julia code. @graeme-a-stewart and @hegner are better equipped to comment on that. There are a few minor things (see also the inline comments)
- I would merge
params.jinja2
andabstracttypes.jinja2
into onejulia_helpers.jinja2
file and include that where necessary in the main jinja2 template files - The
unittest.jl
file should be intests/unittests
, rather than intests
- I would like to have an option
ENABLE_JULIA
in the top level CMakeLists.txt to toggle Julia support manually, rather than relying on finding the Julia executable alone. - Can you bring back the
BEGINRELEASENOTES
andENDRELEASENOTES
in the top level comment of the PR? Those are used as delimiter for our tagging script.
More generally, I am not sure whether mixing in the Julia code generator into the existing c++ code generator is the best idea, as that is already complicated enough on its own and sprinkling a few if lang == "xxx"
in there doesn't help in that regard. Having said that, I think we can also fix this after this PR and ideally split them into to separate generator classes that each handle exactly one language.
The basic idea for splitting classes would be to have a sort of base class that does the common processing and them two dedicated classes for cpp and julia respectively that deal with the specifics. However, as I said, I would first get this PR merged as it is with the things mixed and then we can separate things later, when there are no multiple other PRs touching code generation in flight, so that we don't have to keep all of them synchronized. |
Got it.
|
That looks like a temporary issue unrelated to your changes here: https://github.com/AIDASoft/podio/actions/runs/7003341864/job/19048875848?pr=473#step:4:986 We will simply use the next run if there are more changes, or rerun this later and it should pass. |
For this, should I keep an ENABLE_JULIA toggle like ENABLE_SIO ? If julia executable is found, enable the toggle to on and then run the tests written for julia in tests/CMakeLists.txt? |
Okay. Yes I need to make one more change for ENABLE_JULIA. I may do the rebase as well. And force push the changes. |
Yes, I think doing the same thing as |
Okay. So, the datamodels for julia would only be generated when ENABLE_JULIA is ON and so the julia tests will run? |
Yes, exactly. |
6cdc07e
to
5b62bb9
Compare
I have added the ENABLE_JULIA toggle button. |
@tmadlener I have made all the asked changes. |
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.
Very nice. Thank you. I have just a few final minor comments. I can also just do them via the github web interface.
I will let @hegner or @graeme-a-stewart press the button.
BEGINRELEASENOTES
ENDRELEASENOTES