posit-dev / posit-dev/images-shared
Extract file I/O from config models into a TemplateRenderer service
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2
- Forks
- 0
- Avg merge
- 4d 13h
- Merged PRs (30d)
- 22
Description
`ImageVersion` and `ImageMatrix` both contain Jinja2 rendering logic and filesystem operations alongside model validation. Their `render_files()` implementations are nearly identical — the same Jinja2 environment setup, the same template-walk logic, the same error-aggregation pattern, and the same file-write calls — duplicated across both classes.
Testing `ImageVersion` rendering currently requires constructing a full model hierarchy with parent pointers and a real filesystem. That makes model validation tests expensive and tightly coupled to I/O.
Extract a `TemplateRenderer` service that accepts structured inputs (template values, template paths, output paths) and produces file artifacts. Both `ImageVersion` and `ImageMatrix` delegate to it, eliminating the duplication and allowing model validation tests to run without a real filesystem.
Files: `config/image/version.py`, `config/image/matrix.py`, `config/config.py`, `config/templating/`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the duplicated render_files() implementations in config/image/version.py and config/image/matrix.py, then inspect config/config.py and the existing config/templating/ code. Define the TemplateRenderer around the structured inputs described in the issue, delegate rendering from both models, and verify that model validation no longer requires a real filesystem.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100