exlab_wizard.controller.creation#
Creation controller. Backend Spec §4.4.1, §4.7, §4.8.
Composes the validator, template engine, plugin host, cache writers,
README generator, and NAS sync client into the §4.7 state machine,
driving each session from SessionState.PENDING through to
SessionState.DONE (or SessionState.FAILED /
SessionState.ABORTED on failure / cancel).
Validation gate (UI-spec §2). Before transitioning out of
SessionState.VALIDATING the controller enforces the mandatory
core-field set:
labelnon-empty after trim, ≤ 100 chars.operatornon-empty after trim; allowlisted whenconfig.operators.allowlistis non-empty.objectivenon-empty after trim, ≤ 2000 chars.equipment_idis inconfig.equipment.The project-folder name (the verbatim
<project>/segment, §3.2) is a safe single filesystem path segment perexlab_wizard.paths.validate_project_name().Template-required field ids and config-required field ids are all present in
readme_extra.
ReadmeGenerator and NASSyncClient are injected as Protocols so this
phase ships before Phase 8 / Phase 10 land their concrete
implementations. NoOpReadmeGenerator writes a minimal
README.md that the post-validate pass can scan;
NoOpNASSync is a true no-op (the sync queue is built in
Phase 10).
Classes
|
Drives the §4.7 state machine end-to-end. |
|
The NAS sync surface the controller depends on. |
No-op stand-in for |
|
Lightweight README generator for tests / headless fixtures. |
|
|
Inputs for |
|
The README generator surface the controller depends on. |
|
Inputs for |
|
Snapshot of session state. |
- class exlab_wizard.controller.creation.CreationController(*, config, validator, template_engine, plugin_host, cache_creation, cache_equipment, cache_log=None, readme_generator=None, nas_sync=None, session_store=None)[source]#
Bases:
objectDrives the §4.7 state machine end-to-end.
Composes the validator (Phase 4), template engine (Phase 5), plugin host (Phase 6), cache writers (Phase 3), README generator (Phase 8 – NoOp until then), and NAS sync client (Phase 10 – NoOp until then).
- Parameters:
config (
Config)validator (
Validator)template_engine (
TemplateEngine)plugin_host (
PluginHost|None)cache_creation (
CreationWriter)cache_equipment (
EquipmentCacheWriter)readme_generator (
ReadmeGeneratorProtocol|None)nas_sync (
NASSyncProtocol|None)session_store (
SessionStore|None)
- apply_config(config, *, plugin_host=None)[source]#
Swap the controller’s config (and optionally plugin host) in place.
Every config read happens at create-time, so reassigning
self._configmakes a live settings save take effect on the nextcreate_*call without a tray relaunch.plugin_hostis re-injected only when the coordinator rebuilt it (apaths.plugin_dirchange); otherwise the existing host is kept.- Parameters:
config (
Config)plugin_host (
PluginHost|None)
- Return type:
- async cancel(session_id, *, discard_files=False)[source]#
Abort an in-flight session.
Pushes a
Noneonto the resume queue (so anINPUT_REQUIREDsession wakes immediately), cancels the pipeline task, and runs the cleanup hook.discard_filesdeletes the partially-created directory; otherwise the directory is left in place as an orphan (Backend Spec §4.7 / §4.8).
- async create_project(req)[source]#
Open a project-creation session and start the pipeline.
The session is registered with the store immediately and the pipeline runs as a background asyncio task; the returned
SessionHandlereflects the post-VALIDATING state. Failures from the validation gate transition the session toFAILEDsynchronously before returning – so the caller can detect them on the very first response.- Parameters:
req (
ProjectCreateRequest)- Return type:
- async create_run(req)[source]#
Open a run-creation session and start the pipeline.
- Parameters:
req (
RunCreateRequest)- Return type:
- async resume(session_id, extra_inputs)[source]#
Supply
extra_inputsafter aPluginInputRequiredprompt.Pushes the payload onto the session’s resume queue; the suspended pipeline wakes, re-spawns the trigger plugin’s worker with the new inputs, and continues. Backend Spec §4.7 / §6.4.
- Parameters:
- Return type:
- property session_store: SessionStore#
Expose the in-memory session store for the API surface.
- async status(session_id)[source]#
Return a snapshot
SessionHandleforsession_id.- Parameters:
session_id (
str)- Return type:
- class exlab_wizard.controller.creation.NASSyncProtocol(*args, **kwargs)[source]#
Bases:
ProtocolThe NAS sync surface the controller depends on. Phase 10.
- class exlab_wizard.controller.creation.NoOpNASSync[source]#
Bases:
objectNo-op stand-in for
NASSyncClientuntil Phase 10 lands.
- class exlab_wizard.controller.creation.NoOpReadmeGenerator[source]#
Bases:
objectLightweight README generator for tests / headless fixtures.
Writes a tiny
README.mdcontaining only the core fields – enough for the post-validate pass to scan – and reports the cache path without performing the full §10 field merge or validation. Production injects the realReadmeGenerator.
- class exlab_wizard.controller.creation.ProjectCreateRequest(equipment_id, template_path, lims_project, variables, label, operator, objective, readme_extra=<factory>)[source]#
Bases:
objectInputs for
CreationController.create_project().Backend Spec §4.6.1 / UI-spec §3.1.
lims_projectmirrors the §11.3lims_projectblock (uid,short_id,name_at_creation,source).- Parameters:
- class exlab_wizard.controller.creation.ReadmeContext(level, core, template_fields, config_fields, custom_fields, system, template_field_decls=<factory>, config_field_decls=<factory>)[source]#
Bases:
objectInputs to
ReadmeGenerator. Composed by the controller.The controller pre-merges the four layers into the dicts below so the generator does not need to know about the merge order; the generator’s job is to validate, render, and persist.
- Parameters:
level (
CreationLevel)core (
CoreFields)custom_fields (
list[CustomField])system (
SystemFields)template_field_decls (
list[TemplateFieldDecl])config_field_decls (
list[TemplateFieldDecl])
- config_field_decls: list[TemplateFieldDecl]#
- core: CoreFields#
- custom_fields: list[CustomField]#
- level: CreationLevel#
- system: SystemFields#
- template_field_decls: list[TemplateFieldDecl]#
- class exlab_wizard.controller.creation.ReadmeGeneratorProtocol(*args, **kwargs)[source]#
Bases:
ProtocolThe README generator surface the controller depends on. Backend §10.
Mirrors
exlab_wizard.readme.ReadmeGenerator.generate(): validate the composedReadmeContext, write bothREADME.mdandreadme_fields.json, and return(readme, cache).
- class exlab_wizard.controller.creation.RunCreateRequest(equipment_id, project_name, template_path, run_kind, variables, label, operator, objective, readme_extra=<factory>, run_date=None, lims_project=<factory>)[source]#
Bases:
objectInputs for
CreationController.create_run().Backend Spec §4.6.1 / UI-spec §3.2 / §3.3.
run_kindis the core mode flag and is immutable mid-session per UI-spec §3.3.project_nameis the human-readable LIMS name of the parent project – the verbatim<project>/folder segment (§3.2). The run inherits the parent’s full LIMS identity (uid / short_id) from that project’screation.jsonat pipeline time.- Parameters:
- run_kind: RunKind#
- class exlab_wizard.controller.creation.SessionHandle(session_id, state, current_phase, next_action)[source]#
Bases:
objectSnapshot of session state. Backend Spec §4.4.1.
- Parameters:
session_id (
str)state (
SessionState)next_action (
str)
- state: SessionState#