Aller au contenu

Submit data to a repository, end to end

Ce contenu n’est pas encore disponible dans votre langue.

A platform that produces data, such as an imaging facility, a sequencing core or a network of field sensors, can hand its data to madbot and on to repositories without anyone opening the web application. This tutorial does it with madbot-cli: you describe in a file what a deposit holds, madbot-cli plan shows what is missing in madbot, and madbot-cli apply creates it, up to the identifiers the repositories return.

The file describes the state you want, not the steps to get there. Run apply again after a new series of data and only the new data, samples and metadata are added. Nothing is ever deleted, and nothing is sent to a repository unless you ask.

The example file on this page is the one the madbot CI applies at each merge request, against test plugins that stand for the sources and the repositories, and the code excerpts are read from madbot-cli when the site is built. What you read here is what runs.

  • You know the address of the API of your instance, and you have a personal access token with the read and write scopes: see Get started with the REST API.
  • The instance runs madbot 2.2.0 or later, and has a plugin for each of your sources and repositories. madbot-cli plugins lists them, see Find what the instance offers.
  • You have Python 3.10 or later, or uv, which can fetch one.

madbot-cli is published on the package registry of the madbot project. It holds the madbot-cli command and the madbot_cli Python library, and depends on PyYAML and jsonschema only. Install it the way that suits how you use it.

The command alone, in an environment of its own, so that it neither needs nor changes the Python packages of the machine. With uv, which also fetches a suitable Python when the machine has none:

Terminal window
uv tool install madbot-cli \
--index-url https://gitlab.com/api/v4/projects/50871918/packages/pypi/simple

or with pipx:

Terminal window
pipx install madbot-cli \
--index-url https://gitlab.com/api/v4/projects/50871918/packages/pypi/simple

The library, to call it from the Python tools of your platform: add it to their environment, as any other dependency.

Terminal window
pip install madbot-cli \
--index-url https://gitlab.com/api/v4/projects/50871918/packages/pypi/simple

pip refuses to install it on a Python older than 3.10.

madbot-climadbot API
1.x2.2.0 or later

madbot-cli version checks the address and the token, and tells which version of madbot answers:

Terminal window
export MADBOT_API=https://api.madbot.example.org
export MADBOT_TOKEN=pat_…
madbot-cli version

As for every madbot client, the address is the one of the API, often not the one of the web application, and there is no default: madbot-cli never writes to an instance you did not name. It ends without /api, which madbot-cli adds to each request: an address that ends with it is refused, with this fix. --api replaces MADBOT_API for one command.

The example follows an imaging platform. The raw images of a campaign go to an image repository; the code that analyses them, kept in a code forge, goes to a code repository. Both land on one node of madbot, with one sample per well:

deposit.example.yaml
# A deposit in madbot, described for madbot-cli (format version 1).
#
# An imaging platform deposits the raw images of a campaign in one repository,
# and the code that analyses them in another. Replace every <…> value:
# - a plugin by its slug, as `madbot-cli plugins` lists them;
# - a field by its slug, as `madbot-cli fields <file> <submission>` lists them.
# Credentials never go in this file: it names the environment variables that
# hold them, each as a JSON object.
version: 1
workspace: Imaging platform
# The sources of the data, each declared once under a key the rest of the file
# uses to name it.
sources:
# Images on a storage server.
instrument:
plugin: <data plugin of the storage server>
shared_params:
host: storage.example.org
credentials_env: INSTRUMENT_CREDENTIALS
# Code in a code forge.
code:
plugin: <data plugin of the code forge>
shared_params:
host: forge.example.org
credentials_env: FORGE_CREDENTIALS
nodes:
- title: Campaign 2026-11
# The data linked to the node, each entry from one source.
data:
# The files of a folder whose name matches a pattern.
- source: instrument
browse:
path: [campaign-2026-11, raw]
match: "*"
# A file given by its identifier in the forge, whose format belongs to
# the plugin: `madbot-cli browse` shows it.
- source: code
external_id: eyJwcm9qZWN0IjoxMjM0LCJwYXRoIjoic2VnbWVudC5weSJ9
name: segment.py
# One sample per well, from the names of the images.
samples:
from: [instrument]
pattern: "^(?P<sample>plate\\d+_well[A-H]\\d+)_"
submissions:
- title: Campaign 2026-11, raw images
repository:
plugin: <submission plugin of the image repository>
shared_params:
host: images.repository.example.org
credentials_env: IMAGE_REPOSITORY_CREDENTIALS
settings:
<setting of the image repository>: <its value>
# The data of the node it takes: here every data of the instrument.
data:
- source: instrument
match: "*"
metadata:
study:
<study description field>: Time-lapse imaging of cell growth, campaign of November 2026
sample:
<sample place field>: Imaging facility, room 2
by_alias:
plate3wellb04:
<sample date field>: "2026-11-02"
plate3wellc01:
<sample date field>: "2026-11-03"
- title: Campaign 2026-11, analysis code
repository:
plugin: <submission plugin of the code repository>
shared_params:
host: code.repository.example.org
credentials_env: CODE_REPOSITORY_CREDENTIALS
settings:
<setting of the code repository>: <its value>
# A file of the node, by its name.
data:
- source: code
names: [segment.py]
metadata:
study:
<study description field>: Segmentation of the cells of campaign 2026-11

Copy it and replace every <…> value. The format reference describes every key, and publishes the JSON Schema the file is checked against.

PartWhat it givesFound again by
workspaceThe workspace, created when the account has none of that name.its name
sourcesEach source of data, declared once for the whole file under a key: its plugin, its shared parameters and the environment variable holding the credentials.plugin and shared parameters
nodesThe nodes of the workspace, with their child nodes under nodes, see Child nodes.their path of titles
dataThe data linked to a node, each entry naming its source: by its external_id, or by a path of names in the source and a pattern or a list of names (browse).its external_id
samplesThe pattern that gives the sample of each data from its name, see Samples.their alias
submissionsFor each repository, the data of the node it takes, its settings and the values of its metadata.their title, with their repository

The last column is what makes a second run safe: madbot-cli finds each object by this key before creating it. Rename a node in the web application, and the next apply creates another one.

Credentials never go in the file, which you may keep in version control next to the tools of your platform. The file names the environment variables that hold them, each as a JSON object of the private parameters of the plugin:

Terminal window
export INSTRUMENT_CREDENTIALS='{"username": "…", "password": "…"}'
export FORGE_CREDENTIALS='{"token": "…"}'
export IMAGE_REPOSITORY_CREDENTIALS='{"token": "…"}'
export CODE_REPOSITORY_CREDENTIALS='{"token": "…"}'

A variable is read until madbot holds the connection: the first apply, or browse --connect for a source, gives the credentials to madbot, which keeps them. The next commands no longer need the variable, and a pipeline sets it from its secrets only for a first run or a new account.

Typed in a terminal, these lines stay in the history of the shell, password included, and a password holding " or \ breaks the JSON. Type the password where nothing shows it, then let jq, to install if the machine lacks it, write the JSON:

Terminal window
read -rs "?Password of the storage server: " PASSWORD; echo # zsh; in bash: read -rsp "…" PASSWORD
export INSTRUMENT_CREDENTIALS="$(jq -n --arg username "me" --arg password "$PASSWORD" '{$username, $password}')"
unset PASSWORD

Each source and each repository names a plugin of the instance, its shared parameters, the keys of its credentials and, for a repository, its settings. madbot-cli plugins lists the plugins, each with what it serves as: a data source, a repository, metadata or metadata fields; given a slug, it reads the schemas the plugin publishes and writes what each value may be, then a block to paste in the file. None of these commands needs a deposit file, and none writes anything in madbot:

Terminal window
madbot-cli plugins
madbot-cli plugins <slug of a repository>
archive: Sequence archive (repository, metadata fields)
Shared parameters, under shared_params:
url (required): Select the submission server.
= "https://archive.example.org" Production server — Deposits made public.
= "https://test.archive.example.org" Test server — Deposits for trials, deleted after 24 hours.
Credentials, a JSON object in the environment variable:
login (required)
password (required)
Settings of a submission, under settings:
checklist (required): Checklist
= "CL0001" Default checklist
= "CL0002" Soil samples
access_control (required): Access control
one form, Immediate release
policy (required, always "immediate")
as: {"policy": "immediate"}
one form, Hold until a date
policy (required, always "hold")
release_date (required, a date, YYYY-MM-DD)
as: {"policy": "hold", "release_date": "<YYYY-MM-DD>"}
To paste in a submission, then replace every <…> value:
repository:
plugin: archive
shared_params:
url: <url>
credentials_env: ARCHIVE_CREDENTIALS
settings:
checklist: <checklist>
access_control: <access_control>
The credentials, in the environment (never in the file):
export ARCHIVE_CREDENTIALS='{"login": "<login>", "password": "<password>"}'

The block never chooses a value for you, a production server above all: every value with several possibilities stays a <…> to replace. When the credentials take several forms, such as a password or an SSH key, one export line is written per form. A value of several lines, such as an SSH private key, cannot be typed as is in JSON: for it, the export line calls jq, which reads the value from its file and writes its line breaks the way JSON expects:

Terminal window
export SSHFS_CREDENTIALS="$(jq -n --rawfile private_key ~/.ssh/id_ed25519 '{"username": "me", "credential": {"private_key": $private_key}}')"

The block names its source after the plugin, and its variable too. With two sources of one plugin, such as two storage servers, give each its own key and its own credentials_env.

Some sources serve public data to anyone, such as the open records of Zenodo. When the plugin of a source reads them without credentials, madbot-cli plugins <slug> says so under the name of the plugin, and the source may leave out credentials_env, or leave its variable unset: madbot-cli connects the source without credentials and reads its public data only. The plan says it on the line of the source:

+ source records (url=https://zenodo.org): create — without credentials: public data only

Such a source may list nothing at its root: its records are found by searching. browse --search takes an identifier, a DOI or words of a title, in the whole source or in the folder of the path, and gives the identifier of each result; a record then opens with its identifier or its DOI, after the source in browse as in the path of the file:

Terminal window
madbot-cli browse deposit.yaml records --search "10.5281/zenodo.24343971"
madbot-cli browse deposit.yaml records 10.5281/zenodo.24343971
data:
- source: records
browse:
path: ["10.5281/zenodo.24343971"]
match: "*.csv"

Each search counts against the limits of the source: Zenodo serves 30 searches a minute to an instance, and finds a DOI by a search. The identifier of the record, path: [24343971], opens it with a single read of the record instead: prefer it in a file that plan and apply read again and again. A name written as a number, as YAML reads 24343971, is taken as the text written: 01 stays 01.

browse --connect connects such a source the same way. Only what the source shows to anyone is read: data it keeps for signed-in accounts, such as a record under embargo, fail like any data madbot cannot read. Once the variable is set, the next apply gives the credentials of the account to the same connection, and madbot reads what the account may read. A repository always needs its credentials to submit, even when its plugin also reads public data as a source.

A connection made in the web application can be reused: madbot-cli connections lists those of the account, by workspace, with their plugin and shared parameters, never a credential. A source or a repository of the file with the same plugin and shared parameters uses that connection, in the workspace of the file: a connection belongs to one workspace, and in another one the file gives its credentials_env again. When the account is not connected to it yet, the file still gives its credentials_env. --workspace keeps one workspace. The plan names the connection it uses:

+ submission 'Campaign 2026-11, raw images': create
= repository (host=images.repository.example.org): uses the connection 'Image repository (images.repository.example.org)'

For the metadata, madbot-cli field <slug> tells what a field accepts, see What a field accepts.

madbot identifies a data by its external_id in its source, and its format belongs to each plugin: an absolute path on a storage server, an opaque string in a code forge or a data platform. You can give it as is, or give a path of names in the source, which plan turns into identifiers by browsing the source through the API. In the folder the path leads to, match takes the files whose name matches a pattern, and names takes files named one by one:

data:
- source: code
external_id: eyJwcm9qZWN0IjoxMjM0LCJwYXRoIjoic2VnbWVudC5weSJ9
- source: instrument
browse:
path: [campaign-2026-11, raw]
match: "*.tif"
- source: instrument
browse:
path: [campaign-2026-11, calibration]
names: [dark-frame.tif, flat-field.tif]

Naming a file says it must exist: a name the folder does not hold is an error of plan, and apply links nothing of that entry.

madbot-cli browse shows what a source holds, with the identifiers to copy. Each name of the path after the source is a word of its own, as in the path of the file: campaign-2026-11 raw, not campaign-2026-11/raw. --connect connects the account to the source first if needed, with the credentials of the file, and creates the workspace when the account has none of that name, and says what it made; nothing else is written:

Terminal window
madbot-cli browse deposit.yaml instrument campaign-2026-11 raw --connect
created workspace 'Imaging platform'
connected source instrument
source instrument, campaign-2026-11/raw:
acquisition-notes.txt /data/campaign-2026-11/raw/acquisition-notes.txt
plate3_wellB04_t001.tif /data/campaign-2026-11/raw/plate3_wellB04_t001.tif
plate3_wellB04_t002.tif /data/campaign-2026-11/raw/plate3_wellB04_t002.tif
plate3_wellC01_t001.tif /data/campaign-2026-11/raw/plate3_wellC01_t001.tif
Open a folder with its names after the source, one per argument (campaign raw, not campaign/raw); an external_id goes in the file as is.

A name the folder does not hold is reported with the names close to it, those that differ from it by their case first (README.md for readme.md), or the first ones and how many the folder holds: a folder of a shared server may hold thousands. A long folder comes page after page; when its length changes from one page to the next, as a source may list a folder differently from one request to another, madbot-cli reads it again from its first page rather than miss a name.

Browsing follows GET /api/connections/{id}/external_data, one level at a time, as the data window of the web application does:

madbot_cli/operations.py
def find_in_source(
client: Client, connection_id: str, path: Iterable[str], match: str = "*"
) -> list[dict]:
parent = browse_path(client, connection_id, path)
found = [
{"external_id": item["id"], "name": item.get("name", "")}
for item in browse(client, connection_id, parent)
if fnmatch.fnmatchcase(item.get("name", ""), match)
]
return sorted(found, key=lambda item: item["name"])

A submission takes data of its node, chosen in its data key: all: true, every data of the node, those linked from the web application too, or a list of entries, each naming its source. An entry takes the same forms as in a node, and two more that choose among the data already linked:

EntryTakes
external_idthat data
browse with path and matchthe data of a folder of the source whose name matches the pattern
browse with path and namesthe data of a folder of the source named one by one
match alonethe data of the source linked to the node whose name in madbot matches the pattern, whatever their folder
names alonethe data of the source linked to the node, named one by one
data:
- source: instrument
match: "*.tif"
- source: code
names: [segment.py]

Only data linked to the node are submitted: an entry that designates a data the node does not hold is an error of plan, and apply does not add it. Add the data to the data of the node first.

madbot_cli/plan.py
def select(
client: Client,
submission: Submission,
subtree: list[Linked],
connections: Mapping[str, Mapping],
cache: dict | None = None,
) -> dict:
choice = _Choice(client, submission, subtree, connections, cache)
if submission.take_all:
choice.take_all(submission.via)
for entry in submission.data:
choice.take(entry)
return choice.result()

plan reads madbot and writes nothing. The file is checked first, against the JSON Schema and the rules the schema cannot say: an invalid file is refused before any request, with the path of each error, and the command exits with status 2. A key placed at the wrong level is named with the level it goes to, such as metadata written under repository instead of next to it. A data entry that takes none of its forms is named with the form its keys announce, such as browse with its path, and what does not fit in it.

Then the values are checked against the schemas the instance publishes, as madbot checks them on write: the shared parameters of each source and repository, the keys of each credentials variable, the settings of a submission to create, and each metadata value, by_alias ones included. Every value madbot would refuse is listed at once, with what is expected and the command that tells more:

The file gives values madbot would refuse; nothing was written:
submission 'Campaign 2026-11, raw images', repository.shared_params: the plugin image-archive has no parameter 'host'; it expects url (one of https://images.example.org or https://test.images.example.org) — see `madbot-cli plugins image-archive`
submission 'Campaign 2026-11, raw images', metadata.sample.by_alias.plate3wellb04.collection_date: '2026' is not a full date, YYYY-MM-DD — see `madbot-cli field collection_date --source image-archive`

The command exits with status 2. apply runs the same checks and stops before its first write. Only what apply would write is checked: a connection madbot already holds keeps its parameters, and the metadata of a submission already sent cannot change. A credential never appears in a message, only its key and the form the plugin expects. A format the client cannot check offline, such as an ORCID or a taxon looked up in a referential, is left to madbot.

Terminal window
madbot-cli plan deposit.yaml
+ workspace 'Imaging platform': create
+ source instrument (host=storage.example.org): create, credentials from INSTRUMENT_CREDENTIALS
+ source code (host=forge.example.org): create, credentials from FORGE_CREDENTIALS
+ node 'Campaign 2026-11': create
source instrument
+ campaign-2026-11/raw/*: found once the source is connected
source code
+ link segment.py [eyJwcm9qZWN0IjoxMjM0LCJwYXRoIjoic2VnbWVudC5weSJ9]
+ submission 'Campaign 2026-11, raw images': create
+ repository (host=images.repository.example.org): create, credentials from IMAGE_REPOSITORY_CREDENTIALS
+ add the data of source instrument (match *), once the source is connected
metadata: compared once madbot has made the metadata objects (after apply)
+ submission 'Campaign 2026-11, analysis code': create
+ repository (host=code.repository.example.org): create, credentials from CODE_REPOSITORY_CREDENTIALS
+ add segment.py, once madbot has read it
metadata: compared once madbot has made the metadata objects (after apply)
Plan: 10 to create, 0 to update, 0 unchanged.
2 submissions are sent to their repository by apply --submit only.
Nothing written.

Each line starts with a sign: + to create, ~ to update, = unchanged, ! to look at. --verbose lists the data and samples left as they are; --json prints the whole plan for a program.

plan also reports what madbot holds that the file does not mention, such as a node or a data linked from the web application. apply leaves it as it is.

Terminal window
madbot-cli apply deposit.yaml

apply follows the order of a deposit, and plans again before each step:

  1. the workspace;
  2. the connections to the sources, once for the whole file, with the credentials of the file;
  3. for each node, the node itself, under its parent, then:
    1. its data, by batches of up to 1,000 per request, then the wait until madbot has read them from their sources;
    2. its samples, and the binding of each data to its sample;
    3. its child nodes, the same way;
    4. its submissions, once the nodes under it are done: the connection to their repository, their data, the values of their metadata, then the check by madbot that they are ready.
madbot_cli/operations.py
def link_data(
client: Client,
node_id: str,
connection_id: str,
items: Iterable[Mapping[str, str]],
batch_size: int = BATCH_SIZE,
) -> list[dict]:
items = [
{k: v for k, v in item.items() if k in ("external_id", "name") and v}
for item in items
]
answers = []
for start in range(0, len(items), batch_size):
answers.append(
client.post(
f"/api/nodes/{node_id}/datalinks/batch",
{
"connection": connection_id,
"data": items[start : start + batch_size],
},
)
)
return answers

madbot reads the linked data in a background task. apply waits for it with GET /api/tasks/{id}, including the short time when the task is queued but not started. A data madbot fails to read is reported with its error, and the command exits with status 1. Fix the cause, then read it again:

Terminal window
madbot-cli apply deposit.yaml --retry-failed

While it runs, apply says the step under way. In a terminal, one line is written again in place, with the time spent, and counts the data madbot has read (node 'Campaign 2026-11': madbot reads 4 data: 2/4, 35 s). Written to a file or a CI log, each step is one line, with no control character. --quiet leaves out the steps and keeps what was done and the summary; with --json, the steps go to the standard error.

apply ends with a summary: each node with its data, each submission with its state, then the commands to run next, each with what it is for. Without --submit, nothing is sent:

Done: 15 changes, 0 failures, 0 submissions sent.
node 'Campaign 2026-11': 5 data read
submission 'Campaign 2026-11, raw images': ready
submission 'Campaign 2026-11, analysis code': ready
Next:
madbot-cli apply deposit.yaml --submit
sends the 2 submissions ready to their repositories, once checked: this cannot be undone

A submission that misses mandatory values names the command that writes them, madbot-cli fields deposit.yaml '<title>' --level mandatory; data madbot failed to read, madbot-cli apply deposit.yaml --retry-failed.

When a data of the file cannot be found in its source, such as a name a folder does not hold, apply links the others, and leaves for its next run the submissions that take data of that source: a deposit cannot be completed once sent. When a repository refuses a submission, the summary says so, nothing is deposited, and madbot-cli status deposit.yaml gives what the repository refused, to fix before apply --submit again.

Check them in the web application if you wish, then send them:

Terminal window
madbot-cli apply deposit.yaml --submit
submitted submission 'Campaign 2026-11, raw images': <identifier given by the repository>
submitted submission 'Campaign 2026-11, analysis code': <identifier given by the repository>
Done: 2 changes, 0 failures, 2 submissions sent.
node 'Campaign 2026-11': 5 data read
submission 'Campaign 2026-11, raw images': sent (submitted), <identifier given by the repository>
submission 'Campaign 2026-11, analysis code': sent (submitted), <identifier given by the repository>

Once the deposit is applied, plan has nothing left to do:

= workspace 'Imaging platform': unchanged
= source instrument (host=storage.example.org): uses the connection 'Storage server (storage.example.org)'
= source code (host=forge.example.org): uses the connection 'Code forge (forge.example.org)'
= node 'Campaign 2026-11': unchanged
source instrument
= 4 data linked
source code
= 1 data linked
= 2 samples unchanged
= submission 'Campaign 2026-11, raw images': deposited (submitted)
= 4 data in the submission
= ID: <identifier given by the repository>
= submission 'Campaign 2026-11, analysis code': deposited (submitted)
= 1 data in the submission
= ID: <identifier given by the repository>
Nothing to do: madbot holds what the file describes.
Nothing written.

A deposit cannot be taken back: --submit is never implied.

Complete the metadata a repository asks for

Section titled “Complete the metadata a repository asks for”

A repository asks for metadata of its own, by type of object (a study, a sample, a dataset…). madbot makes these objects once the data are in the submission: after a first apply, plan lists the mandatory values the file does not give, object by object. Had the example left out the collection dates of its samples (its by_alias part), plan would say:

= submission 'Campaign 2026-11, raw images': unchanged (draft)
= 4 data in the submission
= 3 metadata values unchanged
! mandatory, not in the file: sample plate3wellb04: repository__sample__collection_date (Collection date)
! mandatory, not in the file: sample plate3wellc01: repository__sample__collection_date (Collection date)
2 mandatory metadata values are missing: madbot-cli fields <file> <submission> gives the fields to fill.

fields writes the part of the file to complete, with the slugs of the fields of your repository; on that file:

Terminal window
madbot-cli fields deposit.yaml "Campaign 2026-11, raw images"
# The metadata of the submission 'Campaign 2026-11, raw images', to complete.
# Values come from the file, or from madbot. Empty ones are to fill:
# left empty, they write nothing.
metadata:
study:
repository__study__title: "Campaign 2026-11, raw images" # mandatory: Title
repository__study__description: "Time-lapse imaging of cell growth, campaign of November 2026" # recommended: Description
sample:
repository__sample__alias: "" # mandatory: Sample alias, a value of its own for each object
repository__sample__collection_date: "" # mandatory: Collection date
repository__sample__location: "Imaging facility, room 2" # recommended: Location
repository__sample__description: "" # optional: Sample description
by_alias:
plate3wellb04:
repository__sample__collection_date: "" # mandatory, missing for sample plate3wellb04
plate3wellc01:
repository__sample__collection_date: "" # mandatory, missing for sample plate3wellc01

Values under a type apply to every object of that type; values under by_alias apply to the object whose alias they name. Here each well has its own date: fill them under by_alias, as the example does. fields puts a value under the type when every object has it, and under by_alias otherwise. Every field is listed, those that name an object too, such as its title or alias: a repository may count a description among them. The alias madbot holds for each sample is not repeated under by_alias, where it already names the sample. An empty value writes nothing: apply never clears a value, so you can paste the part as it is and fill it in later. A text written in the editor of madbot, such as a description, is given as plain text, or as Markdown for bold, links or lists: madbot makes its paragraphs, and plan compares the words only, without the markup. A slug the repository does not have is an error of plan, with the closest slugs, and so is a field of another type, such as a field of a sample given under the study. The file wins: when a value was changed in the web application since the last apply, plan shows both values before apply writes the one of the file.

With many fields, --level mandatory writes only the mandatory ones, and --level recommended the recommended ones with them; a field the file already fills is written whatever its level, so that the part pasted back loses no value:

Terminal window
madbot-cli fields deposit.yaml "Campaign 2026-11, raw images" --level mandatory

A field whose value is an object is written with its parts, each with what it accepts; a part left empty is no value, and plan names it as missing when the others are filled. A comment too long for a line, such as the models of every sequencing platform, is cut and names the madbot-cli field command that tells all:

repository__sample__instrument: # mandatory: Instrument; one of these forms: Vendor A (platform, model) or Vendor B (platform, model)
platform: "" # required, one of VENDOR_A or VENDOR_B
model: "" # required, Vendor A: one of Model 1 or Model 2; Vendor B: one of Scope

A field may want more than a text: a date, a value from a closed list, or an object of several parts, each with its own list. madbot-cli field reads the schema the field publishes and writes what its value may be, then an example to paste. It needs no deposit file:

Terminal window
madbot-cli field repository__sample__instrument
repository__sample__instrument: Instrument (a field, from repository)
Microscope that took the images
The value:
one of these forms
one form, Vendor A: Microscopes of Vendor A
platform (required, always "VENDOR_A")
model (required)
= "Vendor A Scope"
= "Vendor A Scope Pro"
as: {"platform": "VENDOR_A", "model": "<model>"}
one form, Vendor B: Microscopes of Vendor B
platform (required, always "VENDOR_B")
model (required)
= "Vendor B Confocal"
as: {"platform": "VENDOR_B", "model": "<model>"}
An example, in the deposit file, under the metadata: <type of object>: of a submission, or the metadata: of an association rule for a field of an association:
repository__sample__instrument:
platform: VENDOR_A
model: Vendor A Scope

Where a value is required, the example takes the first one of its list, so that it is valid as written. A value to choose in a list of values, such as a type of data or a language, or in a part that may be left out, stays a <…> value to replace, as a free text does: the example never chooses for you. A list of more than 30 values is cut: --search <text> keeps the values that contain the text, whatever the case, and takes the example among them (--search "scope pro"). When two sources have a field of the same slug, --source chooses one.

The level of a field, mandatory or not, may depend on a setting of the submission, such as a checklist. --in gives the level in a submission of your file, once apply has prepared it, with the values it already has:

Terminal window
madbot-cli field repository__sample__location --in deposit.yaml "Campaign 2026-11, raw images"
In the submission 'Campaign 2026-11, raw images':
sample: recommended
the value of every object: "Imaging facility, room 2"

Each new series of data is a change of the file, or no change at all when it is found by a pattern:

  • plan shows only the new data and samples, and the submissions not sent yet that will take them;
  • an apply stopped half way, by a network failure or a data that cannot be read, goes on where it stopped when you run it again, and creates nothing twice. When the network drops, madbot-cli first sends again, after a growing pause (31 s of pauses in all, five new attempts that each wait up to 2 minutes for an answer), the requests that can be repeated without effect: the reads and the values of the metadata. A request that creates is never sent twice. When madbot stays out of reach, apply stops, says so in its summary, and gives the command to run once it can be reached;
  • once the file is applied, plan says there is nothing to do.

A submission already sent is not changed: madbot cannot update a deposit in a repository yet. plan and status list the data it selects that the deposit does not hold. To deposit them, add a submission with another title.

status tells where the deposit stands: the data madbot read, those it failed to read and why, the tasks still running, and each submission with the identifiers its repository gave:

Terminal window
madbot-cli status deposit.yaml
node 'Campaign 2026-11'
source instrument: 4 active
source code: 1 active
submission 'Campaign 2026-11, raw images': submitted, 4 data
= ID: <identifier given by the repository> <its address>
submission 'Campaign 2026-11, analysis code': submitted, 1 data
= ID: <identifier given by the repository> <its address>

Every command prints its result as JSON with --json, the progress going to the standard error, and exits with a status a pipeline can test:

StatusMeaning
0Success.
1An object failed: a data not read, a submission refused, an error of the API.
2The file or a setting is invalid: nothing was sent.

An error of the API is said in a sentence: the object of the file, what madbot refused and what to do next, such as submission 'Campaign 2026-11, raw images': madbot refused metadata: "study_titel" does not exist; fix it in the file, then run plan. --verbose adds the request and the raw answer of the API under it. With --json, the result of apply gives each failure in failure_details, with the request and the answer in api, and stopped when madbot could not be reached any more; an error that stops another command is printed as {"error": ..., "api": ...}.

madbot-cli is not a workflow engine: call it from the orchestrator of your platform, after each run of the instrument.

The command line is built on the madbot_cli library, which a platform can use in its own Python tools, with or without a file:

from madbot_cli import manifest, plan, apply
from madbot_cli.client import Client
client = Client.from_env()
deposit = manifest.load("deposit.yaml")
print(plan.plan(client, deposit)["summary"])
report = apply.apply(client, deposit, submit=False)

madbot_cli.operations holds each step with explicit inputs, to chain them yourself. Without a file, nothing compares your code with what madbot holds: look for a node or a submission by its title before creating it, so that a second run creates nothing twice.

from madbot_cli import operations as op
client.use_workspace("Imaging platform")
node = op.find_node(client, "Campaign 2026-12") or op.create_node(
client, "Campaign 2026-12"
)
answers = op.link_data(client, node["id"], connection_id, [{"external_id": "…"}])
op.wait_for_data(client, [a["task_id"] for a in answers])
submission = op.find_submission(
client, "Campaign 2026-12", repository_id
) or op.create_submission(client, "Campaign 2026-12", repository_id)
# Once its data are in it and its metadata made:
for metadata_object in op.missing_metadata(client, submission["id"]):
print(metadata_object["type"], [f["slug"] for f in metadata_object["missing"]])

link_data already leaves alone the data a node holds. Integrate madbot in your Python code chains every step in a script, and the library reference describes every function.