Skip to content
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

Add ExtraCode declarationFile and implementationFile directives #601

Merged
merged 13 commits into from
May 22, 2024

Conversation

m-fila
Copy link
Contributor

@m-fila m-fila commented May 13, 2024

BEGINRELEASENOTES

  • Added ExtraCode declarationFile and implementationFile directives

ENDRELEASENOTES

Added 'ExtraCode' directives 'declarationFile' and 'implementationFile' used to include/embed files in code generated with jinja. This feature was planned but not implemented so far. Can be used to fix key4hep/EDM4hep#296

The paths to 'declarationFile' and 'implementationFile 'can be either absolute or relative to datamodel yaml. Should this be relative to working directory?

The files declared in 'declarationFile' and 'implementationFile' are not added as configuration dependency in cmake, so the changes to these files will not automatically trigger re-generating a data model. I don't know if there is an easy way to fix this

TODO:

  • test mutable declaration and mutable implementations in datatype
  • add component 'declarationFile'
  • test declarationFile in component
  • fix tests that copy the yml file

@m-fila m-fila marked this pull request as ready for review May 15, 2024 22:05
Copy link
Collaborator

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on. IIUC the injection happens in the jinja stage, right? This also means that the implementation files (or at least their contents) are not stored in the output files, right? (At least that is my explanation for having to carry them to the tests directory for the roundtrip tests).

Would it be possible to have the "parsing" of these implementation file at the datamodel reading stage? I.e. whenever we encounter such an implementation file, we just inject the contents directly into the existing ExtraCode bit? In that way we they should directly end up in the datamodel definition that is stored in the file (I think / hope). Additionally, I think we would not have to touch the generation step at all(?).

@m-fila
Copy link
Contributor Author

m-fila commented May 16, 2024

Yes, during jinja step a python function is used to read a file and return its content to jinja, which just put it as is into generated file. The files itself are not copied anywhere.
In the metada datamodel definitions the 'declarationFile' and 'implementationFile' are put without any modifications, which was causing problems when the paths are relative, hence I copied the files to build directory

I think appending the contents of 'declatationFile' to 'declaration' during parsing should work better and give more transparent metadata. Thanks 😃

Copy link
Collaborator

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice. Did you check whether this works in the end for EDM4hep and whether it really resolves the issue you set out to fix? edit: yes you did, I missed the corresponding PR. Sorry.


The paths to 'declarationFile' and 'implementationFile 'can be either absolute or relative to datamodel yaml. Should this be relative to working directory?

No I think absolute, or relative to the yaml file is fine. But we should document it.

The files declared in 'declarationFile' and 'implementationFile' are not added as configuration dependency in cmake, so the changes to these files will not automatically trigger re-generating a data model. I don't know if there is an easy way to fix this

One possibility (that would make it easy for us / podio again) would be to document this and tell people that they have to add this to their cmake configuration via, similar to what we do in the macro:

set_property(
DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
${YAML_FILE}
${PODIO_TEMPLATES}
${podio_PYTHON_DIR}/podio_class_generator.py
${podio_PYTHON_DIR}/podio_gen/generator_utils.py
${podio_PYTHON_DIR}/podio_gen/podio_config_reader.py
${podio_PYTHON_DIR}/podio_gen/generator_base.py
${podio_PYTHON_DIR}/podio_gen/cpp_generator.py
${podio_PYTHON_DIR}/podio_gen/julia_generator.py
)

The only thing we could potentially offer is to make the macro take an additional list of the files that are used in the datamodel and add them there. But at that point the users do not gain too much, I think.

@hegner
Copy link
Collaborator

hegner commented May 22, 2024

If builds run through, I will merge it

@hegner hegner merged commit 0a5af60 into AIDASoft:master May 22, 2024
18 checks passed
@m-fila m-fila deleted the extracode branch May 23, 2024 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing methods in doxygen documentation for CovMatrix classes
3 participants