code: def get_ci_builds(args, completed=True):
      bname = args.branch
      # TODO: extend pagination if not done
      url = "https://circleci.com/api/v1.1/project/gh/wandb/wandb?shallow=true&limit=100"
      if completed:
          url = url + "&filter=completed"
      # print("SEND", url)
      r = requests.get(url, auth=(args.api_token, ""))
      assert r.status_code == 200, f"Error making api request: {r}"
      lst = r.json()
      cfirst = None
      ret = []
      done = False
      for d in lst:
          b = d.get("branch")
          if b != bname:
              continue
          v = d.get("vcs_revision")
          n = d.get("build_num")
          j = d.get("workflows", {}).get("job_name")
          w = d.get("workflows", {}).get("workflow_id")
          # print("DDD", d)
          cfirst = cfirst or v
          if cfirst != v:
              done = True
              break
          ret.append((v, n, j, w))
      if not done:
          return
      return ret
  
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 4 for calling a global function with example usage: get_ci_builds(args, completed) and returns: ret