Skip to content

Plug it into your platform

The workshop file works as it is. To use it on your platform, five things change.

Your platform knows what it produced: where the files are, which project they belong to, who asked for them. So it can write the deposit file itself, from a template, at the end of each production:

  • a node per project, per series or per batch, the way you already organise your data;
  • data named by their external_id, which the platform knows, or by a folder and a pattern (match: "*.tif");
  • the metadata the platform already knows (instrument, dates, protocol) written in the submission; the others are left for a person to complete, in the file or in the interface.

As apply only creates what is missing, the platform can rewrite the whole file at each production and apply it again: only what is new is created.

Your data are not public: the source needs credentials. With a file server reached over SSH, for example:

sources:
storage:
plugin: sshfs
shared_params:
host: storage.example.org
credentials_env: SSHFS_CREDENTIALS
Fenêtre de terminal
export SSHFS_CREDENTIALS='{"username": "<account>", "credential": {"password": "<password>"}}'

madbot-cli plugins sshfs gives the exact form, an SSH key included. The credentials stay in an environment variable: in an automated pipeline, they are secrets of the tool, never lines of the file.

A connection made in the interface works too: if the workspace of the file already has a connection with the same plugin and the same shared parameters, madbot-cli uses it. madbot-cli connections lists yours.

To deposit for real, three things change in the repository block:

  • url: the production server of the repository, which madbot-cli plugins <slug> lists next to the test server;
  • the settings: your collection, your license, your access conditions;
  • the credentials: a token of your account on the production repository.

Keep the test server until the file has made a complete deposit, reviewed.

madbot-cli is not an orchestrator: call it from yours, after each production.

  • madbot-cli plan depot.yaml first: it changes nothing, and its exit status says whether the file is valid (0), whether something failed (1) or whether the file is invalid (2).
  • madbot-cli apply depot.yaml to create the nodes, link the data and prepare the submissions.
  • madbot-cli apply depot.yaml --submit only when the deposit must go without review. Otherwise, a person reviews the submission in the interface, then sends it.
  • --json gives each result as JSON, for the pipeline to read; the madbot token (MADBOT_TOKEN) is a secret of the pipeline.

madbot-cli is also a Python library, madbot_cli, that your tools can call directly, 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("depot.yaml")
print(plan.plan(client, deposit)["summary"])
report = apply.apply(client, deposit, submit=False)

Without a deposit file, the optional block From your Python code calls the library step by step, with a script to copy into your tool.

For a platform that does not use Python, or that wants full control, each command of the track is only a series of requests to the API: the “What the command does, on the API side” boxes of each block name them.