anatools.anaclient module¶
AnaClient is a python module for accessing Rendered.AI’s Ana Platform API.
- class anatools.anaclient.AnaClient(workspace=None, environment='prod', verbose=False, email=None, password=None)¶
Bases:
object
- accept_invitation_of_workspace(invitationId)¶
Accept an invite to a workspace. Once accepted, user will be able to access and use the workspace.
- Parameters
invitationId (str) – Id of invite to accept.
- Returns
Succes or error message about accepting invite.
- Return type
str
- add_members(members, workspaceid=None)¶
Add members to an existing workspace.
- Parameters
members (str or list) – Single or list of members email to add.
workspaceid (str) – Workspace ID to add members to. Adds to default workspace if not specified.
- Returns
Response status if members got added to workspace succesfully.
- Return type
str
- add_workspace_channel(channel_name, workspaceId=None)¶
Add an existing channel to a workspace.
- Parameters
channel_name (str) – Name of channel to add to workspace.
workspaceId (str) – Workspace ID to add channel into. If none is provided, the default workspace will get used.
- Returns
Succes or error message about adding the channel.
- Return type
str
- create_channel(channel, packages=None, instance=None, organizations=None)¶
Create a new channel.
- Parameters
channel (str) – Name of new channel.
packages (str) – Package name to use data files from. This is the package that was registered.
instance (str) – The EC2 instance the channel runs on (ie. p2.xlarge)
organizations (list) – Organization list for which this channel must belong to.
- Returns
Succes or error message about channel creation.
- Return type
str
- create_dataset(name, graphid, description=None, interpretations=1, priority=1, seed=1, workspaceid=None)¶
Create a new dataset based off an existing graph. This will start a new job.
- Parameters
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 default workspace will get used.
- Returns
Success or failure message about dataset creation.
- Return type
str
- create_graph(name, channel, graph, workspaceid=None)¶
Generates a new graph based off provided parameters.
- Parameters
name (str) – Graph name that will get generated.
channel (str) – Name of the channel to use for the graph.
graph (json) – Location of yaml file. Check out the readme for more details (step 3 for how to use ana)
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_package(name, location)¶
- create_workspace(name, channels, description=None)¶
Create a new workspace with specific channels.
- Parameters
name (str) – New workspace name.
channels (list) – List of channels to add to workspace.
description (str) – Workspace description.
- 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 default 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 default workspace will get used.
- Returns
A success or error message based on graph’s delete.
- Return type
str
- delete_workspace(workspaceid=None)¶
Delete an existing workspace.
- Parameters
workspaceid (str) – Workspace ID for workspace to get deleted.
- 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.
- 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 default 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
- generate_annotation(datasetId, annotation_format, annotation_map, workspaceId=None)¶
Generate an image annotation for an existing dataset.
- Parameters
datasetId (str) – Dataset ID to generate annotation for.
annotation_format (str) – Image annotation format. Currently only COCO is supported.
annotation_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 default workspace will get used.
- Returns
Succes or error message about generating the annotation.
- Return type
str
- get_channels()¶
Shows all channel names.
- Returns
List of all possible channel names.
- Return type
list
- get_datasets(datasetid=None, name=None, owner=None, status=None, workspaceid=None)¶
Queries the workspace datasets based off provided parameters. Checks on datasetid, name, owner, or status 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) – Graph ID of the graph to download.
name (str) – Dataset name.
owner (str) – Owner of the dataset.
status – Status of a dataset, whether it is running, completed, stopped, etc.
workspaceid (str) – Workspace ID of the graph’s workspace. If none is provided, the default workspace will get used.
- Returns
Information about the dataset based off the query parameters provided or a failure message.
- Return type
str
- get_graphs(graphid=None, name=None, owner=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.
owner (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_members(workspaceid=None)¶
Show workspace members.
- Parameters
workspaceid (str) – Workspace ID for showing member list. Uses default workspace if not specified.
- Returns
List of members emails that belong to a workspace.
- Return type
list
- get_workspace()¶
Get workspace id of current workspace.
- Returns
Workspace ID of current workspace.
- Return type
str
- get_workspaces()¶
Shows list of workspaces with id, name, and owner data.
- Returns
Workspace data for all workspaces for a user.
- Return type
dict
- invite_user_to_workspace(email, workspaceId=None)¶
Invite a new or existing user to a workspace. This will send the user an email with the invite.
- Parameters
email (str) – Email of user to send invite to.
workspaceId (str) – Workspace ID to invite user to. If none is provided, the default workspace will get used.
- Returns
Succes or error message about invite creation.
- Return type
str
- 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 keyring.
- register_channel_owner(email, channel)¶
Set a channel owner.
- Parameters
email (str) – Email adress for setting the channel owner to.
channel (str) – Channel name to set the owner for.
- Returns
True if channel owner was registered successfully, false otherwise.
- Return type
bool
- 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_owner(email, channel_name)¶
Remove owner of existing channel.
- Parameters
email (str) – Email address of user to remove as a channel owner.
channel_name (str) – Name of channel.
- Returns
Succes or error message about channel owner removal.
- Return type
str
- remove_members(members, workspaceid=None)¶
Remove members from an existing workspace.
- Parameters
members (str or list) – Single or list of members email to remove.
workspaceid (str) – Workspace ID to remove members from. Removes from default workspace if not specified.
- Returns
Response status if members got removed from workspace succesfully.
- Return type
str
- remove_workspace_channel(channel_name, workspaceId=None)¶
Remove an existing channel to a workspace.
- Parameters
channel_name (str) – Name of channel to remove from workspace.
workspaceId (str) – Workspace ID to remove channel from. If none is provided, the default workspace will get used.
- Returns
Succes or error message about removing the channel.
- Return type
str
- 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.
- stop_execution(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
- update_dataset(datasetid, description, workspaceid=None)¶
Update dataset description.
- Parameters
datasetid (str) – Dataset ID to update description for.
description (str) – New description.
workspaceid (str) – Workspace ID of the dataset to get updated. If none is provided, the default workspace will get used.
- Returns
Success or failure message about dataset update.
- Return type
str
- update_graph(graphid, description, workspaceid=None)¶
Update graph description.
- Parameters
graphid (str) – Graph id to update.
description (str) – New description to update.
workspaceid (str) – Workspace ID of the graph’s workspace. If none is provided, the default workspace will get used.
- Returns
A success or error message based on graph’s update.
- Return type
str
- update_workspace(description, workspaceid=None)¶
Update workspace description.
- Parameters
description (str) – New description to replace old one.
workspaceid (str) – Workspace ID for workspace to update.
- Returns
Success or failure message if workspace description was sucessfully updated.
- Return type
str