Build modules

Builds on rapyuta.io are a fundamental resource which convert your source code residing in your VCS into a container image.

Builds can be referenced when creating packages and enables an end-to-end “Code to Deployment” pipeline for your Robotics solution.

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_build(build, refresh=True)

Create a new build

Parameters
  • build (Build) – Info about the build to be created

  • refresh (bool) – Whether the build needs to be refreshed

Returns

Instance of Build class.

Following example demonstrates how to create a build.

>>> from rapyuta_io import Client, ROSDistro, Build, SimulationOptions, BuildOptions, CatkinOption, GithubWebhook
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> simulationOptions = SimulationOptions(False)
>>> buildOptions = BuildOptions(catkinOptions=[CatkinOption(rosPkgs='talker')])
>>> webhooks = [GithubWebhook(workflowName='test.yaml', accessToken='github_access_token')]
>>> build = Build(buildName='test-build',
...               strategyType='Source',
...               repository='https://github.com/rapyuta-robotics/io_tutorials.git',
...               architecture='amd64',
...               rosDistro='melodic',
...               isRos=True,
...               contextDir='talk/talker',
...               simulationOptions=simulationOptions,
...               buildOptions=buildOptions,
...               buildWebhooks=webhooks)
>>> build = client.create_build(build)
>>> build.poll_build_till_ready()
delete_build(guid)

Delete a build.

Parameters

guid (str) – GUID of the build to be deleted

Following example demonstrates how to delete a build.

>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> client.delete_build('build-guid')
get_build(guid, include_build_requests=False)

Get a build based on the guid.

Parameters
  • guid (str) – GUID of the build

  • include_build_requests (bool) – Whether to include build request in the response

Returns

Instance of Build class.

Following example demonstrates how to get a build.

  1. Get build without including build requests.

    >>> from rapyuta_io import Client
    >>> client = Client(auth_token='auth_token', project='project_guid')
    >>> build = client.get_build('build-guid')
    
  2. Get build including the build requests.

    >>> from rapyuta_io import Client
    >>> client = Client(auth_token='auth_token', project='project_guid')
    >>> build = client.get_build('build-guid', include_build_requests=True)
    
list_builds(statuses=None)

List builds based on the passed query params

Parameters

statuses (list(BuildStatus)) – statuses based on which the list build response will be filtered.

Returns

list(Build)

Following example demonstrates how to list builds.

  1. List all builds present in the project.

    >>> from rapyuta_io import Client
    >>> client = Client(auth_token='auth_token', project='project_guid')
    >>> build = client.list_builds()
    
  2. List builds based on their statuses.

    >>> from rapyuta_io import Client, BuildStatus
    >>> client = Client(auth_token='auth_token', project='project_guid')
    >>> builds = client.list_builds(statuses=[BuildStatus.COMPLETE, BuildStatus.BUILD_FAILED,
    ...                                       BuildStatus.BUILD_IN_PROGRESS])
    
rollback_build(buildOperation)

Rollback the build to a previously created build request

Parameters

buildOperation (BuildOperation) – Info of the operation to be performed on the build.

Following example demonstrates how to rollback a build:

>>> from rapyuta_io import Client, BuildOperationInfo, BuildOperation
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> request = BuildOperation([BuildOperationInfo('build-guid', 1)])
>>> response = client.rollback_build(request)
>>> for resp in response['buildOperationResponse']:
...     if not resp['success']:
...         print resp['buildGUID'], resp['error']
...     else:
...         print resp['buildGUID'], resp['buildGenerationNumber']
trigger_build(buildOperation)

Trigger a new build request for a particular build

Parameters

buildOperation (BuildOperation) – Info of the operation to be performed on the build.

Following example demonstrates how to trigger a new build request for a build:

>>> from rapyuta_io import Client, BuildOperationInfo, BuildOperation
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> request = BuildOperation([BuildOperationInfo('build-guid', triggerName='trigger-name')])
>>> response = client.trigger_build(request)
>>> for resp in response['buildOperationResponse']:
...     if not resp['success']:
...         print resp['buildGUID'], resp['error']
...     else:
...         print resp['buildGUID'], resp['buildGenerationNumber']

Build

class Build(buildName, strategyType, repository, architecture, rosDistro='', isRos=False, contextDir='', dockerFilePath='', secret='', dockerPullSecret='', dockerPushSecret='', dockerPushRepository='', simulationOptions=None, buildOptions=None, branch='', triggerName='', tagName='', buildWebhooks=None)

Build represents the main class whose instance will be used to perform various operations like create, get, update, delete, trigger and rollback

Parameters
  • buildName (str) – name of build

  • strategyType (Union[StrategyType, str]) – Strategy type used for the build

  • repository (str) – Git repository to be used for building docker image while deploying package.

  • architecture (Union[DeviceArch, str]) – Architecture required for using the build

  • rosDistro (Union[ROSDistro, str]) – ROS distro used by the build

  • isRos (bool) – Whether the build support ros components

  • contextDir (str) – context dir to be used in the build

  • dockerFilePath (str) – Represents Docker file path

  • secret (str) – Represents secret for a private git repository

  • dockerPullSecret (str) – GUID of the docker secret for a private base image in Dockerfile

  • dockerPushSecret (str) – GUID of the docker secret for pushing the image to an external registry.

  • dockerPushRepository (str) – An external docker repository where Build will push the image. For example ‘docker.io/user/example’

  • simulationOptions (SimulationOptions) – Represents simulation options used by the build

  • buildOptions (BuildOptions) – Represents build options used by the build

  • branch (str) – Represents branch corresponding to the repository used by the build

  • triggerName (str) – Represents trigger name of the build

  • tagName (str) – Represents tag name of the build

  • buildWebhooks (list(GithubWebhook)) – Represents webhooks to be triggered on build completion

delete()

Delete the build using the build object. :raises: ForbiddenError: Returned in case of status code 403

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

>>> from rapyuta_io import Client
>>> from rapyuta_io.utils.error import ForbiddenError
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> build = client.get_build('build-guid')
>>> try:
...     build.delete()
... except ForbiddenError as e:
...     print e
poll_build_till_ready(retry_count=120, sleep_interval=5)

Polls the build till its status changes from BuildInProgress to Complete/BuildFailed.

Parameters
  • retry_count (int) – Number of retries.

  • sleep_interval (int) – Sleep seconds between retries.

Raises

BuildFailed: If status becomes BuildFailed.

Raises

RetriesExhausted: If the number of polling retries exhausted before the object was ready.

Following example demonstrates how to poll a newly created build using build object:

>>> from rapyuta_io import Client
>>> from rapyuta_io.utils.error import BuildFailed, RetriesExhausted
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> build = Build('test-build', 'Source', 'repository', 'amd64', 'melodic', isRos=True)
>>> build = client.create_build(build)
>>> try:
...     build.poll_build_till_ready()
... except BuildFailed:
...     print 'Build Failed'
... except RetriesExhausted as e:
...     print e, 'Retry again ?'
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

rollback(buildGenerationNumber)

Rollback a build using build object.

Parameters

buildGenerationNumber (int) – build generation number used for rollback.

Raises

BuildOperationFailed: Returned in case rollback build fails.

Raises

InvalidParameterException

Following example demonstrates how to rollback a build using build object:

>>> from rapyuta_io import Client
>>> from rapyuta_io.utils.error import BuildOperationFailed
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> build = client.get_build('build-guid')
>>> try:
...     build.rollback(1)
... except BuildOperationFailed as e:
...     print e
save()

Save the build after updating attributes

Following are the attributes that can be updated

  • build.buildInfo.repository

  • build.buildInfo.branch

  • build.buildInfo.dockerFilePath

  • build.buildInfo.contextDir

  • build.buildInfo.buildOptions

  • build.secret

  • build.dockerPullSecret

  • build.dockerPushRepository

  • build.buildWebhooks

Following example demonstrates how to save a build:

>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> build = client.get_build('build-guid')
>>> build.buildInfo.branch = 'master'
>>> build.save()
trigger(triggerName=None, tagName=None)

Trigger a new build request for a build using build object.

Raises

BuildOperationFailed: Returned in case trigger build fails

Following example demonstrates how to trigger a new build request using build object:

>>> from rapyuta_io import Client
>>> from rapyuta_io.utils.error import BuildOperationFailed
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> build = client.get_build('build-guid')
>>> try:
...     build.trigger()
... except BuildOperationFailed as e:
...     print e
class BuildOptions(catkinOptions)

BuildOptions represent Build Options.

Variables

catkinOptions – represents list of catkin options CatkinOption.

class BuildStatus(value)

Enumeration variables for build status

Build status can be any of the following types

BuildStatus.BUILD_IN_PROGRESS

BuildStatus.COMPLETE

BuildStatus.BUILD_FAILED

class CatkinOption(rosPkgs=None, cmakeArgs=None, makeArgs=None, blacklist=None, catkinMakeArgs=None)

CatkinOption represents Catkin Options

Variables
  • rosPkgs – Represents ROS packages to be included for build.

  • cmakeArgs – Represents cmakeArgs to be used in the build.

  • makeArgs – Represents makeArgs to be used in the build.

  • blacklist – Used if you want to avoid build certain packages in your build.

  • catkinMakeArgs – Represents catkinMakeArgs to be used in the build.

class GithubWebhook(workflowName, accessToken)

Github Webhook to be triggered on build completion

Variables
  • workflowName – Represents name of the github dispatch workflow file.

  • accessToken – Represents github access token

class SimulationOptions(simulation)

Simulation Options represents whether simulation is required at the time of building package

Variables

simulation – whether simulation is required (bool).

class StrategyType(value)

Enumeration variables for Strategy Types.

Strategy Type can be any of the following types

StrategyType.SOURCE

StrategyType.DOCKER

Operations on Builds

class BuildOperation(buildOperationInfo)

BuildOperation represents Build Operation

Variables

buildOperationInfo – represents a list of information about the operation which will be performed on the build list(BuildOperationInfo).

class BuildOperationInfo(buildGuid, buildGenerationNumber=None, triggerName=None, tagName=None)

BuildOperationInfo represents information about the operation which will be performed on the build.

Variables
  • buildGuid – Represents GUID of the build

  • buildGenerationNumber – Represents build generation number of the build.

  • triggerName – Represents trigger name of the build

  • tagName – Represents tag name of the build