Skip to content

Conversation

@kassyray
Copy link
Member

@kassyray kassyray commented Nov 7, 2025

This pull request introduces support for switching between test mode (default) and production/PHU-specific mode in the pipeline, allowing dynamic selection of template packages and assets. The main changes include adding CLI flags to control the mode, refactoring template renderer selection to be dynamic, and updating Typst template functions for greater flexibility.

Test/Production mode support:

  • Added CLI flags --test-mode and --no-test-mode to pipeline/orchestrator.py, allowing users to toggle between test mode (shared templates/assets) and production mode (PHU-specific templates/assets). The default is test mode. [1] [2] [3]
  • Updated asset and template package selection logic in the orchestrator to use the appropriate directories and package names based on the chosen mode. [1] [2] [3]

Dynamic template renderer selection:

  • Refactored pipeline/generate_notices.py to import template renderers dynamically at runtime, based on the selected template package (templates or phu_templates), instead of hardcoding imports. This includes a new function _import_renderer and a mapping for module names. [1] [2] [3]
  • Updated all relevant functions (render_notice, generate_typst_files, main) to accept a templates_package argument and use the dynamic renderer selection. [1] [2] [3] [4] [5] [6] [7]

Typst template improvements:

  • Modified templates/conf.typ and usage in template files to accept a configurable logo_width and envelope_window_height for more flexible rendering. [1] [2] [3] [4] [5] [6] [7] [8]

Testing and coverage:

  • Updated unit tests to use the new templates_package argument when retrieving language renderers, ensuring compatibility with the refactored API. [1] [2] [3] [4]
  • Excluded print statements from coverage in pyproject.toml.

Documentation:

  • Added a new section to README.md explaining the test/production modes, CLI usage, and import path requirements for template packages.

@kassyray kassyray requested a review from jangevaare November 7, 2025 19:30
@kassyray
Copy link
Member Author

kassyray commented Nov 7, 2025

Note this is a draft pr! Still more to add here.

@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

❌ Patch coverage is 68.00000% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pipeline/generate_notices.py 66.66% 3 Missing and 3 partials ⚠️
pipeline/orchestrator.py 71.42% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@kassyray kassyray marked this pull request as ready for review November 10, 2025 15:15
Comment on lines +76 to +89
TEMPLATE_MODULE_MAP = {
# shared test templates package
"templates": {
Language.ENGLISH.value: "en_template",
Language.FRENCH.value: "fr_template",
},
# PHU-specific templates package (production)
"phu_templates": {
# PHU repo uses a different module name for English templates
Language.ENGLISH.value: "en_template_row",
# If a PHU-specific French template exists name it here, otherwise
# the code will fall back to the shared `templates` package.
Language.FRENCH.value: "fr_template",
},
Copy link
Member

Choose a reason for hiding this comment

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

This should perhaps be in config if needed

columns: (50%,50%),
gutter: 5%,
[#image(logo, width: 6cm)],
[#image(logo, width: logo_width)],
Copy link
Collaborator

Choose a reason for hiding this comment

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

is logo width and envelope width coming from config file?

// Immunization Notice Section
#let immunization_notice(client, client_id, immunizations_due, date, font_size) = block[
#v(0.2cm)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can these hard coded values 6cm and 81pt come from parameters?

Copy link
Member

Choose a reason for hiding this comment

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

See #70

@jangevaare
Copy link
Member

Closed with #111

@jangevaare jangevaare closed this Nov 13, 2025
@jangevaare jangevaare deleted the refactor/PHU-specific-templates branch November 13, 2025 14:31
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.

4 participants