cellmap_flow.serving.launch

The command line that starts an inference server for a model.

Every launcher builds it here: cellmap_flow infer <type>, cellmap_flow yaml and the dashboard’s catalog and Hugging Face models. It is <SERVER_COMMAND> --model <entry> -d <data path>, where the entry is ModelConfig.launch_entry as JSON, which the server rebuilds as it rebuilds a YAML’s model entry, then --resample or --no-resample: always one of them, so a server reads the data as its launcher was told to (a YAML’s resample, infer --no-resample, the dashboard’s checkbox) whatever serve’s own default is.

The serve program is jobs.launch.SERVER_COMMAND, and deployments change it: the fileglancer deploy sets "pixi run cellmap_flow serve". So it is read each time a command is built, never copied at import (a copy misses the override), and split into words (quoted as one token, the shell looks for a program called “pixi run cellmap_flow serve”). cellmap_flow_server, the program before 0.3.0, takes --model too, so a deployment that still sets that works.

A model with an environment of its own (models.envs: its entry’s env, else its type’s default_env) is served from it instead: the entry’s env is taken off, and the program is that environment’s (pixi run --frozen --manifest-path <pixi.toml> -e <env> cellmap_flow serve, or <env>/bin/python -P -m cellmap_flow.cli.main serve) in place of SERVER_COMMAND, which names this deployment’s own.

The launchers submit it as a shell line, which jobs.spec.shell_join quotes: the entry’s JSON is full of double quotes and braces, and shlex.join would single-quote it, which LSF’s own quoting splits apart (jobs.spec.shell_quote says how).

Functions

server_argv(→ list)

The server's argv for model_config reading data_path, resampling

server_argv_for(→ list)

The server's argv for a model given as its type and constructor arguments.

server_command(→ str)

server_argv as the shell line start_hosts takes.

server_command_for(→ str)

server_argv_for as the shell line start_hosts takes.

Module Contents

cellmap_flow.serving.launch.server_argv(model_config, data_path: str, resample: bool = True) → list

The server’s argv for model_config reading data_path, resampling it to the model’s input voxel size when resample.

cellmap_flow.serving.launch.server_argv_for(model_type: str, params: dict, data_path: str, resample: bool = True) → list

The server’s argv for a model given as its type and constructor arguments.

For launchers that have no model config to hand and should not build one (a Hugging Face config fetches its repo’s metadata); None arguments are left out, as in ModelConfig.launch_entry. An env among params serves the model from that environment, else the type’s default_env does. Only a default the class itself sets: one decided per model by a property needs the model, and server_argv.

cellmap_flow.serving.launch.server_command(model_config, data_path: str, resample: bool = True) → str

server_argv as the shell line start_hosts takes.

cellmap_flow.serving.launch.server_command_for(model_type: str, params: dict, data_path: str, resample: bool = True) → str

server_argv_for as the shell line start_hosts takes.