Local - Access your data locally

class manta_light.local.Local(host: str | None = None, port: int | None = None, swarm_id: PairId | None = None, task_id: PairId | None = None)

Local service for accessing local data securely

The Local service allows the user to get local data.

Parameters should not be fulfill manually. Instead, it is managed during the deployment of the task by the Node.

Parameters:
  • host (Optional[str]) – Manager host

  • port (Optional[int]) – Manager port

  • swarm_id (Optional[PairId]) – Swarm ID

  • task_id (Optional[PairId]) – Task ID

get_numpy_data(dataset_name: str) bytes

Get the numpy data

Parameters:

dataset_name (str) – The name of the dataset to get

Returns:

The numpy data

Return type:

bytes

Examples

Inside a Task class, you can access to local data by using the attribute self.local automatically created by Task <manta_light.task.Task:

>>> mnist_data = self.local.get_numpy_data("mnist.npz")
>>> data = np.load(mnist_data)
get_binary_data(dataset_name: str) BytesIO

Get the binary data

Parameters:

dataset_name (str) – The name of the dataset to get

Returns:

The binary data

Return type:

io.BytesIO

Examples

Inside a Task class, you can access to local data by using the attribute self.local automatically created by Task <manta_light.task.Task:

>>> mnist_data = self.local.get_binary_data("mnist.npz")
>>> data = np.load(mnist_data)
list_directories(directory: str) List[str]

List directories

Parameters:

directory (str) – Directory name

Returns:

List of directories

Return type:

List[str]

read_file_lines(file_name: str) List[str]

Read file lines

Parameters:

file_name (str) – File name

Returns:

List of lines

Return type:

List[str]

async async_get_numpy_data(dataset_name: str) BytesIO

Get Numpy Data

Parameters:

dataset_name (str) – Dataset name

Returns:

Binary data

Return type:

io.BytesIO

Examples

Same as select but asynchronous:

>>> mnist_data = await self.local.async_get_numpy_data("mnist.npz")
>>> data = np.load(mnist_data)
async async_get_binary_data(dataset_name: str) BytesIO

Asynchronously get binary data

Parameters:

dataset_name (str) – Dataset name

Returns:

Binary data

Return type:

io.BytesIO

Examples

Same as select but asynchronous:

>>> mnist_data = await self.local.async_get_binary_data("mnist.npz")
>>> data = np.load(mnist_data)
async async_list_directories(directory: str) List[str]

List directories

Parameters:

directory (str) – Directory name

Returns:

List of directories

Return type:

List[str]

async async_read_file_lines(file_name: str) List[str]

Read file lines

Parameters:

file_name (str) – File name

Returns:

List of lines

Return type:

List[str]