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 support for reading .j2 config files with jinja #246

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

Conversation

aelanman
Copy link
Contributor

@aelanman aelanman commented Jun 9, 2022

No description provided.

@andrerenard andrerenard self-requested a review June 9, 2022 20:02
Copy link

@andrerenard andrerenard left a comment

Choose a reason for hiding this comment

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

I think we should add jinja2 to the requirements.txt file.

@aelanman aelanman marked this pull request as ready for review June 13, 2022 15:19
@aelanman
Copy link
Contributor Author

@andrerenard I've updated the requirements and marked this PR ready for review

@jrs65
Copy link
Contributor

jrs65 commented Jun 13, 2022

Is it worth trying to centralise the parsing of Jinja files into configs that kotekan will read? It would be nice to avoid the issue of having potentially divergent schemes for doing this parsing.

This would require solving the issue that kotekan simply embeds its processing into kotekan.cpp.

@andrerenard
Copy link

andrerenard commented Jun 13, 2022

Perhaps this is a worth a wider discussion on the call this week, but I'm hesitant move to a model which calls python first to parse things and then calls kotekan. It could be done, but it creates some potential issues around how logging and debuggers/GPU profilers work. In most production situations kotekan runs as a service and it really has no need for python, and there is no reason to run it through a wrapper. So I could see being in a world where we end up with different files to run in different modes. If we just want to make sure we are parsing the same way (not that we are doing anything fancy yet) we could just call the python/scripts/config_to_json.py script in the kotekan repo which is the source for the kotekan.cpp call.

Copy link

@andrerenard andrerenard left a comment

Choose a reason for hiding this comment

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

Notwithstanding @jrs65's concerns about centralizing the parsing logic, this looks good to me. However, I think we should try to get the aioredis_v2 branch merged into main before we merge this, since the way the CI is configured we aren't running the new unit test here. And it would be nice to keep the aioredis changes as a separate PR from this.

@jrs65
Copy link
Contributor

jrs65 commented Jun 13, 2022

If we just want to make sure we are parsing the same way (not that we are doing anything fancy yet) we could just call the python/scripts/config_to_json.py script in the kotekan repo which is the source for the kotekan.cpp call.

I would suggest doing this:

  • Create a python module as part of the kotekan python package that has routines for doing all the parsing.
  • Adding a if __name__ == "__main__" block to it such that it runs directly as a script without needing the package to be installed.
  • Have coco install the kotekan python package and use the API from the new parsing module.
  • Have kotekan either run the python script from an installed location in the fs, or have CMake embed the script at build time in a .h file, and have kotekan compile the string version of the script into the binary from that file (but otherwise run as it currently does).

I think that can be made to conveniently work in all envisaged cases from a single implementation.

However, we might want to pause on merging this PR until we've figured out what to do as in the case above the logic ends up exclusively in the kotekan python package.

@jrs65
Copy link
Contributor

jrs65 commented Jun 13, 2022

Agree. That we should merge the aioredis branch first. Currently it fails a bunch of the linting and doc building tests though.

@andrerenard
Copy link

@jrs65 I really like that proposal, and I'll also vote we implement this as a python package in the kotekan repo. That also makes it easier and more consistent for projects that want to use something other than coco for system control.

@andrerenard andrerenard self-requested a review June 13, 2022 19:23
Copy link

@andrerenard andrerenard left a comment

Choose a reason for hiding this comment

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

Changing this to "changes needed", in response to @jrs65's proposal, which I think we should implement.

@aelanman
Copy link
Contributor Author

Agree. That we should merge the aioredis branch first. Currently it fails a bunch of the linting and doc building tests though.

@jrs65 It looks like none of these linting errors on that PR are from my changes. Should I still address them all?

@aelanman
Copy link
Contributor Author

@andrerenard @jrs65 I've adjusted this accordingly with the changes in kotekan. I set the requirements.txt file to install the version of kotekan on the ael/jinja branch so the tests could pass, but I'll need to set that back to develop once that branch is merged.
kotekan/kotekan#1030

Base automatically changed from aioredis_v2 to master September 8, 2022 20:38
@jrs65
Copy link
Contributor

jrs65 commented Sep 8, 2022

@aelanman if you update this now #242 is merged I can take another look.

@aelanman aelanman force-pushed the jinja branch 2 times, most recently from 664d376 to 0e54037 Compare September 13, 2022 21:19
@aelanman
Copy link
Contributor Author

aelanman commented Dec 6, 2022

@andrerenard @jrs65 I thought this was merged earlier today, but was mistaken. Is there anything else needed for this to be merged?

@aelanman aelanman requested a review from andrerenard December 31, 2022 16:15
tests/test_state.py Outdated Show resolved Hide resolved
@aelanman aelanman force-pushed the jinja branch 2 times, most recently from e7d522f to 4e8c740 Compare January 24, 2023 21:44
@aelanman aelanman force-pushed the jinja branch 2 times, most recently from bc2071b to 87be818 Compare March 23, 2023 20:22
@aelanman aelanman force-pushed the jinja branch 2 times, most recently from 29df94b to ddf0fe7 Compare July 23, 2023 19:29
@aelanman aelanman dismissed andrerenard’s stale review February 16, 2024 16:16

changes have been made

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.

3 participants