def start_workunit(self, workunit):
    """Implementation of Reporter callback."""

    workunit_data = {
      'name': workunit.name,
      'id': str(workunit.id),
      'parent_name': workunit.parent.name if workunit.parent else '',
      'parent_id': str(workunit.parent.id) if workunit.parent else '',
      'labels': list(workunit.labels),
      'cmd': workunit.cmd or '',
      'start_time': workunit.start_time,
      'outputs': defaultdict(str),
      'children': [],
      'log_entries': [],
    }

    root_id = str(workunit.root().id)

    if not root_id in self._root_id_to_workunit_stack:
      self._root_id_to_workunit_stack[root_id].append(workunit_data)
      self.results[root_id] = workunit_data
    else:
      self._root_id_to_workunit_stack[root_id][-1]['children'].append(workunit_data)
      self._root_id_to_workunit_stack[root_id].append(workunit_data)
Implementation of Reporter callback.