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-configBlockwiseSettings: POST /api/blockwise-configCreateModelConfig: POST /api/create-model-configSetData: POST /api/set-dataSubmitModels: POST /api/modelsEquivalences: POST /update/equivalencesBbxGenerator: POST /api/bbx-generatorFinetuneSubmit: POST /api/finetune/submitFinetuneRestart: POST /api/finetune/job/<job_id>/restartCreateVolume: POST /api/finetune/create-volumeLoadCrops: POST /api/finetune/load-cropsAIAnnotateSettings,AIAnnotateRun,AIAnnotateResendandAIAnnotateDecision: POST /api/finetune/ai-annotate/{settings,run,resend}, and accept and rejectFinetunePublish: POST /api/finetune/model/<name>/publish, andHuggingFaceCredentials: POST /api/huggingface/credentials (both modes answer them: routes/finetune/publish.py, web/src/backend/routes/publish.ts)BlockwiseValidate,BlockwiseGenerate,BlockwisePrecheckandBlockwiseSubmit: POST /api/blockwise/{validate,generate,precheck,submit}, which answer throughcheckinstead (see there)
Attributes
Classes
Any of the saved settings (jobs.settings.SERVER_CONFIG_DEFAULTS); only those |
|
The pipeline builder's blockwise settings. All three counts are |
|
A model type and its constructor's parameters, as the builder's model |
|
The dataset to open a new viewer on, as typed or pasted (a path |
|
A BioImage Model Zoo model ticked on the Models tab: its id or |
|
A Cellpose model ticked on the Models tab's Cellpose panel: its name |
|
The Models tab's Submit: the catalog models, Hugging Face repos, |
|
The ✕ of a model on the Models tab's Loaded models list: the one |
|
A merging postprocessor's merged ids, from its inference server, for |
|
The box tool's viewer on |
|
A new training job: |
|
The next iteration of a job: the training settings to change, each checked as |
|
A new, empty annotation volume, in a new session under |
|
Crops imported into the session's annotation volume: |
|
The provider and model to use (ids the config lists), the target, as |
|
Where to annotate: |
|
The staged annotation to ask the model about again, and the edited |
|
The staged annotation to accept or reject; on accept, whether its |
|
Where to publish a finetuned model on Hugging Face: |
|
A Hugging Face access token to publish with ( |
|
A node of the builder's pipeline (state.js), ``{id, name, params, |
|
A normalizer or postprocessor node, whose params may be null for none. |
|
A model node. It may carry the config the model was defined with (its |
|
A blockwise-config node's params: what a task and its master are |
|
A node of the builder's pipeline (state.js), ``{id, name, params, |
|
The builder's pipeline, one list of nodes per node type, as the |
|
Whether |
|
The task YAML(s) for |
|
The task YAMLs generate wrote, to check. |
|
The task to submit: the YAMLs precheck passed and the name generate gave |
Functions
|
|
|
|
Module Contents
- cellmap_flow.dashboard.requests.WholeNumber
- cellmap_flow.dashboard.requests.Queues
- cellmap_flow.dashboard.requests.parse(model, body)
(model instance, None)for a validbody; 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].
- 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.
- 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_modelbuilds the config from them as from any model entry.typeis 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 deprecatedclass_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 (aselected_modelsname or aselected_hf_modelsrepo), 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_boxesis 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_nametrained on the corrections atcorrections_path, a session’s corrections directory or the base output path of its sessions, with the training settings offinetune.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
- 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
resolvedover 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): formodel_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 atvoxel_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:
yamlis the YAML’s text or its path,output_pathas for CreateVolume, andload_idnames 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
destinationtext 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 todepth_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:
repoasowner/name(blank: the signed-in user’s, named after the model), whether a repository made for it isprivate(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 includesmodel.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 torememberit (wherehf auth loginsaves 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); orforgetthe 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 validbody; 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')]
- blockwise_config: Annotated[list[BlockwiseConfigNode], _required('blockwise_config', message='No blockwise configuration defined')]
- model_mode: Any = ''
- class cellmap_flow.dashboard.requests.BlockwiseValidate(/, **data: Any)
Whether
pipelineis ready to run blockwise.- pipeline: BlockwisePipeline
- class cellmap_flow.dashboard.requests.BlockwiseGenerate(/, **data: Any)
The task YAML(s) for
pipeline;job_namenames 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_pathsis a list of paths, as for precheck.- yaml_paths: list[str] | None = None
- task_name: Any = None