nustack

cell

Cell ops: write one, edit it, place it, drop it.

Module nuspace.ops.cell.

Cell ops: write one, edit it, place it, drop it.

The only writer of the two facts that must agree about a cell's place: the plane's cells list and the cell's plane. Every op here that changes one writes the other in the same commit. A cell stays on the plane it was made on: nothing here moves one to another.

Every op here that writes a cell, or the plane's cells, counts it on the plane's version in the same commit, so following a plane's cells is one key to watch.

A cell is addressed by its id alone. An op that needs its plane reads plane off it, inside its own bracket.

A cell's state is in the other store (States). Dropping a cell drops it too, as a commit of its own after the structure one, in the order atomic_state gives.

NameCallMeaning
add_cellops.add_cell(plane_id, prog, cell_id=None, name='', index=None, made_by='', meta=None, into=None)Write a cell onto a plane and place it at index, in one commit.
remove_cellops.remove_cell(cell_id)Drop a cell: its live cell runs interrupted, off its plane, row deleted, then its state.
rename_cellops.rename_cell(cell_id, name)Set a cell's name. A no-op when it is missing.
reorder_cellsops.reorder_cells(plane_id, cell_ids)Put a plane's cells in the order given.
set_cell_metaops.set_cell_meta(cell_id, fields)Merge fields into a cell's meta. A no-op when it is missing.
set_progops.set_prog(cell_id, prog)Replace a cell's source, and its has_ui with it. Bumps its version.

add_cell

Write a cell onto a plane and place it at index, in one commit.

ops.add_cell(plane_id, prog, cell_id=None, name='', index=None, made_by='', meta=None, into=None)

Path nuspace.ops.add_cell. Defined on nuspace.ops.cell, bound as a function. Builds nu.Nu.

has_ui is worked out from prog (HasUi). The props are written every time, so an existing cell given again takes the ones passed now.

Arguments

NameTypeDefaultMeaning
plane_idnu.StrArgThe plane. Nothing is written when it is missing.
prognu.StrArgThe cell's source.
cell_idnu.StrArg | NoneNoneIts id, unique across the space. Minted when the term is evaluated when absent. Nothing is written when a cell of this id is on another plane.
namenu.StrArg''What to call it.
indexnu.IntArg | NoneNoneWhere in the plane's cells. The end when absent.
made_bynu.StrArg''Prop, the snippet it was made from, "" for none.
metadict[str, Any] | nu.Nu | NoneNoneFields to merge into its meta.
intonu.Ref | NoneNoneSet to the cell id in the commit, "" when nothing was written, for a caller that needs a minted one: the record does not say which cell this call made.

Undocumented: example.

remove_cell

Drop a cell: its live cell runs interrupted, off its plane, row deleted, then its state.

ops.remove_cell(cell_id)

Path nuspace.ops.remove_cell. Defined on nuspace.ops.cell, bound as a function. Builds nu.Nu.

Two commits, the row first. The other way round, a cell still on the plane (and its runs, still live until the interrupt lands) would read its state gone. This way the worst a crash between them leaves is state no cell points at.

Arguments

NameTypeDefaultMeaning
cell_idnu.StrArg

Undocumented: example.

rename_cell

Set a cell's name. A no-op when it is missing.

ops.rename_cell(cell_id, name)

Path nuspace.ops.rename_cell. Defined on nuspace.ops.cell, bound as a function. Builds nu.Nu.

Arguments

NameTypeDefaultMeaning
cell_idnu.StrArg
namenu.StrArg

Undocumented: example.

reorder_cells

Put a plane's cells in the order given.

ops.reorder_cells(plane_id, cell_ids)

Path nuspace.ops.reorder_cells. Defined on nuspace.ops.cell, bound as a function. Builds nu.Nu.

Ids not on the plane are skipped, and cells left out keep their place after the named ones, so a partial order is a move, not a truncation.

Arguments

NameTypeDefaultMeaning
plane_idnu.StrArg
cell_idsSequence[nu.StrArg] | nu.Nu

Undocumented: example.

set_cell_meta

Merge fields into a cell's meta. A no-op when it is missing.

ops.set_cell_meta(cell_id, fields)

Path nuspace.ops.set_cell_meta. Defined on nuspace.ops.cell, bound as a function. Builds nu.Nu.

Arguments

NameTypeDefaultMeaning
cell_idnu.StrArg
fieldsdict[str, Any] | nu.Nu

Undocumented: example.

set_prog

Replace a cell's source, and its has_ui with it. Bumps its version.

ops.set_prog(cell_id, prog)

Path nuspace.ops.set_prog. Defined on nuspace.ops.cell, bound as a function. Builds nu.Nu.

Live cell runs keep running the prog they loaded: rerunning them is the reload service's. Nothing validates: a broken prog stores fine, and reads as not drawing.

Arguments

NameTypeDefaultMeaning
cell_idnu.StrArg
prognu.StrArg

Undocumented: example.

On this page