Skip to content

Commit

Permalink
feat(rosbag): adds rosbag job inspect command
Browse files Browse the repository at this point in the history
  • Loading branch information
pallabpain authored and ankitrgadiya committed Feb 7, 2023
1 parent 35f5a03 commit 8d5556e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions riocli/rosbag/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from riocli.config import new_client
from riocli.deployment.util import name_to_guid as deployment_name_to_guid
from riocli.rosbag.util import ROSBagJobNotFound
from riocli.utils import inspect_with_format
from riocli.utils import tabulate_data


Expand Down Expand Up @@ -80,6 +81,24 @@ def job_create(name: str, deployment_id: str, component_instance_id: str, all_to
raise SystemExit(1)


@rosbag_job.command('inspect')
@click.option('--format', '-f', 'format_type',
type=click.Choice(['json', 'yaml'], case_sensitive=False), default='yaml')
@click.argument('job-guid', type=str)
def job_inspect(job_guid: str, format_type: str) -> None:
"""
Inspect a ROSbag job
"""
try:
client = new_client()
job = client.get_rosbag_job(job_guid)
job = make_rosbag_job_inspectable(job)
inspect_with_format(job, format_type)
except Exception as e:
click.secho(str(e), fg='red')
raise SystemExit(1)


@rosbag_job.command('stop')
@click.argument('deployment-name')
@click.option('--component-instance-ids', help='Filter by component instance ids ', multiple=True)
Expand Down Expand Up @@ -241,3 +260,20 @@ def _display_rosbag_job_list(jobs: typing.List[ROSBagJob], show_header: bool = T
])

tabulate_data(data, headers)


def make_rosbag_job_inspectable(job: ROSBagJob) -> typing.Dict:
return {
"name": job.name,
"status": job.status,
"project": job.project,
"device_id": job.device_id,
"package_id": job.package_id,
"component_id": job.component_id,
"deployment_id": job.deployment_id,
"component_type": job.component_type,
"rosbag_options": job.rosbag_options,
"upload_options": job.upload_options,
"override_options": job.override_options,
"component_instance_id": job.component_instance_id,
}

0 comments on commit 8d5556e

Please sign in to comment.