Package module

A package is a fundamental rapyuta.io resource that represents a declaration of your application. It is the smallest unit of deployment in rapyuta.io, and it can be deployed either on a device or the cloud or both.

To make this possible a package must encapsulate any information about how it should be built, its compatibility and runtime requirements, network endpoints and ROS interfaces it exposes, and any configuration information it may require.

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

create_package(manifest, retry_limit=0)

Create package from manifest dict.

Parameters
  • manifest (dict) – dict containing package details

  • retry_limit (int) – No of retry attempts to be carried out if any failures occurs during the API call.

Raises

ConflictError: Package already exists.

Raises

BadRequestError: Invalid package details.

Returns

dict containing package details

Following example demonstrates how to use create_package.

>>> manifest = {'packageVersion': 'v1.0.0',
     'plans': ['singleton': False,
     'name': 'default',
     'inboundROSInterfaces': {'services': [], 'topics': [], 'actions': []},
     'dependentDeployments': [],
     'components': [{'executables': [{'cmd': ['roslaunch listener listener.launch'],
         'name': 'listenerExec'}],
         'name': 'default',
         'parameters': [],
         'architecture': 'arm32v7',
         'requiredRuntime': 'device',
         'ros': {'services': [], 'topics': [], 'isROS': True, 'actions': []},
         'description': ''}],
         'exposedParameters': [],
         'metadata': {}}],
     'name': 'listener',
     'apiVersion': 'v1.0.0',
     'description': 'listener arm32v7 sdk test package'}
>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> package_details = client.create_package(manifest)
create_package_from_manifest(manifest_filepath, retry_limit=0)

Create package from a manifest file

Parameters
  • manifest_filepath (string) – File path of the manifest

  • retry_limit (int) – No of retry attempts to be carried out if any failures occurs during the API call.

Raises

ConflictError: Package already exists.

Raises

BadRequestError: Invalid package details.

Returns

dict containing package details

Copy the below json to listener.json file

Following example demonstrates how to use create_package_from_manifest.

{ "packageVersion": "v1.0.0", "plans": [{"singleton": false,
"name": "default", "inboundROSInterfaces": {"services": [], "topics": [],
"actions": []}, "dependentDeployments": [], "components": [{"executables": [{"cmd":
["roslaunch listener listener.launch"], "name": "listenerExec"}],
"name": "default", "parameters": [], "architecture": "arm32v7", "requiredRuntime":
 "device", "ros": {"services": [], "topics": [], "isROS": true, "actions": []},
  "description": ""}], "exposedParameters": [], "metadata": {}}], "name": "listener",
  "apiVersion": "v1.0.0", "description": "listener arm32v7 sdk test package" }
>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> package_details = client.create_package_from_manifest('listener.json')
delete_package(package_id)

Delete a package.

Parameters

package_id (str) – ID of the package to be deleted.

Following example demonstrates how to delete a package.

>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> client.delete_package('package_id')
get_all_packages(retry_limit=0, name=None, version=None)

Get list of all packages created by the user.

Parameters
  • retry_limit (int) – Number of retry attempts to be carried out if any failures occurs during the API call.

  • name (str) – Optional parameter to filter the packages based on substring of the package name.

  • version (str) – Optional parameter to filter the packages based on the version of the package.

Returns

List of all packages. Each package is an instance of Package class.

Raises

APIError: If the API returns an error, a status code of anything other than 200/201 is returned.

Following example demonstrates how to get the packages

>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> package_list = client.get_all_packages()
>>> pacakge_list_filter_by_name = client.get_all_packages(name='test-name')
>>> pacakge_list_filter_by_version = client.get_all_packages(version='v0.0.0')
get_package(package_id, retry_limit=0)

Get package class

Parameters
  • package_id (string) – Package ID

  • retry_limit (int) – Number of retry attempts to be carried out if any failures occurs during the API call.

Returns

an instance of Package class.

Raises

PackageNotFound: If the given package id is not found.

Raises

ComponentNotFoundException: If the plan inside the package does not have components.

Raises

APIError: If the API returns an error, a status code of anything other than 200/201 is returned.

Following example demonstrates how to get the packages

>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> package = client.get_package('test_package_id')

Package Module

class ExecutableMount(exec_name, mount_path, sub_path=None)

ExecutableMount defines the mount details specific to an executable.

Variables
  • exec_name (str) – Name of the executable.

  • mount_path (str) – Mountpath of the executable

  • sub_path (str) – Subpath of the executable

Parameters
  • exec_name (str) – Name of the executable.

  • mount_path (str) – Mountpath of the executable

  • sub_path (str) – Subpath of the executable

class Package(*args, **kwargs)

Package class represents a service package. It contains method to provision an instance of the package on cloud or on device. Additionally, it provides other utility method.

Variables marked as (full-only) are only available on a full object. Use refresh() to convert a partial object into a full one.

Variables
  • packageId – Id of the package.

  • packageName – Package name.

  • packageVersion – Version of the package.

  • apiVersion – (full-only) Package API Version.

  • bindable – Package is bindable or not.

  • description – Description of the package.

  • category – (full-only) Package category.

  • plans (list(Plan)) – (full-only) List of plans associated with the package.

  • isPublic – (full-only) Boolean denoting whether the package is public or not.

  • status – (full-only) Status of the package.

  • tags – (full-only) Tags associated with the package.

  • buildGeneration – (full-only) Build generation.

  • ownerProject – (full-only) Owner project guid.

  • creator – (full-only) Creator user guid.

  • CreatedAt – (full-only) Date of creation.

  • UpdatedAt – (full-only) Date of updation.

  • DeletedAt – (full-only) Date of deletion.

delete()

Delete the package using the package object.

Following example demonstrates how to delete a package using package object:

>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> package = client.get_package(package_id='package_id')
>>> package.delete()
deployments(phases=None, retry_limit=0)

Get all the deployments of the package

Parameters
  • phases (list(DeploymentPhaseConstants)) – optional parameter to filter out the deployments based on current deployment

  • retry_limit (int) – Optional parameter to specify the number of retry attempts to be carried out if any failures occurs during the API call.

Returns

list of instance of class Deployment:

Raises

APIError: If deployment info api return an error, the status code is anything other than 200/201

Following example demonstrates how to the deployment list

>>> from rapyuta_io import Client, DeploymentPhaseConstants
>>> client = Client(auth_token='auth_token', project='project')
>>> package = client.get_package('test_package_id')
>>> package.deployments()
>>> deployments_list_filtered_by_phase = package.deployments(phases=
>>>   [DeploymentPhaseConstants.SUCCEEDED, DeploymentPhaseConstants.PROVISIONING])
get_provision_configuration(plan_id=None)

Get provision configuration payload for package provision request.

If the Package object is not complete, as indicated by self.is_partial, then self.refresh() is called to update the object.

Parameters

plan_id (string) – Plan Id

Returns

return instance of class ProvisionConfiguration:

provision(deployment_name, provision_configuration, retry_limit=0)

Provision the package (represented by the package class). Package can be deployed on device or cloud. If the required runtime of the package is device, then specify the device in the package config.

If the Package object is not complete, as indicated by self.is_partial, then self.refresh() is called to update the object.

Parameters
  • deployment_name (string) – Deployment Name

  • provision_configuration (ProvisionConfiguration:) – Provision payload

  • retry_limit (int) – Optional parameter to specify the number of retry attempts to be carried out if any failures occurs during the API call.

Returns

Instance of class Deployment:

Raises

APIError: If the API returns an error, a status code of anything other than 200/201 is returned.

Raises

OperationNotAllowedError: If the provision request is invalid

refresh()

Fetches the updated resource from the server, and adds/updates object attributes based on it.

Raises

APIError: If the api returns an error, the status code is anything other than 200/201

class ProvisionConfiguration(package_id, plan, *args, **kwargs)

ProvisionConfiguration class that contains the component configuration for a package deployment.

add_dependent_deployment(deployment)

Add dependent deployments.

deployment.refresh() is called to get the latest deployment status.

Parameters

deployment (class Deployment:) – Deployment

Returns

Updated instance of class ProvisionConfiguration:

add_device(component_name, device, ignore_device_config=None, set_component_alias=True)

Map component configuration with a device. ie, Setting the component is going to deploy on the given device. By Default, the component alias name is set to the device name, if this has to be ignored please use ‘set_component_alias=False’ as one of the method parameters.

Parameters
  • component_name (string) – Component name

  • device (instance of class Device:) – Device

  • ignore_device_config (list) – Optional parameter to ignore the device config variables

  • set_component_alias (bool) – Optional parameter to set the alias name of the component same as device name. Defaults to True

Returns

Updated instance of class ProvisionConfiguration:

Raises

OperationNotAllowedError: If the device is not online

>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project')
>>> package = client.get_package('test_package_id')
>>> device = client.get_device('test_device_id')
>>> package_provision_config = package.get_provision_configuration('test_plan_id')
>>> # ros_workspace will be ignored while adding device to provision configuration
>>> package_provision_config.add_device('test_component_name', 'test_device_id',
>>>                                     ignore_device_config=['ros_workspace'], set_component_alias=False)
>>> package.provision('deployment_name', package_provision_config)
add_label(key, value)

Add labels

Parameters
  • key (string) – Key

  • value (string) – Value

Returns

Updated instance of class ProvisionConfiguration:

add_native_network(native_network, network_interface=None)

Add Native Network

Parameters
  • native_network (instance of NativeNetwork) – NativeNetwork

  • network_interface (string) – interface to which current deployment to bind, only required for device native network

Returns

Updated instance of class ProvisionConfiguration

Raises

InvalidParameterException: If native network is not valid

Raises

OperationNotAllowedError: If native network is not of cloud runtime

>>> from rapyuta_io import Client
>>> from rapyuta_io.clients.package import ROSDistro, Runtime
>>> from rapyuta_io.clients.native_network import NativeNetwork
>>> client = Client(auth_token='auth_token', project='project')
>>> native_network = NativeNetwork("native_network_name", Runtime.CLOUD,
...                                ROSDistro.KINETIC)
>>> native_network = client.create_native_network(native_network)
>>> native_network.poll_native_network_till_ready()
>>> package = client.get_package('test_package_id')
>>> package_provision_config = package.get_provision_configuration('test_plan_id')
>>> package_provision_config.add_native_network(native_network)
>>> package.provision('deployment_name', package_provision_config)
add_native_networks(native_networks)

Add Native Networks

Parameters

native_networks (list) – list of native network NativeNetwork

Returns

Updated instance of class ProvisionConfiguration

>>> from rapyuta_io import Client
>>> from rapyuta_io.clients.package import ROSDistro, Runtime
>>> from rapyuta_io.clients.native_network import NativeNetwork
>>> client = Client(auth_token='auth_token', project='project')
>>> native_network = NativeNetwork("native_network_name", Runtime.CLOUD,
                                   ROSDistro.KINETIC)
>>> native_network = client.create_native_network(native_network)
>>> native_network.poll_native_network_till_ready()
>>> package = client.get_package('test_package_id')
>>> package_provision_config = package.get_provision_configuration('test_plan_id')
>>> package_provision_config.add_native_networks([native_network])
>>> package.provision('deployment_name', package_provision_config)

add_parameter(component_name, key, value)

Add component parameters

Parameters
  • component_name (string) – Component name

  • key (string) – Parameter key

  • value (string) – Parameter value

Returns

Updated instance of class ProvisionConfiguration:

add_restart_policy(component_name, restart_policy)

Add RestartPolicy for the component

Parameters
  • component_name (string) – Component name

  • restart_policy (enum RestartPolicy) – one of RestartPolicy enums

Returns

Updated instance of class ProvisionConfiguration

Raises

InvalidParameterException: If restart policy is not invalid

add_rosbag_job(component_name, rosbag_job)

Add rosbag for a component

Parameters
  • component_name (string) – Component name

  • rosbag_job (ROSBagJob) – instance of ROSBagJob

Returns

Updated instance of class ProvisionConfiguration

Raises

InvalidParameterException: If rosbag_job is not instance of ROSBagJob

Raises

OperationNotAllowedError: If component is non ros or is a device component

add_routed_network(routed_network, network_interface=None)

Add Routed Network

Parameters
  • routed_network (instance of RoutedNetwork) – RoutedNetwork

  • network_interface (string) – interface to which current deployment to bind

Returns

Updated instance of class ProvisionConfiguration

Raises

InvalidParameterException: If routed network is not valid

Raises

OperationNotAllowedError: If network interface given for cloud runtime

add_routed_networks(routed_networks)
Parameters

routed_networks (list) – list of routed network RoutedNetwork

Returns

Updated instance of class ProvisionConfiguration

>>> from rapyuta_io import Client
>>> from rapyuta_io.clients.package import ROSDistro
>>> client = Client(auth_token='auth_token', project='project')
>>> routed_network = client.create_cloud_routed_network('network_name',
                     ROSDistro.KINETIC, True)
>>> routed_network.poll_routed_network_till_ready()
>>> package = client.get_package('test_package_id')
>>> package_provision_config = package.get_provision_configuration('test_plan_id')
>>> package_provision_config.add_routed_networks([routed_network])
>>> package.provision(deployment_name, package_provision_config)

add_static_route(component_name, endpoint_name, static_route)

Add static route to a component in a package

Parameters
  • component_name – Name of the component to add static route to

  • endpoint_name – Name of the endpoint (Should be exposed externally)

  • static_route – class StaticRoute:

Returns

Updated instance of class ProvisionConfiguration:

mount_volume(component_name, volume=None, device=None, mount_path=None, executable_mounts=None)

To mount a volume instance.

Parameters
  • component_name (string) – Component name

  • volume (instance of class VolumeInstance:) – VolumeInstance class

  • device (instance of class Device:) – Device class

  • mount_path (string) – Mount path

  • executable_mounts (list(ExecutableMount)) – list of executable mounts. mandatory parameter for device volumes

Returns

Updated instance of class ProvisionConfiguration:

remove_rosbag_job(component_name, job_name)

Remove rosbag job by its name

Parameters
  • component_name (string) – Component name

  • job_name (string) – name of ROSBagJob

set_component_alias(component_name, alias='', set_ros_namespace=False)

Set an alias and ROS_NAMESPACE environment variable flag for the selected component. This is used in scoping and targeting. alias defaults to the component name. set_ros_namespace defaults to false

Note: In typical scenarios in the case of a cloud deployment, alias is set to the component name (or some derivation thereof) and on the device it is set to the device name. But it is left to the user. All set aliases in a deployment and its dependent deployments are required to be unique.

Parameters
  • component_name (string) – Component name

  • alias (string) – alias for component

  • set_ros_namespace (bool) – flag to set alias as ROS_NAMESPACE environment variable in the deployment. It should be used only for deployments using native networks.

Returns

Updated instance of class ProvisionConfiguration:

class ROSDistro(value)

Enumeration variables for the Supported ROS Distros. ROS Distro may be one of:

ROSDistro.KINETIC (‘kinetic’)

ROSDistro.MELODIC (‘melodic’)

ROSDistro.NOETIC (‘noetic’)

class RestartPolicy(value)

Enumeration variables for the Restart Policy. Restart Policy may be ‘Always’, ‘Never’ or ‘OnFailure’

RestartPolicy.Always

RestartPolicy.Never

RestartPolicy.OnFailure

class Runtime(value)

Enumeration variables for the Supported Runtimes. Runtime may be ‘cloud’, or ‘device’

Runtime.CLOUD

Runtime.DEVICE

class Plan(*args, **kwargs)

Plan class represents a plan in the package. Member variables of the class represent the properties of the plan.

Variables
  • planId – (full-only) Plan Id.

  • planName – (full-only) Plan Name.

  • packageId – (full-only) Package Id.

  • description – Plan Description.

  • singleton – (full-only) Boolean representing whether the plan is singelton or not.

  • inboundROSInterfaces – (full-only) Dictionary containing inbound ROS interfaces information.

  • dependentDeployments – (full-only) List of other dependent deployments.

  • components – (full-only) Dictionary containing components such as executables.

  • internalComponents – (full-only) Dictionary containing internal components information.

  • metadata – List containing plan metadata.

  • CreatedAt – (full-only) Date of creation.

  • UpdatedAt – (full-only) Date of updation.

  • DeletedAt – (full-only) Date of deletion.