Plan and apply
madbot-cli works in two steps, like many infrastructure tools:
plancompares the file with what madbot holds, and says what should be created or changed. It writes nothing.applydoes whatplanannounces, and nothing else. It never deletes anything: what is in madbot without being in the file stays in place.
So the file describes a desired state, not a list of actions: you can run apply as many times as you like, it only creates what is missing. That is what lets a platform run it after each production, without keeping track of what it already sent.
-
See what will change:
Fenêtre de terminal madbot-cli plan depot.yaml= workspace 'madbot CLI workshop': unchanged= source zenodo (url=https://zenodo.org/): uses the connection 'Zenodo (zenodo.org)' — without credentials: public data only+ node 'Stream water quality': createsource zenodo+ link README.md [24343971/README.md]+ link stations.csv [24343971/stations.csv]+ link mesures.csv [24343971/mesures.csv]apply never deletes: what is not in the file is left as it is.Plan: 4 to create, 0 to update, 2 unchanged.Nothing written.Each line starts with a sign:
+to create,~to change,=unchanged,!to look at. The workspace and the connection to Zenodo already exist:browse --connectcreated them in the previous block, andplansays it reuses this connection. -
Apply:
Fenêtre de terminal madbot-cli apply depot.yamlmadbot-cli creates the node, links the three files, then waits until madbot has read them on Zenodo. It says so at each step, and ends with a summary:
Done: 4 changes, 0 failures, 0 submissions sent.node 'Stream water quality': 3 data read -
Run
planagain:Fenêtre de terminal madbot-cli plan depot.yamlThis time, everything is
=: madbot holds what the file describes.
Optional See it in the interface
Open the madbot interface: the workspace madbot CLI workshop holds the node Stream water quality, and its Datalinks tab the three files. They are the same objects as those created by hand: a person can take over in the interface what a platform created, and the other way round.
Optional What the command does, on the API side
plan only reads: workspaces, nodes, connections, linked data, and GET /api/connections/{id}/external_data to find the files named in the folder. apply then writes:
POST /api/nodesfor the node;POST /api/nodes/{id}/datalinks/batchto link the three files in one request;GET /api/tasks/{id}to wait until madbot has read them.
A node is found again by its title, under its parent: changing the title in the file creates another node. A data is found again by its source and its external_id.
Checkpoint
Section titled “Checkpoint”If you are stuck
Section titled “If you are stuck”planshows a!line “nodes in the workspace, not in the file”: your workspace holds other nodes, created in the interface or by another file. It is not an error:applyleaves them in place.- “! error: … not in the folder: readme.md (close to it: README.md); nothing of this entry is linked”: a name in
namesmatches no file of the record, and madbot-cli offers the close names. Names are written exactly asbrowsegives them, case included.applylinks nothing of this entry as long as it is wrong. applystops on a network error, then goes on: madbot-cli replays by itself the requests that allow it, up to five times. If it stops anyway, runapplyagain: it goes on where it was, without creating anything twice.- “1 failed to read” in the summary: madbot could not read a file on Zenodo, often because Zenodo limits the number of reads. Wait a minute, then run
madbot-cli apply depot.yaml --retry-failed. - A second node with the same name in the interface: the title in the file changed between two
applyruns. Put the original title back, and delete the extra node in the interface.

