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

  • AIAnnotateSettings, AIAnnotateRun, AIAnnotateResend and AIAnnotateDecision: POST /api/finetune/ai-annotate/{settings,run,resend}, and accept and reject

  • FinetunePublish: POST /api/finetune/model/<name>/publish, and HuggingFaceCredentials: POST /api/huggingface/credentials (both modes answer them: routes/finetune/publish.py, web/src/backend/routes/publish.ts)

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

Attributes

WholeNumber

Queues

PROMPT_MAX_CHARS

LABEL_MAX_CHARS

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 model type and its constructor's parameters, as the builder's model

SetData

The dataset to open a new viewer on, as typed or pasted (a path

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,

RemoveModel

The ✕ of a model on the Models tab's Loaded models list: the one

Equivalences

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

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 training settings to change, each checked as

CreateVolume

A new, empty annotation volume, in a new session under

LoadCrops

Crops imported into the session's annotation volume: yaml is the

AIAnnotateSettings

The provider and model to use (ids the config lists), the target, as

AIAnnotateRun

Where to annotate: point_nm (z, y, x, world nm) in the plane

AIAnnotateResend

The staged annotation to ask the model about again, and the edited

AIAnnotateDecision

The staged annotation to accept or reject; on accept, whether its

FinetunePublish

Where to publish a finetuned model on Hugging Face: repo as

HuggingFaceCredentials

A Hugging Face access token to publish with (token, hf_...),

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.Queues
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 and the queue a list of at least one queue; 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].

queue: Queues = None
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: Queues = None
charge_group: Any = None
nb_cores_master: WholeNumber
nb_cores_worker: WholeNumber
nb_workers: WholeNumber
tmp_dir: Any = None
blockwise_tasks_dir: Any = None
class cellmap_flow.dashboard.requests.CreateModelConfig(/, **data: Any)

A model type and its constructor’s parameters, as the builder’s model form sends them; registry.build_model builds the config from them as from any model entry. type is the type’s name (registry.model_types, “fly”); class_name, the class name (“FlyModelConfig”) the form posted before 0.3.0, is still taken in its place, with a deprecation warning, until the release after.

type: str | None = None
class_name: str | None = None
params: dict
type_name() → str

The model type to build: type, else the deprecated class_name.

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

The dataset to open a new viewer on, as typed or pasted (a path copied from Neuroglancer opens without its format: portable/pasted.py).

dataset_path: Annotated[str, _required('dataset_path', strip=True), AfterValidator(pasted_path)]
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)]
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, whether it segments in 3D, and for 2D 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)]
voxel_size: Annotated[list | None, BeforeValidator(_voxel_size)] = None
output: str = 'flows'
do_3d: bool = False
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.

run_voxel_sizes: the voxel size (nm, z, y, x) to run a ticked catalog or Hugging Face model at, by its row’s value (a selected_models name or a selected_hf_models repo), as typed beside it (“32”, “32,16,16”, 32 or [32, 16, 16]). A model left out, or left blank, runs at its own (ModelConfig.run_voxel_size).

selected_models: list[str] = []
selected_hf_models: list[str] = []
selected_bioimage_models: list[BioimageSelection] = []
selected_cellpose_models: list[CellposeSelection] = []
resample: bool | None = None
run_voxel_sizes: Annotated[dict[str, str | float | list | None], BeforeValidator(_run_voxel_sizes)]
class cellmap_flow.dashboard.requests.RemoveModel(/, **data: Any)

The ✕ of a model on the Models tab’s Loaded models list: the one model to stop (services.launch.remove_model), by its name.

name: Annotated[str, _required('name', strip=True)]
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.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'), AfterValidator(pasted_path)]
num_boxes: WholeNumber = 1
existing_bounding_boxes: list[cellmap_flow.blockwise.bounding_box.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, with the training settings of finetune.options.TrainingOptions, whose defaults are the server form’s (_finetune_tab.html’s values and selected options, checked against them by tests/web/test_schema.py; cellmap_flow.schema exports them to the browser as FINETUNE_DEFAULTS). The route adjusts them for painted annotations and for the model’s target (TrainingOptions.for_session).

model_name: Annotated[str, _required('model_name')]
corrections_path: Annotated[str, _required('corrections_path', message='corrections_path is required. Please specify the output path where annotation crops are saved.')]
checkpoint_path: str | None = None
auto_serve: bool = True
queue: Queues
charge_group: str | None = None
options(**resolved) → cellmap_flow.finetune.options.TrainingOptions

The settings this body asks for: TrainingOptions with the fields the body gave, and resolved over them (what the route worked out: the output type and offsets, the model’s output class).

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

The next iteration of a job: the training settings to change, each checked as TrainingOptions checks it (changes; the trainer applies them, cli.apply_restart_params), and the manifest overrides. Nothing is required: the job’s model and corrections stay as launched.

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

A new, empty annotation volume, in a new session under output_path (by default ~/.cellmap_flow/corrections): for model_name, on the grid its prediction is served on; or, with no model named, a volume painted before any model (a “paint-first” one), on the raw’s grid at voxel_size (nm, z, y, x, or one number for all three; none: the raw level the viewer shows), which Which model to start from’s Use this model carries onto a model’s grid. A voxel size with a model is refused: a model’s volume lies on the model’s grid.

model_name: Annotated[Optional[str], BeforeValidator(lambda v: None if v is None or isinstance(v, str) and not v.strip() else v)] = None
voxel_size: Annotated[list | None, BeforeValidator(_voxel_size)] = None
output_path: Any = None
class cellmap_flow.dashboard.requests.LoadCrops(/, **data: Any)

Crops imported into the session’s annotation volume: yaml is the YAML’s text or its path, output_path as for CreateVolume, and load_id names the import’s progress. model_name, the model picked, is only asked for when the session has no volume yet, to lay a new one on its grid; without one the new volume is painted before any model, as New Volume makes one.

yaml: Annotated[str, _required('yaml', message="Missing 'yaml' field")]
model_name: str | None = None
output_path: Any = None
load_id: Any = None
cellmap_flow.dashboard.requests.PROMPT_MAX_CHARS = 4000
cellmap_flow.dashboard.requests.LABEL_MAX_CHARS = 100
class cellmap_flow.dashboard.requests.AIAnnotateSettings(/, **data: Any)

The provider and model to use (ids the config lists), the target, as an organelle catalog key and/or a name, the editable prompt (null: the catalog’s), and whether the user acknowledges where the provider sends the images, with the destination text the page showed them.

provider: Annotated[_Id, _required('provider', strip=True)]
model: Annotated[_Id, _required('model', strip=True)]
label_key: _Label = None
label_name: _Label = None
prompt: str | None
acknowledge: bool | None = None
destination: str | None
class cellmap_flow.dashboard.requests.AIAnnotateRun(/, **data: Any)

Where to annotate: point_nm (z, y, x, world nm) in the plane normal to depth_axis (0 z: XY, 1 y: XZ, 2 x: YZ). Either may be left out: the view centre, and the viewer layout’s plane.

point_nm: Annotated[_Triple | None, AfterValidator(_finite)] = None
depth_axis: Annotated[int, Field(ge=0, le=2)] | None = None
class cellmap_flow.dashboard.requests.AIAnnotateResend(/, **data: Any)

The staged annotation to ask the model about again, and the edited prompt (null or blank: the catalog’s).

annotate_id: Annotated[_ANNOTATE_ID, _required('annotate_id')]
prompt: str | None
class cellmap_flow.dashboard.requests.AIAnnotateDecision(/, **data: Any)

The staged annotation to accept or reject; on accept, whether its labels replace voxels that already have one (overwrite) or only fill unannotated ones.

annotate_id: Annotated[_ANNOTATE_ID, _required('annotate_id')]
overwrite: bool = False
class cellmap_flow.dashboard.requests.FinetunePublish(/, **data: Any)

Where to publish a finetuned model on Hugging Face: repo as owner/name (blank: the signed-in user’s, named after the model), whether a repository made for it is private (a model repository is public otherwise), whether its manifest and model card name the dataset it was trained on (include_dataset: off unless asked, since a dataset’s URL can be internal), and, for a server’s publish, whether its copy of the network includes model.pt2 (lora_copy): the program a LoRA finetune of the published model attaches to, as cellmap’s own repositories ship it, at the cost of uploading the weights a second time; and whether a smaller copy for the browser is trained (finetune.distill, a cluster job of hours) and added to the repository once it is done (small_copy, off unless asked). A browser’s publish has neither.

repo: str | None
private: bool = False
include_dataset: bool = False
lora_copy: bool = True
small_copy: bool = False
class cellmap_flow.dashboard.requests.HuggingFaceCredentials(/, **data: Any)

A Hugging Face access token to publish with (token, hf_…), which the server also saves when asked to remember it (where hf auth login saves one; the browser keeps a token in the page only); device: a sign-in with a code the user enters at huggingface.co, the server’s Sign in (the browser’s is a popup); or forget the one in use: signing out.

token: str | None
remember: bool = False
device: bool = False
forget: bool = False
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')]
outputs: Annotated[list[PipelineNode], _required('outputs', message='No output nodes defined')]
models: Annotated[list[ModelNode], _required('models', message='No models defined')]
blockwise_config: Annotated[list[BlockwiseConfigNode], _required('blockwise_config', message='No blockwise configuration defined')]
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
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.')]
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