cellmap_flow.dashboard.requests

The typed bodies of the dashboard’s POST routes, and how a bad one is answered.

parse(Model, body) gives (request, None), or (None, response) where the response is the 400 every route answers a bad body with, {"success": False, "error": <message>}, before anything is changed. The message names what is wrong: a body that is not a JSON object is “expected a JSON object”, a count that is not a whole number says so and shows what was sent (the settings forms show it as it stands), and any other field’s message is pydantic’s, after the field’s name.

  • ServerConfigUpdate: POST /api/server-config

  • BlockwiseSettings: POST /api/blockwise-config

  • CreateModelConfig: POST /api/create-model-config

  • SetData: POST /api/set-data

  • SubmitModels: POST /api/models

  • Equivalences: POST /update/equivalences

  • BbxGenerator: POST /api/bbx-generator

  • FinetuneSubmit: POST /api/finetune/submit

  • FinetuneRestart: POST /api/finetune/job/<job_id>/restart

  • CreateVolume: POST /api/finetune/create-volume

  • LoadCrops: POST /api/finetune/load-crops

  • BlockwiseValidate, BlockwiseGenerate, BlockwisePrecheck and BlockwiseSubmit: POST /api/blockwise/{validate,generate,precheck,submit}, which answer through check instead (see there)

Attributes

WholeNumber

Classes

ServerConfigUpdate

Any of the saved settings (jobs.settings.SERVER_CONFIG_DEFAULTS); only those

BlockwiseSettings

The pipeline builder's blockwise settings. All three counts are

CreateModelConfig

A ModelConfig subclass's name and its constructor's parameters, as the

SetData

The dataset to open a new viewer on.

BioimageSelection

A BioImage Model Zoo model ticked on the Models tab: its id or

CellposeSelection

A Cellpose model ticked on the Models tab's Cellpose panel: its name

SubmitModels

The Models tab's Submit: the catalog models, Hugging Face repos,

Equivalences

A merging postprocessor's merged ids, from its inference server, for

BoundingBox

A box drawn or loaded on an INPUT node: its corner and its size.

BbxGenerator

The box tool's viewer on dataset_path, showing the boxes the

FinetuneSubmit

A new training job: model_name trained on the corrections at

FinetuneRestart

The next iteration of a job: the manifest overrides, and the training

CreateVolume

A new, empty annotation volume for model_name, in a new session

LoadCrops

Crops imported into the session's annotation volume for model_name:

PipelineNode

A node of the builder's pipeline (state.js), ``{id, name, params,

ChainNode

A normalizer or postprocessor node, whose params may be null for none.

ModelNode

A model node. It may carry the config the model was defined with (its

BlockwiseTaskSettings

A blockwise-config node's params: what a task and its master are

BlockwiseConfigNode

A node of the builder's pipeline (state.js), ``{id, name, params,

BlockwisePipeline

The builder's pipeline, one list of nodes per node type, as the

BlockwiseValidate

Whether pipeline is ready to run blockwise.

BlockwiseGenerate

The task YAML(s) for pipeline; job_name names the task.

BlockwisePrecheck

The task YAMLs generate wrote, to check.

BlockwiseSubmit

The task to submit: the YAMLs precheck passed and the name generate gave

Functions

parse(model, body)

(model instance, None) for a valid body; else (None, the 400 response).

check(model, body)

(model instance, None) for a valid body; else ``(None, what is

Module Contents

cellmap_flow.dashboard.requests.WholeNumber
cellmap_flow.dashboard.requests.parse(model, body)

(model instance, None) for a valid body; else (None, the 400 response).

class cellmap_flow.dashboard.requests.ServerConfigUpdate(/, **data: Any)

Any of the saved settings (jobs.settings.SERVER_CONFIG_DEFAULTS); only those sent change. The counts must be whole numbers; the rest are kept as sent, and keys that are not settings are ignored.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

nb_cores_master: WholeNumber = None
nb_cores_worker: WholeNumber = None
nb_workers: WholeNumber = None
updates() → dict

{setting: value} for each setting the request sent.

class cellmap_flow.dashboard.requests.BlockwiseSettings(/, **data: Any)

The pipeline builder’s blockwise settings. All three counts are required, as whole numbers; a missing one is reported as None.

queue: Any = None
charge_group: Any = None
nb_cores_master: WholeNumber = None
nb_cores_worker: WholeNumber = None
nb_workers: WholeNumber = None
tmp_dir: Any = None
blockwise_tasks_dir: Any = None
class cellmap_flow.dashboard.requests.CreateModelConfig(/, **data: Any)

A ModelConfig subclass’s name and its constructor’s parameters, as the builder’s model form sends them (registry.coerce_form_params parses them).

class_name: Annotated[str, _required('class_name')] = None
params: dict
class cellmap_flow.dashboard.requests.SetData(/, **data: Any)

The dataset to open a new viewer on.

dataset_path: Annotated[str, _required('dataset_path', strip=True)] = None
class cellmap_flow.dashboard.requests.BioimageSelection(/, **data: Any)

A BioImage Model Zoo model ticked on the Models tab: its id or nickname, and the voxel size typed beside it (blank: the model’s own).

id: Annotated[str, _required('id', strip=True)] = None
voxel_size: Annotated[list | None, BeforeValidator(_voxel_size)] = None
class cellmap_flow.dashboard.requests.CellposeSelection(/, **data: Any)

A Cellpose model ticked on the Models tab’s Cellpose panel: its name (cpsam_v2, cpsam), the voxel size typed beside it, its output, and for masks how much two slices’ masks must overlap to be linked (IoU; blank or 0: not linked). A blank voxel size is kept as None here, and refused by services.launch with a message naming the model.

model: Annotated[str, _required('model', strip=True)] = None
voxel_size: Annotated[list | None, BeforeValidator(_voxel_size)] = None
output: str = 'flows'
stitch_threshold: Annotated[Optional[float], BeforeValidator(lambda v: None if v is None or isinstance(v, str) and not v.strip() else _number(v, float, 'stitch_threshold'))] = None
class cellmap_flow.dashboard.requests.SubmitModels(/, **data: Any)

The Models tab’s Submit: the catalog models, Hugging Face repos, BioImage Model Zoo and Cellpose models to run. Every other running model is stopped (services.launch). resample, when given, becomes the session’s (Session.resample) before the models are started.

selected_models: list[str] = []
selected_hf_models: list[str] = []
selected_bioimage_models: list[BioimageSelection] = []
selected_cellpose_models: list[CellposeSelection] = []
resample: bool | None = None
class cellmap_flow.dashboard.requests.Equivalences(/, **data: Any)

A merging postprocessor’s merged ids, from its inference server, for the segmentation layer whose source ends in dataset: each list is a set of ids shown as one.

dataset: str
equivalences: list[list[int]]
class cellmap_flow.dashboard.requests.BoundingBox(/, **data: Any)

A box drawn or loaded on an INPUT node: its corner and its size.

offset: _Triple = [0, 0, 0]
shape: _Triple = [1, 1, 1]
class cellmap_flow.dashboard.requests.BbxGenerator(/, **data: Any)

The box tool’s viewer on dataset_path, showing the boxes the INPUT node has; num_boxes is how many the dialog counts up to.

dataset_path: Annotated[str, _required('dataset_path', message='Dataset path is required')] = None
num_boxes: WholeNumber = 1
existing_bounding_boxes: list[BoundingBox] | None = []
class cellmap_flow.dashboard.requests.FinetuneSubmit(/, **data: Any)

A new training job: model_name trained on the corrections at corrections_path, a session’s corrections directory or the base output path of its sessions.

The defaults are the form’s. The rest of the fields are passed on as sent, and the route adjusts the loss for painted annotations and for a distance target.

model_name: Annotated[str, _required('model_name')] = None
corrections_path: Annotated[str, _required('corrections_path', message='corrections_path is required. Please specify the output path where annotation crops are saved.')] = None
lora_r: _form_number(int, 8)
num_epochs: _form_number(int, 10)
batch_size: _form_number(int, 2)
learning_rate: _form_number(float, 0.0001)
loss_type: Any = 'mse'
label_smoothing: _form_number(float, 0.1)
distillation_lambda: _form_number(float, None)
distillation_scope: Any = 'unlabeled'
margin: _form_number(float, 0.3)
balance_classes: Any = False
augment: Any = False
output_type: Any = None
offsets: Any = None
select_channel: _form_number(int, None)
checkpoint_path: Any = None
auto_serve: Any = True
queue: Any = None
charge_group: Any = None
class cellmap_flow.dashboard.requests.FinetuneRestart(/, **data: Any)

The next iteration of a job: the manifest overrides, and the training settings to change (common.build_restart_params picks those; the trainer checks them).

class cellmap_flow.dashboard.requests.CreateVolume(/, **data: Any)

A new, empty annotation volume for model_name, in a new session under output_path (by default ~/.cellmap_flow/corrections).

model_name: Annotated[str, _required('model_name')] = None
output_path: Any = None
class cellmap_flow.dashboard.requests.LoadCrops(/, **data: Any)

Crops imported into the session’s annotation volume for model_name: yaml is the YAML’s text or its path, output_path as for CreateVolume, and load_id names the import’s progress.

yaml: Annotated[str, _required('yaml', message="Missing 'yaml' field")] = None
model_name: Annotated[str, _required('model_name', message="Missing 'model_name' field")] = None
output_path: Any = None
load_id: Any = None
cellmap_flow.dashboard.requests.check(model, body)

(model instance, None) for a valid body; else (None, what is wrong), the message parse() would answer with.

class cellmap_flow.dashboard.requests.PipelineNode(/, **data: Any)

A node of the builder’s pipeline (state.js), {id, name, params, position}, of which the routes read the name and the params.

name: Any = None
params: dict
class cellmap_flow.dashboard.requests.ChainNode(/, **data: Any)

A normalizer or postprocessor node, whose params may be null for none.

params: dict | None = None
class cellmap_flow.dashboard.requests.ModelNode(/, **data: Any)

A model node. It may carry the config the model was defined with (its ModelConfig.to_dict()), which stands in for params when it has none.

config: dict
settings() → dict

Its params, or its config when it was sent without params.

class cellmap_flow.dashboard.requests.BlockwiseTaskSettings(/, **data: Any)

A blockwise-config node’s params: what a task and its master are submitted with. Each is required, and taken as sent (precheck checks the task’s).

charge_group: Any
queue: Any
nb_workers: Any
nb_cores_worker: Any
nb_cores_master: Any
tmp_dir: Any
class cellmap_flow.dashboard.requests.BlockwiseConfigNode(/, **data: Any)

A node of the builder’s pipeline (state.js), {id, name, params, position}, of which the routes read the name and the params.

params: BlockwiseTaskSettings
class cellmap_flow.dashboard.requests.BlockwisePipeline(/, **data: Any)

The builder’s pipeline, one list of nodes per node type, as the blockwise routes read it: the first input, output and blockwise-config node are the ones used, and the models are run on the chain the normalizers and postprocessors make. The four lists must have a node, and the input and output a dataset_path, checked in that order.

inputs: Annotated[list[PipelineNode], _required('inputs', message='No input nodes defined')] = None
outputs: Annotated[list[PipelineNode], _required('outputs', message='No output nodes defined')] = None
models: Annotated[list[ModelNode], _required('models', message='No models defined')] = None
blockwise_config: Annotated[list[BlockwiseConfigNode], _required('blockwise_config', message='No blockwise configuration defined')] = None
normalizers: list[ChainNode] = []
postprocessors: list[ChainNode] = []
model_mode: Any = ''
class cellmap_flow.dashboard.requests.BlockwiseValidate(/, **data: Any)

Whether pipeline is ready to run blockwise.

pipeline: BlockwisePipeline = None
class cellmap_flow.dashboard.requests.BlockwiseGenerate(/, **data: Any)

The task YAML(s) for pipeline; job_name names the task.

job_name: Any = ''
class cellmap_flow.dashboard.requests.BlockwisePrecheck(/, **data: Any)

The task YAMLs generate wrote, to check.

yaml_paths: Annotated[list[str], _required('yaml_paths', message='No YAML paths provided. Please generate task first.')] = None
class cellmap_flow.dashboard.requests.BlockwiseSubmit(/, **data: Any)

The task to submit: the YAMLs precheck passed and the name generate gave them, or else, when none are given or they are not all there, pipeline’s, generated anew. yaml_paths is a list of paths, as for precheck.

yaml_paths: list[str] | None = None
task_name: Any = None