nustack
ReferenceNu

context

The Context fabric: the in-memory `ctx.attrs` and fabric bindings.

Module nu.context.

The Context fabric: the in-memory ctx.attrs and fabric bindings.

A Fabric is an addressable space where Refs live; it resolves Refs and carries out the Interactions over them. The Context fabric has two axes:

  • attrs - a flat, name-keyed store (ctx.attrs) for short-lived primitives (loop counters, accumulators, markers). Ref: AttrRef; writes: SetCmd / Delete; existence: AttrExists. The read is AttrRef itself.
  • fabric - typed bindings (ctx.bind / ctx.get) for every other ctx-bound thing: execution resources, storage handles, cluster handles, compute actors. Ref: FabricRef (read-only, self-yields); existence: FabricExists. Provisioning brackets Provide / ProvideList / ProvideDict install fabrics into the Context for a body's duration. Protocols Fabric (empty marker; every ctx-bound thing satisfies it) and FabricLifecycle(Fabric) (with optional setup / cleanup) describe the contract.

The read on the attrs axis is the Ref's dual role; only existence needs an explicit query. Other concrete fabrics (virtuals, mem, ray, ...) follow the same shape in their own dirs: concrete Refs plus the interactions that touch that fabric. Nothing in nu.core touches a fabric - core is the pure Python builtins.

attrs.interactions

Module nu.context.attrs.interactions.

Attr-fabric interactions: SetCmd, Delete, AttrExists, Let.

Full entries

NameSortCallMeaning
AttrExistsscalar_queryAttrExists(ref)Whether the address of its AttrRef is bound in ctx.attrs.
Deletescalar_commandDelete(ref)Removes the slot its Ref names from the fabric, through that Ref.
LetbracketLet(name, value, body=None)Binds a name to a value in ctx.attrs for the body's duration.
SetCmdscalar_commandSetCmd(ref, value)Writes a value into the slot its Ref names, through that Ref.

fabric.queries

Module nu.context.fabric.queries.

Fabric existence query.

Full entries

NameSortCallMeaning
FabricExistsscalar_queryFabricExists(ref)Whether the fabric type of its FabricRef is bound on the Context.

fabric.lifecycle

Module nu.context.fabric.lifecycle.

Provide brackets: construct + bind fabrics for the body's duration.

Full entries

NameSortCallMeaning
ProvidebracketProvide(cls, kwargs=None, body=None, tag=None, tags=(), predicate=None, bind_as=None)Constructs one fabric and binds it on the Context for the body's duration.
ProvideDictbracketProvideDict(cls, specs, body=None, extra_tags=(), predicate=None, bind_as=None, parallel=False)Constructs a fleet of one class and binds each member under its own key.
ProvideListbracketProvideList(cls, specs, body=None, base_tag=0, extra_tags=(), predicate=None, bind_as=None)Constructs a fleet of one class and binds each member under its index.
WithbracketWith(body=None)Enters several lifecycle brackets around one body, tearing down in reverse.

attrs.refs

Module nu.context.attrs.refs.

AttrRef and its typed variants.

Full entries

NameSortCallMeaning
AnyAttrRefrefAnyAttrRef()An AttrRef with the dynamic any interface.
AttrRefrefAttrRef(address)A Ref into the ctx.attrs store, keyed by its resolved address.
BoolAttrRefrefBoolAttrRef()An AttrRef with the full boolean interface.
BytesAttrRefrefBytesAttrRef()An AttrRef with the full bytes interface.
DictAttrRefrefDictAttrRef()An AttrRef with the full dict interface.
FloatAttrRefrefFloatAttrRef()An AttrRef with the full float interface.
FrozenSetAttrRefrefFrozenSetAttrRef()An AttrRef with the full frozenset interface.
IntAttrRefrefIntAttrRef()An AttrRef with the full integer interface.
ListAttrRefrefListAttrRef()An AttrRef with the full list interface.
NoneAttrRefrefNoneAttrRef(source=None)An AttrRef with the none interface.
SetAttrRefrefSetAttrRef()An AttrRef with the full set interface.
StrAttrRefrefStrAttrRef()An AttrRef with the full string interface.
TupleAttrRefrefTupleAttrRef()An AttrRef with the full tuple interface.

fabric.refs

Module nu.context.fabric.refs.

FabricRef: a Ref into a Context binding.

Full entries

NameSortCallMeaning
FabricRefrefFabricRef(address=None)A Ref into a Context binding, keyed by the fabric type it resolves to.

On this page