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_alias

Add a type alias to the namespace.

add_named_struct

Add a named struct to the namespace.

extract_aliases

Get a mapping from type alias names to type schemes.

extract_contents

Convert to a generic namespace used to define Tierkreis signatures.

extract_signature

Convert to a Tierkreis signature.

function

Decorator to register a python function as a Tierkreis function within the namespace.

get

get_function

Recursively search namespace tree for function by name.

items

keys

merge_namespace

Merge two namespaces together, joining on keys.

values

Attributes

functions

aliases

subspaces

add_alias(name: str, type_: Type) Type[source]#

Add a type alias to the namespace.

add_named_struct(name, type_: Type) Type[source]#

Add a named struct to the namespace.

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.

extract_signature(can_scope: bool) Signature[source]#

Convert to a Tierkreis signature.

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#