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

Jinja2 Templating Infra #446

Merged
merged 8 commits into from
Jan 13, 2025
Merged

Jinja2 Templating Infra #446

merged 8 commits into from
Jan 13, 2025

Conversation

TimothyWillard
Copy link
Contributor

Describe your changes.

This pull request extracts out the Jinja2 templating infrastructure from GH-394 to make that pull request a bit more simple to review. It adds an internal _jinja module to the gempyor package with the (closely related) functions:

  • _get_template to pull templates from the templates/ directory,
  • _render_template to render a template with provided template data,
  • _render_template_to_file to render a template and save it to a file, and
  • _render_template_to_temp_file to render a template to a temp file and return that temp file.

Changes include unit tests and docstrings to document internal functionality.

Does this pull request make any user interface changes? If so please describe.

The user interface changes are none. All changes provide internal utilities to the gempyor python package.

Those are reflected in updates to the documentation in the docstrings of the relevant functions.

What does your pull request address? Tag relevant issues.

This pull request addresses GH-365 by simplifying GH-394.

Functionality to render jinja2 templates to make creating batch files
easier. Also opens up the door to future use of templates like creating
config files. Associated docs+tests included.
@TimothyWillard TimothyWillard added enhancement Request for improvement or addition of new feature(s). gempyor Concerns the Python core. batch Relating to batch processing. medium priority Medium priority. next release Marks a PR as a target to include in the next release. labels Jan 6, 2025
@TimothyWillard TimothyWillard changed the base branch from main to dev January 6, 2025 22:45
@TimothyWillard TimothyWillard mentioned this pull request Jan 6, 2025
11 tasks
Attempt to fix Jinja2 lader issue by falling back to a file system
loader if a package loader fails.
@TimothyWillard TimothyWillard force-pushed the feature/365/templating-infra branch from b5f3aad to 1d82cd4 Compare January 6, 2025 22:52
@TimothyWillard TimothyWillard linked an issue Jan 7, 2025 that may be closed by this pull request
Copy link
Contributor

@pearsonca pearsonca left a comment

Choose a reason for hiding this comment

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

Seems fine, but I think there are some engineering questions to answer.

Related: how should we be maintaining the answers to questions like these? I see the method docstrings, but where is the developer comments explaining our thinking / decisions?

flepimop/gempyor_pkg/src/gempyor/_jinja.py Show resolved Hide resolved
Per @pearsonca request:
* Only use the `PackageLoader` for setting up the jinja environment.
* Removed `gempyor._jinja._get_template/_render_template`.
@TimothyWillard
Copy link
Contributor Author

how should we be maintaining the answers to questions like these? I see the method docstrings, but where is the developer comments explaining our thinking / decisions?

Isn't that what PRs are for? I don't see why code needs documentation to reflect the decisions made to produce it.

@TimothyWillard TimothyWillard merged commit 5eee4a6 into dev Jan 13, 2025
3 checks passed
@TimothyWillard TimothyWillard deleted the feature/365/templating-infra branch January 13, 2025 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
batch Relating to batch processing. enhancement Request for improvement or addition of new feature(s). gempyor Concerns the Python core. medium priority Medium priority. next release Marks a PR as a target to include in the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature request]: EMCEE integration with inference_job.py
5 participants