Configuration module¶
As a robotic developer, you need to represent, store, and review parameters. Additionally, you might want to access parameters in your source code, modify a subset of parameters for a particular robot, or add new parameters and apply those to a group of robots.
The rapyuta.io platform provides a mechanism that allows a developer to set, review, update and override configuration for any connected robot. Configuration parameters in the rapyuta.io platform are represented by a tree-like hierarchical structure called configuration hierarchy.
Client Module¶
- class Client(auth_token, project=None)¶
Client class provides access to device, package, volume and deployment classes.
- __init__(auth_token, project=None)¶
Get new client object
- Parameters
auth_token (string) – Authentication token
project (string) – project_guid of the user
- apply_parameters(device_list, tree_names=None, retry_limit=0)¶
Applies configuration parameters for the given device_list. If tree_names is given, only these trees are applied.
- Parameters
- Returns
List of dictionaries - each with device_id, bool success status, and an error message if the success status is False for that device_id
- Return type
Following example demonstrates how to use apply_parameters and handle errors.
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> devices = client.get_all_devices() >>> response = client.apply_parameters([device.deviceId for device in devices]) >>> for device in response: ... if not device['success']: ... print device['device_id'], device['error']
- download_configurations(rootdir, tree_names=None, delete_existing_trees=False)¶
Download all configurations to rootdir following the same directory structure. If rootdir does not exist, it is created.
- Parameters
rootdir (str) – Path to directory to store downloaded configurations
tree_names (list[str], optional) – List of specific configuration trees to download. If None, all trees are downloaded
delete_existing_trees (bool, optional) – For each tree to download, delete existing tree on the filesystem. Defaults to False
Following example demonstrates how to use download_configurations and handle errors.
>>> from rapyuta_io import Client >>> from rapyuta_io.utils.error import APIError, InternalServerError, ConfigNotFoundException >>> client = Client(auth_token='auth_token', project='project_guid') >>> try: ... client.download_configurations('path/to/destination_dir', ... tree_names=['config_tree1', 'config_tree2'], ... delete_existing_trees=True) ... except (APIError, InternalServerError) as e: ... print('failed API request', e.tree_path, e) except ConfigNotFoundException as e: print ('config not found') ... except (IOError, OSError) as e: ... print('failed file/directory creation', e)
- upload_configurations(rootdir, tree_names=None, delete_existing_trees=False, as_folder=False)¶
Traverses rootdir and uploads configurations following the same directory structure.
- Parameters
rootdir (str) – Path to directory containing configurations
tree_names (list[str], optional) – List of specific configuration trees to upload. If None, all trees under rootdir are uploaded
delete_existing_trees (bool, optional) – For each tree to upload, delete existing tree at the server. Defaults to False
as_folder – For each tree to upload, upload as an folder hierarchy
- As_folder
bool, optional
Following example demonstrates how to use upload_configurations and handle errors.
>>> from rapyuta_io import Client >>> from rapyuta_io.utils.error import BadRequestError, InternalServerError >>> client = Client(auth_token='auth_token', project='project_guid') >>> try: ... client.upload_configurations('path/to/configs/source_dir', ... tree_names=['config_tree1', 'config_tree2'], ... delete_existing_trees=True) ... except (BadRequestError, InternalServerError) as e: ... print 'failed API request', e.tree_path, e ... except (IOError, OSError) as e: ... print 'failed file/directory read', e