IFC-2275 Add Jinja2 filters for artifact composition#889
IFC-2275 Add Jinja2 filters for artifact composition#889gmazoyer wants to merge 10 commits intogma-20260323-infp504-planfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (4)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying infrahub-sdk-python with
|
| Latest commit: |
02b33a1
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e43d48d6.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://gma-infp-504-artifact-compos.infrahub-sdk-python.pages.dev |
ce7a42e to
d7514e6
Compare
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## gma-20260323-infp504-plan #889 +/- ##
============================================================
Coverage ? 80.85%
============================================================
Files ? 120
Lines ? 10454
Branches ? 1557
============================================================
Hits ? 8453
Misses ? 1485
Partials ? 516
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Why
Customers building modular configuration pipelines need to compose larger artifacts from smaller sub-artifacts inside Jinja2 transforms, without duplicating template logic or GraphQL query fields. Today there is no way for a template to reference the rendered content of another artifact.
This PR implements the SDK side of the "Artifact of Artifacts" initiative, adding new Jinja2 filters and the supporting infrastructure to enable artifact content composition.
What changed
artifact_contentthat accepts astorage_idstring, fetches artifact content from the object store viaObjectStore.get()file_object_contentwith the same pattern but uses the/api/files/by-storage-id/{storage_id}endpoint, with binary content-type rejectionfrom_json/from_yamlto parse strings into Python dicts/lists, enabling chaining like{{ sid | artifact_content | from_json }}FilterDefinition.trusted: boolwithallowed_contexts: ExecutionContextusing Python'sFlagenumCORE(API server computed attributes, most restrictive),WORKER(Prefect workers),LOCAL(CLI/unrestricted)client: InfrahubClientconstructor parameterset_client()method for deferred client injection (per PR Add plan to implement INFP-504 #885 feedback)JinjaFilterErrorwith an actionable messageJinjaFilterError(filter_name, message, hint)subclassingJinjaTemplateErrorget_file_by_storage_id()method (async + sync) using/api/files/by-storage-id/{storage_id}application/octet-stream, etc.)Suggested review order
infrahub_sdk/template/filters.pyforExecutionContextenum andFilterDefinitionmigrationinfrahub_sdk/template/infrahub_filters.pyforInfrahubFiltersclass,from_json,from_yaml3
infrahub_sdk/template/__init__.pyforJinja2Templatewiring,set_client(),validate()changesinfrahub_sdk/object_store.pyforget_file_by_storage_id()How to review
validate()context logic iit is the core of the trust model change_register_client_filters()andset_client()ensure client-dependent filters are correctly bound or fallbackHow to test
Impact & rollout
validate(restricted=True/False)continues to work as before.FilterDefinition.trustedproperty preserved.Jinja2Templateconstructor is backward compatible (newclientparam is optional with defaultNone).Checklist
uv run towncrier create ...)