class_docstr: PipelineProfiler to trace one pipeline.
class_docstr_tok: ["PipelineProfiler","to","trace","one","pipeline","."]
code: def gen_profiler_json(self, num=None):
      profiler_json = []
      if num is None:
          pipe_name = "Pipeline"
      else:
          pipe_name = "Pipeline:" + str(num)
      profiler_json.append(
          {
              "ph": "M",
              "pid": pipe_name,
              "tid": pipe_name,
              "id": pipe_name,
              "name": "process_name",
              "args": {"name": pipe_name},
          }
      )
      profiler_json.append(
          {
              "ph": "b",
              "pid": pipe_name,
              "tid": pipe_name,
              "id": pipe_name,
              "name": pipe_name,
              "ts": self.time_in * 1000000,
              "cat": "Running Pipeline",
          }
      )
      profiler_json.append(
          {
              "ph": "e",
              "pid": pipe_name,
              "tid": pipe_name,
              "id": pipe_name,
              "name": pipe_name,
              "ts": self.time_out * 1000000,
              "cat": "Running Pipeline",
              "args": {"input": self.data},
          }
      )
  
      for n_id, n_tracer in self.node_tracer.items():
          profiler_json.append(
              {
                  "ph": "M",
                  "pid": pipe_name,
                  "tid": n_tracer["name"]
                  + "("
                  + n_tracer["iter"]
                  + ")",
                  "id": n_id + str(num),
                  "name": n_tracer["name"],
                  "args": {"name": n_tracer["name"]},
              }
          )
          if len(n_tracer["init_in"]) == 0:
              total_in = n_tracer["queue_in"][0] * 1000000
          else:
              total_in = n_tracer["init_in"][0] * 1000000
          profiler_json.append(
              {
                  "ph": "b",
                  "pid": pipe_name,
                  "tid": n_tracer["name"]
                  + "("
                  + n_tracer["iter"]
                  + ")",
                  "id": n_id + str(num),
                  "name": n_tracer["name"],
                  "ts": total_in,
                  "cat": n_tracer["name"] + "_" + n_id,
              }
          )
          if len(n_tracer["process_in"]) == 0:
              profiler_json.append(
                  {
                      "ph": "e",
                      "pid": pipe_name,
                      "tid": n_tracer["name"]
                      + "("
                      + n_tracer["iter"]
                      + ")",
                      "id": n_id + str(num),
                      "name": n_tracer["name"],
                      "ts": total_in,
                      "cat": n_tracer["name"] + "_" + n_id,
                  }
              )
              continue
          profiler_json.append(
              {
                  "ph": "e",
                  "pid": pipe_name,
                  "tid": n_tracer["name"]
                  + "("
                  + n_tracer["iter"]
                  + ")",
                  "id": n_id + str(num),
                  "name": n_tracer["name"],
                  "ts": n_tracer["queue_out"][
                      len(n_tracer["process_in"]) - 1
                  ]
                  * 1000000,
                  "cat": n_tracer["name"] + "_" + n_id,
              }
          )
  
          if len(n_tracer["init_in"]) != 0:
              profiler_json.append(
                  {
                      "ph": "B",
                      "pid": pipe_name,
                      "tid": n_tracer["name"]
                      + "("
                      + n_tracer["iter"]
                      + ")",
                      "id": n_id + str(num),
                      "name": "init",
                      "ts": n_tracer["init_in"][0] * 1000000,
                  }
              )
              profiler_json.append(
                  {
                      "ph": "E",
                      "pid": pipe_name,
                      "tid": n_tracer["name"]
                      + "("
                      + n_tracer["iter"]
                      + ")",
                      "id": n_id + str(num),
                      "name": "init",
                      "ts": n_tracer["init_out"][0] * 1000000,
                  }
              )
  
          for i in range(len(n_tracer["process_in"])):
              profiler_json.append(
                  {
                      "ph": "B",
                      "pid": pipe_name,
                      "tid": n_tracer["name"]
                      + "("
                      + n_tracer["iter"]
                      + ")",
                      "id": n_id + str(num),
                      "name": "wait_data",
                      "ts": n_tracer["queue_in"][i] * 1000000,
                  }
              )
              profiler_json.append(
                  {
                      "ph": "E",
                      "pid": pipe_name,
                      "tid": n_tracer["name"]
                      + "("
                      + n_tracer["iter"]
                      + ")",
                      "id": n_id + str(num),
                      "name": "wait_data",
                      "ts": n_tracer["process_in"][i] * 1000000,
                  }
              )
              profiler_json.append(
                  {
                      "ph": "B",
                      "pid": pipe_name,
                      "tid": n_tracer["name"]
                      + "("
                      + n_tracer["iter"]
                      + ")",
                      "id": n_id + str(num),
                      "name": "call_op",
                      "ts": n_tracer["process_in"][i] * 1000000,
                  }
              )
              profiler_json.append(
                  {
                      "ph": "E",
                      "pid": pipe_name,
                      "tid": n_tracer["name"]
                      + "("
                      + n_tracer["iter"]
                      + ")",
                      "id": n_id + str(num),
                      "name": "call_op",
                      "ts": n_tracer["process_out"][i] * 1000000,
                  }
              )
              profiler_json.append(
                  {
                      "ph": "B",
                      "pid": pipe_name,
                      "tid": n_tracer["name"]
                      + "("
                      + n_tracer["iter"]
                      + ")",
                      "id": n_id + str(num),
                      "name": "output_data",
                      "ts": n_tracer["process_out"][i] * 1000000,
                  }
              )
              profiler_json.append(
                  {
                      "ph": "E",
                      "pid": pipe_name,
                      "tid": n_tracer["name"]
                      + "("
                      + n_tracer["iter"]
                      + ")",
                      "id": n_id + str(num),
                      "name": "output_data",
                      "ts": n_tracer["queue_out"][i] * 1000000,
                  }
              )
      return profiler_json
  
imports: import json
  from typing import Dict, List
  from tabulate import tabulate
  from copy import deepcopy
  from pathlib import Path
  from towhee.runtime.constants import WindowAllConst
  from towhee.runtime.time_profiler import Event
  from towhee.utils.log import engine_log
label_desc: Use image node_id 6 for calling the PipelineProfiler obj's underlying member method code with example usage: obj.gen_profiler_json(num) and returns: profiler_json