Skip to content

Describe the submission

A submission gathers data of a node and the description a repository expects of them. Each repository has its own fields: madbot fills them with what it already knows (your name, the title, the description of the node), and madbot-cli fields gives the ones left to fill, in the format of the file.

  1. Give your token of the demo of Recherche Data Gouv, in the terminal, as madbot-cli plugins recherche_data_gouv showed:

    Fenêtre de terminal
    export RECHERCHE_DATA_GOUV_CREDENTIALS='{"token": "<your token of the demo>"}'

    The token never goes in the file: the file only names the variable that holds it. So you can version the file, or have your platform write it, without leaving a secret in it.

  2. Add the submission to the node, with the block given by plugins, filled for the demo:

    depot.yaml
    version: 1
    workspace: madbot CLI workshop
    sources:
    zenodo:
    plugin: zenodo
    shared_params:
    url: https://zenodo.org/
    nodes:
    - title: Stream water quality
    description: A year of water quality measurements in a stream, read on Zenodo.
    data:
    - source: zenodo
    browse:
    path: [24343971]
    names: [README.md, stations.csv, mesures.csv]
    submissions:
    - title: Stream water quality
    repository:
    plugin: recherche_data_gouv
    shared_params:
    url: https://demo.recherche.data.gouv.fr
    credentials_env: RECHERCHE_DATA_GOUV_CREDENTIALS
    settings:
    target_collection: tp
    metadata_language: en
    access_condition: {"access_condition": "open", "license": {"name": "etalab 2.0", "uri": "https://spdx.org/licenses/etalab-2.0.html"}}
    data:
    all: true
    • url: the demo, not the production repository;
    • target_collection: the Travaux Pratiques collection of the demo, whose alias is tp;
    • access_condition: the Open form with the etalab 2.0 license, copied from the as: line under access_condition, in the output of madbot-cli plugins recherche_data_gouv;
    • data: all: true: the submission takes every data of the node.
  3. Create the submission:

    Fenêtre de terminal
    madbot-cli plan depot.yaml
    madbot-cli apply depot.yaml

    apply creates the submission, adds the three data to it, then madbot prepares the metadata the repository expects. The submission stays a draft: mandatory values are missing, and apply tells which command gives them.

    Done: 4 changes, 0 failures, 0 submissions sent.
    node 'Stream water quality': 3 data read
    submission 'Stream water quality': draft, 3 mandatory values missing
    Next:
    madbot-cli fields depot.yaml 'Stream water quality' --level mandatory
    writes the 3 values missing, to fill in the file
  4. Read the mandatory fields:

    Fenêtre de terminal
    madbot-cli fields depot.yaml "Stream water quality" --level mandatory
    metadata:
    general:
    recherche_data_gouv__general__author: [{"name": "Formation, Camille"}] # mandatory: Author
    recherche_data_gouv__general__contact: "" # mandatory: Point of contact
    recherche_data_gouv__general__ds_description: [{"value": "A year of water quality measurements in a stream, read on Zenodo."}] # mandatory: Description
    recherche_data_gouv__general__kind_of_data: # mandatory: Data type
    kind_of_data: "" # required, a list
    other_kind_of_data: "" # a text
    recherche_data_gouv__general__subject: "" # mandatory: Subject
    recherche_data_gouv__general__title: "Stream water quality" # mandatory: Title

    madbot already filled the author (your name, from your profile), the description (the one of the node) and the title (the one of the submission). Left empty: the point of contact, the data type and the subject.

  5. Find out what a field accepts, before filling it:

    Fenêtre de terminal
    madbot-cli field recherche_data_gouv__general__contact
    madbot-cli field recherche_data_gouv__general__kind_of_data
    madbot-cli field recherche_data_gouv__general__subject --search earth

    Each command gives the form of the value (a text, a list, an object of several parts), the allowed values, then an example to paste. --search filters a long list of values.

  6. Fill the three fields in the file, under the submission, after data:

    depot.yaml
    data:
    all: true
    metadata:
    general:
    recherche_data_gouv__general__contact:
    - name: Formation, Camille
    affiliation: IFB
    email: camille.formation@example.org
    recherche_data_gouv__general__kind_of_data:
    kind_of_data: [Dataset]
    recherche_data_gouv__general__subject: [Earth and Environmental Sciences]

    Put your name, your institution and your address in the contact. No need to copy the fields madbot already filled: a value missing from the file clears nothing.

Optional The object types of a submission

general is an object type of Recherche Data Gouv: a dataset has only one. Other repositories have several: at the ENA, a study, samples and reads. Values written under a type apply to all its objects; a value specific to one object is written under by_alias, under the name of that object. fields puts each value in the right place.

Optional What the command does, on the API side

apply creates the submission (POST /api/submissions), adds the data to it (POST /api/submissions/{id}/data), then asks madbot to prepare its metadata (POST /api/submissions/{id}/actions with generate_metadata). fields reads the objects so prepared and their values (GET /api/submissions/{id}/metadata_objects), and the definition of the fields (GET /api/metadata_fields). The values of the file are then written object by object, on …/metadata_objects/{id}/metadata.

  • “! no credentials: set RECHERCHE_DATA_GOUV_CREDENTIALS”: the variable is not set in this terminal. Run the export of step 1 again, with single quotes around the JSON.
  • The token of the demo is refused: it must be the one of the demo instance, created once signed in on demo.recherche.data.gouv.fr, API Token page. A token of the production repository does not work on the demo.
  • A <…> value pasted as is, such as <Data Type>: the example of field leaves each value to choose that way. Replace it with one of the values it lists, here Dataset. Leave other_kind_of_data aside: it only goes with Other.
  • “The file gives values madbot would refuse; nothing was written”: plan lists each refused value, with the path of the field in the file, then the command that explains what it accepts. Nothing is written as long as a value is refused.
    • “is not an allowed value; closest: …”: the value is not in the list of the field. Take one of the values offered, to the letter.
    • “the repository … has no field ‘…’; closest: …”: the slug is copied wrong. Take the slug offered, or copy it from the output of fields.
    • The form does not fit: a list is written between brackets ([Dataset]) or as lines starting with - ; an object, with its parts indented. madbot-cli field <slug> gives an example.
  • “‘metadata’ is not expected here”: the metadata key goes under the submission, at the same level as repository and data, not under the node.
  • apply does not create the submission and says “left for the next apply”: a data of the node is not read yet. Run apply again a minute later.