Serve¶
How a workbench starts: the femforge bridge, the serve entry points, the command line, the shell, the launcher, the demo, the background tasks and the dev reload loop.
femforge.workbench
¶
The workbench API from the femforge-workbench package, which the workbench extra installs.
Without the extra, importing this module, and so reading femforge.workbench, raises an ImportError that names the install command.
Type Aliases:
-
TaskFactory–A module-level function listing a script's tasks; called again after every save and in every task's child process.
Classes:
-
FieldControlsPanel–The viewer's controls: the field, mode and colormap selects, the display switches, the colour range, the body tree and the field-line options.
-
FieldViewerPanel–The 3D view of the field scene, mirrored in the browser by default; its visibility feeds the controller.
-
FigurePanel–Shows one plotly figure;
updateswaps it (uirevision keeps brushes and cameras),bindroutes its events to handlers. -
Panel–One tab: its title, the builder that makes its component once the shell exists, and its share of the axis.
-
PanelComponent–A dock panel: its template is built once inside
layout; state variables go throughkey. -
RunBrowserPanel–The run index as a virtual table: text, status, tag and physics filters narrow it in polars, a row click selects the run.
-
RunDetailPanel–One run bundle: its manifest summary, stage timeline, results, artifact inputs, files and retention.
-
SetupPanel–The Setup tab beside the field viewer's controls: the frame, every body and boundary group with what it received, and the glyph legend.
-
Split–Panels, tab groups or splits sharing one axis by weight; the axis alternates with nesting, horizontal at the root.
-
TablePanel–A read-only table whose rows go over once, the client sorting, filtering, faceting, reordering, hiding and grouping them;
leadorders the leading columns and pins the first. -
Tabs–Panels sharing one tab group, the first shown.
-
Task–One background task: a label unique in its plan and the zero-argument callable a child process runs.
-
Window–Where a served workbench opens.
-
Workbench–One trame server with the header, the dock and the panels of a named workbench.
Functions:
-
artifact_store–The store the artifact panels read:
FEMFORGE_ARTIFACTSwhen set, else the root the index rows name. -
field_viewer–The field viewer dock: the controls and the Setup tab beside the view.
-
show–Serves a workbench until its window closes: a Split as built, a factory or card rebuilt on every save, or the launcher when none is given.
TaskFactory
¶
A module-level function listing a script's tasks; called again after every save and in every task's child process.
FieldControlsPanel
¶
Bases: PanelComponent
The viewer's controls: the field, mode and colormap selects, the display switches, the colour range, the body tree and the field-line options.
Parameters:
-
app(Workbench) –The workbench shell the panel is built in.
-
id(str) –The panel id, which names its template and namespaces its state.
-
title(str) –The panel's tab title.
-
controller(FieldViewerController) –The viewer's controller, shared with the view.
Methods:
-
build_run_picker–The run select, disabled while it has nothing to offer, and beside it the open run's bundle path to read or copy and a button that opens its folder; the app bar holds it.
-
reveal_run–Opens the open run's bundle directory in the file manager.
-
build_colormap–The field colormap picker: searchable, filtered by type and favorites, the arrow keys stepping through it while it is closed.
-
slider–A slider over
modelwhose thumbs move with the drag and whose scene follows the release. -
build_range–The Auto Range switch over the two-thumb color range across the data range, its ends read out above it and the colormap between its thumbs; a moved thumb pins the range.
-
build_legend–The legend's three states as one segmented choice.
-
build_opacity–The Opacity mapping switch and, while it is on, the opacity at each end of the color range; the body table holds the overall opacity.
-
build_symmetry–The symmetry section of a section run that can be expanded: what it was solved as, the forms its frame offers and how far a revolution sweeps.
-
build_deformation–The deformation section: the Deformed Shape switch and, while it is on, the scale the displacement is exaggerated by.
-
build_field–The field section: what is shown and how it is colored, from the field select to the opacity mapping.
-
build_bodies–The body table: the All Bodies row, whose look sets every body and the overall opacity, then a row per body and per material group, each its look and its name.
-
build_lines–The field-line section: the switch, the seeds, the region and the two integration sliders.
-
build–Builds the busy bar over the symmetry, deformation, field, field-line and body sections.
-
dispose–Detaches from the controller, then releases the panel.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
build_run_picker
¶
The run select, disabled while it has nothing to offer, and beside it the open run's bundle path to read or copy and a button that opens its folder; the app bar holds it.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
reveal_run
¶
Opens the open run's bundle directory in the file manager.
build_colormap
¶
The field colormap picker: searchable, filtered by type and favorites, the arrow keys stepping through it while it is closed.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
slider
¶
A slider over model whose thumbs move with the drag and whose scene follows the release.
Parameters:
-
model(FieldVar) –The state variable holding the thumb values.
-
label(str) –The slider's accessible name.
-
bounds(tuple[float, float | Bind]) –The low and high ends; the high end may be a client expression.
-
step(float | Bind) –The step between values; it may be a client expression.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
build_range
¶
The Auto Range switch over the two-thumb color range across the data range, its ends read out above it and the colormap between its thumbs; a moved thumb pins the range.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
build_legend
¶
The legend's three states as one segmented choice.
build_opacity
¶
The Opacity mapping switch and, while it is on, the opacity at each end of the color range; the body table holds the overall opacity.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
build_symmetry
¶
The symmetry section of a section run that can be expanded: what it was solved as, the forms its frame offers and how far a revolution sweeps.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
build_deformation
¶
The deformation section: the Deformed Shape switch and, while it is on, the scale the displacement is exaggerated by.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
build_field
¶
The field section: what is shown and how it is colored, from the field select to the opacity mapping.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
build_bodies
¶
The body table: the All Bodies row, whose look sets every body and the overall opacity, then a row per body and per material group, each its look and its name.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 | |
build_lines
¶
The field-line section: the switch, the seeds, the region and the two integration sliders.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
build
¶
Builds the busy bar over the symmetry, deformation, field, field-line and body sections.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
dispose
¶
FieldViewerPanel
¶
Bases: ScenePanel
The 3D view of the field scene, mirrored in the browser by default; its visibility feeds the controller.
Parameters:
-
app(Workbench) –The workbench shell the panel is built in.
-
id(str) –The panel id, which names its template and namespaces its state.
-
title(str) –The panel's tab title.
-
controller(FieldViewerController) –The viewer's controller, shared with the controls.
Methods:
-
clear–Empties the plotter and pushes the empty frame.
-
refit–Fits the camera to the model and, while the Setup tab shows them, the glyphs and their labels;
glidemoves the mirror's camera there instead of jumping. -
highlights–The hidden hover outline of each entity the shown glyph layer drew.
-
hover_key–The Setup tab's hovered row, which both tabs share through the controller's state.
-
rescale–Sizes the text for the new window scale and has the controller redraw, so the glyph layer takes the scale too.
-
switch–Switches the transport, then redraws the glyph layer for the other window scale.
-
on_visible–Tells the scene and the controller whether the view is on screen.
-
dispose–Detaches from the controller, then frees the view.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
clear
¶
refit
¶
refit(*, glide: bool = False) -> None
Fits the camera to the model and, while the Setup tab shows them, the glyphs and their labels; glide moves the mirror's camera there instead of jumping.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
highlights
¶
The hidden hover outline of each entity the shown glyph layer drew.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
hover_key
¶
hover_key() -> str
The Setup tab's hovered row, which both tabs share through the controller's state.
rescale
¶
Sizes the text for the new window scale and has the controller redraw, so the glyph layer takes the scale too.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
switch
¶
switch(mode: ViewMode, *, persist: bool) -> None
Switches the transport, then redraws the glyph layer for the other window scale.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
on_visible
¶
on_visible(visible: bool) -> None
Tells the scene and the controller whether the view is on screen.
dispose
¶
FigurePanel
¶
FigurePanel(app: Workbench, id: str, title: str, figure: Figure | None = None, *, mode_bar: bool = True)
Bases: PanelComponent
Shows one plotly figure; update swaps it (uirevision keeps brushes and cameras), bind routes its events to handlers.
Parameters:
-
app(Workbench) –The workbench shell the panel is built in.
-
id(str) –The panel id, which names its template and namespaces its state.
-
title(str) –The panel's tab title.
-
figure(Figure | None, default:None) –The figure shown first; None starts empty.
-
mode_bar(bool, default:True) –Whether plotly's modebar shows.
Methods:
-
build–Pushes the figure into the state and builds the plot bound to it.
-
encode–The figure as plain JSON with the modebar switch and the export name it carries.
-
update–Replaces the figure.
-
bind–Routes a plotly event to
handlerwith the event payload as its one argument.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/figure.py
build
¶
Pushes the figure into the state and builds the plot bound to it.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/figure.py
encode
¶
The figure as plain JSON with the modebar switch and the export name it carries.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/figure.py
update
¶
bind
¶
Routes a plotly event to handler with the event payload as its one argument.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/figure.py
Panel
dataclass
¶
One tab: its title, the builder that makes its component once the shell exists, and its share of the axis.
Attributes:
-
name(str) –The tab title, from which the panel id is derived when
idis None. -
build(Builder) –Makes the panel's component from the shell, the panel id and the title, once the shell exists.
-
weight(float) –[-]: The panel's share of its parent's axis, relative to its siblings' weights. -
id(str | None) –The panel id; None derives it from
name. -
panel_id(str) –The id the dock knows the panel by:
idwhen given, elsenamelowercased with dashes.
name
instance-attribute
¶
name: str
The tab title, from which the panel id is derived when id is None.
build
instance-attribute
¶
build: Builder
Makes the panel's component from the shell, the panel id and the title, once the shell exists.
weight
class-attribute
instance-attribute
¶
weight: float = 1
[-]: The panel's share of its parent's axis, relative to its siblings' weights.
PanelComponent
¶
Bases: TrameComponent
A dock panel: its template is built once inside layout; state variables go through key.
Parameters:
-
app(Workbench) –The workbench shell the panel is built in.
-
id(str) –The panel id, which names its template and namespaces its state.
-
title(str) –The panel's tab title.
Methods:
-
build–Adds the panel's widgets to its layout.
-
key–A state variable or trigger name namespaced to this panel.
-
status–Reports in the shell's status line.
-
toast–Shows a short message in the shell's bottom-right corner.
-
download–Hands the browser a file to save, through the shell.
-
refresh–Pushes the template again after its widgets changed.
-
callback–A client event handler calling
fnwith the JSargs, unregistered again when the panel is disposed. -
optimistic–A client event handler that writes the JS
valueinto the state variablemodelat once, then callsfnwith the JSargson the server. -
listen–Registers a state listener like
state.change, one the panel drops again when disposed. -
dispose–Releases what the panel registered on the server once it left the dock: triggers, state listeners and controller slots.
-
succeed–Called on a panel rebuilt under the id of
previous, already disposed, to carry over what a fresh build would lose. -
on_visible–Called when dockview shows or hides the panel.
-
restyle–Called after the render settings changed, for a panel that draws with them to redraw.
-
on_layout_changed–Called after the dock re-laid out its groups.
Attributes:
-
listeners(list[Listener]) –The state listeners registered through
listen, dropped again bydispose. -
bound(list[Handler]) –The callables handed to
callback, whose triggersdisposeunregisters. -
legacy(dict[Carry, object]) –What
disposeleaves for a successor; read by itssucceed, never through the reloadable classes.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/__init__.py
listeners
instance-attribute
¶
The state listeners registered through listen, dropped again by dispose.
bound
instance-attribute
¶
The callables handed to callback, whose triggers dispose unregisters.
legacy
instance-attribute
¶
What dispose leaves for a successor; read by its succeed, never through the reloadable classes.
build
¶
key
¶
download
¶
Hands the browser a file to save, through the shell.
Parameters:
-
name(str) –The file name the browser suggests.
-
data(bytes) –The file's bytes.
-
media_type(str) –The file's media type, such as
image/png.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/__init__.py
refresh
¶
callback
¶
A client event handler calling fn with the JS args, unregistered again when the panel is disposed.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/__init__.py
optimistic
¶
A client event handler that writes the JS value into the state variable model at once, then calls fn with the JS args on the server.
Parameters:
-
fn(Handler) –The server handler, which writes the same value and so changes nothing the control shows.
-
model(str) –The state variable the control binds.
-
value(str) –The JS expression the control's new state evaluates to.
-
args(str) –The JS expression of
fn's argument list, evaluated after the write, so the model already holds the new value.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/__init__.py
listen
¶
Registers a state listener like state.change, one the panel drops again when disposed.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/__init__.py
dispose
¶
Releases what the panel registered on the server once it left the dock: triggers, state listeners and controller slots.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/__init__.py
succeed
¶
succeed(previous: PanelComponent) -> None
Called on a panel rebuilt under the id of previous, already disposed, to carry over what a fresh build would lose.
restyle
¶
RunBrowserPanel
¶
Bases: TablePanel
The run index as a virtual table: text, status, tag and physics filters narrow it in polars, a row click selects the run.
Parameters:
-
app(Workbench) –The workbench shell the panel is built in.
-
id(str) –The panel id, which names its template and namespaces its state.
-
title(str) –The panel's tab title.
-
telemetry(Telemetry) –The telemetry root whose run index the table lists.
Methods:
-
query–The run index query before the toolbar's filters.
-
index–The narrowed index frame, with the live claims joined on.
-
table_frame–One index frame as the table's rows, remembering which of its runs are claimed and where their bundles live.
-
vocabulary–The distinct non-null values of one index column, for a filter's choices.
-
tag_vocabulary–Every
key=valuepair the indexed runs carry, deduplicated. -
build–Builds the filter toolbar over the run table and listens to the filters.
-
count–The status text: how many runs the table holds and how many are live.
-
chosen–The one value a filter names, or nothing while it names
any. -
on_narrowing–Re-queries the index after a toolbar filter changed.
-
poll–Refreshed rows while a run is claimed or a claim just came or went, else None: an idle table costs one directory glob.
-
publish–Writes one index frame into the table.
-
on_pick–Publishes the clicked run for the detail panel.
-
on_visible–Runs the live refresh only while the panel is on screen.
-
dispose–Stops the live refresh, then releases the panel.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
index
¶
table_frame
¶
One index frame as the table's rows, remembering which of its runs are claimed and where their bundles live.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
vocabulary
¶
The distinct non-null values of one index column, for a filter's choices.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
tag_vocabulary
¶
Every key=value pair the indexed runs carry, deduplicated.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
build
¶
Builds the filter toolbar over the run table and listens to the filters.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
chosen
¶
The one value a filter names, or nothing while it names any.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
on_narrowing
¶
on_narrowing(**_: object) -> None
Re-queries the index after a toolbar filter changed.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
poll
¶
Refreshed rows while a run is claimed or a claim just came or went, else None: an idle table costs one directory glob.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
publish
¶
Writes one index frame into the table.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
on_pick
¶
on_pick(row: Row) -> None
Publishes the clicked run for the detail panel.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
RunDetailPanel
¶
RunDetailPanel(app: Workbench, id: str, title: str, *, telemetry: Telemetry, store: LocalArtifactStore)
Bases: PanelComponent
One run bundle: its manifest summary, stage timeline, results, artifact inputs, files and retention.
Parameters:
-
app(Workbench) –The workbench shell the panel is built in.
-
id(str) –The panel id, which names its template and namespaces its state.
-
title(str) –The panel's tab title.
-
telemetry(Telemetry) –The telemetry root whose run index locates a run's bundle.
-
store(LocalArtifactStore) –The artifact store a bundle's inputs resolve in and rehydrate from.
Methods:
-
build–Builds the toolbar, the bundle's sections and the purge dialog, then follows the shared run selection.
-
build_header–Builds the title, the status badge, the bundle path and the manifest summary.
-
build_stages–Builds the stage timeline, shown once the run has stages.
-
build_scalars–Builds the result scalars, shown once the run has a result.
-
build_tables–Builds the component forces, currents, inputs, files and retention passes, each shown once it has rows.
-
build_purge_dialog–Builds the purge dialog: a preset, a rule per retention class, and the preview and delete actions.
-
rule_key–The state variable holding one retention class's rule in the purge dialog.
-
bytes_key–The state variable holding one retention class's planned size in the purge dialog.
-
load_preset–Fills every per-class rule from a preset and clears the last preview.
-
policy–The policy the dialog's per-class choices describe.
-
on_preset–Fills the per-class rules from the preset just chosen.
-
locate–The bundle directory of an indexed run, or None when the index does not know it.
-
load–Read one bundle into what the panel shows; the whole read happens off the server loop.
-
summary–The manifest's identity and provenance as label/value pairs.
-
publish–Writes one view into the panel's state variables.
-
on_selected–Shows the run the shared selection names.
-
show–Loads a bundle off the server loop and publishes it, re-reading it while it solves; a failed read lands in the status line.
-
reread–The shown run read again, named so a reply that outlives its selection is dropped.
-
refresh–Publishes a re-read of the shown run, and ends the watch once the run has.
-
selected–The run the panel shows, reporting in the status line when there is none.
-
open_fields–Hands the bundle to the field viewer, or says so when no viewer is registered.
-
open_ref–Selects a store-sourced input, so the artifact detail follows.
-
reveal–Opens the bundle's directory in the file manager.
-
rehydrate–Fetches the bundle's store-sourced inputs back into its directory.
-
open_purge–Opens the purge dialog when the panel shows a run.
-
close_purge–Closes the purge dialog.
-
on_dialog–Follows the dialog the client closed with Escape or the backdrop.
-
preview_purge–Plans the dialog's policy against the bundle and shows the bytes each class would free.
-
apply_purge–Applies the previewed policy to the bundle and reloads the panel from what is left.
-
succeed–Shows the selected run again, which a fresh build would leave blank.
-
dispose–Stops the watch, then releases the panel.
Attributes:
-
run_id–The run the panel shows, which the watch re-reads while it solves.
-
showing(Task[None] | None) –The show a rebuild started, held until it finishes.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
run_id
instance-attribute
¶
The run the panel shows, which the watch re-reads while it solves.
showing
instance-attribute
¶
showing: Task[None] | None = None
The show a rebuild started, held until it finishes.
build
¶
Builds the toolbar, the bundle's sections and the purge dialog, then follows the shared run selection.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
build_header
¶
Builds the title, the status badge, the bundle path and the manifest summary.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
build_stages
¶
Builds the stage timeline, shown once the run has stages.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
build_scalars
¶
Builds the result scalars, shown once the run has a result.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
build_tables
¶
Builds the component forces, currents, inputs, files and retention passes, each shown once it has rows.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
build_purge_dialog
¶
Builds the purge dialog: a preset, a rule per retention class, and the preview and delete actions.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
rule_key
¶
rule_key(file_class: RunFile) -> str
The state variable holding one retention class's rule in the purge dialog.
bytes_key
¶
bytes_key(file_class: RunFile) -> str
The state variable holding one retention class's planned size in the purge dialog.
load_preset
¶
load_preset(preset: Preset) -> None
Fills every per-class rule from a preset and clears the last preview.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
policy
¶
policy() -> RetentionPolicy
The policy the dialog's per-class choices describe.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
locate
¶
The bundle directory of an indexed run, or None when the index does not know it.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
load
¶
load(run_id: str) -> RunView
Read one bundle into what the panel shows; the whole read happens off the server loop.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
summary
¶
summary(manifest: RunManifest) -> list[Row]
The manifest's identity and provenance as label/value pairs.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
publish
¶
Writes one view into the panel's state variables.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
on_selected
async
¶
on_selected(**_: object) -> None
Shows the run the shared selection names.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
show
async
¶
show(run_id: str) -> None
Loads a bundle off the server loop and publishes it, re-reading it while it solves; a failed read lands in the status line.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
reread
¶
The shown run read again, named so a reply that outlives its selection is dropped.
refresh
¶
Publishes a re-read of the shown run, and ends the watch once the run has.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
selected
¶
selected() -> Run | None
The run the panel shows, reporting in the status line when there is none.
open_fields
¶
Hands the bundle to the field viewer, or says so when no viewer is registered.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
open_ref
¶
open_ref(path: str) -> None
Selects a store-sourced input, so the artifact detail follows.
reveal
¶
Opens the bundle's directory in the file manager.
rehydrate
¶
Fetches the bundle's store-sourced inputs back into its directory.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
open_purge
¶
Opens the purge dialog when the panel shows a run.
close_purge
¶
on_dialog
¶
on_dialog(open_: object) -> None
Follows the dialog the client closed with Escape or the backdrop.
preview_purge
¶
Plans the dialog's policy against the bundle and shows the bytes each class would free.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
apply_purge
¶
Applies the previewed policy to the bundle and reloads the panel from what is left.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
succeed
¶
succeed(previous: PanelComponent) -> None
Shows the selected run again, which a fresh build would leave blank.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/runs.py
SetupPanel
¶
Bases: PanelComponent
The Setup tab beside the field viewer's controls: the frame, every body and boundary group with what it received, and the glyph legend.
Parameters:
-
app(Workbench) –The workbench shell the panel is built in.
-
id(str) –The panel id, which names its template and namespaces its state.
-
title(str) –The panel's tab title.
-
controller(FieldViewerController) –The field viewer's controller, shared with the controls and the view.
Methods:
-
view–What the tables show besides the run, from the state.
-
show_run–Shows a run; a fresh one resets its legend, selection and filter, while the scene switches carry over.
-
publish–Puts the open run's frame, tables, counts, legend and notices in the state.
-
name_of–The name a published row reads for an entity id; the id itself when no row has it.
-
select–Highlights an entity in the scene, or clears the highlight for an empty id, and reads the change aloud.
-
on_select–A row clicked or chosen: selects it, and keeps it selected when it already was, so the clicks of a double-click never clear it; Escape clears the selection.
-
on_frame–A row double-clicked or framed with F: fits the camera to it.
-
on_show–A hidden body's Show: shows it in the Field Viewer again.
-
on_all_kinds–The All Glyphs checkbox: shows every glyph kind the run draws, or none.
-
on_kind–A legend checkbox: shows or hides every glyph of one kind.
-
show_all–The More row: lists every boundary group.
-
on_rows–Republishes the tables after the filter or the visible bodies changed.
-
on_warp_scale–Republishes the ghost's warp note after the Field Viewer's deformation scale changed.
-
on_visible–Tells the scene whether the tab is on screen, the only time it draws glyphs.
-
dispose–Hides the glyphs and detaches from the controller, then releases the panel.
-
build_notices–The notice, a failed geometry check and the caption over the tables.
-
build_frame–The Frame section: the frame's facts as read-only fields and, for a 2D frame, the outline and ghost switches.
-
grid–One table of rows under its column headers, wired to the selection, the hover outline, the framing and the Show of a hidden body.
-
build_boundaries–The Boundaries section: the With Conditions | All filter, the table and the More row.
-
build_legend–The Glyphs section: an All Glyphs row whose checkbox shows every kind or none, then one row per glyph kind the run draws with its icon, count and checkbox.
-
build–Builds the busy bar, the empty state, the notices, the sections and the live region.
Attributes:
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
rows
instance-attribute
¶
The rows last published, for the names the announcements read.
view
¶
What the tables show besides the run, from the state.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
show_run
¶
show_run(model: SetupModel | None, *, fresh: bool = True) -> None
Shows a run; a fresh one resets its legend, selection and filter, while the scene switches carry over.
Parameters:
-
model(SetupModel | None) –The run, None when none is open.
-
fresh(bool, default:True) –Whether the run differs from the one shown, False when a solving run reopens with its fields.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
publish
¶
Puts the open run's frame, tables, counts, legend and notices in the state.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
name_of
¶
The name a published row reads for an entity id; the id itself when no row has it.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
select
¶
select(entity: str) -> None
Highlights an entity in the scene, or clears the highlight for an empty id, and reads the change aloud.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
on_select
¶
on_select(entity: object) -> None
A row clicked or chosen: selects it, and keeps it selected when it already was, so the clicks of a double-click never clear it; Escape clears the selection.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
on_frame
¶
on_frame(entity: object) -> None
A row double-clicked or framed with F: fits the camera to it.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
on_show
¶
on_show(entity: object) -> None
A hidden body's Show: shows it in the Field Viewer again.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
on_all_kinds
¶
on_all_kinds(on: object) -> None
The All Glyphs checkbox: shows every glyph kind the run draws, or none.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
on_kind
¶
A legend checkbox: shows or hides every glyph of one kind.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
show_all
¶
on_rows
¶
on_rows(**_: object) -> None
Republishes the tables after the filter or the visible bodies changed.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
on_warp_scale
¶
on_warp_scale(**_: object) -> None
Republishes the ghost's warp note after the Field Viewer's deformation scale changed.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
on_visible
¶
on_visible(visible: bool) -> None
Tells the scene whether the tab is on screen, the only time it draws glyphs.
dispose
¶
Hides the glyphs and detaches from the controller, then releases the panel.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
build_notices
¶
The notice, a failed geometry check and the caption over the tables.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
build_frame
¶
The Frame section: the frame's facts as read-only fields and, for a 2D frame, the outline and ghost switches.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
grid
¶
One table of rows under its column headers, wired to the selection, the hover outline, the framing and the Show of a hidden body.
Parameters:
-
rows(SetupVar) –The state variable holding the rows.
-
label(str) –The grid's accessible name.
-
columns(Sequence[str] | Bind) –The column headers, or a binding to them.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
build_boundaries
¶
The Boundaries section: the With Conditions | All filter, the table and the More row.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
build_legend
¶
The Glyphs section: an All Glyphs row whose checkbox shows every kind or none, then one row per glyph kind the run draws with its icon, count and checkbox.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
build
¶
Builds the busy bar, the empty state, the notices, the sections and the live region.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/setup.py
Split
dataclass
¶
Panels, tab groups or splits sharing one axis by weight; the axis alternates with nesting, horizontal at the root.
Attributes:
TablePanel
¶
TablePanel(app: Workbench, id: str, title: str, frame: DataFrame, *, grouped: bool = False, filterable: bool = False, lead: Sequence[str] = (), hidden: Sequence[str] = (), pick: Pick | None = None, selectable: Selectable = NO_SELECTION, select: Select | None = None, virtual: bool = False)
Bases: PanelComponent
A read-only table whose rows go over once, the client sorting, filtering, faceting, reordering, hiding and grouping them; lead orders the leading columns and pins the first.
Parameters:
-
app(Workbench) –The workbench shell the panel is built in.
-
id(str) –The panel id, which names its template and namespaces its state.
-
title(str) –The panel's tab title.
-
frame(DataFrame) –The rows to show.
-
grouped(bool, default:False) –Groups the rows by the
grouplabel column thatgroup_rowsadds. -
filterable(bool, default:False) –Shows the column filters.
-
lead(Sequence[str], default:()) –The columns sent first, in order; the first is pinned.
-
hidden(Sequence[str], default:()) –The frame's columns sent with the rows but given no column, so a pick still sees them.
-
pick(Pick | None, default:None) –Receives a clicked row; None leaves the rows unclickable.
-
selectable(Selectable, default:NO_SELECTION) –Whether the user selects no rows, one or several.
-
select(Select | None, default:None) –Receives the selected rows on every change; None ignores the selection.
-
virtual(bool, default:False) –Renders only the rows in view, for frames too long to draw whole.
Methods:
-
build–Pushes the columns, rows and options into the state and builds the table bound to them.
-
names–The columns sent:
leadfirst, the group label while grouped, then the rest withouthidden; the client applies the persisted order. -
columns–The column specs: numbers sort, filter and facet as numbers; the group label never facets.
-
defaults–The authored layout: grouped by the label column while grouped.
-
options–The table options: the layout the last session left, the authored defaults, and the filter, selection and virtual switches.
-
set_rows–Replaces the rows; the columns follow a changed schema, the client keeping its order, visibility, sort and filters.
-
restore–Applies a layout document on every client, the authored defaults for None.
-
reset_layout–Returns the table to the authored layout on every client.
-
scroll_to_end–Scrolls the table to its last row.
-
scroll_to_row–Scrolls the row at
indexof the shown rows into view. -
open_config–Shows, or hides, the column configuration panel.
-
on_layout–Persists the layout the client reports and pushes it back, so a page that reloads is not served the layout this one replaced.
-
on_click–Hands a clicked data row to the pick handler.
-
on_select–Hands the selected rows to the select handler.
Attributes:
-
saved(Layout | None) –The layout the last session left, handed to the client through the options.
-
store_key(str) –The persisted document of this panel's layout.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/table.py
saved
instance-attribute
¶
The layout the last session left, handed to the client through the options.
build
¶
Pushes the columns, rows and options into the state and builds the table bound to them.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/table.py
names
¶
The columns sent: lead first, the group label while grouped, then the rest without hidden; the client applies the persisted order.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/table.py
columns
¶
columns() -> list[ColumnSpec]
The column specs: numbers sort, filter and facet as numbers; the group label never facets.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/table.py
defaults
¶
defaults() -> LayoutDefaults
The authored layout: grouped by the label column while grouped.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/table.py
options
¶
options() -> TableOptions
The table options: the layout the last session left, the authored defaults, and the filter, selection and virtual switches.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/table.py
set_rows
¶
Replaces the rows; the columns follow a changed schema, the client keeping its order, visibility, sort and filters.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/table.py
restore
¶
Applies a layout document on every client, the authored defaults for None.
reset_layout
¶
Returns the table to the authored layout on every client.
scroll_to_end
¶
scroll_to_row
¶
scroll_to_row(index: int) -> None
Scrolls the row at index of the shown rows into view.
open_config
¶
open_config(open: bool = True) -> None
Shows, or hides, the column configuration panel.
on_layout
¶
on_layout(document: object) -> None
Persists the layout the client reports and pushes it back, so a page that reloads is not served the layout this one replaced.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/table.py
on_click
¶
on_click(row: object) -> None
Hands a clicked data row to the pick handler.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/table.py
on_select
¶
on_select(selection: object) -> None
Hands the selected rows to the select handler.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/table.py
Tabs
dataclass
¶
Panels sharing one tab group, the first shown.
Attributes:
Task
dataclass
¶
One background task: a label unique in its plan and the zero-argument callable a child process runs.
Attributes:
-
label(str) –The name the task strip shows, unique in its plan; the child process finds the task by it.
-
run(Callable[[], object]) –What the child process calls; its return value is dropped.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
Workbench
¶
Workbench(name: str, *, palette: Palette | None = None, title: str = 'femforge workbench', server: Server | None = None, persist: UiStateStore | None = None, user: str | None = None, catalogue: Sequence[WorkbenchSpec] | None = None)
Bases: TrameApp
One trame server with the header, the dock and the panels of a named workbench.
Parameters:
-
name(str) –The workbench name, which names the trame server and scopes the persisted state.
-
palette(Palette | None, default:None) –The colours the shell and its panels paint in; None loads the dist's palette.
-
title(str, default:'femforge workbench') –The title the header and the browser tab show.
-
server(Server | None, default:None) –The trame server to run on; None makes one named after
name. -
persist(UiStateStore | None, default:None) –Where layouts and opened cards persist; None keeps them in JSON files under the per-user config directory.
-
user(str | None, default:None) –The user the persisted state is scoped to; None takes the OS user.
-
catalogue(Sequence[WorkbenchSpec] | None, default:None) –The cards the title menu and a launcher panel list; None lists the discovered ones.
Methods:
-
load_catalogue–The discovered specs, empty with a warning when an entry point is broken.
-
build_ui–The header and the dock, whose panel bodies are the server templates the placements name.
-
build_task_bar–The task bar, one button that opens and closes the drawer: the tasks counted by how they ended, each with its icon, then the task it leads with and any script error.
-
build_task_sheet–The drawer's body: the script error in full, then a row per task with its state, elapsed time and run; a click on a row opens its run, else its details.
-
open_task_row–A click on a task row: opens its run, else shows or hides its details.
-
show_tasks–Shows the task board's rows, summary and focus row in the strip and its sheet.
-
follow_run–Hands a task's newer run to the field viewer, which opens it when it shows the task's previous run.
-
toggle_tasks–Opens or closes the task sheet.
-
on_render_choice–Applies a render setting a toggle or a switch chose; a slider applies on its release instead.
-
apply_render–Takes the render settings the state shows, saves them for every workbench and has each panel redraw with them; settings that do not validate are put back.
-
reset_render–Puts every render setting back to its default.
-
on_task_sheet–Remembers whether the task sheet is open for the next start, however it opened or closed.
-
open_task_run–Opens a task's run in the field viewer, which waits for its fields while it solves.
-
toggle_task_details–Shows one task's traceback or log under its row, or hides it.
-
cancel_task–Arms Cancel for a few seconds on the first press and cancels the task on the second.
-
count_down–Shows the seconds left on an armed Cancel the user left alone, and reverts it when none is left.
-
retry_task–Queues one ended task again.
-
build_switcher–The title as a menu over the catalogue.
-
add_tour_steps–Adds stops to the tour before the shell's closing one; a stop at a target already listed replaces it, so a rebuilt panel adds nothing twice.
-
start_tour–Opens the tour at its first stop.
-
offer_tour–Opens the tour on its own a moment after the first scene shows, until the user has finished or skipped it once.
-
on_tour_finish–Records that the user has seen the tour, finished or skipped; the status line keeps whatever the panels last reported.
-
add–Builds every panel's component and template; the dock arranges them once the client reports ready.
-
open–Adds a Split's panels to the running dock, building those not built yet, and activates the first.
-
open_spec–Opens a dock card: its target builds the Split, remembered under the card's name so the next start rebuilds it.
-
opened_first–The first panel id of the open card of that name, None when it is not open.
-
close–Takes an opened card out of the dock and the shell and stops rebuilding it on save.
-
close_all–Closes every opened card.
-
discard–Takes an opened card out of the dock and the shell: its panels are removed and disposed, its header widgets dropped, the card forgotten.
-
register–Builds each leaf and registers it before the next is built, so a panel can see the ones already standing (a second scene panel must know a mirror is taken).
-
retire–Disposes the built panels of those ids and drops them from the shell.
-
drop_header–Removes a Split's widgets from the header, those still there.
-
watch–Rebuilds the spec's Split after every .py save under its roots once the server runs; a spec of the shell core is left to the dev supervisor.
-
unwatch–Stops rebuilding a card on save.
-
rebuild–Swaps a card's panels for a fresh build under the same ids, the dock untouched; other ids close and reopen the card, and a card no longer open reopens.
-
replace_root–Rebuilds the authored Split in place; changed ids re-lay the dock out from the authored arrangement.
-
replace_card–Rebuilds an open card in place; changed ids close and reopen it, and a card not open opens.
-
swap–Disposes the retired panels, then builds the Split's leaves, whose templates overwrite those of the same ids; returns the header widgets the build added.
-
find_spec–The catalogue card of that name, None when the catalogue has none.
-
restore_opened–Reopens the cards the last session left in the dock, dropping any whose card is gone or whose target no longer builds a Split.
-
remember_opened–Persists the cards open in the dock, in opening order, and names them in the state for the launcher's cards.
-
prune_opened–Forgets an opened Split whose first panel is missing from a settled layout, one that shows every panel handed to the dock since the last.
-
place–add_panel for every placement of a Split, its first panel within
reference's group when given; ids already in the dock are left alone. -
panel–The built component of a panel, checked to be of
kind. -
status–Writes the status line, flushing so it also lands from outside a handler.
-
download–Hands the browser a file to save to its downloads.
-
on_downloaded–Drops the file the browser now has from the state.
-
toast–Shows a short message in the bottom-right corner for a few seconds.
-
marshal–Runs
fn(*args)on the server loop from any thread. -
when_ready–Calls
fnon the server loop: now when the server runs, else once it is ready. -
authored_layout–The dockview layout of the authored Split; RuntimeError before
add. -
on_dock_ready–Restores the saved arrangement when it names the authored panels, else applies the authored one; add_panel then fills any gap.
-
activate–Brings a panel's tab to the front, or once the dock is ready when it is not yet.
-
on_layout_changed–Persists the layout the dock reports, forgets the cards it no longer shows and tells every panel.
-
on_panel_removed–Disposes the panel whose tab the user closed; the dock reports only a user close here, never its own teardown, and Reset layout builds a closed panel again.
-
rebuild_closed–Rebuilds every card a closed tab left incomplete, header widgets included, so an arrangement naming its panels finds them live.
-
on_panel_visibility–Records that the dock showed or hid a panel and tells that panel.
-
reset_layout–Rebuilds the authored arrangement, which also recovers a group orphaned by a killed popout window.
-
open_workbench–Hands a catalogue selection to the open_workbench hook, or names the command that opens it.
-
on_server_ready–Takes the server loop and opens the app window when one was asked for.
-
on_client_connected–Forgets the dock a reloaded page left, so
activateholds a panel until the new dock reports ready. -
on_client_exited–Forgets the dock of the page that left, so
activateholds a panel until the next dock reports ready. -
on_server_exited–Stops every reloader and the running task, then flushes the persisted state.
-
open_app_window–Chrome (Edge fallback) as an app window on its own profile; the server stops when the window process exits. Without either, a system browser tab.
-
install_break_handler–Makes a break or termination signal a clean stop, so the exit hooks flush the persisted state; the --dev supervisor stops its child this way.
-
on_break–Schedules the server's stop on its loop, which ends the main loop and runs the exit hooks.
-
run–Serves until stopped, or until an app window closes.
Attributes:
-
render–The render settings every 3D view of the user draws with, in every workbench.
-
authored(Opened | None) –The Split add() built, named after the spec it serves when it is to be rebuilt on save.
-
opened(dict[str, Opened]) –Splits opened into the running dock by their first panel id.
-
pending(set[str]) –Panel ids handed to the dock since a layout last showed them all; a layout still missing one is a placement in flight, not a close.
-
on_screen(set[str]) –Panel ids the dock last reported visible; the dock reports a panel only when it mounts, so a panel rebuilt in place learns it from here.
-
catalogue–The cards the title menu and a launcher panel list: the discovered ones unless the constructor was given its own.
-
tour_steps(list[TourStep]) –The tour's stops in order, before the shell's own closing one; panels add theirs through
add_tour_steps. -
docked–Whether the client dock has reported ready; until then it drops activations and its layout restore decides the front tabs.
-
front(str | None) –The panel
activateasked to the front before the dock was ready, activated once the layout is restored. -
notices–How many downloads and toasts the shell sent, which numbers the next.
-
header–The header's slot for a workbench's own controls: build widgets inside
with app.header:and flush_content() after a later change. -
root(Split | None) –The authored Split, None before
add. -
panel_ids(list[str]) –The ids of the built panels, in build order.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | |
render
instance-attribute
¶
render = load_render(self.persist, self.scope[0])
The render settings every 3D view of the user draws with, in every workbench.
authored
instance-attribute
¶
authored: Opened | None = None
The Split add() built, named after the spec it serves when it is to be rebuilt on save.
opened
instance-attribute
¶
Splits opened into the running dock by their first panel id.
pending
instance-attribute
¶
Panel ids handed to the dock since a layout last showed them all; a layout still missing one is a placement in flight, not a close.
on_screen
instance-attribute
¶
Panel ids the dock last reported visible; the dock reports a panel only when it mounts, so a panel rebuilt in place learns it from here.
catalogue
instance-attribute
¶
catalogue = list(catalogue) if catalogue is not None else self.load_catalogue()
The cards the title menu and a launcher panel list: the discovered ones unless the constructor was given its own.
tour_steps
instance-attribute
¶
The tour's stops in order, before the shell's own closing one; panels add theirs through add_tour_steps.
docked
instance-attribute
¶
Whether the client dock has reported ready; until then it drops activations and its layout restore decides the front tabs.
front
instance-attribute
¶
front: str | None = None
The panel activate asked to the front before the dock was ready, activated once the layout is restored.
notices
instance-attribute
¶
How many downloads and toasts the shell sent, which numbers the next.
header
instance-attribute
¶
The header's slot for a workbench's own controls: build widgets inside with app.header: and flush_content() after a later change.
load_catalogue
¶
load_catalogue() -> list[WorkbenchSpec]
The discovered specs, empty with a warning when an entry point is broken.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
build_ui
¶
The header and the dock, whose panel bodies are the server templates the placements name.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
build_task_bar
¶
The task bar, one button that opens and closes the drawer: the tasks counted by how they ended, each with its icon, then the task it leads with and any script error.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
build_task_sheet
¶
The drawer's body: the script error in full, then a row per task with its state, elapsed time and run; a click on a row opens its run, else its details.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | |
open_task_row
¶
open_task_row(label: str) -> None
A click on a task row: opens its run, else shows or hides its details.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
show_tasks
¶
show_tasks(view: TaskView) -> None
Shows the task board's rows, summary and focus row in the strip and its sheet.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
follow_run
¶
Hands a task's newer run to the field viewer, which opens it when it shows the task's previous run.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
toggle_tasks
¶
on_render_choice
¶
on_render_choice(**_: object) -> None
Applies a render setting a toggle or a switch chose; a slider applies on its release instead.
apply_render
¶
Takes the render settings the state shows, saves them for every workbench and has each panel redraw with them; settings that do not validate are put back.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
reset_render
¶
Puts every render setting back to its default.
on_task_sheet
¶
on_task_sheet(**_: object) -> None
Remembers whether the task sheet is open for the next start, however it opened or closed.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
open_task_run
¶
open_task_run(run_id: str) -> None
Opens a task's run in the field viewer, which waits for its fields while it solves.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
toggle_task_details
¶
toggle_task_details(label: str) -> None
Shows one task's traceback or log under its row, or hides it.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
cancel_task
¶
cancel_task(label: str) -> None
Arms Cancel for a few seconds on the first press and cancels the task on the second.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
count_down
¶
Shows the seconds left on an armed Cancel the user left alone, and reverts it when none is left.
Parameters:
-
label(str) –The task whose Cancel is armed.
-
armed(int) –The arming this countdown belongs to; a later arming stops it.
-
left(int) –The seconds to show.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
build_switcher
¶
The title as a menu over the catalogue.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
add_tour_steps
¶
Adds stops to the tour before the shell's closing one; a stop at a target already listed replaces it, so a rebuilt panel adds nothing twice.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
start_tour
¶
offer_tour
¶
Opens the tour on its own a moment after the first scene shows, until the user has finished or skipped it once.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_tour_finish
¶
on_tour_finish(reason: str) -> None
Records that the user has seen the tour, finished or skipped; the status line keeps whatever the panels last reported.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
add
¶
add(root: Split, *, spec: WorkbenchSpec | None = None, watch: Sequence[Path] = ()) -> None
Builds every panel's component and template; the dock arranges them once the client reports ready.
Parameters:
-
root(Split) –The Split to serve.
-
spec(WorkbenchSpec | None, default:None) –The card the Split was built from; given, the Split is rebuilt on every save.
-
watch(Sequence[Path], default:()) –More directories whose .py saves rebuild the Split, beside the spec's own roots.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
open
¶
Adds a Split's panels to the running dock, building those not built yet, and activates the first.
Parameters:
-
root(Split) –The Split whose panels to add.
-
reference(str | None, default:None) –The panel whose group the first panel joins; None lets the dock place it.
-
name(str | None, default:None) –The card the Split comes from, remembered so the next start reopens it; None for a bare Split.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
open_spec
¶
open_spec(spec: WorkbenchSpec, *, reference: str | None = None) -> None
Opens a dock card: its target builds the Split, remembered under the card's name so the next start rebuilds it.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
opened_first
¶
The first panel id of the open card of that name, None when it is not open.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
close
¶
close(name: str) -> None
Takes an opened card out of the dock and the shell and stops rebuilding it on save.
close_all
¶
Closes every opened card.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
discard
¶
discard(name: str) -> None
Takes an opened card out of the dock and the shell: its panels are removed and disposed, its header widgets dropped, the card forgotten.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
register
¶
register(leaves: Sequence[Panel]) -> list[PanelComponent]
Builds each leaf and registers it before the next is built, so a panel can see the ones already standing (a second scene panel must know a mirror is taken).
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
retire
¶
Disposes the built panels of those ids and drops them from the shell.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
drop_header
¶
Removes a Split's widgets from the header, those still there.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
watch
¶
watch(spec: WorkbenchSpec, *, reference: str | None = None, extra: Sequence[Path] = ()) -> None
Rebuilds the spec's Split after every .py save under its roots once the server runs; a spec of the shell core is left to the dev supervisor.
Parameters:
-
spec(WorkbenchSpec) –The card whose target builds the Split.
-
reference(str | None, default:None) –The panel whose group the rebuilt card joins when it is no longer open.
-
extra(Sequence[Path], default:()) –More directories to watch, beside the femforge core, the workbench package and the spec's own source root.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
rebuild
¶
Swaps a card's panels for a fresh build under the same ids, the dock untouched; other ids close and reopen the card, and a card no longer open reopens.
Parameters:
-
name(str) –The card to rebuild.
-
root(Split) –The fresh build of its Split.
-
reference(str | None, default:None) –The panel whose group the card joins when it is no longer open.
-
seconds(float, default:0.0) –The seconds the build took, added to the rebuild time the status line reports.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
replace_root
¶
Rebuilds the authored Split in place; changed ids re-lay the dock out from the authored arrangement.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
replace_card
¶
Rebuilds an open card in place; changed ids close and reopen it, and a card not open opens.
Parameters:
-
name(str) –The card to rebuild.
-
root(Split) –The fresh build of its Split.
-
reference(str | None) –The panel whose group the card joins when it is not open.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
swap
¶
Disposes the retired panels, then builds the Split's leaves, whose templates overwrite those of the same ids; returns the header widgets the build added.
Parameters:
-
root(Split) –The Split whose leaves to build.
-
retired(Sequence[str]) –The ids of the panels to dispose first.
-
header(Sequence[object]) –The header widgets the retired panels added, dropped with them.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
find_spec
¶
find_spec(name: str) -> WorkbenchSpec | None
The catalogue card of that name, None when the catalogue has none.
restore_opened
¶
Reopens the cards the last session left in the dock, dropping any whose card is gone or whose target no longer builds a Split.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
remember_opened
¶
Persists the cards open in the dock, in opening order, and names them in the state for the launcher's cards.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
prune_opened
¶
Forgets an opened Split whose first panel is missing from a settled layout, one that shows every panel handed to the dock since the last.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
place
¶
place(root: Split, reference: str | None = None) -> None
add_panel for every placement of a Split, its first panel within reference's group when given; ids already in the dock are left alone.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
panel
¶
The built component of a panel, checked to be of kind.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
status
¶
status(message: str) -> None
Writes the status line, flushing so it also lands from outside a handler.
download
¶
Hands the browser a file to save to its downloads.
Parameters:
-
name(str) –The file name the browser suggests.
-
data(bytes) –The file's bytes.
-
media_type(str) –The file's media type, such as
image/png.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_downloaded
¶
toast
¶
toast(text: str) -> None
Shows a short message in the bottom-right corner for a few seconds.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
marshal
¶
Runs fn(*args) on the server loop from any thread.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
when_ready
¶
when_ready(fn: Callable[[], None]) -> None
Calls fn on the server loop: now when the server runs, else once it is ready.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
authored_layout
¶
The dockview layout of the authored Split; RuntimeError before add.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_dock_ready
¶
Restores the saved arrangement when it names the authored panels, else applies the authored one; add_panel then fills any gap.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
activate
¶
activate(panel_id: str) -> None
Brings a panel's tab to the front, or once the dock is ready when it is not yet.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_layout_changed
¶
Persists the layout the dock reports, forgets the cards it no longer shows and tells every panel.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_panel_removed
¶
Disposes the panel whose tab the user closed; the dock reports only a user close here, never its own teardown, and Reset layout builds a closed panel again.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
rebuild_closed
¶
Rebuilds every card a closed tab left incomplete, header widgets included, so an arrangement naming its panels finds them live.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_panel_visibility
¶
Records that the dock showed or hid a panel and tells that panel.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
reset_layout
¶
Rebuilds the authored arrangement, which also recovers a group orphaned by a killed popout window.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
open_workbench
¶
open_workbench(name: str) -> None
Hands a catalogue selection to the open_workbench hook, or names the command that opens it.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_server_ready
¶
on_server_ready(**_: object) -> None
Takes the server loop and opens the app window when one was asked for.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_client_connected
¶
on_client_connected(**_: object) -> None
Forgets the dock a reloaded page left, so activate holds a panel until the new dock reports ready.
on_client_exited
¶
on_client_exited(**_: object) -> None
Forgets the dock of the page that left, so activate holds a panel until the next dock reports ready.
on_server_exited
¶
on_server_exited(**_: object) -> None
Stops every reloader and the running task, then flushes the persisted state.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
open_app_window
¶
Chrome (Edge fallback) as an app window on its own profile; the server stops when the window process exits. Without either, a system browser tab.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
install_break_handler
¶
Makes a break or termination signal a clean stop, so the exit hooks flush the persisted state; the --dev supervisor stops its child this way.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_break
¶
Schedules the server's stop on its loop, which ends the main loop and runs the exit hooks.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
run
¶
Serves until stopped, or until an app window closes.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
artifact_store
¶
artifact_store(store: Telemetry) -> LocalArtifactStore
The store the artifact panels read: FEMFORGE_ARTIFACTS when set, else the root the index rows name.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/browsers.py
field_viewer
¶
field_viewer(run: Result | Location | None = None, *, display: DisplaySpec = DEFAULTS, telemetry: str | Path | None = None) -> Split
The field viewer dock: the controls and the Setup tab beside the view.
Parameters:
-
run(Result | Location | None, default:None) –The run to open once the server runs: a Result, a Run, a run id or a bundle directory; None opens the newest indexed run once one lands.
-
display(DisplaySpec, default:DEFAULTS) –The display the controls start from; one without a field opens each run on its own default display.
-
telemetry(str | Path | None, default:None) –The telemetry root whose run index the run picker lists; None reads FEMFORGE_TELEMETRY.
Source code in packages/femforge-workbench/src/femforge_workbench/panels/field_viewer.py
show
¶
show(workbench: Split | Factory | WorkbenchSpec | None = None, *, title: str | None = None, workbenches: Sequence[WorkbenchSpec] = (), window: Window = APP, port: int = DEFAULT_PORT, telemetry: str | Path | None = None, persist: str | Path | None = None, watch: Sequence[str | Path] = (), tasks: TaskFactory | None = None) -> None
Serves a workbench until its window closes: a Split as built, a factory or card rebuilt on every save, or the launcher when none is given.
Parameters:
-
workbench(Split | Factory | WorkbenchSpec | None, default:None) –The Split, factory or card to serve; None serves the launcher.
-
title(str | None, default:None) –The header title; None keeps the card's own, or femforge workbench for a Split.
-
workbenches(Sequence[WorkbenchSpec], default:()) –Cards the launcher lists beside the discovered ones, and the only cards a single workbench's title menu lists.
-
window(Window, default:APP) –Where the workbench opens.
-
port(int, default:DEFAULT_PORT) –The port the server listens on.
-
telemetry(str | Path | None, default:None) –The telemetry root the panels read, exported as FEMFORGE_TELEMETRY; None keeps the environment's.
-
persist(str | Path | None, default:None) –The directory layouts and opened cards persist under; None uses the per-user config directory.
-
watch(Sequence[str | Path], default:()) –More directories whose .py saves rebuild a factory or card, beside its own roots.
-
tasks(TaskFactory | None, default:None) –A module-level function listing the Tasks to run in child processes, one at a time, while the workbench serves; listed again on every save.
Source code in packages/femforge-workbench/src/femforge_workbench/serve.py
femforge_workbench.serve
¶
Serves a workbench from a script or the command line: a dock, a catalogue card, or the launcher.
Type Aliases:
-
Factory–A module-level function building a dock Split or a Renderable.
Classes:
-
NotAWorkbench–A target that builds neither a dock Split nor a Renderable.
Functions:
-
show–Serves a workbench until its window closes: a Split as built, a factory or card rebuilt on every save, or the launcher when none is given.
-
attach–Gives the shell a board running the factory's tasks once the server runs, re-submitting them on every save under the factory's roots and
watch. -
card–The spec to open: the launcher for None, a dock card named after a factory.
-
build–A shell holding the spec's dock, rebuilt on every save under its roots, or a viewer of its Renderable.
-
viewer–One scene panel that shows the spec's Renderable once the server runs, rebuilding it on every save under its roots.
Attributes:
-
DEFAULT_PORT–The port a workbench serves on unless told otherwise.
DEFAULT_PORT
module-attribute
¶
The port a workbench serves on unless told otherwise.
Factory
¶
Factory = Callable[[], Split | Renderable]
A module-level function building a dock Split or a Renderable.
show
¶
show(workbench: Split | Factory | WorkbenchSpec | None = None, *, title: str | None = None, workbenches: Sequence[WorkbenchSpec] = (), window: Window = APP, port: int = DEFAULT_PORT, telemetry: str | Path | None = None, persist: str | Path | None = None, watch: Sequence[str | Path] = (), tasks: TaskFactory | None = None) -> None
Serves a workbench until its window closes: a Split as built, a factory or card rebuilt on every save, or the launcher when none is given.
Parameters:
-
workbench(Split | Factory | WorkbenchSpec | None, default:None) –The Split, factory or card to serve; None serves the launcher.
-
title(str | None, default:None) –The header title; None keeps the card's own, or femforge workbench for a Split.
-
workbenches(Sequence[WorkbenchSpec], default:()) –Cards the launcher lists beside the discovered ones, and the only cards a single workbench's title menu lists.
-
window(Window, default:APP) –Where the workbench opens.
-
port(int, default:DEFAULT_PORT) –The port the server listens on.
-
telemetry(str | Path | None, default:None) –The telemetry root the panels read, exported as FEMFORGE_TELEMETRY; None keeps the environment's.
-
persist(str | Path | None, default:None) –The directory layouts and opened cards persist under; None uses the per-user config directory.
-
watch(Sequence[str | Path], default:()) –More directories whose .py saves rebuild a factory or card, beside its own roots.
-
tasks(TaskFactory | None, default:None) –A module-level function listing the Tasks to run in child processes, one at a time, while the workbench serves; listed again on every save.
Source code in packages/femforge-workbench/src/femforge_workbench/serve.py
attach
¶
attach(app: Workbench, tasks: TaskFactory | None, watch: Sequence[Path]) -> None
Gives the shell a board running the factory's tasks once the server runs, re-submitting them on every save under the factory's roots and watch.
Parameters:
-
app(Workbench) –The shell the task strip shows in.
-
tasks(TaskFactory | None) –The module-level function listing the tasks; None attaches nothing.
-
watch(Sequence[Path]) –More directories whose .py saves list the tasks again.
Source code in packages/femforge-workbench/src/femforge_workbench/serve.py
card
¶
card(workbench: Factory | WorkbenchSpec | None) -> WorkbenchSpec
The spec to open: the launcher for None, a dock card named after a factory.
Source code in packages/femforge-workbench/src/femforge_workbench/serve.py
build
¶
build(spec: WorkbenchSpec, *, catalogue: Sequence[WorkbenchSpec] | None = None, watch: Sequence[Path] = (), persist: UiStateStore | None = None, tasks: TaskFactory | None = None) -> Workbench
A shell holding the spec's dock, rebuilt on every save under its roots, or a viewer of its Renderable.
Parameters:
-
spec(WorkbenchSpec) –The card to serve.
-
catalogue(Sequence[WorkbenchSpec] | None, default:None) –The cards the title menu lists; None lists the discovered ones.
-
watch(Sequence[Path], default:()) –More directories whose .py saves rebuild the card, beside its own roots.
-
persist(UiStateStore | None, default:None) –Where layouts and opened cards persist; None uses JSON files under the per-user config directory.
-
tasks(TaskFactory | None, default:None) –The module-level function listing the tasks to run while the workbench serves; None runs none.
Source code in packages/femforge-workbench/src/femforge_workbench/serve.py
viewer
¶
viewer(app: Workbench, spec: WorkbenchSpec, watch: Sequence[Path]) -> SceneViewerPanel
One scene panel that shows the spec's Renderable once the server runs, rebuilding it on every save under its roots.
Parameters:
-
app(Workbench) –The shell to add the scene panel to.
-
spec(WorkbenchSpec) –The card whose target builds the Renderable.
-
watch(Sequence[Path]) –More directories whose .py saves rebuild the Renderable, beside the spec's own roots.
Source code in packages/femforge-workbench/src/femforge_workbench/serve.py
femforge_workbench.cli
¶
The femforge-workbench command: parses its flags and shows the launcher, a catalogue entry or a module through serve.show.
Classes:
-
CliError–A user-facing failure: main prints the message and exits 2.
-
Options–The parsed command line.
Functions:
-
select–The spec to open: a catalogue entry by name, a module given as
pkg.module[:attr](main() -> Renderable when no attr), else the launcher. -
build_parser–The
femforge-workbenchargument parser with every flag registered. -
main–Parses the command line and shows the chosen workbench, or supervises the server under --dev.
Options
dataclass
¶
select
¶
select(name: str | None, module: str | None) -> WorkbenchSpec
The spec to open: a catalogue entry by name, a module given as pkg.module[:attr] (main() -> Renderable when no attr), else the launcher.
Source code in packages/femforge-workbench/src/femforge_workbench/cli.py
build_parser
¶
build_parser() -> ArgumentParser
The femforge-workbench argument parser with every flag registered.
Source code in packages/femforge-workbench/src/femforge_workbench/cli.py
main
¶
Parses the command line and shows the chosen workbench, or supervises the server under --dev.
Source code in packages/femforge-workbench/src/femforge_workbench/cli.py
femforge_workbench.app
¶
The workbench shell: a React header over a dock whose panels are trame templates, with persisted layouts and a worker-thread marshal.
Classes:
-
WidgetLibrary–A trame widget package whose initialize() enables its client module on a server.
-
Cls–The shell's Tailwind compositions; the strings appear literally so the stylesheet build scans them.
-
Window–Where a served workbench opens.
-
Template–Templates rendered outside the panels.
-
StateVar–The shell's own state variables.
-
TourKey–The fields of the persisted tour document.
-
TaskSheetKey–The fields of the persisted task sheet document.
-
Hook–Controller slots panels fill: the launcher takes OPEN_WORKBENCH, the field viewer FIELD_OPEN.
-
OpenedKey–The fields of the persisted opened document: the cards open in the dock, in opening order.
-
CardKey–The fields of a catalogue card in the state.
-
Opened–A Split in the running dock: the card it serves (None for a bare Split), the panel it was anchored to and the header widgets it added.
-
Watch–A card rebuilt on save and the reloader watching its target's roots.
-
Reporting–Anything with a status line: the shell and its panels.
-
Workbench–One trame server with the header, the dock and the panels of a named workbench.
Functions:
-
check_unique–Rejects a panel id used twice in one Split.
-
aria–Sets attributes trame's html elements leave out, such as
roleand the ARIA ones,aria_livewritten asaria-live. -
guard–Prints a handler's exception with rich and reports it in the status line instead of letting it escape into wslink.
Attributes:
-
FAVICON_VAR–The trame state variable the client puts in the page's icon link.
-
FAVICON–The state variable trame's client shows as the page title.
-
PANEL_PARAM–The render-prop parameter carrying a dock panel's params to its server template.
-
TOUR_DELAY–Seconds after the first scene shows before the tour opens on its own.
-
HELP_ID–The id of the app bar's help button, the tour's last stop.
-
CONFIRM_S–t_confirm[s]: How long a pressed Cancel waits for the second press before it reverts, counted down a second at a time. -
COPIED_MS–t_copied[ms]: How long a Copy button reads Copied after it copied. -
TASK_ICON_PX–The size of the task bar's and the task rows' icons in CSS pixels.
-
WIDGET_LIBRARIES(tuple[WidgetLibrary, ...]) –Every widget library a panel may use: a client loads only the modules enabled before it connected, and a card can open such panels later.
-
QUIET_LIBRARIES–Stdlib loggers gated to WARNING by every shell, whichever entry point built it: the access log alone writes thousands of lines per page load.
-
TASK_TALLIES(tuple[tuple[StateVar, IconName, str, Cls], ...]) –The task bar's counts: the state variable holding each, its icon, its word and its tone.
FAVICON_VAR
module-attribute
¶
The trame state variable the client puts in the page's icon link.
FAVICON
module-attribute
¶
The state variable trame's client shows as the page title.
PANEL_PARAM
module-attribute
¶
The render-prop parameter carrying a dock panel's params to its server template.
TOUR_DELAY
module-attribute
¶
Seconds after the first scene shows before the tour opens on its own.
HELP_ID
module-attribute
¶
The id of the app bar's help button, the tour's last stop.
CONFIRM_S
module-attribute
¶
t_confirm [s]: How long a pressed Cancel waits for the second press before it reverts, counted down a second at a time.
COPIED_MS
module-attribute
¶
t_copied [ms]: How long a Copy button reads Copied after it copied.
TASK_ICON_PX
module-attribute
¶
The size of the task bar's and the task rows' icons in CSS pixels.
WIDGET_LIBRARIES
module-attribute
¶
WIDGET_LIBRARIES: tuple[WidgetLibrary, ...] = (widgets, rca, vtklocal)
Every widget library a panel may use: a client loads only the modules enabled before it connected, and a card can open such panels later.
QUIET_LIBRARIES
module-attribute
¶
QUIET_LIBRARIES = ('trame_server', 'trame_client', 'trame_common', 'trame_rca', 'trame_vtklocal', 'wslink', 'aiohttp', 'aiohttp.access', 'watchdog', 'asyncio')
Stdlib loggers gated to WARNING by every shell, whichever entry point built it: the access log alone writes thousands of lines per page load.
TASK_TALLIES
module-attribute
¶
TASK_TALLIES: tuple[tuple[StateVar, IconName, str, Cls], ...] = ((StateVar.TASK_DONE, 'check', 'Done', Cls.TASK_TALLY), (StateVar.TASK_REUSED, 'copy-check', 'Reused', Cls.TASK_TALLY), (StateVar.TASK_FAILED, 'x', 'Failed', Cls.TASK_TALLY_FAILED), (StateVar.TASK_STALLED, 'triangle-alert', 'Stalled', Cls.TASK_TALLY_WARNING))
The task bar's counts: the state variable holding each, its icon, its word and its tone.
WidgetLibrary
¶
Bases: Protocol
A trame widget package whose initialize() enables its client module on a server.
Methods:
-
initialize–Enables the library's client module on
server.
Cls
¶
Bases: StrEnum
The shell's Tailwind compositions; the strings appear literally so the stylesheet build scans them.
Hook
¶
Bases: StrEnum
Controller slots panels fill: the launcher takes OPEN_WORKBENCH, the field viewer FIELD_OPEN.
Attributes:
-
FIELD_FOLLOW–Takes the previous and the newer run of a task: a viewer showing the previous one opens the newer.
-
FIELD_TASKS–Takes the task strip's view, which an empty viewer names the task it waits for from.
OpenedKey
¶
Bases: StrEnum
The fields of the persisted opened document: the cards open in the dock, in opening order.
Opened
dataclass
¶
Opened(root: Split, reference: str | None, name: str | None = None, header: tuple[object, ...] = ())
A Split in the running dock: the card it serves (None for a bare Split), the panel it was anchored to and the header widgets it added.
Watch
dataclass
¶
A card rebuilt on save and the reloader watching its target's roots.
Reporting
¶
Workbench
¶
Workbench(name: str, *, palette: Palette | None = None, title: str = 'femforge workbench', server: Server | None = None, persist: UiStateStore | None = None, user: str | None = None, catalogue: Sequence[WorkbenchSpec] | None = None)
Bases: TrameApp
One trame server with the header, the dock and the panels of a named workbench.
Parameters:
-
name(str) –The workbench name, which names the trame server and scopes the persisted state.
-
palette(Palette | None, default:None) –The colours the shell and its panels paint in; None loads the dist's palette.
-
title(str, default:'femforge workbench') –The title the header and the browser tab show.
-
server(Server | None, default:None) –The trame server to run on; None makes one named after
name. -
persist(UiStateStore | None, default:None) –Where layouts and opened cards persist; None keeps them in JSON files under the per-user config directory.
-
user(str | None, default:None) –The user the persisted state is scoped to; None takes the OS user.
-
catalogue(Sequence[WorkbenchSpec] | None, default:None) –The cards the title menu and a launcher panel list; None lists the discovered ones.
Methods:
-
load_catalogue–The discovered specs, empty with a warning when an entry point is broken.
-
build_ui–The header and the dock, whose panel bodies are the server templates the placements name.
-
build_task_bar–The task bar, one button that opens and closes the drawer: the tasks counted by how they ended, each with its icon, then the task it leads with and any script error.
-
build_task_sheet–The drawer's body: the script error in full, then a row per task with its state, elapsed time and run; a click on a row opens its run, else its details.
-
open_task_row–A click on a task row: opens its run, else shows or hides its details.
-
show_tasks–Shows the task board's rows, summary and focus row in the strip and its sheet.
-
follow_run–Hands a task's newer run to the field viewer, which opens it when it shows the task's previous run.
-
toggle_tasks–Opens or closes the task sheet.
-
on_render_choice–Applies a render setting a toggle or a switch chose; a slider applies on its release instead.
-
apply_render–Takes the render settings the state shows, saves them for every workbench and has each panel redraw with them; settings that do not validate are put back.
-
reset_render–Puts every render setting back to its default.
-
on_task_sheet–Remembers whether the task sheet is open for the next start, however it opened or closed.
-
open_task_run–Opens a task's run in the field viewer, which waits for its fields while it solves.
-
toggle_task_details–Shows one task's traceback or log under its row, or hides it.
-
cancel_task–Arms Cancel for a few seconds on the first press and cancels the task on the second.
-
count_down–Shows the seconds left on an armed Cancel the user left alone, and reverts it when none is left.
-
retry_task–Queues one ended task again.
-
build_switcher–The title as a menu over the catalogue.
-
add_tour_steps–Adds stops to the tour before the shell's closing one; a stop at a target already listed replaces it, so a rebuilt panel adds nothing twice.
-
start_tour–Opens the tour at its first stop.
-
offer_tour–Opens the tour on its own a moment after the first scene shows, until the user has finished or skipped it once.
-
on_tour_finish–Records that the user has seen the tour, finished or skipped; the status line keeps whatever the panels last reported.
-
add–Builds every panel's component and template; the dock arranges them once the client reports ready.
-
open–Adds a Split's panels to the running dock, building those not built yet, and activates the first.
-
open_spec–Opens a dock card: its target builds the Split, remembered under the card's name so the next start rebuilds it.
-
opened_first–The first panel id of the open card of that name, None when it is not open.
-
close–Takes an opened card out of the dock and the shell and stops rebuilding it on save.
-
close_all–Closes every opened card.
-
discard–Takes an opened card out of the dock and the shell: its panels are removed and disposed, its header widgets dropped, the card forgotten.
-
register–Builds each leaf and registers it before the next is built, so a panel can see the ones already standing (a second scene panel must know a mirror is taken).
-
retire–Disposes the built panels of those ids and drops them from the shell.
-
drop_header–Removes a Split's widgets from the header, those still there.
-
watch–Rebuilds the spec's Split after every .py save under its roots once the server runs; a spec of the shell core is left to the dev supervisor.
-
unwatch–Stops rebuilding a card on save.
-
rebuild–Swaps a card's panels for a fresh build under the same ids, the dock untouched; other ids close and reopen the card, and a card no longer open reopens.
-
replace_root–Rebuilds the authored Split in place; changed ids re-lay the dock out from the authored arrangement.
-
replace_card–Rebuilds an open card in place; changed ids close and reopen it, and a card not open opens.
-
swap–Disposes the retired panels, then builds the Split's leaves, whose templates overwrite those of the same ids; returns the header widgets the build added.
-
find_spec–The catalogue card of that name, None when the catalogue has none.
-
restore_opened–Reopens the cards the last session left in the dock, dropping any whose card is gone or whose target no longer builds a Split.
-
remember_opened–Persists the cards open in the dock, in opening order, and names them in the state for the launcher's cards.
-
prune_opened–Forgets an opened Split whose first panel is missing from a settled layout, one that shows every panel handed to the dock since the last.
-
place–add_panel for every placement of a Split, its first panel within
reference's group when given; ids already in the dock are left alone. -
panel–The built component of a panel, checked to be of
kind. -
status–Writes the status line, flushing so it also lands from outside a handler.
-
download–Hands the browser a file to save to its downloads.
-
on_downloaded–Drops the file the browser now has from the state.
-
toast–Shows a short message in the bottom-right corner for a few seconds.
-
marshal–Runs
fn(*args)on the server loop from any thread. -
when_ready–Calls
fnon the server loop: now when the server runs, else once it is ready. -
authored_layout–The dockview layout of the authored Split; RuntimeError before
add. -
on_dock_ready–Restores the saved arrangement when it names the authored panels, else applies the authored one; add_panel then fills any gap.
-
activate–Brings a panel's tab to the front, or once the dock is ready when it is not yet.
-
on_layout_changed–Persists the layout the dock reports, forgets the cards it no longer shows and tells every panel.
-
on_panel_removed–Disposes the panel whose tab the user closed; the dock reports only a user close here, never its own teardown, and Reset layout builds a closed panel again.
-
rebuild_closed–Rebuilds every card a closed tab left incomplete, header widgets included, so an arrangement naming its panels finds them live.
-
on_panel_visibility–Records that the dock showed or hid a panel and tells that panel.
-
reset_layout–Rebuilds the authored arrangement, which also recovers a group orphaned by a killed popout window.
-
open_workbench–Hands a catalogue selection to the open_workbench hook, or names the command that opens it.
-
on_server_ready–Takes the server loop and opens the app window when one was asked for.
-
on_client_connected–Forgets the dock a reloaded page left, so
activateholds a panel until the new dock reports ready. -
on_client_exited–Forgets the dock of the page that left, so
activateholds a panel until the next dock reports ready. -
on_server_exited–Stops every reloader and the running task, then flushes the persisted state.
-
open_app_window–Chrome (Edge fallback) as an app window on its own profile; the server stops when the window process exits. Without either, a system browser tab.
-
install_break_handler–Makes a break or termination signal a clean stop, so the exit hooks flush the persisted state; the --dev supervisor stops its child this way.
-
on_break–Schedules the server's stop on its loop, which ends the main loop and runs the exit hooks.
-
run–Serves until stopped, or until an app window closes.
Attributes:
-
render–The render settings every 3D view of the user draws with, in every workbench.
-
authored(Opened | None) –The Split add() built, named after the spec it serves when it is to be rebuilt on save.
-
opened(dict[str, Opened]) –Splits opened into the running dock by their first panel id.
-
pending(set[str]) –Panel ids handed to the dock since a layout last showed them all; a layout still missing one is a placement in flight, not a close.
-
on_screen(set[str]) –Panel ids the dock last reported visible; the dock reports a panel only when it mounts, so a panel rebuilt in place learns it from here.
-
catalogue–The cards the title menu and a launcher panel list: the discovered ones unless the constructor was given its own.
-
tour_steps(list[TourStep]) –The tour's stops in order, before the shell's own closing one; panels add theirs through
add_tour_steps. -
docked–Whether the client dock has reported ready; until then it drops activations and its layout restore decides the front tabs.
-
front(str | None) –The panel
activateasked to the front before the dock was ready, activated once the layout is restored. -
notices–How many downloads and toasts the shell sent, which numbers the next.
-
header–The header's slot for a workbench's own controls: build widgets inside
with app.header:and flush_content() after a later change. -
root(Split | None) –The authored Split, None before
add. -
panel_ids(list[str]) –The ids of the built panels, in build order.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | |
render
instance-attribute
¶
render = load_render(self.persist, self.scope[0])
The render settings every 3D view of the user draws with, in every workbench.
authored
instance-attribute
¶
authored: Opened | None = None
The Split add() built, named after the spec it serves when it is to be rebuilt on save.
opened
instance-attribute
¶
Splits opened into the running dock by their first panel id.
pending
instance-attribute
¶
Panel ids handed to the dock since a layout last showed them all; a layout still missing one is a placement in flight, not a close.
on_screen
instance-attribute
¶
Panel ids the dock last reported visible; the dock reports a panel only when it mounts, so a panel rebuilt in place learns it from here.
catalogue
instance-attribute
¶
catalogue = list(catalogue) if catalogue is not None else self.load_catalogue()
The cards the title menu and a launcher panel list: the discovered ones unless the constructor was given its own.
tour_steps
instance-attribute
¶
The tour's stops in order, before the shell's own closing one; panels add theirs through add_tour_steps.
docked
instance-attribute
¶
Whether the client dock has reported ready; until then it drops activations and its layout restore decides the front tabs.
front
instance-attribute
¶
front: str | None = None
The panel activate asked to the front before the dock was ready, activated once the layout is restored.
notices
instance-attribute
¶
How many downloads and toasts the shell sent, which numbers the next.
header
instance-attribute
¶
The header's slot for a workbench's own controls: build widgets inside with app.header: and flush_content() after a later change.
load_catalogue
¶
load_catalogue() -> list[WorkbenchSpec]
The discovered specs, empty with a warning when an entry point is broken.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
build_ui
¶
The header and the dock, whose panel bodies are the server templates the placements name.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
build_task_bar
¶
The task bar, one button that opens and closes the drawer: the tasks counted by how they ended, each with its icon, then the task it leads with and any script error.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
build_task_sheet
¶
The drawer's body: the script error in full, then a row per task with its state, elapsed time and run; a click on a row opens its run, else its details.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | |
open_task_row
¶
open_task_row(label: str) -> None
A click on a task row: opens its run, else shows or hides its details.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
show_tasks
¶
show_tasks(view: TaskView) -> None
Shows the task board's rows, summary and focus row in the strip and its sheet.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
follow_run
¶
Hands a task's newer run to the field viewer, which opens it when it shows the task's previous run.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
toggle_tasks
¶
on_render_choice
¶
on_render_choice(**_: object) -> None
Applies a render setting a toggle or a switch chose; a slider applies on its release instead.
apply_render
¶
Takes the render settings the state shows, saves them for every workbench and has each panel redraw with them; settings that do not validate are put back.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
reset_render
¶
Puts every render setting back to its default.
on_task_sheet
¶
on_task_sheet(**_: object) -> None
Remembers whether the task sheet is open for the next start, however it opened or closed.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
open_task_run
¶
open_task_run(run_id: str) -> None
Opens a task's run in the field viewer, which waits for its fields while it solves.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
toggle_task_details
¶
toggle_task_details(label: str) -> None
Shows one task's traceback or log under its row, or hides it.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
cancel_task
¶
cancel_task(label: str) -> None
Arms Cancel for a few seconds on the first press and cancels the task on the second.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
count_down
¶
Shows the seconds left on an armed Cancel the user left alone, and reverts it when none is left.
Parameters:
-
label(str) –The task whose Cancel is armed.
-
armed(int) –The arming this countdown belongs to; a later arming stops it.
-
left(int) –The seconds to show.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
build_switcher
¶
The title as a menu over the catalogue.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
add_tour_steps
¶
Adds stops to the tour before the shell's closing one; a stop at a target already listed replaces it, so a rebuilt panel adds nothing twice.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
start_tour
¶
offer_tour
¶
Opens the tour on its own a moment after the first scene shows, until the user has finished or skipped it once.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_tour_finish
¶
on_tour_finish(reason: str) -> None
Records that the user has seen the tour, finished or skipped; the status line keeps whatever the panels last reported.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
add
¶
add(root: Split, *, spec: WorkbenchSpec | None = None, watch: Sequence[Path] = ()) -> None
Builds every panel's component and template; the dock arranges them once the client reports ready.
Parameters:
-
root(Split) –The Split to serve.
-
spec(WorkbenchSpec | None, default:None) –The card the Split was built from; given, the Split is rebuilt on every save.
-
watch(Sequence[Path], default:()) –More directories whose .py saves rebuild the Split, beside the spec's own roots.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
open
¶
Adds a Split's panels to the running dock, building those not built yet, and activates the first.
Parameters:
-
root(Split) –The Split whose panels to add.
-
reference(str | None, default:None) –The panel whose group the first panel joins; None lets the dock place it.
-
name(str | None, default:None) –The card the Split comes from, remembered so the next start reopens it; None for a bare Split.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
open_spec
¶
open_spec(spec: WorkbenchSpec, *, reference: str | None = None) -> None
Opens a dock card: its target builds the Split, remembered under the card's name so the next start rebuilds it.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
opened_first
¶
The first panel id of the open card of that name, None when it is not open.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
close
¶
close(name: str) -> None
Takes an opened card out of the dock and the shell and stops rebuilding it on save.
close_all
¶
Closes every opened card.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
discard
¶
discard(name: str) -> None
Takes an opened card out of the dock and the shell: its panels are removed and disposed, its header widgets dropped, the card forgotten.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
register
¶
register(leaves: Sequence[Panel]) -> list[PanelComponent]
Builds each leaf and registers it before the next is built, so a panel can see the ones already standing (a second scene panel must know a mirror is taken).
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
retire
¶
Disposes the built panels of those ids and drops them from the shell.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
drop_header
¶
Removes a Split's widgets from the header, those still there.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
watch
¶
watch(spec: WorkbenchSpec, *, reference: str | None = None, extra: Sequence[Path] = ()) -> None
Rebuilds the spec's Split after every .py save under its roots once the server runs; a spec of the shell core is left to the dev supervisor.
Parameters:
-
spec(WorkbenchSpec) –The card whose target builds the Split.
-
reference(str | None, default:None) –The panel whose group the rebuilt card joins when it is no longer open.
-
extra(Sequence[Path], default:()) –More directories to watch, beside the femforge core, the workbench package and the spec's own source root.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
rebuild
¶
Swaps a card's panels for a fresh build under the same ids, the dock untouched; other ids close and reopen the card, and a card no longer open reopens.
Parameters:
-
name(str) –The card to rebuild.
-
root(Split) –The fresh build of its Split.
-
reference(str | None, default:None) –The panel whose group the card joins when it is no longer open.
-
seconds(float, default:0.0) –The seconds the build took, added to the rebuild time the status line reports.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
replace_root
¶
Rebuilds the authored Split in place; changed ids re-lay the dock out from the authored arrangement.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
replace_card
¶
Rebuilds an open card in place; changed ids close and reopen it, and a card not open opens.
Parameters:
-
name(str) –The card to rebuild.
-
root(Split) –The fresh build of its Split.
-
reference(str | None) –The panel whose group the card joins when it is not open.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
swap
¶
Disposes the retired panels, then builds the Split's leaves, whose templates overwrite those of the same ids; returns the header widgets the build added.
Parameters:
-
root(Split) –The Split whose leaves to build.
-
retired(Sequence[str]) –The ids of the panels to dispose first.
-
header(Sequence[object]) –The header widgets the retired panels added, dropped with them.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
find_spec
¶
find_spec(name: str) -> WorkbenchSpec | None
The catalogue card of that name, None when the catalogue has none.
restore_opened
¶
Reopens the cards the last session left in the dock, dropping any whose card is gone or whose target no longer builds a Split.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
remember_opened
¶
Persists the cards open in the dock, in opening order, and names them in the state for the launcher's cards.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
prune_opened
¶
Forgets an opened Split whose first panel is missing from a settled layout, one that shows every panel handed to the dock since the last.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
place
¶
place(root: Split, reference: str | None = None) -> None
add_panel for every placement of a Split, its first panel within reference's group when given; ids already in the dock are left alone.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
panel
¶
The built component of a panel, checked to be of kind.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
status
¶
status(message: str) -> None
Writes the status line, flushing so it also lands from outside a handler.
download
¶
Hands the browser a file to save to its downloads.
Parameters:
-
name(str) –The file name the browser suggests.
-
data(bytes) –The file's bytes.
-
media_type(str) –The file's media type, such as
image/png.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_downloaded
¶
toast
¶
toast(text: str) -> None
Shows a short message in the bottom-right corner for a few seconds.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
marshal
¶
Runs fn(*args) on the server loop from any thread.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
when_ready
¶
when_ready(fn: Callable[[], None]) -> None
Calls fn on the server loop: now when the server runs, else once it is ready.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
authored_layout
¶
The dockview layout of the authored Split; RuntimeError before add.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_dock_ready
¶
Restores the saved arrangement when it names the authored panels, else applies the authored one; add_panel then fills any gap.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
activate
¶
activate(panel_id: str) -> None
Brings a panel's tab to the front, or once the dock is ready when it is not yet.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_layout_changed
¶
Persists the layout the dock reports, forgets the cards it no longer shows and tells every panel.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_panel_removed
¶
Disposes the panel whose tab the user closed; the dock reports only a user close here, never its own teardown, and Reset layout builds a closed panel again.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
rebuild_closed
¶
Rebuilds every card a closed tab left incomplete, header widgets included, so an arrangement naming its panels finds them live.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_panel_visibility
¶
Records that the dock showed or hid a panel and tells that panel.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
reset_layout
¶
Rebuilds the authored arrangement, which also recovers a group orphaned by a killed popout window.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
open_workbench
¶
open_workbench(name: str) -> None
Hands a catalogue selection to the open_workbench hook, or names the command that opens it.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_server_ready
¶
on_server_ready(**_: object) -> None
Takes the server loop and opens the app window when one was asked for.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_client_connected
¶
on_client_connected(**_: object) -> None
Forgets the dock a reloaded page left, so activate holds a panel until the new dock reports ready.
on_client_exited
¶
on_client_exited(**_: object) -> None
Forgets the dock of the page that left, so activate holds a panel until the next dock reports ready.
on_server_exited
¶
on_server_exited(**_: object) -> None
Stops every reloader and the running task, then flushes the persisted state.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
open_app_window
¶
Chrome (Edge fallback) as an app window on its own profile; the server stops when the window process exits. Without either, a system browser tab.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
install_break_handler
¶
Makes a break or termination signal a clean stop, so the exit hooks flush the persisted state; the --dev supervisor stops its child this way.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
on_break
¶
Schedules the server's stop on its loop, which ends the main loop and runs the exit hooks.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
run
¶
Serves until stopped, or until an app window closes.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
check_unique
¶
Rejects a panel id used twice in one Split.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
aria
¶
aria(element: E, **attributes: object) -> E
Sets attributes trame's html elements leave out, such as role and the ARIA ones, aria_live written as aria-live.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
guard
¶
guard(handler: Callable[Concatenate[S, P], None]) -> Callable[Concatenate[S, P], None]
Prints a handler's exception with rich and reports it in the status line instead of letting it escape into wslink.
Source code in packages/femforge-workbench/src/femforge_workbench/app.py
femforge_workbench.launcher
¶
The built-in launcher dock: the catalogue cards on the left, the scene, the outputs and the log as tabs on the right.
Functions:
-
workbench–The launcher dock.
workbench
¶
workbench() -> Split
The launcher dock.
Source code in packages/femforge-workbench/src/femforge_workbench/launcher.py
femforge_workbench.demo
¶
The built-in demo workbench: a sphere in the scene, a line figure and a grouped table, exercising the shell without lab data.
Classes:
-
DemoPanel–The demo's panel ids.
-
DemoVar–The demo's state variables.
-
Sphere–A Renderable: a faceted sphere beside a smaller smooth one, painted from the palette.
Functions:
-
signal_figure–Two damped sinusoids named for export through layout.meta.title.
-
rows_frame–A hundred rows over five series with a group label carrying the count and the peak y.
-
series_rows–The grouped rows of one series, or all of them.
-
workbench–The demo dock: the sphere on the left, the figure over the table on the right, with a series filter in the app bar.
Attributes:
-
SPEC–The catalogue card the workbench entry point exposes.
Sphere
¶
Sphere(palette: Palette)
A Renderable: a faceted sphere beside a smaller smooth one, painted from the palette.
Methods:
-
render–Draws the two spheres into
plotterand fits the camera.
Source code in packages/femforge-workbench/src/femforge_workbench/demo.py
render
¶
Draws the two spheres into plotter and fits the camera.
Source code in packages/femforge-workbench/src/femforge_workbench/demo.py
signal_figure
¶
Two damped sinusoids named for export through layout.meta.title.
Source code in packages/femforge-workbench/src/femforge_workbench/demo.py
rows_frame
¶
A hundred rows over five series with a group label carrying the count and the peak y.
Source code in packages/femforge-workbench/src/femforge_workbench/demo.py
series_rows
¶
series_rows(frame: DataFrame, selected: str) -> DataFrame
The grouped rows of one series, or all of them.
Source code in packages/femforge-workbench/src/femforge_workbench/demo.py
workbench
¶
workbench() -> Split
The demo dock: the sphere on the left, the figure over the table on the right, with a series filter in the app bar.
Source code in packages/femforge-workbench/src/femforge_workbench/demo.py
femforge_workbench.settings
¶
Environment switches the workbench reads, each spelled once.
Classes:
-
Setting–The environment variables that switch optional workbench behaviour on.
Functions:
-
enabled–Whether the switch is set to a true value.
Setting
¶
Bases: StrEnum
The environment variables that switch optional workbench behaviour on.
Attributes:
-
OCP_VSCODE–Also push every CompoundRenderable to the OCP CAD Viewer in VS Code.
OCP_VSCODE
class-attribute
instance-attribute
¶
Also push every CompoundRenderable to the OCP CAD Viewer in VS Code.
enabled
¶
femforge_workbench.tasks
¶
Background tasks: a script's labelled callables, run one at a time in child processes while the workbench serves, each shown as a row of the task strip.
Type Aliases:
-
Spawn–Starts the child process of a job, whose files live in the given folder.
-
TaskFactory–A module-level function listing a script's tasks; called again after every save and in every task's child process.
-
TaskOutcome–The outcome file of a task's child process, told apart by its
status.
Classes:
-
Task–One background task: a label unique in its plan and the zero-argument callable a child process runs.
-
TaskPhase–Where a task stands: queued, one of the steps of its run, or how it ended.
-
TaskField–The keys of a task row in the client state; each names a field or computed field of
TaskRow. -
TaskRow–One task as the strip shows it: where it stands, the run it is on, and how its last run ended.
-
TaskJob–What a task's child process is handed: the factory to list the plan with, the label to run, and the directory to import from.
-
OutcomeKind–How a task's child process ended.
-
TaskDone–A task whose callable returned.
-
TaskFailed–A task whose callable, or the import of its plan, raised.
-
TaskExit–The task worker's exit codes.
-
TaskProcess–A task's child process as the board drives it.
-
ChildTask–A task worker started by
spawn_task, in a process tree of its own. -
TaskView–What the task strip shows: every row, the summary line and the row it leads with.
-
TaskHost–What a task board needs of the shell it runs in.
-
Running–The task whose child process runs now.
-
TaskBoard–Runs a script's plan one task at a time in child processes, re-submits it after every save, and publishes a row per task.
Functions:
-
shown_label–A label as the strip shows it: as written when it has a capital, else in Title Case.
-
plan_of–The tasks a factory listed; TypeError for anything but a list of Task, ValueError for an empty plan, an empty label or a label used twice.
-
ordinal–2nd,3rd,11th: the number as a place in a line. -
clock–A duration as the task strip shows it:
0.3s,12s,1m 12s,1h 02m; a dash for None. -
observe–The row after one record of its task's child: a new run id starts a run, a stage, a claim wait or a reuse moves the phase, a progress record moves the bar, a stall record says why.
-
task_outcomes–The validator of a task's outcome file.
-
read_outcome–The outcome a child process wrote, None when it wrote none or an unreadable one.
-
spawn_task–Starts
python -m femforge_workbench.task_workeron the job in its own process group and tree, its job and outcome files infolder. -
break_until_exit–Sends the break every
BREAK_REPEAT_Suntil the process exits orgraceseconds pass; whether it exited, False at once without a console. -
tree_pids–The ids of a process and every process it started, read before a stop ends them; on Windows a venv's
python.exeis a launcher, and the interpreter holding the claims is its child. -
reap–Breaks the claims a stopped task left on its runs, so the next run need not wait for them to go stale.
Attributes:
-
STOP_GRACE_S–t_grace[s]: How long a stopped task gets to release its run before its process tree is killed. -
PUBLISH_PERIOD_S–t_publish[s]: The shortest gap between two pushes of the task rows to the client. -
KILL_WAIT_S–t_kill[s]: How long a killed task process gets to vanish before its claims are reaped. -
BREAK_REPEAT_S–t_break[s]: How often a stopping task's process group gets the break again; a process started after a break never saw it. -
WORKER_MODULE–The module a task's child process runs.
-
LOG_TAIL–How many of a task process's last plain output lines a failure without an outcome shows, and of its last log messages a stall shows.
-
FOCUS_ORDER–The phases the collapsed strip leads with, most telling first.
STOP_GRACE_S
module-attribute
¶
t_grace [s]: How long a stopped task gets to release its run before its process tree is killed.
PUBLISH_PERIOD_S
module-attribute
¶
t_publish [s]: The shortest gap between two pushes of the task rows to the client.
KILL_WAIT_S
module-attribute
¶
t_kill [s]: How long a killed task process gets to vanish before its claims are reaped.
BREAK_REPEAT_S
module-attribute
¶
t_break [s]: How often a stopping task's process group gets the break again; a process started after a break never saw it.
WORKER_MODULE
module-attribute
¶
The module a task's child process runs.
LOG_TAIL
module-attribute
¶
How many of a task process's last plain output lines a failure without an outcome shows, and of its last log messages a stall shows.
FOCUS_ORDER
module-attribute
¶
FOCUS_ORDER = (TaskPhase.SOLVING, TaskPhase.MESHING, TaskPhase.GEOMETRY, TaskPhase.WAITING, TaskPhase.FINISHING, TaskPhase.RUNNING, TaskPhase.STARTING, TaskPhase.QUEUED)
The phases the collapsed strip leads with, most telling first.
TaskFactory
¶
A module-level function listing a script's tasks; called again after every save and in every task's child process.
TaskOutcome
¶
TaskOutcome = TaskDone | TaskFailed
The outcome file of a task's child process, told apart by its status.
Spawn
¶
Spawn = Callable[[TaskJob, Path], Awaitable[TaskProcess]]
Starts the child process of a job, whose files live in the given folder.
Task
dataclass
¶
One background task: a label unique in its plan and the zero-argument callable a child process runs.
Attributes:
-
label(str) –The name the task strip shows, unique in its plan; the child process finds the task by it.
-
run(Callable[[], object]) –What the child process calls; its return value is dropped.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
TaskPhase
¶
Bases: StrEnum
Where a task stands: queued, one of the steps of its run, or how it ended.
Methods:
-
of–The phase a Driver stage puts its task in.
Attributes:
-
WAITING–Waits for another process that holds the claim on the same run.
-
RUNNING–Runs the task's own code between or after its evaluations.
-
REUSED–Done, every evaluation answered by a finished bundle.
-
STALLED–Ended on a solve the watchdog stopped.
-
word(str) –The phase as the task strip names it.
-
icon(IconName) –The icon ahead of the phase, so a state never reads by colour alone.
-
active(bool) –Whether a child process runs the task.
-
ended(bool) –Whether the task's last run is over.
WAITING
class-attribute
instance-attribute
¶
Waits for another process that holds the claim on the same run.
RUNNING
class-attribute
instance-attribute
¶
Runs the task's own code between or after its evaluations.
REUSED
class-attribute
instance-attribute
¶
Done, every evaluation answered by a finished bundle.
STALLED
class-attribute
instance-attribute
¶
Ended on a solve the watchdog stopped.
of
classmethod
¶
The phase a Driver stage puts its task in.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
TaskField
¶
Bases: StrEnum
The keys of a task row in the client state; each names a field or computed field of TaskRow.
TaskRow
pydantic-model
¶
Bases: BaseModel
One task as the strip shows it: where it stands, the run it is on, and how its last run ended.
Config:
use_attribute_docstrings:True
Fields:
-
label(str) -
title(str) -
phase(TaskPhase) -
run_id(str | None) -
runs(int) -
solves(int) -
reuses(int) -
fetched(bool) -
mesh_cached(bool) -
solver(str | None) -
stack(list[str]) -
direct(list[str]) -
progress(float | None) -
iteration(int | None) -
max_iterations(int | None) -
elapsed(float | None) -
error(str | None) -
traceback(str | None) -
stall(str | None) -
position(int | None) -
again(bool) -
removed(bool) -
stopping(bool)
fetched
pydantic-field
¶
fetched: bool = False
Whether a reused bundle came from the artifact cache rather than the run directory.
mesh_cached
pydantic-field
¶
mesh_cached: bool = False
Whether the artifact cache served the running run's mesh.
stack
pydantic-field
¶
The running solve's solvers of a linear system, in sif order.
direct
pydantic-field
¶
Those of them that factorize their system instead of iterating.
progress
pydantic-field
¶
progress: float | None = None
f [-]: The share of the running solve's convergence covered, never moving back within one solver's solve; None when unknown.
iteration
pydantic-field
¶
iteration: int | None = None
The running linear solve's latest iteration, from its progress line; None before one.
max_iterations
pydantic-field
¶
max_iterations: int | None = None
The running linear solve's iteration cap; None when unknown.
elapsed
pydantic-field
¶
elapsed: float | None = None
t [s]: Wall time of the task's current or last run; None before it first starts.
error
pydantic-field
¶
error: str | None = None
The failure's type and the first line of its message.
traceback
pydantic-field
¶
traceback: str | None = None
The failure's traceback, the process's last output lines when it left no outcome, or a stalled task's last log lines.
stall
pydantic-field
¶
stall: str | None = None
Why the watchdog stopped a solve of the task's current or last run; None when none stalled.
position
pydantic-field
¶
position: int | None = None
The task's place in the queue, from 1; None when it is not queued.
again
pydantic-field
¶
again: bool = False
Whether a save queued the task again while it was running.
removed
pydantic-field
¶
removed: bool = False
Whether a save dropped the task while it was running; the row leaves once the run ends.
stopping
pydantic-field
¶
stopping: bool = False
Whether a confirmed Cancel is stopping the running task.
current
property
¶
current: str | None
The solver solving now: the one last reported on, else the stack's first.
factorizing
property
¶
factorizing: bool
Whether the solver solving now factorizes its system, so no percent can show.
solving
property
¶
solving: str
The solve's qualifier: the solver, its place in a stack of several, and Direct for a factorization; empty when unknown.
iterations
property
¶
iterations: str
The linear iteration against its cap, It 412/5000, empty before the first progress line.
failed
property
¶
failed: bool
Whether the task's last run failed or stalled, which the strip marks in the destructive colour.
stalled
property
¶
stalled: bool
Whether the task's last run ended on a stalled solve, whose details are its log.
cancellable
property
¶
cancellable: bool
Whether Cancel applies: the task waits in the queue, or runs and no Cancel is stopping it yet.
retryable
property
¶
retryable: bool
Whether Retry applies: the task's last run failed, stalled or was cancelled.
queued
¶
queued() -> TaskRow
The row queued afresh: no run, no clock and no failure until the task starts again.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
TaskJob
pydantic-model
¶
Bases: BaseModel
What a task's child process is handed: the factory to list the plan with, the label to run, and the directory to import from.
Config:
use_attribute_docstrings:True
Fields:
TaskDone
pydantic-model
¶
TaskFailed
pydantic-model
¶
Bases: BaseModel
A task whose callable, or the import of its plan, raised.
Config:
use_attribute_docstrings:True
Fields:
TaskProcess
¶
Bases: Protocol
A task's child process as the board drives it.
Methods:
-
lines–Each merged output line, until the process closes its output.
-
wait–Waits for the process to exit and returns its exit code.
-
wait_for–Blocks until the process exits or
timeoutseconds pass; whether it exited. -
interrupt–Sends the break to the process group; False when it cannot be sent.
-
kill–Ends every process in the tree now.
-
close–Ends what is left of the tree and releases it; a second call does nothing.
Attributes:
ChildTask
dataclass
¶
ChildTask(process: Process, tree: ProcessTree, closed: bool = False)
A task worker started by spawn_task, in a process tree of its own.
Methods:
-
lines–Each merged output line, decoded as UTF-8.
-
wait–The worker's exit code, once it exits.
-
wait_for–Whether the worker exited within
timeoutseconds. -
interrupt–Sends the break to the worker's group.
-
kill–Ends the worker's whole tree.
-
close–Ends what is left of the tree and releases it, once.
Attributes:
lines
async
¶
lines() -> AsyncIterator[str]
Each merged output line, decoded as UTF-8.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
wait_for
¶
Whether the worker exited within timeout seconds.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
kill
¶
close
¶
TaskView
pydantic-model
¶
Bases: BaseModel
What the task strip shows: every row, the summary line and the row it leads with.
Config:
use_attribute_docstrings:True
Fields:
-
rows(list[TaskRow]) -
summary(str) -
count(str) -
focus(TaskRow | None) -
busy(bool) -
done(int) -
reused(int) -
failed(int) -
stalled(int) -
error(str | None) -
submitted(str)
rows
pydantic-field
¶
The tasks in plan order, then a dropped one still finishing.
focus
pydantic-field
¶
focus: TaskRow | None
The row the collapsed strip leads with: the most telling active one, else the last failure, else none.
done
pydantic-field
¶
done: int
How many tasks ended their last run done, past the ones that reused finished bundles alone.
TaskHost
¶
Bases: Protocol
What a task board needs of the shell it runs in.
Methods:
-
marshal–Runs
fn(*args)on the server loop from any thread. -
show_tasks–Shows the rows on the client.
-
follow_run–Opens
currentin a viewer that showsprevious.
Running
dataclass
¶
Running(label: str, process: TaskProcess, folder: Path, started: float, exited: Event = Event(), stopping: bool = False, run_dir: Path | None = None, messages: deque[str] = (lambda: deque(maxlen=LOG_TAIL))())
The task whose child process runs now.
Attributes:
TaskBoard
¶
TaskBoard(app: TaskHost, factory: str, plan: Sequence[Task], *, path: str | None, roots: Sequence[Path], spawn: Spawn = spawn_task)
Runs a script's plan one task at a time in child processes, re-submits it after every save, and publishes a row per task.
Parameters:
-
app(TaskHost) –The shell the rows show in.
-
factory(str) –The
module:attrtarget of the factory listing the plan, which every save and every child calls again. -
plan(Sequence[Task]) –The tasks the factory listed at startup.
-
path(str | None) –The directory each child puts first on its import path; None leaves the path alone.
-
roots(Sequence[Path]) –The directories whose .py saves re-submit the plan.
-
spawn(Spawn, default:spawn_task) –Starts a task's child process.
Methods:
-
start–Runs the queue and watches the roots, on the server loop.
-
background–Runs a coroutine on the loop, kept alive until it ends.
-
apply–Submits the plan a save listed, or reports why it listed none and keeps the rows.
-
script_error–Shows why the script listed no tasks, keeping the rows of the last plan.
-
submit–Queues every task of the plan in order; a running task finishes on its old code and runs once more, and a dropped one leaves once it ends.
-
retry–Queues a failed or cancelled task of the plan again, after those already queued.
-
cancel–Takes a queued task out of the queue, or stops the running one, which then reads Cancelled.
-
rows–The rows in order, the running one's elapsed time and each queued one's place brought up to date.
-
view–The rows, the summary and the focus row as the strip shows them.
-
publish–Pushes the rows to the client now, or marks them for the next tick.
-
tick–Pushes the rows once a period while a task runs or a record moved them.
-
drain–Runs the queued tasks one at a time until the board shuts down; a task that fails in any way fails its row, never the server.
-
run_one–Runs one task in its own child process, relaying its records and moving its row, then settles the row by its outcome.
-
relay–Moves the row by one output line of its child and logs the line here, for the terminal only: the child stored its own records.
-
settle–Ends the row by how the child exited: done or reused when it returned with no stall, else cancelled when stopped, else stalled with its log, else failed.
-
end–Sets a row's final phase, follows its newer run into the viewer, and drops a row a save removed.
-
stop–Breaks the running task until it exits, kills its tree when it is still there after the grace, then reaps the claim it left.
-
shutdown–Stops the board for good: empties the queue, breaks the running task until it exits or
graceseconds pass, kills what is left, and reaps the claim it left.
Attributes:
-
by_label(dict[str, TaskRow]) –Each task's row by label, in the order the strip lists them.
-
last_runs(dict[str, str]) –The run each label last ended on, which a newer run of the same label takes over in the viewer.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
by_label
instance-attribute
¶
Each task's row by label, in the order the strip lists them.
last_runs
instance-attribute
¶
The run each label last ended on, which a newer run of the same label takes over in the viewer.
start
¶
Runs the queue and watches the roots, on the server loop.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
background
¶
background(work: Awaitable[None]) -> None
Runs a coroutine on the loop, kept alive until it ends.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
apply
¶
Submits the plan a save listed, or reports why it listed none and keeps the rows.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
script_error
¶
script_error(error: Exception) -> None
Shows why the script listed no tasks, keeping the rows of the last plan.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
submit
¶
Queues every task of the plan in order; a running task finishes on its old code and runs once more, and a dropped one leaves once it ends.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
retry
¶
retry(label: str) -> None
Queues a failed or cancelled task of the plan again, after those already queued.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
cancel
¶
cancel(label: str) -> None
Takes a queued task out of the queue, or stops the running one, which then reads Cancelled.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
rows
¶
The rows in order, the running one's elapsed time and each queued one's place brought up to date.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
view
¶
view() -> TaskView
The rows, the summary and the focus row as the strip shows them.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
publish
¶
publish(*, now: bool = False) -> None
Pushes the rows to the client now, or marks them for the next tick.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
tick
async
¶
Pushes the rows once a period while a task runs or a record moved them.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
drain
async
¶
Runs the queued tasks one at a time until the board shuts down; a task that fails in any way fails its row, never the server.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
run_one
async
¶
run_one(label: str) -> None
Runs one task in its own child process, relaying its records and moving its row, then settles the row by its outcome.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
relay
¶
Moves the row by one output line of its child and logs the line here, for the terminal only: the child stored its own records.
Parameters:
-
running(Running) –The task whose child printed the line.
-
line(str) –The output line.
-
tail(deque[str]) –The child's last plain lines, which a failure without an outcome shows.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
settle
¶
settle(running: Running, code: int, outcome: TaskDone | TaskFailed | None, tail: Sequence[str]) -> None
Ends the row by how the child exited: done or reused when it returned with no stall, else cancelled when stopped, else stalled with its log, else failed.
Parameters:
-
running(Running) –The task whose child exited.
-
code(int) –The child's exit code.
-
outcome(TaskDone | TaskFailed | None) –The outcome file the child wrote; None when it wrote none.
-
tail(Sequence[str]) –The child's last plain lines.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
end
¶
end(label: str, *, phase: TaskPhase, error: str | None = None, traceback: str | None = None) -> None
Sets a row's final phase, follows its newer run into the viewer, and drops a row a save removed.
Parameters:
-
label(str) –The task whose run ended.
-
phase(TaskPhase) –How it ended.
-
error(str | None, default:None) –The failure's one-line summary.
-
traceback(str | None, default:None) –The failure's traceback or last output lines.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
stop
async
¶
stop(running: Running) -> None
Breaks the running task until it exits, kills its tree when it is still there after the grace, then reaps the claim it left.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
shutdown
¶
shutdown(grace: float = STOP_GRACE_S) -> None
Stops the board for good: empties the queue, breaks the running task until it exits or grace seconds pass, kills what is left, and reaps the claim it left.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
shown_label
¶
A label as the strip shows it: as written when it has a capital, else in Title Case.
plan_of
¶
The tasks a factory listed; TypeError for anything but a list of Task, ValueError for an empty plan, an empty label or a label used twice.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
ordinal
¶
2nd, 3rd, 11th: the number as a place in a line.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
clock
¶
A duration as the task strip shows it: 0.3s, 12s, 1m 12s, 1h 02m; a dash for None.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
observe
¶
The row after one record of its task's child: a new run id starts a run, a stage, a claim wait or a reuse moves the phase, a progress record moves the bar, a stall record says why.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | |
task_outcomes
cached
¶
task_outcomes() -> TypeAdapter[TaskDone | TaskFailed]
The validator of a task's outcome file.
read_outcome
¶
read_outcome(path: Path) -> TaskDone | TaskFailed | None
The outcome a child process wrote, None when it wrote none or an unreadable one.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
spawn_task
async
¶
spawn_task(job: TaskJob, folder: Path) -> TaskProcess
Starts python -m femforge_workbench.task_worker on the job in its own process group and tree, its job and outcome files in folder.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
break_until_exit
¶
break_until_exit(process: TaskProcess, grace: float) -> bool
Sends the break every BREAK_REPEAT_S until the process exits or grace seconds pass; whether it exited, False at once without a console.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
tree_pids
¶
The ids of a process and every process it started, read before a stop ends them; on Windows a venv's python.exe is a launcher, and the interpreter holding the claims is its child.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
reap
¶
Breaks the claims a stopped task left on its runs, so the next run need not wait for them to go stale.
Parameters:
-
running(Running) –The stopped task.
-
gone(bool) –Whether its process tree has exited, so its own processes count as dead.
-
tree(frozenset[int], default:frozenset()) –The ids of the processes it started, read before the stop.
Source code in packages/femforge-workbench/src/femforge_workbench/tasks.py
femforge_workbench.task_worker
¶
The task worker: python -m femforge_workbench.task_worker JOB OUTCOME runs one labelled task of a script's plan and writes how it ended.
Functions:
-
interrupt–Turns the first break into KeyboardInterrupt, so the task's own cleanup releases its run; the breaks the board repeats after it are ignored.
-
main–Runs the task the job file
JOBnames and writes the outcome fileOUTCOME; a break ends it with no outcome.
Attributes:
-
BREAK_SIGNUM–The signal the board's break arrives as: CTRL_BREAK_EVENT is SIGBREAK on Windows.
BREAK_SIGNUM
module-attribute
¶
The signal the board's break arrives as: CTRL_BREAK_EVENT is SIGBREAK on Windows.
interrupt
¶
Turns the first break into KeyboardInterrupt, so the task's own cleanup releases its run; the breaks the board repeats after it are ignored.
Source code in packages/femforge-workbench/src/femforge_workbench/task_worker.py
main
¶
Runs the task the job file JOB names and writes the outcome file OUTCOME; a break ends it with no outcome.
Source code in packages/femforge-workbench/src/femforge_workbench/task_worker.py
femforge_workbench.reload
¶
Watchdog-driven module reload: a .py save under the roots purges and re-imports a workbench target, builds its result on a worker thread and hands it to the server loop.
Type Aliases:
-
Apply–Receives the fresh result and the seconds the purge, import and factory took.
Classes:
-
Watched–What the shared purge needs of a reloader: the roots it watches.
-
Purge–The last eviction the reloaders shared: when it started and the roots it covered.
-
SaveWatcher–Calls
on_saveonce per burst of .py saves under the roots (onlyfileswhen given),debounceseconds after the last one; a save is an event whose file's mtime changed. -
Reloader–Rebuilds the target on a worker thread after each burst of saves under the roots, one rebuild at a time with at most one more queued.
Functions:
-
package_root–The directory of the top-level package a module belongs to.
-
source_root–The directory to watch for a module: the
srcdirectory of a src layout, so its sibling packages reload with it, else the package itself. -
persistent–Whether a module stays loaded across a purge.
-
shell_files–The source files of the shell core.
-
default_roots–The femforge core's source root, the workbench package's (its panels, widgets and theme rebuild in process) and the module's own.
-
outermost–The resolved roots without repeats and without any lying under another, since each is watched recursively.
-
is_source_save–The saved .py path an event reports, None for anything else; an editor saves as a modification, or as a create or move of a temp file.
Attributes:
-
DEBOUNCE_SECONDS–Seconds after the last save of a burst before it is acted on: an editor writes one file in several events, a save-all several files.
-
REBUILD_LOCK–Serializes purge-and-import across the reloaders of every open card: two threads evicting and importing the same modules at once corrupt each other.
-
WATCHING_LOCK–Guards the watching list alone, never held across a rebuild, so stopping a reloader does not wait for one.
-
SHELL_MODULES–The shell core, relative to the workbench package: never purged in process, restarted by the --dev supervisor instead.
-
PERSISTENT_PACKAGES–Modules the purge leaves alive: the shell core and the logging singleton it shares with the reloaded code.
-
WATCHING(list[Watched]) –The reloaders of the open cards, whose roots the shared purge covers.
-
PURGED–Read and written under REBUILD_LOCK only.
DEBOUNCE_SECONDS
module-attribute
¶
Seconds after the last save of a burst before it is acted on: an editor writes one file in several events, a save-all several files.
REBUILD_LOCK
module-attribute
¶
Serializes purge-and-import across the reloaders of every open card: two threads evicting and importing the same modules at once corrupt each other.
WATCHING_LOCK
module-attribute
¶
Guards the watching list alone, never held across a rebuild, so stopping a reloader does not wait for one.
SHELL_MODULES
module-attribute
¶
SHELL_MODULES = ('app', 'cli', 'dev', 'dock', 'persist', 'registry', 'reload', 'runner', 'serve', 'settings', 'tasks', 'widgets.element', 'widgets.module')
The shell core, relative to the workbench package: never purged in process, restarted by the --dev supervisor instead.
PERSISTENT_PACKAGES
module-attribute
¶
PERSISTENT_PACKAGES = (*(f'{femforge_workbench.__name__}.{name}' for name in SHELL_MODULES), 'femforge.common.log')
Modules the purge leaves alive: the shell core and the logging singleton it shares with the reloaded code.
WATCHING
module-attribute
¶
The reloaders of the open cards, whose roots the shared purge covers.
Apply
¶
Receives the fresh result and the seconds the purge, import and factory took.
Watched
¶
Purge
dataclass
¶
The last eviction the reloaders shared: when it started and the roots it covered.
Methods:
-
covers–Whether this purge followed the save at
requestedand evicted every one of those roots.
covers
¶
Whether this purge followed the save at requested and evicted every one of those roots.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
SaveWatcher
¶
SaveWatcher(roots: Sequence[Path], on_save: Callable[[], None], *, debounce: float = DEBOUNCE_SECONDS, files: Sequence[Path] | None = None)
Bases: FileSystemEventHandler
Calls on_save once per burst of .py saves under the roots (only files when given), debounce seconds after the last one; a save is an event whose file's mtime changed.
Parameters:
-
roots(Sequence[Path]) –The directories watched recursively.
-
on_save(Callable[[], None]) –Called once per burst of saves.
-
debounce(float, default:DEBOUNCE_SECONDS) –Seconds after the last save of a burst before
on_saveruns. -
files(Sequence[Path] | None, default:None) –The only files whose saves count; None counts every .py file under the roots.
Methods:
-
watched–The files whose saves count:
fileswhen given, else every source file under the roots. -
changed–Whether the file's mtime differs from the last one seen; a file never seen counts as changed, a vanished one as unchanged.
-
start–Records every watched file's mtime and starts observing the roots.
-
stop–Cancels a pending call and stops observing.
-
on_any_event–Every save restarts the timer, so only the last of a burst fires.
-
fire–Calls
on_savefor the burst that just settled.
Attributes:
-
stamps(dict[Path, int]) –The mtime last seen per file: watchdog also reports access-time updates, which NTFS writes on reads.
-
observed–When the last save of the current burst was seen, which every reloader watching it reads before any purge.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
stamps
instance-attribute
¶
The mtime last seen per file: watchdog also reports access-time updates, which NTFS writes on reads.
observed
instance-attribute
¶
When the last save of the current burst was seen, which every reloader watching it reads before any purge.
watched
¶
The files whose saves count: files when given, else every source file under the roots.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
changed
¶
Whether the file's mtime differs from the last one seen; a file never seen counts as changed, a vanished one as unchanged.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
start
¶
Records every watched file's mtime and starts observing the roots.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
stop
¶
Cancels a pending call and stops observing.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
on_any_event
¶
Every save restarts the timer, so only the last of a burst fires.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
Reloader
¶
Reloader(target: str, roots: Sequence[Path], apply: Apply[R], *, kind: type[R], marshal: Marshal, failed: Failed | None = None)
Rebuilds the target on a worker thread after each burst of saves under the roots, one rebuild at a time with at most one more queued.
Parameters:
-
target(str) –The
pkg.module:attrfactory rebuilt after every save. -
roots(Sequence[Path]) –The directories whose .py saves trigger a rebuild.
-
apply(Apply[R]) –Receives each result and the seconds it took, on the server loop.
-
kind(type[R]) –The type the factory must return.
-
marshal(Marshal) –Runs a callable on the server loop.
-
failed(Failed | None, default:None) –Receives a failed build's error on the server loop; None drops it.
Methods:
-
start–Watches the roots;
requestbuilds now. -
stop–Stops watching and leaves the shared purge.
-
request–Starts a rebuild, or queues one more when a rebuild is running.
-
work–Rebuilds until no request is queued.
-
rebuild–Builds once and delivers the result, or the failure, to the server loop.
-
deliver–Runs
outcomeon the server loop, dropping it when the loop is gone. -
report–Hands a failed build's error to
failed. -
build–Purges the watched modules, imports the target afresh and calls it, one reloader at a time; a build without a save behind it always purges.
-
purge–Drops every loaded module under the watched roots except the persistent packages, once per save however many cards are open.
Attributes:
-
requested–When the save that asked for the pending rebuild was seen; a purge older than that is not this rebuild's.
-
roots(list[Path]) –The directories the watcher observes.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
requested
instance-attribute
¶
When the save that asked for the pending rebuild was seen; a purge older than that is not this rebuild's.
start
¶
Watches the roots; request builds now.
stop
¶
Stops watching and leaves the shared purge.
request
¶
Starts a rebuild, or queues one more when a rebuild is running.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
work
¶
Rebuilds until no request is queued.
rebuild
¶
Builds once and delivers the result, or the failure, to the server loop.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
deliver
¶
deliver(outcome: Callable[[], None]) -> None
Runs outcome on the server loop, dropping it when the loop is gone.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
build
¶
build(requested: float | None = None) -> R
Purges the watched modules, imports the target afresh and calls it, one reloader at a time; a build without a save behind it always purges.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
purge
¶
purge(requested: float) -> None
Drops every loaded module under the watched roots except the persistent packages, once per save however many cards are open.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
package_root
¶
The directory of the top-level package a module belongs to.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
source_root
¶
The directory to watch for a module: the src directory of a src layout, so its sibling packages reload with it, else the package itself.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
persistent
¶
Whether a module stays loaded across a purge.
shell_files
¶
The source files of the shell core.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
default_roots
¶
The femforge core's source root, the workbench package's (its panels, widgets and theme rebuild in process) and the module's own.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
outermost
¶
The resolved roots without repeats and without any lying under another, since each is watched recursively.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
is_source_save
¶
is_source_save(event: FileSystemEvent) -> str | None
The saved .py path an event reports, None for anything else; an editor saves as a modification, or as a create or move of a temp file.
Source code in packages/femforge-workbench/src/femforge_workbench/reload.py
femforge_workbench.dev
¶
The dev loop for the shell core: a supervisor that reruns the server after every save of a core module, and the page script that follows it back and reloads on a rebuilt dist.
Classes:
-
Supervisor–Runs a command as a child process and restarts it after every burst of .py saves under the roots, or of the
fileswhen given.
Functions:
-
reload_script–Probes the server and the dist each second: the page reloads when the server comes back after a restart, when version.json changes, and when the library failed to install.
-
without_dev–The arguments without the dev flag.
-
child_command–The server as
python -m module, given the arguments without the dev flag. -
supervise–Serves
python -m module argvunder a supervisor restarting it on a save of a shell core module, until Ctrl-C; every other save rebuilds in process.
Attributes:
-
DEV_ENV–Set in the supervised server's environment; the shell then serves the self-reload script.
-
POLL_SECONDS–How often the supervisor looks at its child between saves; a bare wait would hold Ctrl-C on Windows.
-
PROBE_PAGE–Probed beside the page's own URL: the root answers HEAD with 403, the page itself with 200.
-
LIBRARY_GRACE_MS–How long after load the page waits for the widget library before reloading once more.
-
STOP_GRACE–Seconds a child gets to exit on its own after the break, so its exit hooks flush the persisted state.
DEV_ENV
module-attribute
¶
Set in the supervised server's environment; the shell then serves the self-reload script.
POLL_SECONDS
module-attribute
¶
How often the supervisor looks at its child between saves; a bare wait would hold Ctrl-C on Windows.
PROBE_PAGE
module-attribute
¶
Probed beside the page's own URL: the root answers HEAD with 403, the page itself with 200.
LIBRARY_GRACE_MS
module-attribute
¶
How long after load the page waits for the widget library before reloading once more.
STOP_GRACE
module-attribute
¶
Seconds a child gets to exit on its own after the break, so its exit hooks flush the persisted state.
Supervisor
¶
Runs a command as a child process and restarts it after every burst of .py saves under the roots, or of the files when given.
Parameters:
-
command(Sequence[str]) –The server command the child runs.
-
roots(Sequence[Path]) –The directories whose .py saves restart the child.
-
files(Sequence[Path] | None, default:None) –The only files whose saves restart the child; None counts every .py file under the roots.
Methods:
-
spawn–Starts the child in its own process group and tree, flagged as supervised.
-
stop_child–Asks the child to exit, so its exit hooks flush the persisted state, and kills its tree when it does not within the grace.
-
release–Closes the child's tree once the child is gone, which also ends anything the child left behind.
-
await_save–Returns at the next save or stop, noting once when the child exits on its own meanwhile.
-
serve–Runs the child until Ctrl-C or
stop, restarting it after each save. -
stop–Ends
serve, which then stops the child.
Source code in packages/femforge-workbench/src/femforge_workbench/dev.py
spawn
¶
Starts the child in its own process group and tree, flagged as supervised.
Source code in packages/femforge-workbench/src/femforge_workbench/dev.py
stop_child
¶
Asks the child to exit, so its exit hooks flush the persisted state, and kills its tree when it does not within the grace.
Source code in packages/femforge-workbench/src/femforge_workbench/dev.py
release
¶
Closes the child's tree once the child is gone, which also ends anything the child left behind.
await_save
¶
Returns at the next save or stop, noting once when the child exits on its own meanwhile.
Source code in packages/femforge-workbench/src/femforge_workbench/dev.py
serve
¶
Runs the child until Ctrl-C or stop, restarting it after each save.
Source code in packages/femforge-workbench/src/femforge_workbench/dev.py
reload_script
¶
reload_script() -> str
Probes the server and the dist each second: the page reloads when the server comes back after a restart, when version.json changes, and when the library failed to install.
Source code in packages/femforge-workbench/src/femforge_workbench/dev.py
without_dev
¶
child_command
¶
The server as python -m module, given the arguments without the dev flag.
supervise
¶
Serves python -m module argv under a supervisor restarting it on a save of a shell core module, until Ctrl-C; every other save rebuilds in process.