Skip to content

madbot_cli.operations

The steps of a deposit in madbot, each with explicit inputs.

Each function takes a Client and the identifiers it works on, and returns what the API answered. None of them reads a deposit file: a platform that writes Python can chain them in its own tool. madbot_cli.plan and madbot_cli.apply chain them from a file.

Functions named find_* and list_* only read; the others write.

Attributes

NameDescription
BATCH_SIZEMost data the API takes in one batch (DATALINK_BATCH_MAX_SIZE of the instance).
DATA_ACTIVEState of a data madbot has read from its source.
DATA_FAILEDState of a data madbot failed to read: see its enrichment_error.
DATA_IN_PROGRESSState of a data madbot is reading from its source.
FOUND_SHOWNThe most names a message gives of what a folder holds instead of the name sought.
LogCalled with a message for each change and failure.
NODE_ACTIVEState of a node in use.
NODE_PENDINGState of a node madbot was given no state for: the web application shows it
RATE_LIMITEDThe code of a source that refuses requests for a while.
SEARCH_MIN_LENGTHThe shortest text the API searches for (EXTERNAL_SEARCH_MIN_LENGTH of the instance).
SUBMISSION_BUSYStates of a submission while madbot works on it in the background.

Functions

NameDescription
activate_nodeMake a node created as a draft (NODE_PENDING) a node in use.
add_submission_dataAdd data of a node to a submission.
alias_ofMake the alias of a sample name, as the web application makes it.
apply_samplesCreate the missing samples of a plan and bind their data to them.
bind_sampleBind a data of a node to a sample of that node.
browseList what a source holds at one level.
browse_pathFollow a path of names from the root of a source.
close_namesFind the names of a folder close to a name, whatever their case.
connectConnect the workspace to a source or a repository, or give the account its credentials.
create_nodeCreate a node in the workspace of the client, at the top or under a node.
create_sampleCreate a sample in a node.
create_submissionCreate a submission to a repository.
create_workspaceCreate a workspace, owned by the account.
current_valueReturn the value of a metadata item of a submission.
data_nameReturn the name of the data of a datalink.
error_codesGive the codes of a madbot error answer and of its details.
error_messageReturn the message of an error the API reports, such as why a data could not be read.
find_connectionFind the connection of a plugin with given shared parameters.
find_in_sourceResolve a path of names and a pattern into the external identifiers of a source.
find_nodeFind a node by its title, at the top of the workspace or under a node.
find_submissionFind a submission of the workspace by its title.
find_workspaceFind a workspace of the account by its name.
found_by_searchFind an object a folder does not list, by searching the source.
found_insteadSay what a folder holds instead of a name not found, in a few names.
generate_metadataAsk madbot to make the metadata of a submission again, and check whether it is ready.
get_submissionRead a submission.
is_connectedTell whether the account has working credentials for a connection.
is_emptyTell whether a metadata value is empty.
link_dataLink data of a source to a node, by batches.
list_child_nodesList the nodes right under a node.
list_datalinksList the data linked to a node.
list_metadata_objectsList the metadata objects of a submission with their values.
list_pluginsList the plugins of the instance.
list_root_nodesList the nodes at the top of the workspace of the client.
list_sample_datalinksReturn the datalinks bound to a sample.
list_samplesList the samples of a node.
list_submission_dataList the data of a submission.
list_submissionsList the submissions of the workspace of the client.
missing_metadataList the metadata objects of a submission that still lack mandatory values.
object_idReturn the identifier of an object the API gives either embedded or by identifier.
plan_samplesGroup the data of a node into samples, by the sample group of a pattern.
plugin_id_ofReturn the plugin identifier of a connection.
reads_without_credentialsTell whether a plugin reads the public data of its source without credentials.
resolve_pluginFind a plugin by its identifier or its slug.
retry_dataRead again from its source a data madbot failed to read.
searchSearch the data of a source, one page of results.
set_metadataGive values to fields of a metadata object of a submission, replacing those already there.
shared_params_ofReturn the shared parameters of a connection as a mapping.
submitSend a ready submission to its repository. This cannot be undone.
wait_for_dataWait until madbot has read the data of some batches from their sources.
wait_submissionWait until madbot no longer works on a submission in the background.

BATCH_SIZEattributemodule attribute#

BATCH_SIZE = 1000

Most data the API takes in one batch (DATALINK_BATCH_MAX_SIZE of the instance).

DATA_ACTIVEattributemodule attribute#

DATA_ACTIVE = 'active'

State of a data madbot has read from its source.

DATA_FAILEDattributemodule attribute#

DATA_FAILED = 'failed'

State of a data madbot failed to read: see its enrichment_error.

DATA_IN_PROGRESSattributemodule attribute#

DATA_IN_PROGRESS = 'in progress'

State of a data madbot is reading from its source.

FOUND_SHOWNattributemodule attribute#

FOUND_SHOWN = 10

The most names a message gives of what a folder holds instead of the name sought.

Logattributemodule attribute#

Log = Callable[[str], None]

Called with a message for each change and failure.

NODE_ACTIVEattributemodule attribute#

NODE_ACTIVE = 'active'

State of a node in use.

NODE_PENDINGattributemodule attribute#

NODE_PENDING = 'pending'

State of a node madbot was given no state for: the web application shows it as a draft and asks how to create it.

RATE_LIMITEDattributemodule attribute#

RATE_LIMITED = 'rate_limited'

The code of a source that refuses requests for a while.

SEARCH_MIN_LENGTHattributemodule attribute#

SEARCH_MIN_LENGTH = 3

The shortest text the API searches for (EXTERNAL_SEARCH_MIN_LENGTH of the instance).

SUBMISSION_BUSYattributemodule attribute#

SUBMISSION_BUSY = {'generating metadata', 'submission in progress'}

States of a submission while madbot works on it in the background.

activate_nodefunction#

def activate_node(client: Client, node: Mapping) -> dict

Make a node created as a draft (NODE_PENDING) a node in use.

Its title, description and icon are sent back as they are: the API replaces the node with what it is given.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
nodemappingThe node, as the API gives it.

Returns

dict
The node.

add_submission_datafunction#

def add_submission_data(client: Client, submission_id: str, datalinks: Iterable[Mapping]) -> list[dict]

Add data of a node to a submission.

madbot then makes the metadata objects of the submission again, in the background: wait for it with wait_submission.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
submission_idstrThe submission.
datalinksiterable of mappingThe datalinks whose data to add, none already in the submission.

Returns

list of dict
The data added.

alias_offunction#

def alias_of(name: str) -> str

Make the alias of a sample name, as the web application makes it.

Parameters

NameTypeDescription
namestrThe sample name.

Returns

str
The name without its accents, in lower case, with every character other than a letter, a digit or a space removed, then each run of spaces replaced by ”-”: Élevage_1 (A) gives elevage1-a. A sample created in the web application is thus found again.

apply_samplesfunction#

def apply_samples(client: Client, node_id: str, plan: Mapping, log: Log = _silent) -> dict

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

A failure is reported and the next sample or data is handled.

Parameters

NameTypeDefaultDescription
clientClientrequiredThe client, with its workspace set.
node_idstrrequiredThe node.
planmappingrequiredThe plan made by plan_samples.
logcallable_silentCalled with a message for each change and failure.

Returns

dict
created, linked and already_linked counts, the failures, and for each sample its alias, id and bound files.

bind_samplefunction#

def bind_sample(client: Client, data_id: str, datalink_id: str, sample_id: str) -> bool

Bind a data of a node to a sample of that node.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
data_idstrThe data.
datalink_idstrIts datalink in the node of the sample.
sample_idstrThe sample.

Returns

bool
True when the binding is new, False when it was already there.

browsefunction#

def browse(client: Client, connection_id: str, parent: str | None = None) -> list[dict]

List what a source holds at one level.

Parameters

NameTypeDefaultDescription
clientClientrequiredThe client, with its workspace set.
connection_idstrrequiredThe connection to the source.
parentstrNoneThe id (external identifier) of a container; the root of the source when None.

Returns

list of dict
The objects, each with its id, name, type and has_children.

browse_pathfunction#

def browse_path(client: Client, connection_id: str, path: Iterable[str]) -> str | None

Follow a path of names from the root of a source.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
connection_idstrThe connection to the source.
pathiterable of strThe names of the containers, from the root.

Returns

str or None
The external identifier of the last container, None for the root.

Raises

MadbotError
When a name is not found, with the names found at that level.

close_namesfunction#

def close_names(name: str, names: Iterable[str]) -> list[str]

Find the names of a folder close to a name, whatever their case.

Parameters

NameTypeDescription
namestrThe name sought.
namesiterable of strThe names the folder holds.

Returns

list of str
At most FOUND_SHOWN names: those equal to name but for the case first, such as README.md for readme.md, then the closest.

connectfunction#

def connect(client: Client, plugin_id: str, shared_params: Mapping[str, Any], private_params: Mapping[str, Any] | None = None, name: str | None = None) -> dict

Connect the workspace to a source or a repository, or give the account its credentials.

The API returns the existing connection when one has the same plugin and shared parameters, and stores the credentials of the account for it.

Parameters

NameTypeDefaultDescription
clientClientrequiredThe client, with its workspace set.
plugin_idstrrequiredThe identifier of the plugin.
shared_paramsmappingrequiredThe parameters shared by the members, such as the address.
private_paramsmappingNoneThe credentials of the account. A repository may go without.
namestrNoneThe name of a new connection; computed by the plugin otherwise.

Returns

dict
The connection.

create_nodefunction#

def create_node(client: Client, title: str, description: str | None = None, parent: str | None = None) -> dict

Create a node in the workspace of the client, at the top or under a node.

Parameters

NameTypeDefaultDescription
clientClientrequiredThe client, with its workspace set.
titlestrrequiredThe title of the node.
descriptionstrNoneIts description.
parentstrNoneThe node to create it under; at the top of the workspace when None.

Returns

dict
The node.

create_samplefunction#

def create_sample(client: Client, node_id: str, title: str, alias: str) -> dict

Create a sample in a node.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
node_idstrThe node.
titlestrThe title of the sample.
aliasstrIts alias, unique in the node.

Returns

dict
The sample.

create_submissionfunction#

def create_submission(client: Client, title: str, connection_id: str, settings: Mapping[str, Any] | None = None) -> dict

Create a submission to a repository.

Parameters

NameTypeDefaultDescription
clientClientrequiredThe client, with its workspace set.
titlestrrequiredThe title of the submission.
connection_idstrrequiredThe connection to the repository.
settingsmappingNoneThe settings the repository asks for, such as a checklist.

Returns

dict
The submission.

create_workspacefunction#

def create_workspace(client: Client, name: str) -> dict

Create a workspace, owned by the account.

Parameters

NameTypeDescription
clientClientThe client.
namestrThe name of the workspace.

Returns

dict
The workspace.

current_valuefunction#

def current_value(item: Mapping) -> Any

Return the value of a metadata item of a submission.

Parameters

NameTypeDescription
itemmappingA metadata item, as include_metadata=true lists it.

Returns

Any
Its value, None when it has none.

data_namefunction#

def data_name(datalink: Mapping) -> str

Return the name of the data of a datalink.

Parameters

NameTypeDescription
datalinkdictA datalink as the API lists it.

Returns

str
The name of its data, "" when it has none.

error_codesfunction#

def error_codes(error: ApiError) -> set[str]

Give the codes of a madbot error answer and of its details.

Parameters

NameTypeDescription
errorApiErrorThe failed request.

Returns

set of str
Its code and the code of each of its details.

error_messagefunction#

def error_message(error: Any) -> str

Return the message of an error the API reports, such as why a data could not be read.

Parameters

NameTypeDescription
errorAnyThe error: a dict with a message, a text, or None.

Returns

str
Its message.

find_connectionfunction#

def find_connection(connections: Iterable[Mapping], plugin_id: str, shared_params: Mapping[str, Any]) -> dict | None

Find the connection of a plugin with given shared parameters.

madbot keeps one connection per plugin and shared parameters in a workspace: this is how a connection is recognised.

Parameters

NameTypeDescription
connectionsiterable of dictThe connections of the workspace.
plugin_idstrThe identifier of the plugin.
shared_paramsmappingThe shared parameters, such as the address of the source.

Returns

dict or None
The connection, None when there is none.

find_in_sourcefunction#

def find_in_source(client: Client, connection_id: str, path: Iterable[str], match: str = '*') -> list[dict]

Resolve a path of names and a pattern into the external identifiers of a source.

The external identifier of a data has a format of its own in each plugin; a path of names is easier to write. The source is browsed through the API: nothing is written.

Parameters

NameTypeDefaultDescription
clientClientrequiredThe client, with its workspace set.
connection_idstrrequiredThe connection to the source.
pathiterable of strrequiredThe names of the containers to open, from the root.
matchstr'*'A shell-style pattern (*.csv) the names of the objects found there must match.

Returns

list of dict
external_id and name of each object found, sorted by name.

find_nodefunction#

def find_node(client: Client, title: str, parent: str | None = None) -> dict | None

Find a node by its title, at the top of the workspace or under a node.

A node has no other name than its title: look for it before creating it, so that a second run creates nothing twice.

Parameters

NameTypeDefaultDescription
clientClientrequiredThe client, with its workspace set.
titlestrrequiredThe title of the node.
parentstrNoneThe node to look under; the top of the workspace when None.

Returns

dict or None
The node, None when there is none of that title.

Raises

MadbotError
When several nodes have that title there: madbot cannot tell which one is meant.

find_submissionfunction#

def find_submission(client: Client, title: str, connection_id: str | None = None) -> dict | None

Find a submission of the workspace by its title.

A submission has no other name than its title: look for it before creating it, so that a second run creates nothing twice.

Parameters

NameTypeDefaultDescription
clientClientrequiredThe client, with its workspace set.
titlestrrequiredThe title of the submission.
connection_idstrNoneThe connection to the repository it must go to.

Returns

dict or None
The submission, None when the workspace has none of that title.

Raises

MadbotError
When several submissions have that title, or the one of that title goes to another repository than connection_id. Two submissions of the same title are refused even when they go to two repositories: connection_id checks the one found, it does not choose between them, as madbot-cli plan does.

find_workspacefunction#

def find_workspace(client: Client, name: str) -> dict | None

Find a workspace of the account by its name.

Parameters

NameTypeDescription
clientClientThe client.
namestrThe name of the workspace.

Returns

dict or None
The workspace, None when the account has none of that name.
def found_by_search(client: Client, connection_id: str, name: str, parent: str | None) -> dict | None

Find an object a folder does not list, by searching the source.

The object found is the one whose identifier or name is name, else the only result of the search, such as the record a DOI names. Only a folder that lists nothing is searched, such as the root of Zenodo.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
connection_idstrThe connection to the source.
namestrThe name, identifier or DOI written in the path.
parentstr or NoneThe container searched; the whole source when None.

Returns

dict or None
The object; None when the search finds none or several, or when the source cannot search.

found_insteadfunction#

def found_instead(name: str, children: list[dict]) -> str

Say what a folder holds instead of a name not found, in a few names.

A folder may hold thousands of objects: the message gives those close to the name sought, else the first ones, and how many there are.

Parameters

NameTypeDescription
namestrThe name sought.
childrenlist of dictWhat the folder holds.

Returns

str
Such as Close to it: raw, raw-old (1,204 in all; madbot-cli browse lists them).

generate_metadatafunction#

def generate_metadata(client: Client, submission_id: str) -> dict

Ask madbot to make the metadata of a submission again, and check whether it is ready.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
submission_idstrThe submission.

Returns

dict
The submission, generating its metadata.

get_submissionfunction#

def get_submission(client: Client, submission_id: str) -> dict

Read a submission.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
submission_idstrThe submission.

Returns

dict
The submission, with its status, errors, error_reason and external_identifiers.

is_connectedfunction#

def is_connected(connection: Mapping) -> bool

Tell whether the account has working credentials for a connection.

Parameters

NameTypeDescription
connectiondictA connection as the API returns it.

Returns

bool
True when its credential is connected.

is_emptyfunction#

def is_empty(value: Any) -> bool

Tell whether a metadata value is empty.

Parameters

NameTypeDescription
valueAnyThe value.

Returns

bool
True for None, an empty text, an EditorJS text without blocks (as the web client saves a cleared description, with its time and version), or a mapping or a list whose parts are all empty (none at all included).
def link_data(client: Client, node_id: str, connection_id: str, items: Iterable[Mapping[str, str]], batch_size: int = BATCH_SIZE) -> list[dict]

Link data of a source to a node, by batches.

Data already linked to the node are left as they are. madbot then reads each new data from its source in a background task: wait for it with wait_for_data.

Parameters

NameTypeDefaultDescription
clientClientrequiredThe client, with its workspace set.
node_idstrrequiredThe node.
connection_idstrrequiredThe connection to the source.
itemsiterable of mappingrequiredEach data, as {"external_id": ..., "name": ...}; the name is optional and shown until the data is read.
batch_sizeintBATCH_SIZEMost data sent in one request.

Returns

list of dict
The answer to each batch: task_id, created, existing and results.

list_child_nodesfunction#

def list_child_nodes(client: Client, parent_id: str) -> list[dict]

List the nodes right under a node.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
parent_idstrThe parent node.

Returns

list of dict
Its child nodes, not their own children.
def list_datalinks(client: Client, node_id: str, status: str | None = None) -> list[dict]

List the data linked to a node.

Parameters

NameTypeDefaultDescription
clientClientrequiredThe client, with its workspace set.
node_idstrrequiredThe node.
statusstrNoneOnly the data in this state: active, in progress or failed.

Returns

list of dict
The datalinks, each with its data (id, name, connection, external_id, status, enrichment_error).

list_metadata_objectsfunction#

def list_metadata_objects(client: Client, submission_id: str) -> list[dict]

List the metadata objects of a submission with their values.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
submission_idstrThe submission.

Returns

list of dict
Each object with its type, summary_fields and metadata_items: the field (slug, level) and its value.

list_pluginsfunction#

def list_plugins(client: Client) -> list[dict]

List the plugins of the instance.

Parameters

NameTypeDescription
clientClientThe client.

Returns

list of dict
The plugins, each with its id (the path a connection names) and its slug.

list_root_nodesfunction#

def list_root_nodes(client: Client) -> list[dict]

List the nodes at the top of the workspace of the client.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.

Returns

list of dict
The nodes without a parent.
def list_sample_datalinks(client: Client, node_id: str, sample_id: str) -> set[str]

Return the datalinks bound to a sample.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
node_idstrThe node of the sample.
sample_idstrThe sample.

Returns

set of str
The identifiers of its datalinks.

list_samplesfunction#

def list_samples(client: Client, node_id: str) -> list[dict]

List the samples of a node.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
node_idstrThe node.

Returns

list of dict
The samples, each with its id, alias and title.

list_submission_datafunction#

def list_submission_data(client: Client, submission_id: str) -> list[dict]

List the data of a submission.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
submission_idstrThe submission.

Returns

list of dict
Each data of the submission, with its data and datalink.

list_submissionsfunction#

def list_submissions(client: Client) -> list[dict]

List the submissions of the workspace of the client.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.

Returns

list of dict
Each submission, with its title, status and connection.

missing_metadatafunction#

def missing_metadata(client: Client, submission_id: str) -> list[dict]

List the metadata objects of a submission that still lack mandatory values.

Give the values with set_metadata, object by object. Once none is left, generate_metadata has madbot check the submission as a whole.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
submission_idstrThe submission, its metadata made (see wait_submission).

Returns

list of dict
Each object with mandatory fields still empty: its id, type and summary_fields (such as its alias), and missing, each field (slug, name, description) to fill.

object_idfunction#

def object_id(value: Any) -> str | None

Return the identifier of an object the API gives either embedded or by identifier.

Parameters

NameTypeDescription
valueAnyA dict with an id, an identifier, or None.

Returns

str or None
The identifier.

plan_samplesfunction#

def plan_samples(datalinks: Iterable[Mapping], samples: Iterable[Mapping], pattern: re.Pattern | str, bound: Mapping[str, set[str]] | None = None) -> dict

Group the data of a node into samples, by the sample group of a pattern.

Nothing is read nor written: the inputs come from the API.

Parameters

NameTypeDefaultDescription
datalinksiterable of dictrequiredThe datalinks the samples are made from.
samplesiterable of dictrequiredThe samples already on the node, found again by their alias, else by their title.
patternre.Pattern or strrequiredA regular expression with a sample group, searched in each data name.
boundmappingNoneThe datalinks already bound to each sample, by sample identifier.

Returns

dict
samples: one entry per sample, {alias, title, exists, sample_id, files: [{name, datalink, data, linked}]}; ignored: the names that do not match; warnings: names that give the same alias.

plugin_id_offunction#

def plugin_id_of(connection: Mapping) -> str | None

Return the plugin identifier of a connection.

Parameters

NameTypeDescription
connectiondictA connection as the API returns it.

Returns

str or None
The identifier of its plugin.

reads_without_credentialsfunction#

def reads_without_credentials(plugin: Mapping) -> bool

Tell whether a plugin reads the public data of its source without credentials.

Parameters

NameTypeDescription
plugindictA plugin as GET /api/plugins returns it.

Returns

bool
True for a data plugin with supports_anonymous_access; false with an API older than this field.

resolve_pluginfunction#

def resolve_plugin(plugins: Iterable[Mapping], reference: str) -> dict

Find a plugin by its identifier or its slug.

Parameters

NameTypeDescription
pluginsiterable of dictThe plugins of the instance, from list_plugins.
referencestrThe identifier of the plugin (its Python path) or its slug.

Returns

dict
The plugin.

Raises

MadbotError
When the instance has no such plugin.

retry_datafunction#

def retry_data(client: Client, node_id: str, datalink_id: str) -> dict

Read again from its source a data madbot failed to read.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
node_idstrThe node of the datalink.
datalink_idstrThe datalink of the failed data.

Returns

dict
task_id of the new reading, and the datalink.

searchfunction#

def search(client: Client, connection_id: str, query: str, parent: str | None = None) -> dict

Search the data of a source, one page of results.

A source that serves public data to anyone, such as Zenodo, lists nothing at its root: its records are found by searching, by identifier, DOI or title. Follows GET /api/connections/{id}/external_data/search.

Parameters

NameTypeDefaultDescription
clientClientrequiredThe client, with its workspace set.
connection_idstrrequiredThe connection to the source.
querystrrequiredThe text to search, at least SEARCH_MIN_LENGTH characters.
parentstrNoneThe id of a container to search in; the whole source when None.

Returns

dict
count, the number of results in all, results, the first page (each object with its id, name, type and has_children), and message, why it is empty when the source says so.

set_metadatafunction#

def set_metadata(client: Client, submission_id: str, object_id: str, values: Mapping[str, Any]) -> list[dict]

Give values to fields of a metadata object of a submission, replacing those already there.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
submission_idstrThe submission.
object_idstrThe metadata object.
valuesmappingEach value by field slug.

Returns

list of dict
The metadata of the object.

shared_params_offunction#

def shared_params_of(connection: Mapping) -> dict[str, str]

Return the shared parameters of a connection as a mapping.

Parameters

NameTypeDescription
connectiondictA connection as the API returns it.

Returns

dict
Each shared parameter by its key.

submitfunction#

def submit(client: Client, submission_id: str) -> dict

Send a ready submission to its repository. This cannot be undone.

Parameters

NameTypeDescription
clientClientThe client, with its workspace set.
submission_idstrThe submission, ready.

Returns

dict
The submission, being submitted: wait for it with wait_submission.

wait_for_datafunction#

def wait_for_data(client: Client, task_ids: Iterable[str | None], **wait: Any) -> list[dict]

Wait until madbot has read the data of some batches from their sources.

Parameters

NameTypeDefaultDescription
clientClientrequiredThe client.
task_idsiterable of strrequiredThe tasks of the batches; None values are skipped.
**waitAny{}Passed to Client.wait_task, such as timeout.

Returns

list of dict
Each task, with its result: enriched and failed counts, and the outcome of each data in items.

wait_submissionfunction#

def wait_submission(client: Client, submission_id: str, *, timeout: float = 1800, interval: float = 2, on_wait: Callable[[float], None] | None = None) -> dict

Wait until madbot no longer works on a submission in the background.

Parameters

NameTypeDefaultDescription
clientClientrequiredThe client, with its workspace set.
submission_idstrrequiredThe submission.
timeoutfloat1800Seconds to wait in all.
intervalfloat2Seconds between two reads.
on_waitcallableNoneCalled with the seconds waited so far, before each pause: shows the progress.

Returns

dict
The submission, neither generating its metadata nor being submitted.

Raises

WaitTimeout
When it is still busy after timeout seconds.