Agent API

exception supervisely_lib.api.agent_api.AgentNotFound[source]

Bases: Exception

exception supervisely_lib.api.agent_api.AgentNotRunning[source]

Bases: Exception

class supervisely_lib.api.agent_api.AgentApi(api)[source]

Bases: supervisely_lib.api.module_api.ModuleApi, supervisely_lib.api.module_api.ModuleWithStatus

API for working with agent. AgentApi object is immutable.

Parameters

api (Api) – API connection to the server

Usage example
# You can connect to API directly
address = 'https://app.supervise.ly/'
token = 'Your Supervisely API Token'
api = sly.Api(address, token)

# Or you can use API from environment
os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

team_id = 8
agents = api.agent.get_list(team_id)
class Status(value)[source]

Bases: enum.Enum

An enumeration.

WAITING = 'waiting'
RUNNING = 'running'
static info_sequence()[source]

NamedTuple AgentInfo information about Agent.

Example
AgentInfo("some info")
static info_tuple_name()[source]

NamedTuple name - AgentInfo.

get_list(team_id: int, filters: Optional[List[dict]] = None) → List[NamedTuple][source]

List of all agents in the given Team.

Parameters
  • team_id (int) – Team ID in Supervisely.

  • filters (List[dict], optional) – List of params to sort output Agents.

Returns

List of Agents with information. See info_sequence

Return type

List[NamedTuple]

Usage example
os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

team_id = 16087
agents = api.agent.get_list(team_id)

filter_agents = api.agent.get_list(team_id, filters=[{ 'field': 'name', 'operator': '=', 'value': 'Gorgeous Chicken' }])
get_info_by_id(id: int) → NamedTuple[source]

Get Agent information by ID.

Parameters

id (int) – Agent ID in Supervisely.

Returns

Information about Agent. See info_sequence

Return type

NamedTuple

Usage example
os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

agent = api.agent.get_info_by_id(7)
get_status(id: int)Status[source]

Status object containing status of Agent: waiting or running.

Parameters

id (int) – Agent ID in Supervisely.

Returns

Agent Status

Return type

Status

Usage example
os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

agent = api.agent.get_status(7)
raise_for_status(status)[source]
InfoType

alias of supervisely_lib.api.module_api.AgentInfo