Welcome to rapyuta.io Python Client’s documentation!¶
This client is a python interface for rapyuta.io. By using it, developers are able to write software that makes use of the services provided by rapyuta.io rapyuta.io Python SDK enables you to provision packages either on the cloud or on a device, add a dependent deployment, and access various rapyuta.io resources and services in your python applications.
Requirements¶
The rapyuta.io Python SDK is compatible with python applications supporting Python2.7
Note
We have added Python3.9 support to the rapyuta.io python SDK. Note that this is still in alpha stage.
Example Usage¶
Here is an example script showcasing how you can use the python SDK to create various resources on rapyuta.io
Here is a summary of the steps we do in this example
Create a rapyuta.io client object using auth_token and project_guid
Create a Build using an example git repository
Create a cloud Routed Network
Create a Package using a manifest object
Create a cloud Deployment and wait for it to reach running state.
from rapyuta_io.clients.package import ROSDistro
from rapyuta_io import Client, ROSDistro, SimulationOptions, BuildOptions, CatkinOption
from rapyuta_io.clients.build import Build
from rapyuta_io.clients.package import Package
# AUTH CONFIG
AUTH_TOKEN='<<< AUTH_TOKEN_HERE >'
PROJECT_ID = '<<< PROJECT ID >>>'
# Create Client
client = Client(auth_token=AUTH_TOKEN, project=PROJECT_ID)
# Create a Build
simulationOptions = SimulationOptions(False)
buildOptions = BuildOptions(catkinOptions=[CatkinOption(rosPkgs='talker')])
build = Build(buildName='io-tutorials',
strategyType='Source',
repository='https://github.com/rapyuta/io_tutorials.git',
architecture='amd64',
rosDistro='kinetic',
isRos=True,
contextDir='',
simulationOptions=simulationOptions,
buildOptions=buildOptions)
build = client.create_build(build)
build.poll_build_till_ready()
build_id = build.guid
# Create a Routed Network
routed_network = client.create_cloud_routed_network("CLOUD_ROUTED_NETWORK", ROSDistro.MELODIC, True)
routed_network.poll_routed_network_till_ready()
# Create cloud talker package
talker_manifest = {'name': 'Talker',
'packageVersion': 'v1.0.0',
'description': 'ROS Publisher',
'bindable': True,
'plans': [{'name': 'default',
'metadata': {},
'singleton': False,
'components': [{'name': 'TALKER',
'description': '',
'cloudInfra': {'replicas': 1, 'endpoints': []},
'ros': {'topics': [{'name': '/telemetry',
'qos': 'max',
'compression': '',
'scoped': False,
'targeted': False}],
'services': [],
'actions': [],
'isROS': True,
'ros_distro': 'kinetic'},
'requiredRuntime': 'cloud',
'architecture': 'amd64',
'executables': [{'name': 'talker_executable',
'simulationOptions': {'simulation': False},
'buildGUID': build_id,
'cmd': ['roslaunch talker talker.launch'],
'limits': {'cpu': 0.5, 'memory': 2048}}],
'parameters': [],
'rosBagJobDefs': []}],
'dependentDeployments': [],
'inboundROSInterfaces': {'anyIncomingScopedOrTargetedRosConfig': False},
'exposedParameters': []}]}
talker = client.create_package(talker_manifest)
talker_plan_id = talker[u'planIds'][0][u'planId']
talker_id = talker[u'packageId']
# Deploy Talker on cloud
talker = client.get_package(talker_id)
talker_configuration = talker.get_provision_configuration(talker_plan_id)
talker_configuration.add_routed_network(routed_network)
talker_cloud_deployment = talker.provision(deployment_name="ROS PUBLISHER", provision_configuration=talker_configuration)
talker_cloud_deployment.poll_deployment_till_ready()
SDK Modules¶
rapyuta.io SDK has modules for each rapyuta.io resource.
Client
is the main module which has methods for creation, listing, deletion and deployment of resources.
from rapyuta_io import Client
You can read about the individual resource level modules, and their accompanying Client module methods here: