Python Sequential High-level API

Python Sequential API module provides high-level functions for initialization of the backend, for working with object storage and submitting tasks.

API

Function is_initialized() allows to check if the execution backend has been initialized.

unidist.core.backends.pyseq.core.api.is_initialized()

Check if Python Sequential backend has already been initialized.

Returns:

True or False.

Return type:

bool

Function init() creates an instance of singleton class ObjectStore.

unidist.core.backends.pyseq.core.api.init()

Initialize an object storage.

Notes

Run initialization of singleton object unidist.core.backends.pyseq.core.object_store.ObjectStore.

Functions get() and put() are responsible for read/write, respectively, objects from/to ObjectStore.

unidist.core.backends.pyseq.core.api.get(data_ids)

Get object(s) associated with data_ids from the object storage.

Parameters:

data_ids (unidist.core.backends.common.data_id.DataID or list) – ID(s) to object(s) to get data from.

Returns:

A Python object.

Return type:

object

unidist.core.backends.pyseq.core.api.put(data)

Put data into object storage.

Parameters:

data (object) – Data to be put.

Returns:

An ID of object in object storage.

Return type:

unidist.core.backends.common.data_id.DataID

submit() executes a task, which result will be put into ObjectStore.

unidist.core.backends.pyseq.core.api.submit(func, *args, num_returns=1, **kwargs)

Execute function.

Parameters:
  • func (callable) – Function to be executed.

  • *args (iterable) – Positional arguments to be passed in the func.

  • num_returns (int, default: 1) – Number of results to be returned from func.

  • **kwargs (dict) – Keyword arguments to be passed in the func.

Returns:

Type of returns depends on num_returns value:

  • if num_returns == 1, DataID will be returned.

  • if num_returns > 1, list of DataID-s will be returned.

  • if num_returns == 0, None will be returned.

Return type:

unidist.core.backends.common.data_id.DataID, list or None