Skip to content

builtin_tags

Module that implements renderers for builtin-tags

render_node(node, tag, **ctx)

[!path] Construct an absolute file path by joining a path fragment to the known path of the parent of config root directory

Examples:

should point to <config-root>/../data/hello_world.csv

my_var: !path data/hello_world.csv

Source code in gamma/config/builtin_tags.py
@dispatch
def render_node(node: Node, tag: PathTag, **ctx) -> str:
    """[!path] Construct an absolute file path by joining a path
    fragment to the known path of the *parent* of config root directory

    Examples:
        # should point to `<config-root>/../data/hello_world.csv`
        my_var: !path data/hello_world.csv
    """
    path_fragment = node.value
    roots = get_config_roots()
    if len(roots) > 1:
        raise ValueError("More than one root defined, cannot use !path")
    base = get_config_roots()[0].parent
    return str(base.joinpath(path_fragment).absolute())