# madbot_cli.apply

*module*

Make madbot hold what a deposit file describes.

`apply` follows the order of a deposit: the workspace, the connections, then
each node under its parent with its data (and the wait until madbot has read
them), its samples, its child nodes, and last its submissions, which take
their data in the whole subtree. Each step plans again from what madbot holds, so an
`apply` stopped half way is run again and goes on where it stopped, without
creating anything twice.

An object that fails does not stop the others. When madbot cannot be reached
any more, once the client has tried again, apply stops: the report says so,
and running it again goes on where it stopped.

Nothing is ever deleted. A submission goes to its repository only when asked
(``submit=True``): a deposit cannot be taken back. A submission already
deposited is never changed.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L1-1)

## madbot_cli.apply.DATA_COUNT_INTERVAL

*attribute* · *module attribute*

```python
DATA_COUNT_INTERVAL = 10
```

Seconds between two counts of the data madbot has read, while waiting.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L59-59)

## madbot_cli.apply.DEFAULT_TIMEOUT

*attribute* · *module attribute*

```python
DEFAULT_TIMEOUT = 1800
```

How long to wait for what madbot does in the background, in seconds.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L56-56)

## madbot_cli.apply.Log

*attribute* · *module attribute*

```python
Log = Callable[[str], None]
```

Called with a line for each change, warning and failure.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L53-53)

## madbot_cli.apply.RESUME

*attribute* · *module attribute*

```python
RESUME = 'apply stopped: madbot cannot be reached. Run apply again once it can: it goes on from what madbot holds, and creates nothing twice.'
```

What the report says when apply stops on a lost connection.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L76-79)

## madbot_cli.apply.Applier

*class*

```python
class Applier
```

Apply a deposit file, step after step.

**Parameters**

- `client` (`Client`) — The client.
- `manifest` (`Manifest`) — The deposit file.
- `submit` (`bool`) (default: `False`) — Send the ready submissions to their repositories.
- `retry_failed` (`bool`) (default: `False`) — Read again the data madbot failed to read.
- `environ` (`mapping`) (default: `None`) — The environment holding the credentials; `os.environ` by default.
- `log` (`callable`) (default: `_silent`) — Called with a line for each change, warning and failure.
- `timeout` (`float`) (default: `DEFAULT_TIMEOUT`) — Seconds to wait for what madbot does in the background.
- `progress` (`Progress`) (default: `None`) — Says the step under way; none by default.
- `verbose` (`bool`) (default: `False`) — Log the request and the answer of the API under a failure.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L342-1252)

### madbot_cli.apply.Applier.cache

*attribute* · *instance attribute*

```python
cache: dict = {}
```

The folders of the sources already listed.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L393-393)

### madbot_cli.apply.Applier.client

*attribute* · *instance attribute*

```python
client = client
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L382-382)

### madbot_cli.apply.Applier.connections

*attribute* · *instance attribute*

```python
connections: dict[str, dict] = {}
```

The connection of each source of the file, by key: its ``id``, None when it failed.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L391-391)

### madbot_cli.apply.Applier.environ

*attribute* · *instance attribute*

```python
environ = os.environ if environ is None else environ
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L386-386)

### madbot_cli.apply.Applier.manifest

*attribute* · *instance attribute*

```python
manifest = manifest
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L383-383)

### madbot_cli.apply.Applier.progress

*attribute* · *instance attribute*

```python
progress = progress
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L389-389)

### madbot_cli.apply.Applier.report

*attribute* · *instance attribute*

```python
report = Report(log, verbose=verbose)
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L387-387)

### madbot_cli.apply.Applier.retry_failed

*attribute* · *instance attribute*

```python
retry_failed = retry_failed
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L385-385)

### madbot_cli.apply.Applier.state

*attribute* · *instance attribute*

```python
state: State | None = None
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L390-390)

### madbot_cli.apply.Applier.submit

*attribute* · *instance attribute*

```python
submit = submit
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L384-384)

### madbot_cli.apply.Applier.timeout

*attribute* · *instance attribute*

```python
timeout = timeout
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L388-388)

### madbot_cli.apply.Applier.unlisted

*attribute* · *instance attribute*

```python
unlisted: dict[tuple[str, ...], set[str]] = {}
```

For each node some data of which could not be found, the keys of their sources.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L395-395)

### madbot_cli.apply.Applier.add_data

*method*

```python
def add_data(submission: Submission, submission_id: str, subtree: list[Linked], label: str) -> tuple[bool, list[dict]]
```

Add to a submission the data it selects that it does not hold yet.

A data an entry designates that the node does not hold is a failure,
and is not added. A data the submission holds through another node
than the one the file chooses is a warning: apply does not move it.

**Parameters**

- `submission` (`Submission`) — The submission, from the file.
- `submission_id` (`str`) — Its identifier.
- `subtree` (`list of Linked`) — The data of its node, then of each node under it.
- `label` (`str`) — The submission, in the messages.

**Returns**

- (`tuple`) — True when data were added; and the data held through another node, from `moved_data`.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L1001-1064)

### madbot_cli.apply.Applier.apply_associations

*method*

```python
def apply_associations(node: Node, node_id: str, datalinks: list[dict]) -> None
```

Create the associations of a node and write the values of their fields.

They are made before the submissions above, which give each data its
associations.

**Parameters**

- `node` (`Node`) — The node, from the file.
- `node_id` (`str`) — Its identifier.
- `datalinks` (`list of dict`) — The datalinks of the node.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L818-866)

### madbot_cli.apply.Applier.apply_node

*method*

```python
def apply_node(node: Node, parent_id: str | None = None) -> Linked
```

Apply a node and what it holds, its submissions aside.

**Parameters**

- `node` (`Node`) — The node, from the file.
- `parent_id` (`str`) (default: `None`) — The node it goes under; the top of the workspace when None.

**Returns**

- (`Linked`) — The data of the node, once linked and bound to their samples.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L659-709)

### madbot_cli.apply.Applier.apply_samples

*method*

```python
def apply_samples(node: Node, node_id: str, datalinks: list[dict]) -> None
```

Create the samples of a node and bind their data to them.

**Parameters**

- `node` (`Node`) — The node, from the file.
- `node_id` (`str`) — Its identifier.
- `datalinks` (`list of dict`) — The datalinks of the node.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L784-816)

### madbot_cli.apply.Applier.apply_sources

*method*

```python
def apply_sources(node: Node, node_id: str) -> None
```

Link the data of a node, and wait until madbot has read them.

**Parameters**

- `node` (`Node`) — The node, from the file.
- `node_id` (`str`) — Its identifier.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L711-758)

### madbot_cli.apply.Applier.apply_submission

*method*

```python
def apply_submission(submission: Submission, subtree: list[Linked]) -> None
```

Prepare a submission, and send it to its repository when asked.

**Parameters**

- `submission` (`Submission`) — The submission, from the file.
- `subtree` (`list of Linked`) — The data of its node, then of each node under it.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L868-887)

### madbot_cli.apply.Applier.apply_tree

*method*

```python
def apply_tree(node: Node, parent_id: str | None = None) -> tuple[list[Linked], list[str]]
```

Apply a node, then the nodes under it, then the submissions of the node.

A node that fails does not stop its siblings; the nodes under it are
left for the next apply. The submissions of the nodes above it are
left too: their data would miss those of the failed node, and a
deposit cannot be completed once sent.

**Parameters**

- `node` (`Node`) — The node, from the file.
- `parent_id` (`str`) (default: `None`) — The node it goes under; the top of the workspace when None.

**Returns**

- (`tuple`) — The data of the node and of each node under it, empty when the node failed; and the nodes of the subtree that failed, for a person.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L494-563)

### madbot_cli.apply.Applier.can_submit

*method*

```python
def can_submit(submission: Submission) -> bool
```

Tell whether the account has credentials for the repository of a submission.

**Parameters**

- `submission` (`Submission`) — The submission, from the file.

**Returns**

- (`bool`) — True when the connection is connected; madbot refuses a submission otherwise.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L946-962)

### madbot_cli.apply.Applier.connect_sources

*method*

```python
def connect_sources() -> None
```

Connect the sources of the file, once for the whole file.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L643-657)

### madbot_cli.apply.Applier.describe

*method* · *staticmethod*

```python
def describe(submission: Mapping) -> dict
```

Keep what a person needs to know of a submission.

**Parameters**

- `submission` (`mapping`) — The submission, as the API returns it.

**Returns**

- (`dict`) — Its ``id``, ``status``, ``error_reason`` and ``external_identifiers``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L1232-1252)

### madbot_cli.apply.Applier.ensure_connection

*method*

```python
def ensure_connection(spec: Mapping[str, Any], label: str, *, source: bool = False) -> str | None
```

Connect to a source or a repository when the account is not yet.

**Parameters**

- `spec` (`mapping`) — ``plugin``, ``shared_params`` and ``credentials_env`` from the file.
- `label` (`str`) — What the connection is for, in the messages.
- `source` (`bool`) (default: `False`) — True for a source of data, which may be read without credentials.

**Returns**

- (`str or None`) — The identifier of the connection; None when it could not be made.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L593-641)

### madbot_cli.apply.Applier.not_ready

*method*

```python
def not_ready(submission: Submission, current: Mapping, label: str, outcome: dict) -> None
```

Report why a submission is not ready: a failure when it was to be sent.

**Parameters**

- `submission` (`Submission`) — The submission, from the file.
- `current` (`mapping`) — The submission, as the API returns it.
- `label` (`str`) — The submission, in the messages.
- `outcome` (`dict`) — The report of the submission, given the ``missing`` values.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L1111-1143)

### madbot_cli.apply.Applier.open_submission

*method*

```python
def open_submission(submission: Submission, label: str) -> str | None
```

Find a submission of the file, or create it with its repository.

**Parameters**

- `submission` (`Submission`) — The submission, from the file.
- `label` (`str`) — The submission, in the messages.

**Returns**

- (`str or None`) — Its identifier; None when its repository could not be connected.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L964-999)

### madbot_cli.apply.Applier.prepare_metadata

*method*

```python
def prepare_metadata(submission: Submission, submission_id: str, label: str, changed: bool) -> dict
```

Write the metadata of the file, then have madbot check the submission.

**Parameters**

- `submission` (`Submission`) — The submission, from the file.
- `submission_id` (`str`) — Its identifier.
- `label` (`str`) — The submission, in the messages.
- `changed` (`bool`) — Whether data were added.

**Returns**

- (`dict`) — The submission, checked: ``ready`` or ``draft``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L1066-1109)

### madbot_cli.apply.Applier.run

*method*

```python
def run() -> dict
```

Apply the file.

**Returns**

- (`dict`) — The report: ``changes``, ``warnings``, ``failures``, and for each submission its ``title``, ``status``, ``submitted`` and ``external_identifiers``; ``stopped`` when madbot could not be reached any more.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L454-474)

### madbot_cli.apply.Applier.send

*method*

```python
def send(submission_id: str, label: str, outcome: dict) -> None
```

Send a ready submission to its repository, and wait for its answer.

**Parameters**

- `submission_id` (`str`) — The submission.
- `label` (`str`) — The submission, in the messages.
- `outcome` (`dict`) — The report of the submission.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L1145-1185)

### madbot_cli.apply.Applier.settle_submission

*method*

```python
def settle_submission(submission: Submission, subtree: list[Linked], label: str, outcome: dict[str, Any]) -> None
```

Open a submission, give it its data and metadata, and send it when asked.

**Parameters**

- `submission` (`Submission`) — The submission, from the file.
- `subtree` (`list of Linked`) — The data of its node, then of each node under it.
- `label` (`str`) — The submission, in the messages.
- `outcome` (`dict`) — The report of the submission, completed as it goes.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L889-944)

### madbot_cli.apply.Applier.step

*method*

```python
def step(text: str) -> None
```

Say the step under way, when the progress is shown.

**Parameters**

- `text` (`str`) — What apply does.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L400-410)

### madbot_cli.apply.Applier.steps

*method*

```python
def steps() -> None
```

Apply the workspace, the sources, then each node, in order.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L476-492)

### madbot_cli.apply.Applier.unlisted_for

*method*

```python
def unlisted_for(node: Node, submission: Submission) -> list[str]
```

Name the nodes of a subtree that miss data of the file a submission takes.

**Parameters**

- `node` (`Node`) — The node of the submission.
- `submission` (`Submission`) — The submission, from the file.

**Returns**

- (`list of str`) — The nodes, under `node` or `node` itself, some data of which were not found in a source the submission takes data from.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L565-591)

### madbot_cli.apply.Applier.wait_for_data

*method*

```python
def wait_for_data(node: Node, node_id: str, tasks: list[str]) -> None
```

Wait until madbot has read the data of a node.

**Parameters**

- `node` (`Node`) — The node, from the file.
- `node_id` (`str`) — Its identifier.
- `tasks` (`list of str`) — The tasks reading them; an empty one is left.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L760-782)

### madbot_cli.apply.Applier.waiting

*method*

```python
def waiting(text: str) -> Callable[[float], None] | None
```

Return what says a wait, from its first pause: a quick answer says nothing.

**Parameters**

- `text` (`str`) — What madbot does meanwhile.

**Returns**

- (`callable or None`) — Called with the seconds waited, at each pause; None when the progress is not shown.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L412-429)

### madbot_cli.apply.Applier.waiting_for_data

*method*

```python
def waiting_for_data(node: Node, node_id: str) -> DataCount | None
```

Return what says how many data madbot has read, while waiting for them.

**Parameters**

- `node` (`Node`) — The node, from the file.
- `node_id` (`str`) — Its identifier.

**Returns**

- (`DataCount or None`) — Called with the seconds waited, at each pause; None when the progress is not shown.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L431-450)

### madbot_cli.apply.Applier.write_metadata

*method*

```python
def write_metadata(submission: Submission, submission_id: str, label: str) -> bool
```

Write the values of the file that differ from those of a submission.

**Parameters**

- `submission` (`Submission`) — The submission, from the file.
- `submission_id` (`str`) — Its identifier.
- `label` (`str`) — The submission, in the messages.

**Returns**

- (`bool`) — True when a value was written.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L1187-1230)

## madbot_cli.apply.ConnectionLost

*class*

```python
class ConnectionLost(Exception)
```

Bases: `Exception`

madbot cannot be reached any more: apply stops, the report says so.

It derives from neither `ApiError` nor `MadbotError`, so that the steps
that go on after a failure let it through.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L67-73)

## madbot_cli.apply.DataCount

*class*

```python
class DataCount
```

Says how many data of a node madbot has read, while apply waits for them.

At the first pause, the data being read are listed; they are counted again
every `DATA_COUNT_INTERVAL` seconds at most. A quick answer reads and says
nothing.

**Parameters**

- `client` (`Client`) — The client.
- `progress` (`Progress`) — Where to say the count.
- `node` (`Node`) — The node, from the file.
- `node_id` (`str`) — Its identifier.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L256-339)

### madbot_cli.apply.DataCount.at

*attribute* · *instance attribute*

```python
at = 0.0
```

When they were last counted.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L288-288)

### madbot_cli.apply.DataCount.client

*attribute* · *instance attribute*

```python
client = client
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L282-282)

### madbot_cli.apply.DataCount.elapsed

*attribute* · *instance attribute*

```python
elapsed = 0.0
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L291-291)

### madbot_cli.apply.DataCount.label

*attribute* · *instance attribute*

```python
label = node {node.label}: madbot reads
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L285-285)

### madbot_cli.apply.DataCount.node_id

*attribute* · *instance attribute*

```python
node_id = node_id
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L284-284)

### madbot_cli.apply.DataCount.pending

*attribute* · *instance attribute*

```python
pending: set | None = None
```

The data being read at the first pause; None before it.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L286-286)

### madbot_cli.apply.DataCount.progress

*attribute* · *instance attribute*

```python
progress = progress
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L283-283)

### madbot_cli.apply.DataCount.read

*attribute* · *instance attribute*

```python
read = 0
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L290-290)

### madbot_cli.apply.DataCount.finish

*method*

```python
def finish() -> None
```

Say the data are all read, once the wait is over, when it said anything.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L325-329)

### madbot_cli.apply.DataCount.reading

*method*

```python
def reading() -> set
```

Return the identifiers of the data madbot is still reading.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L293-300)

### madbot_cli.apply.DataCount.say

*method*

```python
def say() -> None
```

Write where the data stand.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L331-339)

## madbot_cli.apply.Report

*class*

```python
class Report
```

What an apply did: the changes, the failures, and the state of each submission.

**Parameters**

- `log` (`callable`) — Called with a line for each change, warning and failure.
- `verbose` (`bool`) (default: `False`) — Log the request and the answer of the API under a failure.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L120-253)

### madbot_cli.apply.Report.change_count

*attribute* · *instance attribute*

```python
change_count = 0
```

The objects and values written: a line of `changes` may stand for several.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L137-137)

### madbot_cli.apply.Report.changes

*attribute* · *instance attribute*

```python
changes: list[str] = []
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L136-136)

### madbot_cli.apply.Report.failure_details

*attribute* · *instance attribute*

```python
failure_details: list[dict] = []
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L141-141)

### madbot_cli.apply.Report.failures

*attribute* · *instance attribute*

```python
failures: list[str] = []
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L140-140)

### madbot_cli.apply.Report.log

*attribute* · *instance attribute*

```python
log = log
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L134-134)

### madbot_cli.apply.Report.nodes

*attribute* · *instance attribute*

```python
nodes: list[dict] = []
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L142-142)

### madbot_cli.apply.Report.stopped

*attribute* · *instance attribute*

```python
stopped: str | None = None
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L144-144)

### madbot_cli.apply.Report.submissions

*attribute* · *instance attribute*

```python
submissions: list[dict] = []
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L143-143)

### madbot_cli.apply.Report.verbose

*attribute* · *instance attribute*

```python
verbose = verbose
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L135-135)

### madbot_cli.apply.Report.warnings

*attribute* · *instance attribute*

```python
warnings: list[str] = []
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L139-139)

### madbot_cli.apply.Report.as_dict

*method*

```python
def as_dict() -> dict
```

Return the report.

**Returns**

- (`dict`) — ``changes``, ``change_count`` (the objects and values written, a change of several data counting each), ``warnings``, ``failures``; ``failure_details``, each failure with its ``object``, its ``message`` and the request and answer of the ``api`` (None when the API did not answer it); ``nodes``, ``submissions``; and ``stopped``, why apply stopped before the end (None when it did not).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L229-253)

### madbot_cli.apply.Report.change

*method*

```python
def change(message: str, count: int = 1) -> None
```

Record a change.

**Parameters**

- `message` (`str`) — What was done.
- `count` (`int`) (default: `1`) — The objects or values it wrote, such as the data of one batch.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L146-159)

### madbot_cli.apply.Report.fail

*method*

```python
def fail(what: str, error: Exception | str, api: Mapping | None = None) -> None
```

Record a failure; apply goes on with the next object.

**Parameters**

- `what` (`str`) — The object that failed, as the file names it.
- `error` (`Exception or str`) — Why. An `ApiError` is said in a sentence; its request and answer go to the details, and to the log with ``verbose``.
- `api` (`mapping`) (default: `None`) — The request and the answer, when `error` is already a sentence.

**Raises**

- `ConnectionLost` — When `error` says madbot cannot be reached: apply stops.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L173-197)

### madbot_cli.apply.Report.record

*method*

```python
def record(what: str | None, error: Exception | str, api: Mapping | None = None) -> None
```

Record a failure, in the summary, the details and the log.

**Parameters**

- `what` (`str or None`) — The object that failed, as the file names it; None out of an object.
- `error` (`Exception or str`) — Why; see `fail`.
- `api` (`mapping`) (default: `None`) — The request and the answer, when `error` is already a sentence.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L199-222)

### madbot_cli.apply.Report.stop

*method*

```python
def stop() -> None
```

Record that apply stops, madbot being out of reach.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L224-227)

### madbot_cli.apply.Report.warn

*method*

```python
def warn(message: str) -> None
```

Record something to look at, which is not a failure.

**Parameters**

- `message` (`str`) — What to look at.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L161-171)

## madbot_cli.apply.apply

*function*

```python
def apply(client: Client, manifest: Manifest, *, submit: bool = False, retry_failed: bool = False, environ: Mapping[str, str] | None = None, log: Log = _silent, timeout: float = DEFAULT_TIMEOUT, progress: Progress | None = None, verbose: bool = False) -> dict
```

Make madbot hold what a deposit file describes, without deleting anything.

**Parameters**

- `client` (`Client`) — The client.
- `manifest` (`Manifest`) — The deposit file.
- `submit` (`bool`) (default: `False`) — Send the ready submissions to their repositories. This cannot be undone.
- `retry_failed` (`bool`) (default: `False`) — Read again the data madbot failed to read.
- `environ` (`mapping`) (default: `None`) — The environment holding the credentials; `os.environ` by default.
- `log` (`callable`) (default: `_silent`) — Called with a line for each change, warning and failure.
- `timeout` (`float`) (default: `DEFAULT_TIMEOUT`) — Seconds to wait for what madbot does in the background.
- `progress` (`Progress`) (default: `None`) — Says the step under way; none by default.
- `verbose` (`bool`) (default: `False`) — Log the request and the answer of the API under a failure.

**Returns**

- (`dict`) — ``changes``, ``warnings``, ``failures`` with their ``failure_details``, and ``stopped`` when madbot could not be reached any more; for each node its ``label`` and its data ``read``, ``reading`` and ``failed_data``, ``failed`` True when the node itself failed; and for each submission its ``title``, ``status``, ``submitted``, ``external_identifiers`` and the mandatory metadata ``missing`` (``left`` True when a node under it failed, ``failed`` True when it failed itself).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L1255-1313)

## madbot_cli.apply.credentials_hint

*function*

```python
def credentials_hint(spec: Mapping[str, Any]) -> str
```

Say how to give the credentials of a connection.

**Parameters**

- `spec` (`mapping`) — The source or the repository, from the file.

**Returns**

- (`str`) — The variable to set, or that the file must name one.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L83-98)

## madbot_cli.apply.failure_message

*function*

```python
def failure_message(submission: Mapping) -> str | None
```

Return why the last task madbot ran on a submission failed.

**Parameters**

- `submission` (`mapping`) — The submission, as the API returns it.

**Returns**

- (`str or None`) — The message of the failure, such as what the repository answered; None when the last task did not fail.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L101-117)

## madbot_cli.apply.node_outcome

*function*

```python
def node_outcome(node: Node, linked: Linked) -> dict
```

Count the data of a node by their state, for the summary of apply.

**Parameters**

- `node` (`Node`) — The node, from the file.
- `linked` (`Linked`) — Its data, as apply leaves them.

**Returns**

- (`dict`) — Its ``label``, and its data ``read``, still ``reading`` and ``failed_data``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/apply.py#L1316-1340)
