Skip to content

Document order of execution of Jinja Expressions #220

@gilesknap

Description

@gilesknap

This needs adding to the docs as an essential guide to how your yaml gets turned into runtime assets.

  • ioc.yaml files have their entities loaded in the order they appear in the file
  • first pass of rendering is for arguments and this applies to values supplied in ioc.yaml as well as defaults coming from the .support.yaml
    • argument values are interpreted in the order they appear in the file
    • Jinja expressions are allowed in string args (todo we would like to support jinja string | other_type unions).
    • The jinja context for argument rendering contains all the other arguments of the current entity.
    • An argument may therfore forward or backward reference other arguments
    • However only backward references will have any Jinja rendering already done
    • Note that a Jinja expression with (backward only) reference to another entity (using its id) will become a dataclass of the object's args (for complicated reasons it is not an actual Entity class - but the behaviour is nearly identical)
  • Once all Entity have been read in, we then render the pre_init and post_init using Jina
    • The order is again top to bottom of the file
    • The jinja context contains a dictionary of Entity classes indexed by their id (entities that have no id are not available to Jinja at this stage)

That's it! (phew!). Although this reads as complicated it is essentially just saying everything happens top to bottom of the yaml.

UPDATE: Caveat: Values are always evalutated after Args - this might be an issue. Maybe we need a PreValues and a PostValues to support the Technosoft axis number field??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions