Skip to content

Commit

Permalink
tools/rerun: streaming to one Viewer from multiple processes (#32595)
Browse files Browse the repository at this point in the history
* one spawn only

* one blueprint

* comment
  • Loading branch information
bongbui321 authored Jun 3, 2024
1 parent 00b10f3 commit f717e1e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tools/rerun/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def log_msg(msg, parent_key=''):
pass # Not a plottable value

def createBlueprint():
blueprint = None
timeSeriesViews = []
for topic in sorted(SERVICE_LIST.keys()):
timeSeriesViews.append(rrb.TimeSeriesView(name=topic, origin=f"/{topic}/", visible=False))
Expand All @@ -51,9 +52,12 @@ def log_thumbnail(thumbnailMsg):
bytesImgData = thumbnailMsg.get('thumbnail')
rr.log("/thumbnail", rr.ImageEncoded(contents=bytesImgData))

def process(blueprint, lr):
@rr.shutdown_at_exit
def process(lr):
rr.init("rerun_test")
rr.connect()

ret = []
rr.init("rerun_test", spawn=True, default_blueprint=blueprint)
for msg in lr:
ret.append(msg)
rr.set_time_nanos("TIMELINE", msg.logMonoTime)
Expand All @@ -75,8 +79,11 @@ def process(blueprint, lr):

args = parser.parse_args()

route_or_segment_name = DEMO_ROUTE if args.demo else args.route_or_segment_name.strip()
blueprint = createBlueprint()
rr.init("rerun_test", default_blueprint=blueprint)
rr.spawn(connect=False) # child processes stream data to Viewer

route_or_segment_name = DEMO_ROUTE if args.demo else args.route_or_segment_name.strip()
print("Getting route log paths")
lr = LogReader(route_or_segment_name)
lr.run_across_segments(NUM_CPUS, partial(process, blueprint))
lr.run_across_segments(NUM_CPUS, partial(process))

0 comments on commit f717e1e

Please sign in to comment.