api Package

api Package

This module provides the API for fastr that users should use. This API will be considered stable between major versions. If users only interact via this API (and refrain from operating on parent attributes), their code should be compatible within major version of fastr.

class fastr.api.ResourceLimit(cores=1, memory='2G', time=None)[source]

Bases: object

__eq__(other)[source]

Check if two resource limits are equal

Parameters

other – resource limit to test against

Return type

bool

__getstate__()[source]
Return type

dict

__hash__ = None
__init__(cores=1, memory='2G', time=None)[source]

An object describing resource requirements/limits for a node

Parameters
  • cores (Optional[int]) – number of cores

  • memory (Union[str, int, None]) – memory specification, can be int with number of megabytes or a string with numbers ending on M, G, T, P for megabytes, gigabytes, terrabytes or petabytes. Note that the number has to be an integer, e.g. 1500M would work, whereas 1.5G would be invalid

  • time (Union[str, int, None]) – run time specification, this can be an int with the number of seconds or a string in the HH:MM:SS, MM:SS, or SS format. Where HH, MM, and SS are integers representing the number of hours, minutes and seconds.

__module__ = 'fastr.core.resourcelimit'
__ne__(other)[source]

Check if two resource limits are not equal

Parameters

other – resource limit to test against

Return type

bool

__setstate__(state)[source]
__slots__ = ('_cores', '_memory', '_time')
copy()[source]

Return a copy of current resource limit object

Return type

ResourceLimit

property cores

The required number of gpus

Return type

int

property memory

The required memory in megabytes

Return type

int

property time

The required time in seconds

Return type

int

fastr.api.create_network(id, version=None)[source]

Create a new Network object

Parameters
  • id (str) – id of the network

  • version (Union[Version, str, None]) – version of the network

Return type

Network

Returns

fastr.api.create_network_copy(network_state)[source]

Create a network based on another Network state. The network state can be a Network or the state gotten from a Network with __getstate__.

Parameters

network_state (Union[Network, Network, dict]) – Network (state) to create a copy of

Return type

Network

Returns

The rebuilt network