Skip to content

Commit

Permalink
feat(packages): uses v2 packages APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
RomilShah authored and pallabpain committed Sep 4, 2024
1 parent d967d18 commit 1048ff5
Show file tree
Hide file tree
Showing 16 changed files with 172 additions and 256 deletions.
3 changes: 2 additions & 1 deletion examples/kiba-robots/03_packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ spec:
executables:
- type: docker
name: django
command: /code/docker/entrypoint.sh
command:
- /code/docker/entrypoint.sh
docker:
image: rrdockerhub/sootballs_wcs:1.14.0-rc4
pullSecret:
Expand Down
4 changes: 2 additions & 2 deletions riocli/apply/manifests/package-nonros-cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
name: "package-nonros-cloud" # Required
version: "v1.0.0" # Required
description: "A RIO non ROS cloud package"
project: "project-guid"
labels:
app: test
spec:
Expand All @@ -14,7 +13,8 @@ spec:
executables: # Required
- name: "exec-docker"
type: docker # Options: [docker (default), preInstalled]
command: "sleep infinity"
command:
- "sleep infinity"
runAsBash: True
simulation: False
limits:
Expand Down
14 changes: 8 additions & 6 deletions riocli/apply/manifests/package-nonros-device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: "package-nonros-device" # Required
version: "v1.0.0" # Required
description: "A RIO non ROS device package"
project: "project-guid"
#project: "project-guid"
labels:
app: test
spec:
Expand All @@ -14,8 +14,9 @@ spec:
restart: always # Options: [always, never, onfailure]
executables: # Required
- name: "exec-docker"
type: docker # Options: [docker (default), preInstalled]
command: "roslaunch talker talker.launch"
type: preInstalled # Options: [docker (default), preInstalled]
command:
- "roslaunch talker talker.launch"
runAsBash: True
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
Expand All @@ -24,7 +25,7 @@ spec:
httpGet:
path: "/"
port: 90
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
initialDelaySeconds: 50 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
Expand All @@ -39,8 +40,9 @@ spec:
nameOrGUID: "secret-docker"
- name: "exec-preInstalled"
type: preInstalled # Options: [docker (default), preInstalled]
command: "roslaunch talker talker.launch"
environmentVars:
command:
- "roslaunch talker talker.launch"
environmentArgs:
- name: "key1" # Required
default: "key1-value"
description: "A environment variable"
Expand Down
4 changes: 2 additions & 2 deletions riocli/apply/manifests/package-ros-cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
name: "package-ros-cloud" # Required
version: "v1.0.0" # Required
description: "A RIO cloud ROS package"
project: "project-guid"
labels:
app: test
spec:
Expand All @@ -14,7 +13,8 @@ spec:
executables: # Required
- name: "exec-docker"
type: docker # Options: [docker (default), preInstalled]
command: "roslaunch talker talker.launch"
command:
- "roslaunch talker talker.launch"
runAsBash: True
simulation: False
limits:
Expand Down
1 change: 0 additions & 1 deletion riocli/apply/manifests/package-ros-device-no-rosbag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
name: "package-ros-device-no-rosbag" # Required
version: "v1.0.0" # Required
description: "A RIO device ROS package without rosbag"
project: "project-guid"
labels:
app: test
spec:
Expand Down
6 changes: 3 additions & 3 deletions riocli/apply/manifests/package-ros-device-rosbag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
name: "package-ros-device-rosbag" # Required
version: "v1.0.0" # Required
description: "A RIO device ROS package with rosbag"
project: "project-guid"
labels:
app: test
spec:
Expand All @@ -16,7 +15,8 @@ spec:
executables: # Required
- name: "exec-docker"
type: docker # Options: [docker (default), preInstalled]
command: "roslaunch talker talker.launch"
command:
- "roslaunch talker talker.launch"
runAsBash: True
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
Expand Down Expand Up @@ -114,7 +114,7 @@ spec:
- type: topic # Required, Options: [ topic, service, action ]
name: "/telemetry"
compression: False
scoped: False
scoped: True
targeted: False
qos: low # Options: [low, med, hi, max]
- type: service # Required, Options: [ topic, service, action ]
Expand Down
61 changes: 46 additions & 15 deletions riocli/apply/manifests/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
name: "package-ros-cloud" # Required
version: "v1.0.0" # Required
description: "A RIO cloud ROS package"
project: "project-guid"
labels:
app: test
spec:
Expand All @@ -14,7 +13,8 @@ spec:
executables: # Required
- name: "exec-docker"
type: docker # Options: [docker (default), preInstalled]
command: "roslaunch talker talker.launch"
command:
- "roslaunch talker talker.launch"
runAsBash: True
simulation: False
limits:
Expand Down Expand Up @@ -138,7 +138,6 @@ metadata:
name: "package-ros-device-rosbag" # Required
version: "v1.0.0" # Required
description: "A RIO device ROS package with rosbag"
project: "project-guid"
labels:
app: test
spec:
Expand All @@ -149,7 +148,8 @@ spec:
executables: # Required
- name: "exec-docker"
type: docker # Options: [docker (default), preInstalled]
command: "roslaunch talker talker.launch"
command:
- "shell-cmd"
runAsBash: True
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
Expand Down Expand Up @@ -268,7 +268,6 @@ metadata:
name: "package-nonros-cloud" # Required
version: "v1.0.0" # Required
description: "A RIO non ROS cloud package"
project: "project-guid"
labels:
app: test
spec:
Expand All @@ -278,7 +277,8 @@ spec:
executables: # Required
- name: "exec-docker"
type: docker # Options: [docker (default), preInstalled]
command: "sleep infinity"
command:
- "sleep infinity"
runAsBash: True
simulation: False
limits:
Expand Down Expand Up @@ -334,7 +334,6 @@ metadata:
name: "package-nonros-device" # Required
version: "v1.0.0" # Required
description: "A RIO non ROS device package"
project: "project-guid"
labels:
app: test
spec:
Expand All @@ -345,7 +344,8 @@ spec:
executables: # Required
- name: "exec-docker-01"
type: docker # Options: [docker (default), preInstalled]
command: "roslaunch talker talker.launch"
command:
- "roslaunch talker talker.launch"
runAsBash: True
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
Expand Down Expand Up @@ -385,8 +385,9 @@ spec:
imagePullPolicy: "Always" # Always, Never, IfNotPresent(default)
- name: "exec-preInstalled"
type: preInstalled # Options: [docker (default), preInstalled]
command: "roslaunch talker talker.launch"
environmentVars:
command:
- "roslaunch talker talker.launch"
environmentArgs:
- name: "key1" # Required
default: "key1-value"
description: "A environment variable"
Expand All @@ -403,7 +404,6 @@ metadata:
name: "package-ros-device-no-rosbag" # Required
version: "v1.0.0" # Required
description: "A RIO device ROS package without rosbag"
project: "project-guid"
labels:
app: test
spec:
Expand All @@ -414,7 +414,8 @@ spec:
executables: # Required
- name: "exec-docker"
type: docker # Options: [docker (default), preInstalled]
command: "roslaunch talker talker.launch"
command:
- "roslaunch talker talker.launch"
runAsBash: True
limits:
cpu: 0.025 # Unit: Core (Optional)
Expand All @@ -437,8 +438,9 @@ spec:
nameOrGUID: "secret-docker"
- name: "exec-preInstalled"
type: preInstalled # Options: [docker (default), preInstalled]
command: "roslaunch talker talker.launch"
environmentVars:
command:
- "roslaunch talker talker.launch"
environmentArgs:
- name: "key1" # Required
default: "key1-value"
description: "A environment variable"
Expand Down Expand Up @@ -471,4 +473,33 @@ spec:
compression: False
scoped: False
targeted: False
targeted: False
targeted: False

---
apiVersion: "apiextensions.rapyuta.io/v1"
kind: "Package"
metadata:
name: "tc128-talker" # Required
version: "v1.0.0" # Required
description: "A RIO cloud ROS package"
labels:
app: test
spec:
runtime: cloud # Options: [device, cloud (default)]
cloud:
replicas: 1 # Required
executables: # Required
- name: "exec-build"
type: docker # Options: [docker (default), build, preInstalled]
command:
- "roslaunch talker talker.launch"
simulation: False
runAsBash: False
limits:
cpu: 0.025 # Unit: Core Options: [Multiple of 0.025, <= 8]
memory: 128 # Unit: MB Options: [Multiple of 128, <= 32768]
docker:
image: "quay.io/rapyuta/io_tutorials:latest"
ros:
enabled: True
version: melodic # Required, Options: [ kinetic, melodic, noetic ]
6 changes: 3 additions & 3 deletions riocli/apply/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _guid_functor(self, kind):
mapping = {
'secret': lambda x: munchify(x).metadata.guid,
"project": lambda x: munchify(x).metadata.guid,
"package": lambda x: munchify(x)['id'],
"package": lambda x: munchify(x)['metadata']['guid'],
"staticroute": lambda x: munchify(x)['metadata']['guid'],
"deployment": lambda x: munchify(x)['deploymentId'],
"network": lambda x: munchify(x)['metadata']['guid'],
Expand All @@ -134,7 +134,7 @@ def _list_functors(self, kind):
mapping = {
'secret': self.v2client.list_secrets,
"project": self.v2client.list_projects,
"package": self.client.get_all_packages,
"package": self.v2client.list_packages,
"staticroute": self.v2client.list_static_routes,
"deployment": functools.partial(self.client.get_all_deployments,
phases=[DeploymentPhaseConstants.SUCCEEDED,
Expand All @@ -153,7 +153,7 @@ def _find_functors(self, kind):
'secret': lambda name, secrets: filter(lambda i: i.metadata.name == name, secrets),
"project": lambda name, projects: filter(lambda i: i.metadata.name == name, projects),
"package": lambda name, obj_list, version: filter(
lambda x: name == x.name and version == x['packageVersion'], obj_list),
lambda x: name == x.metadata.name and version == x.metadata.version, obj_list),
"staticroute": lambda name, obj_list: filter(
lambda x: name == x.metadata.name.rsplit('-', 1)[0], obj_list),
"deployment": self._generate_find_guid_functor(),
Expand Down
10 changes: 0 additions & 10 deletions riocli/deployment/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from riocli.deployment.util import add_mount_volume_provision_config, process_deployment_errors
from riocli.jsonschema.validate import load_schema
from riocli.model import Model
from riocli.package.util import find_package_guid
from riocli.parameter.utils import list_trees
from riocli.static_route.util import find_static_route_guid
from riocli.utils.cache import get_cache
Expand Down Expand Up @@ -271,15 +270,6 @@ def delete_object(self, client: Client, obj: typing.Any) -> typing.Any:
def pre_process(cls, client: Client, d: typing.Dict) -> None:
pass

def _get_package(self, client: Client) -> Package:
name = self.metadata.depends.nameOrGUID
if name.startswith('pkg-') or name.startswith('io-'):
guid = name
else:
guid = find_package_guid(client, name, self.metadata.depends.version)

return client.get_package(package_id=guid)

def _get_provision_config(self, client: Client, pkg: Package):
comp_name = pkg['plans']['components'][0]['name']
prov_config = pkg.get_provision_configuration()
Expand Down
Loading

0 comments on commit 1048ff5

Please sign in to comment.