Skip to content

Document and refactor jinja2 macros for consistency and modularity#203

Merged
bschwedler merged 20 commits intomainfrom
macro-fixes-and-enhancements
Sep 18, 2025
Merged

Document and refactor jinja2 macros for consistency and modularity#203
bschwedler merged 20 commits intomainfrom
macro-fixes-and-enhancements

Conversation

@ianpittwood
Copy link
Contributor

No description provided.

@github-actions
Copy link

github-actions bot commented Sep 17, 2025

Test Results

646 tests   646 ✅  3m 6s ⏱️
  1 suites    0 💤
  1 files      0 ❌

Results for commit f3bf649.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@bschwedler bschwedler left a comment

Choose a reason for hiding this comment

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

The comments on the python file apply to the other dependencies.

I'm on the fence about which approach is better:

  • More smarts in the macros, more compact Containerfile template, less end-user flexibility
  • Call more macros directly, larger Containerfile template, more end-user flexibility

Comment on lines 71 to 78
{%- if packages -%}
{{ install_packages_from_list(packages, False) }}{% if files or clean %} && \{% endif %}
{%- endif -%}
{%- if files -%}
{%- for file in files -%}
{{ install_packages_from_file(file | trim, clean) }}{% if (not loop.last) or clean %} && \{% endif %}
{%- endfor -%}
{%- endif -%}
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this approach It condenses a lot of the work down into a single layer.

install packages from. Optional if packages is provided.
:param clean: Whether to remove the requirements.txt file(s) after installation. Defaults to True.
#}
{% macro install_packages(version, packages = None, requirements_files = None, clean = True) -%}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it would be useful to have a combined step that would install the dependency version and then install the packages, even if they are defined in separate layers?

It would just be fewer lines in the Containerfile template, but is more indirection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I broke them out because I think caching works better if we install the version independently of any packages. Packages will change frequently while the version install should remain the same, right?

@ianpittwood ianpittwood marked this pull request as ready for review September 18, 2025 17:22
Copy link
Contributor

@bschwedler bschwedler left a comment

Choose a reason for hiding this comment

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

Thank you sooo much for doing this!

All comments are generally about style, not substance.

@bschwedler bschwedler merged commit 87d7f31 into main Sep 18, 2025
3 checks passed
@bschwedler bschwedler deleted the macro-fixes-and-enhancements branch September 18, 2025 20:27
@ianpittwood ianpittwood mentioned this pull request Sep 19, 2025
12 tasks
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.

2 participants