Namespace#
- class tierkreis.worker.namespace.Namespace[source]#
Bases:
Mapping
[str
,Namespace
]Namespace containing Tierkreis Functions, keyed by function name. Used to construct Tierkreis namespaces from python defined functions in workers.
Methods
Add a type alias to the namespace.
Add a named struct to the namespace.
Get a mapping from type alias names to type schemes.
Convert to a generic namespace used to define Tierkreis signatures.
Convert to a Tierkreis signature.
Decorator to register a python function as a Tierkreis function within the namespace.
Recursively search namespace tree for function by name.
Merge two namespaces together, joining on keys.
Attributes
functions
aliases
subspaces
- extract_aliases() dict[str, TypeScheme] [source]#
Get a mapping from type alias names to type schemes.
- extract_contents() Namespace [source]#
Convert to a generic namespace used to define Tierkreis signatures.
- function(name: str | None = None, constraints: List[Constraint] | None = None, type_vars: Dict[str | TypeVar, Kind] | None = None, callback: bool = False, metadata_keys: list[str] | None = None) Callable[[Callable], Callable] [source]#
Decorator to register a python function as a Tierkreis function within the namespace.
- Parameters:
name – Optionally explicitly set the name of the function, defaults to None (in which case the function name is used)
constraints – Type constraints needed to define the type scheme of the function.
type_vars – Declare type variables used in the function signature.
callback – Whether the function expects a callback client as the first argument, in order to make graph execution requests.
metadata_keys – List of keys in the metadata dictionary that the function uses. If present, the function should expect a parameter named tierkreis_metadata which is a dictionary with specified keys, mapped to the values present in the function request GRPC metadata.
- get(k[, d]) D[k] if k in D, else d. d defaults to None. #
- get_function(name: FunctionName) Function | None [source]#
Recursively search namespace tree for function by name.
- items() a set-like object providing a view on D's items #
- keys() a set-like object providing a view on D's keys #
- merge_namespace(other: Namespace)[source]#
Merge two namespaces together, joining on keys. On collisions raises
NamespaceClash
.
- values() an object providing a view on D's values #