code: def trigger(args):
      url = (
          "https://circleci.com/api/v2/project/gh/wandb/wandb/pipeline"
      )
      payload = {
          "branch": args.branch,
      }
      manual: bool = any(
          [
              args.platform,
              args.toxenv,
              args.test_file,
              args.test_name,
              args.test_repeat,
          ]
      )
      if manual:
          parameters = {"manual": True}
          platforms = (
              args.platform.split(",") if args.platform else ["linux"]
          )
          toxenv = args.toxenv or "py37"
          toxcmd = toxenv
          if args.test_file or args.test_repeat:
              toxcmd += " --"
          if args.test_file:
              toxcmd += " " + args.test_file
              if args.test_name:
                  toxcmd += " -k " + args.test_name
          if args.test_repeat:
              toxcmd += (
                  f" --flake-finder --flake-runs={args.test_repeat}"
              )
          # get last token split by hyphen as python version
          pyver = toxenv.split("-")[-1]
          pyname = py_name_dict.get(pyver)
          assert pyname, f"unknown pyver: {pyver}"
          # handle more complex pyenv (func tests)
          if pyver != toxenv:
              toxsplit = toxenv.split("-")
              assert len(toxsplit) == 3
              tsttyp, tstshard, tstver = toxsplit
              prefix = "s_"
              if tstshard.startswith(prefix):
                  tstshard = tstshard[len(prefix) :]
              pyname = f"{pyname}-{tsttyp}-{tstshard}"
          pyimage = py_image_dict.get(pyver)
          assert pyimage, f"unknown pyver: {pyver}"
          for p in platforms:
              job = platforms_dict.get(p)
              assert job, f"unknown platform: {p}"
              pshort = platforms_short_dict.get(p)
              jobname = f"{pshort}-{pyname}"
              parameters["manual_" + job] = True
              parameters["manual_" + job + "_name"] = jobname
              if job == "test":
                  parameters["manual_" + job + "_image"] = pyimage
              parameters["manual_" + job + "_toxenv"] = toxcmd
              if args.parallelism:
                  parameters["manual_parallelism"] = args.parallelism
              if args.xdist:
                  parameters["manual_xdist"] = args.xdist
          payload["parameters"] = parameters
      print("Sending to CircleCI:", payload)
      if args.dryrun:
          return
      r = requests.post(url, json=payload, auth=(args.api_token, ""))
      assert r.status_code == 201, "Error making api request"
      d = r.json()
      uuid = d["id"]
      print("CircleCI workflow started:", uuid)
      if args.wait or args.loop:
          poll(args, pipeline_id=uuid)
  
file_path: wandb/tools/circleci-tool.py
imports: import argparse
  import os
  import subprocess
  import sys
  import time
  import requests
label_desc: Use image node_id 2 for calling a global function with example usage: trigger(args) without return types