luna.template
TemplateNoRuntimeContext Objects
class TemplateNoRuntimeContext()
Context class that allows to use a template out of runtime. This is useful when needing to access a template's members without the magic passthroughs.
An example of a passthrough is self.param
returning the parameter value instead
of the actual Parameter
object.
Template Objects
class Template()
without_runtime
def without_runtime() -> TemplateNoRuntimeContext
Returns the template without the runtime passthrough magic activated.
info
@classmethod
def info(cls) -> TemplateInfo
Returns general information about a given template.
parse_parameters
@classmethod
def parse_parameters(
cls,
params: Dict[str,
JsonValue]) -> Result[Dict[str, Any], List[ValidationError]]
Given a string dict of parameter names and values, this function parses the dict and returns a same-shaped dict but with Python types instead of string representations. This is used to parse user inputs from the UI.
get_parameters
@classmethod
def get_parameters(cls) -> Dict[str, Parameter]
Get all parameter definitions of template.
get_variables
@classmethod
def get_variables(cls) -> dict[str, Variable]
Get all variable definitions of template.
get_connections
@classmethod
def get_connections(cls) -> dict[str, Connection]
Get all connection definitions of template.
RuntimeTemplate Objects
class RuntimeTemplate()
This class wraps a Template and a State together such that the template gets injected with the state. This is useful to pass the two around whilst avoiding errors such as
- mixing different states
- forgetting to inject the state into the template