anatools.anaclient module

AnaClient is a python module for accessing Rendered.AI’s Ana Platform API.

class anatools.anaclient.AnaClient(workspaceId=None, environment='prod', verbose=False, email=None, password=None, local=False)

Bases: object

add_channel_access(channelId, organizationId=None)

Add access to a channel for an organization.

Parameters
  • channel (str) – Name of channel to add access for.

  • organizationId (str) – Organization ID. Defaults to current if not specified.

Returns

Access status.

Return type

json

add_member(email, role=None, organizationId=None, workspaceId=None)

Add a user to an existing organization.

Parameters
  • email (str) – Email of user to add.

  • role (str) – Role for user.

  • organizationId (str) – Organization ID to add members too. Uses current if not specified.

  • workspaceId (str) – Workspace ID to add members to. Uses current if not specified.

Returns

Response status if user got added to workspace succesfully.

Return type

str

cancel_dataset(datasetId, workspaceId=None)

Stop a running job.

Parameters
  • datasetId (str) – Dataset ID of the running job to stop.

  • workspaceId (str) – Workspace ID of the running job. If none is provided, the default workspace will get used.

Returns

Succes or error message about stopping the job execution.

Return type

str

create_annotation(datasetId, format, map, workspaceId=None)

Generate an image annotation for an existing dataset.

Parameters
  • datasetId (str) – Dataset ID to generate annotation for.

  • format (str) – Image annotation format. Currently only COCO is supported.

  • map (str) – Image annotation mapping. Currently only afv is supported.

  • workspaceId (str) – Workspace ID of the dataset to generate annotation for. If none is provided, the current workspace will get used.

Returns

Succes or error message about generating the annotation.

Return type

str

create_channel(name, dataVolumes=None, instanceType=None, organizationId=None, timeout=None)

Create a new channel.

Parameters
  • name (str) – Name of new channel.

  • dataVolumes (str or list) – Data Volume name(s) in AWS to use data files from. This is the package that was registered.

  • instanceType (str) – The EC2 instance the channel runs on (ie. p2.xlarge)

  • organizationId (str) – Organization Id for which this channel must belong to. Will create the channel in the current organization if organization Id is not provided.

Returns

Succes or error message about channel creation.

Return type

str

create_dataset(name, graphId, description, interpretations=1, priority=1, seed=1, workspaceId=None)

Create a new dataset based off an existing graph. This will start a new job.

Parameters
  • name (str) – Name for dataset.

  • graphId (str) – Graph ID of the graph to create dataset from.

  • description (str) – Description for new dataset.

  • interpretations (int) – Number of interpretations.

  • priority (int) – Job priority.

  • seed (int) – Seed number.

  • workspaceId (str) – Workspace ID of the graph’s workspace. If none is provided, the current workspace will get used.

Returns

Success or failure message about dataset creation.

Return type

str

create_graph(name, channel, graph, description=None, workspaceId=None)

Generates a new graph based off provided parameters.

Parameters
  • name (str) – Graph name that will get generated.

  • channel (str) – Name of channel to generate the graph with.

  • graph (json) – Location of yaml file. Check out the readme for more details (step 3 for how to use ana)

  • description (str) – Description of graph. Optional.

  • workspaceId (str) – Workspace ID create the graph in. If none is provided, the default workspace will get used.

Returns

The graph id if it was created sucessfully or an error message.

Return type

str

create_managed_channel(name, organizationId=None, dataVolumes=None, instanceType=None, timeout=None)

Create a managed channel for your organization.

Parameters
  • organizationId (str) – Organization ID. Defaults to current if not specified.

  • name (name) – Channel name.

  • dataVolumes (str) – Data volume

  • instanceType (str) – AWS Instance type

  • timeout (int) – Timeout

Returns

channel data

Return type

json

create_organization(name)

Creates a new organization with provided name.

Parameters

name (str) – Name of organization to create.

Returns

True if organization was created successfully, False otherwise.

Return type

Bool

create_workspace(name, channels)

Create a new workspace with specific channels.

Parameters
  • name (str) – New workspace name.

  • channels (list) – List of channel names to add to workspace.

Returns

Workspace ID if creation was successful. Otherwise returns message.

Return type

str

delete_dataset(datasetId, workspaceId=None)

Delete an existing dataset.

Parameters
  • datasetId (str) – Dataset ID of dataset to delete.

  • workspaceId (str) – Workspace ID that the dataset is in. If none is provided, the current workspace will get used.

Returns

Success or failure message about dataset deletion.

Return type

str

delete_graph(graphId, workspaceId=None)

Delete a graph in a workspace.

Parameters
  • graphId (str) – Graph id to delete.

  • workspaceId (str) – Workspace ID of the graph’s workspace. If none is provided, the current workspace will get used.

Returns

A success or error message based on graph’s delete.

Return type

str

delete_organization(organizationId)

Deletes an organization.

Parameters

organizationId (str) – Id of organization to create.

Returns

True if organization was deleted successfully, False otherwise.

Return type

Bool

delete_workspace(workspaceId=None, prompt=True)

Delete an existing workspace.

Parameters
  • workspaceId (str) – Workspace ID for workspace to get deleted. Deletes current workspace if not specified.

  • prompt (bool) – Set to True if avoiding prompts for deleting workspace.

Returns

Success or failure message if workspace was sucessfully removed.

Return type

str

deploy_channel(channel, environment='test')

Deploy a channel between environments.

Parameters
  • channel (str) – Name of channel to deploy.

  • environment (str) – Environment to deploy channel to. Defaults to test environment.

Returns

Succes or error message about channel deployment.

Return type

str

download_annotation(datasetId, annotationId, workspaceId=None)

Download a generated image annotation file.

Parameters
  • datasetId (str) – Dataset ID to download image annotation for.

  • annotationId (str) – Id of previously generated image annotation.

  • workspaceId (str) – Workspace ID of the dataset to generate annotation for. If none is provided, the current workspace will get used.

Returns

URL if annotation download was successful or failure message. The URL can be used within a browser to download the image annotation file.

Return type

str

download_dataset(datasetId, workspaceId=None)

Download a dataset.

Parameters
  • datasetId (str) – Dataset ID of dataset to download.

  • workspaceId (str) – Workspace ID that the dataset is in. If none is provided, the default workspace will get used.

Returns

Success or failure message about dataset download.

Return type

str

download_graph(graphId, workspaceId=None)

Download a graph.

Parameters
  • graphId (str) – Graph ID of the graph to download.

  • workspaceId (str) – Workspace ID of the graph’s workspace. If none is provided, the default workspace will get used.

Returns

A download URL that can be used in the browser or a failure message.

Return type

str

edit_dataset(datasetId, description=None, name=None, workspaceId=None)

Update dataset description.

Parameters
  • datasetId (str) – Dataset ID to update description for.

  • description (str) – New description.

  • name (str) – New name for dataset.

  • workspaceId (str) – Workspace ID of the dataset to get updated. If none is provided, the current workspace will get used.

Returns

Success or failure message about dataset update.

Return type

str

edit_graph(graphId, description=None, name=None, workspaceId=None)

Update graph description and name.

Parameters
  • graphId (str) – Graph id to update.

  • description (str) – New description to update.

  • name (str) – New name to update.

  • workspaceId (str) – Workspace ID of the graph’s workspace. If none is provided, the current workspace will get used.

Returns

A success or error message based on graph’s update.

Return type

str

edit_member(email, role, organizationId=None)

Edit a member’s role.

Parameters
  • email (str) – Member email to edit.

  • role (str) – Role to assign.

  • organizationId (str) – Organization ID to remove member from. Edits member in current organization if not specified.

Returns

Response if member got edited succesfully.

Return type

str

edit_organization(name, organizationId=None)

Update the organization name. Uses current organization if no organizationId provided.

Parameters
  • name (str) – Name to update organization to.

  • organizationId (str) – Organization Id to update.

Returns

True if organization was edited successfully, False otherwise.

Return type

Bool

edit_workspace(name, workspaceId=None, channels=None)

Edit workspace information. Provided channels list will result in the workspace having those channels. If channels is not provided, then no change will occur.

Parameters
  • name (str) – New name to replace old one.

  • workspaceId (str) – Workspace ID for workspace to update.

  • channels (list) – Names of channels to add to workspace.

Returns

Success or failure message if workspace description was sucessfully updated.

Return type

str

get_channels(organizationId=None, workspaceId=None, channelId=None)

Shows all channels available to the user. Can filter by organizationId, workspaceId, or channelId.

Parameters
  • organizationId (str) – Filter channel list on what’s available to the organization.

  • workspaceId (str) – Filter channel list on what’s available to the workspace.

  • channelId (str) – Filter channel list on the specific channelId.

Returns

List of all possible channel names.

Return type

list

get_datasets(datasetId=None, name=None, email=None, workspaceId=None)

Queries the workspace datasets based off provided parameters. Checks on datasetId, name, owner in this respective order within the specified workspace. If only workspace ID is provided, this will return all the graphs in a workspace.

Parameters
  • datasetId (str) – Dataset ID to filter.

  • name (str) – Dataset name.

  • email (str) – Owner of the dataset.

  • workspaceId (str) – Workspace ID of the graph’s workspace. If none is provided, the current workspace will get used.

Returns

Information about the dataset based off the query parameters provided or a failure message.

Return type

str

get_default_graph(channel)

Gets the default graph for a channel.

Parameters

channel – Name of channel to get the default graph for.

Returns

json data representing the graph.

Return type

json

get_graphs(graphId=None, name=None, email=None, workspaceId=None)

Queries the workspace graphs based off provided parameters. Checks on graphId, name, or owner in this respective order within the specified workspace. If only workspace ID is provided, this will return all the graphs in a workspace.

Parameters
  • graphid (str) – GraphID to filter on. Optional.

  • name (str) – Name of the graph to filter on. Optional.

  • email (str) – Owner of graphs to filter on. Optional.

  • workspaceId (str) – Workspace ID to filter on. If none is provided, the default workspace will get used.

Returns

A list of graphs based off provided query parameters if any parameters match.

Return type

list

get_managed_channels(organizationId=None, channel=None)

Get managed channels by organization.

Parameters
  • organizationId (str) – Organization ID. Defaults to current if not specified.

  • channel (name) – Channel name to filter.

Returns

channel data

Return type

json

get_members(organizationId=None, workspaceId=None)

Get users of an organization optionally filtered on workspace.

Parameters
  • organizationId (str) – Organization ID. Defaults to current if not specified.

  • workspaceId (str) – Workspace Id. Optional.

Returns

json object with users of an organization

Return type

json

get_organization_limits(organizationId=None, setting=None)

Get information about Organization limits and setting.

Parameters
  • organizationId (str) – Organization ID. Defaults to current if not specified.

  • setting (str) – Setting name.

Returns

Organization limit information.

Return type

json

get_organization_usage(organizationId, year, month, workspaceId=None, member=None)

Get organization usage optionally filtered on workspace or a user.

Parameters
  • organizationId (str) – Organization ID. Defaults to current if not specified.

  • year (str) – Usage year to filter on.

  • month (str) – Usage month to filter on.

  • workspaceId (str) – Workspace Id. Optional.

  • member (str) – User email. Optional.

Returns

json object with organization usage by channels, instanceType, and time as integer.

Return type

json

get_organizations()

Shows the organizations the user belongs to and the user’s role in that organization.

Returns

List of members emails that belong to a workspace.

Return type

list

get_platform_limits(tier=None, setting=None)

Get information about Platform limits and setting.

Parameters
  • tier (str) – Tier

  • setting (str) – Setting name.

Returns

Platform limit information.

Return type

json

get_workspace()

Get workspace id of current workspace.

Returns

Workspace ID of current workspace.

Return type

str

get_workspace_limits(workspaceId=None, setting=None)

Get information about Organization limits and setting.

Parameters
  • workspaceId (str) – Workspace ID. Defaults to current if not specified.

  • setting (str) – Setting name.

Returns

Workspace limit information.

Return type

json

get_workspaces(organizationId=None, workspaceId=None)

Shows list of workspaces with id, name, and owner data.

Returns

Workspace data for all workspaces for a user.

Return type

dict

login(workspace=None, environment='prod', email=None, password=None)

Log in to ana sdk

Parameters
  • workspace (str) – ID of the workspace to log in to. Uses default if not specified.

  • environment (str) – Environment to log into. Defaults to production.

logout(clear=False)

Logs out of the ana sdk and removes credentials from ana.

register_datafile(package, filepath)

Upload single data file to be available for use with a channel.

Parameters
  • package (str) – File name.

  • filepath (str) – Local directory to search in for the filename. It is the path to the filename.

Returns

Succes or error message about file upload.

Return type

str

register_docker(channel)

Register the docker image of a channel.

Parameters

channel (str) – Channel name for the docker image, this must match the channel docker image.

Returns

Success or failure message about docker registration.

Return type

str

register_package_data(package, location)

Upload a folder to be available for use with a channel. This is used when uploading multiple files.

Parameters
  • package (str) – Folder name of the package inside the location parameter.

  • location (str) – Local directory to search in for the package. It is the path to the package folder.

Returns

Succes or error message about package upload.

Return type

str

remove_channel_access(channelId, organizationId=None)

Remove access to a channel for an organization.

Parameters
  • channel (str) – Name of channel to remove access to.

  • organizationId (str) – Organization ID. Defaults to current if not specified.

Returns

Access status.

Return type

json

remove_member(email, organizationId=None, workspaceId=None)

Remove a member from an existing workspace.

Parameters
  • email (str) – Member email to remove.

  • organizationId (str) – Organization ID to remove member from. Removes from current organization if not specified.

  • workspaceId (str) – Workspace ID to remove member from. Removes from current workspace if not specified.

Returns

Response status if member got removed from organization or workspace succesfully.

Return type

str

set_organization_limit(setting, limit, organizationId=None)

Set Organization limits for a setting.

Parameters
  • organizationId (str) – Organization ID. Defaults to current if not specified.

  • setting (str) – Setting name.

  • limit (int) – Limit to set at.

Returns

Organization limit information.

Return type

json

set_platform_limit(tier, setting, limit)

Set Platform limits for a tier and a setting.

Parameters
  • tier (str) – Tier

  • setting (str) – Setting name.

  • limit (int) – Limit to set.

Returns

Platform limit information.

Return type

json

set_workspace(workspaceId=None)

Set the workspace to the one you wish to work in.

Parameters

workspaceid (str) – Workspace ID for the workspace you wish to work in. Uses default workspace if this is not set.

set_workspace_limit(setting, limit, workspaceId=None)

Get information about Organization limits and setting.

Parameters
  • workspaceId (str) – Workspace ID. Defaults to current if not specified.

  • setting (str) – Setting name.

  • limit (Int) – Limit to set at.

Returns

Workspace limit information.

Return type

json