2024-08-06T20:02:55.7654853Z Current runner version: '2.317.0' 2024-08-06T20:02:55.7681184Z ##[group]Operating System 2024-08-06T20:02:55.7681801Z Ubuntu 2024-08-06T20:02:55.7682265Z 22.04.4 2024-08-06T20:02:55.7682559Z LTS 2024-08-06T20:02:55.7682889Z ##[endgroup] 2024-08-06T20:02:55.7683245Z ##[group]Runner Image 2024-08-06T20:02:55.7683771Z Image: ubuntu-22.04 2024-08-06T20:02:55.7684168Z Version: 20240730.2.0 2024-08-06T20:02:55.7685262Z Included Software: https://github.com/actions/runner-images/blob/ubuntu22/20240730.2/images/ubuntu/Ubuntu2204-Readme.md 2024-08-06T20:02:55.7686687Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu22%2F20240730.2 2024-08-06T20:02:55.7687560Z ##[endgroup] 2024-08-06T20:02:55.7688032Z ##[group]Runner Image Provisioner 2024-08-06T20:02:55.7688482Z 2.0.374.1 2024-08-06T20:02:55.7688832Z ##[endgroup] 2024-08-06T20:02:55.7691155Z ##[group]GITHUB_TOKEN Permissions 2024-08-06T20:02:55.7692736Z Actions: read 2024-08-06T20:02:55.7693453Z Attestations: read 2024-08-06T20:02:55.7693929Z Checks: read 2024-08-06T20:02:55.7694483Z Contents: read 2024-08-06T20:02:55.7694835Z Deployments: read 2024-08-06T20:02:55.7695250Z Discussions: read 2024-08-06T20:02:55.7695687Z Issues: read 2024-08-06T20:02:55.7696010Z Metadata: read 2024-08-06T20:02:55.7696400Z Packages: read 2024-08-06T20:02:55.7696844Z Pages: read 2024-08-06T20:02:55.7697189Z PullRequests: read 2024-08-06T20:02:55.7697601Z RepositoryProjects: read 2024-08-06T20:02:55.7698130Z SecurityEvents: read 2024-08-06T20:02:55.7698515Z Statuses: read 2024-08-06T20:02:55.7698885Z ##[endgroup] 2024-08-06T20:02:55.7701983Z Secret source: Actions 2024-08-06T20:02:55.7702553Z Prepare workflow directory 2024-08-06T20:02:55.8597543Z Prepare all required actions 2024-08-06T20:02:55.8772954Z Uses: pytorch/pytorch/.github/workflows/_runner-determinator.yml@refs/pull/132710/merge (bf5bb5a1585a03379137fab341e87c02c77e76cd) 2024-08-06T20:02:55.8780516Z ##[group] Inputs 2024-08-06T20:02:55.8781037Z triggering_actor: drisspg 2024-08-06T20:02:55.8781646Z issue_owner: drisspg 2024-08-06T20:02:55.8782084Z curr_branch: gh/drisspg/23/head 2024-08-06T20:02:55.8782617Z curr_ref_type: branch 2024-08-06T20:02:55.8783119Z issue_number: 5132 2024-08-06T20:02:55.8783517Z ##[endgroup] 2024-08-06T20:02:55.8784361Z Complete job name: get-label-type / runner-determinator 2024-08-06T20:02:55.9702398Z ##[group]Run cat < runner_determinator.py 2024-08-06T20:02:55.9703915Z cat < runner_determinator.py 2024-08-06T20:02:55.9704498Z # flake8: noqa: G004 2024-08-06T20:02:55.9705085Z  2024-08-06T20:02:55.9705414Z import logging 2024-08-06T20:02:55.9705849Z import os 2024-08-06T20:02:55.9706412Z from argparse import ArgumentParser 2024-08-06T20:02:55.9706990Z from logging import LogRecord 2024-08-06T20:02:55.9707571Z from typing import Any, Iterable 2024-08-06T20:02:55.9708194Z  2024-08-06T20:02:55.9708553Z from github import Auth, Github 2024-08-06T20:02:55.9709155Z from github.Issue import Issue 2024-08-06T20:02:55.9709751Z  2024-08-06T20:02:55.9710051Z  2024-08-06T20:02:55.9710522Z WORKFLOW_LABEL_META = "" # use meta runners 2024-08-06T20:02:55.9711939Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2024-08-06T20:02:55.9713012Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2024-08-06T20:02:55.9713941Z  2024-08-06T20:02:55.9714430Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2024-08-06T20:02:55.9715120Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2024-08-06T20:02:55.9715753Z  2024-08-06T20:02:55.9716092Z  2024-08-06T20:02:55.9716526Z class ColorFormatter(logging.Formatter): 2024-08-06T20:02:55.9717384Z  """Color codes the log messages based on the log level""" 2024-08-06T20:02:55.9718068Z  2024-08-06T20:02:55.9718398Z  COLORS = { 2024-08-06T20:02:55.9719244Z  "WARNING": "\033[33m", # Yellow 2024-08-06T20:02:55.9719872Z  "ERROR": "\033[31m", # Red 2024-08-06T20:02:55.9720417Z  "CRITICAL": "\033[31m", # Red 2024-08-06T20:02:55.9721073Z  "INFO": "\033[0m", # Reset 2024-08-06T20:02:55.9721678Z  "DEBUG": "\033[0m", # Reset 2024-08-06T20:02:55.9722210Z  } 2024-08-06T20:02:55.9722598Z  2024-08-06T20:02:55.9723076Z  def format(self, record: LogRecord) -> str: 2024-08-06T20:02:55.9724053Z  log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2024-08-06T20:02:55.9725058Z  record.msg = f"{log_color}{record.msg}\033[0m" 2024-08-06T20:02:55.9725762Z  return super().format(record) 2024-08-06T20:02:55.9726305Z  2024-08-06T20:02:55.9726684Z  2024-08-06T20:02:55.9727111Z handler = logging.StreamHandler() 2024-08-06T20:02:55.9727971Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2024-08-06T20:02:55.9728816Z  2024-08-06T20:02:55.9729324Z log = logging.getLogger(os.path.basename(__file__)) 2024-08-06T20:02:55.9730015Z log.addHandler(handler) 2024-08-06T20:02:55.9730586Z log.setLevel(logging.INFO) 2024-08-06T20:02:55.9731113Z  2024-08-06T20:02:55.9731448Z  2024-08-06T20:02:55.9732000Z def set_github_output(key: str, value: str) -> None: 2024-08-06T20:02:55.9732654Z  """ 2024-08-06T20:02:55.9733261Z  Defines outputs of the github action that invokes this script 2024-08-06T20:02:55.9734050Z  """ 2024-08-06T20:02:55.9734454Z  if not GITHUB_OUTPUT: 2024-08-06T20:02:55.9735855Z  # See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ for deprecation notice 2024-08-06T20:02:55.9737307Z  log.warning( 2024-08-06T20:02:55.9738387Z  "No env var found for GITHUB_OUTPUT, you must be running this code locally. Falling back to the deprecated print method." 2024-08-06T20:02:55.9739532Z  ) 2024-08-06T20:02:55.9740284Z  print(f"::set-output name={key}::{value}") 2024-08-06T20:02:55.9740910Z  return 2024-08-06T20:02:55.9741338Z  2024-08-06T20:02:55.9741854Z  with open(GITHUB_OUTPUT, "a") as f: 2024-08-06T20:02:55.9742516Z  log.info(f"Setting output: {key}='{value}'") 2024-08-06T20:02:55.9743206Z  f.write(f"{key}={value}\n") 2024-08-06T20:02:55.9743797Z  2024-08-06T20:02:55.9744114Z  2024-08-06T20:02:55.9744484Z def parse_args() -> Any: 2024-08-06T20:02:55.9745330Z  parser = ArgumentParser("Get dynamic rollout settings") 2024-08-06T20:02:55.9746431Z  parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2024-08-06T20:02:55.9747337Z  parser.add_argument( 2024-08-06T20:02:55.9747921Z  "--github-issue-repo", 2024-08-06T20:02:55.9748467Z  type=str, 2024-08-06T20:02:55.9748923Z  required=False, 2024-08-06T20:02:55.9749497Z  default="pytorch/test-infra", 2024-08-06T20:02:55.9750161Z  help="GitHub repo to get the issue", 2024-08-06T20:02:55.9750966Z  ) 2024-08-06T20:02:55.9751504Z  parser.add_argument( 2024-08-06T20:02:55.9752032Z  "--github-repo", 2024-08-06T20:02:55.9752518Z  type=str, 2024-08-06T20:02:55.9753015Z  required=True, 2024-08-06T20:02:55.9753590Z  help="GitHub repo where CI is running", 2024-08-06T20:02:55.9754185Z  ) 2024-08-06T20:02:55.9754642Z  parser.add_argument( 2024-08-06T20:02:55.9755402Z  "--github-issue", type=int, required=True, help="GitHub issue number" 2024-08-06T20:02:55.9756400Z  ) 2024-08-06T20:02:55.9756827Z  parser.add_argument( 2024-08-06T20:02:55.9757607Z  "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2024-08-06T20:02:55.9758425Z  ) 2024-08-06T20:02:55.9758848Z  parser.add_argument( 2024-08-06T20:02:55.9759636Z  "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2024-08-06T20:02:55.9760459Z  ) 2024-08-06T20:02:55.9760911Z  parser.add_argument( 2024-08-06T20:02:55.9761696Z  "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2024-08-06T20:02:55.9762564Z  ) 2024-08-06T20:02:55.9763020Z  parser.add_argument( 2024-08-06T20:02:55.9763499Z  "--github-ref-type", 2024-08-06T20:02:55.9764031Z  type=str, 2024-08-06T20:02:55.9764542Z  required=True, 2024-08-06T20:02:55.9765132Z  help="Current GitHub ref type, branch or tag", 2024-08-06T20:02:55.9765764Z  ) 2024-08-06T20:02:55.9766234Z  2024-08-06T20:02:55.9766604Z  return parser.parse_args() 2024-08-06T20:02:55.9767122Z  2024-08-06T20:02:55.9767529Z  2024-08-06T20:02:55.9767977Z def get_gh_client(github_token: str) -> Github: 2024-08-06T20:02:55.9768679Z  auth = Auth.Token(github_token) 2024-08-06T20:02:55.9769318Z  return Github(auth=auth) 2024-08-06T20:02:55.9769798Z  2024-08-06T20:02:55.9770127Z  2024-08-06T20:02:55.9770767Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: 2024-08-06T20:02:55.9771486Z  repo = gh.get_repo(repo) 2024-08-06T20:02:55.9772084Z  return repo.get_issue(number=issue_num) 2024-08-06T20:02:55.9772741Z  2024-08-06T20:02:55.9773043Z  2024-08-06T20:02:55.9773421Z def get_potential_pr_author( 2024-08-06T20:02:55.9774257Z  gh: Github, repo: str, username: str, ref_type: str, ref_name: str 2024-08-06T20:02:55.9774971Z ) -> str: 2024-08-06T20:02:55.9775813Z  # If the trigger was a new tag added by a bot, this is a ciflow case 2024-08-06T20:02:55.9776945Z  # Fetch the actual username from the original PR. The PR number is 2024-08-06T20:02:55.9777877Z  # embedded in the tag name: ciflow// 2024-08-06T20:02:55.9778702Z  if username == "pytorch-bot[bot]" and ref_type == "tag": 2024-08-06T20:02:55.9779519Z  split_tag = ref_name.split("/") 2024-08-06T20:02:55.9780089Z  if ( 2024-08-06T20:02:55.9780506Z  len(split_tag) == 3 2024-08-06T20:02:55.9781164Z  and split_tag[0] == "ciflow" 2024-08-06T20:02:55.9781788Z  and split_tag[2].isnumeric() 2024-08-06T20:02:55.9782339Z  ): 2024-08-06T20:02:55.9782847Z  pr_number = split_tag[2] 2024-08-06T20:02:55.9783416Z  try: 2024-08-06T20:02:55.9783921Z  repository = gh.get_repo(repo) 2024-08-06T20:02:55.9784742Z  pull = repository.get_pull(number=int(pr_number)) 2024-08-06T20:02:55.9785480Z  except Exception as e: 2024-08-06T20:02:55.9786179Z  raise Exception( # noqa: TRY002 2024-08-06T20:02:55.9786980Z  f"issue with pull request {pr_number} from repo {repository}" 2024-08-06T20:02:55.9787772Z  ) from e 2024-08-06T20:02:55.9788365Z  return pull.user.login 2024-08-06T20:02:55.9789056Z  # In all other cases, return the original input username 2024-08-06T20:02:55.9789773Z  return username 2024-08-06T20:02:55.9790280Z  2024-08-06T20:02:55.9790578Z  2024-08-06T20:02:55.9791575Z def is_exception_branch(branch: str) -> bool: 2024-08-06T20:02:55.9792637Z  return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2024-08-06T20:02:55.9793421Z  2024-08-06T20:02:55.9793758Z  2024-08-06T20:02:55.9794497Z def get_workflow_type(issue: Issue, workflow_requestors: Iterable[str]) -> str: 2024-08-06T20:02:55.9795348Z  try: 2024-08-06T20:02:55.9795901Z  first_comment = issue.get_comments()[0].body.strip("\n\t ") 2024-08-06T20:02:55.9796677Z  2024-08-06T20:02:55.9797086Z  if first_comment[0] == "!": 2024-08-06T20:02:55.9797891Z  log.info("LF Workflows are disabled for everyone. Using meta runners.") 2024-08-06T20:02:55.9798944Z  return WORKFLOW_LABEL_META 2024-08-06T20:02:55.9799578Z  elif first_comment[0] == "*": 2024-08-06T20:02:55.9800368Z  log.info("LF Workflows are enabled for everyone. Using LF runners.") 2024-08-06T20:02:55.9801306Z  return WORKFLOW_LABEL_LF 2024-08-06T20:02:55.9801854Z  else: 2024-08-06T20:02:55.9802270Z  all_opted_in_users = { 2024-08-06T20:02:55.9803128Z  usr_raw.strip("\n\t@ ") for usr_raw in first_comment.split() 2024-08-06T20:02:55.9803882Z  } 2024-08-06T20:02:55.9804345Z  opted_in_requestors = { 2024-08-06T20:02:55.9805175Z  usr for usr in workflow_requestors if usr in all_opted_in_users 2024-08-06T20:02:55.9805930Z  } 2024-08-06T20:02:55.9806401Z  if opted_in_requestors: 2024-08-06T20:02:55.9806976Z  log.info( 2024-08-06T20:02:55.9807830Z  f"LF Workflows are enabled for {', '.join(opted_in_requestors)}. Using LF runners." 2024-08-06T20:02:55.9808707Z  ) 2024-08-06T20:02:55.9809236Z  return WORKFLOW_LABEL_LF 2024-08-06T20:02:55.9809806Z  else: 2024-08-06T20:02:55.9810262Z  log.info( 2024-08-06T20:02:55.9811314Z  f"LF Workflows are disabled for {', '.join(workflow_requestors)}. Using meta runners." 2024-08-06T20:02:55.9812208Z  ) 2024-08-06T20:02:55.9812725Z  return WORKFLOW_LABEL_META 2024-08-06T20:02:55.9813355Z  2024-08-06T20:02:55.9813713Z  except Exception as e: 2024-08-06T20:02:55.9814221Z  log.error( 2024-08-06T20:02:55.9815151Z  f"Failed to get determine workflow type. Falling back to meta runners. Exception: {e}" 2024-08-06T20:02:55.9816033Z  ) 2024-08-06T20:02:55.9816466Z  return WORKFLOW_LABEL_META 2024-08-06T20:02:55.9817068Z  2024-08-06T20:02:55.9817384Z  2024-08-06T20:02:55.9817739Z def main() -> None: 2024-08-06T20:02:55.9818270Z  args = parse_args() 2024-08-06T20:02:55.9818729Z  2024-08-06T20:02:55.9819417Z  if args.github_ref_type == "branch" and is_exception_branch(args.github_branch): 2024-08-06T20:02:55.9820662Z  log.info(f"Exception branch: '{args.github_branch}', using meta runners") 2024-08-06T20:02:55.9821512Z  label_type = WORKFLOW_LABEL_META 2024-08-06T20:02:55.9822076Z  else: 2024-08-06T20:02:55.9822556Z  try: 2024-08-06T20:02:55.9823027Z  gh = get_gh_client(args.github_token) 2024-08-06T20:02:55.9823981Z  # The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2024-08-06T20:02:55.9825136Z  issue = get_issue(gh, args.github_issue_repo, args.github_issue) 2024-08-06T20:02:55.9825978Z  username = get_potential_pr_author( 2024-08-06T20:02:55.9826700Z  gh, 2024-08-06T20:02:55.9827267Z  args.github_repo, 2024-08-06T20:02:55.9827843Z  args.github_actor, 2024-08-06T20:02:55.9828403Z  args.github_ref_type, 2024-08-06T20:02:55.9829106Z  args.github_branch, 2024-08-06T20:02:55.9829605Z  ) 2024-08-06T20:02:55.9830129Z  label_type = get_workflow_type( 2024-08-06T20:02:55.9831054Z  issue, 2024-08-06T20:02:55.9831522Z  ( 2024-08-06T20:02:55.9832076Z  args.github_issue_owner, 2024-08-06T20:02:55.9832756Z  username, 2024-08-06T20:02:55.9833223Z  ), 2024-08-06T20:02:55.9833671Z  ) 2024-08-06T20:02:55.9834186Z  except Exception as e: 2024-08-06T20:02:55.9834697Z  log.error( 2024-08-06T20:02:55.9835457Z  f"Failed to get issue. Falling back to meta runners. Exception: {e}" 2024-08-06T20:02:55.9836302Z  ) 2024-08-06T20:02:55.9836771Z  label_type = WORKFLOW_LABEL_META 2024-08-06T20:02:55.9837363Z  2024-08-06T20:02:55.9837859Z  # For Canary builds use canary runners 2024-08-06T20:02:55.9838836Z  if args.github_repo == "pytorch/pytorch-canary" and label_type == WORKFLOW_LABEL_LF: 2024-08-06T20:02:55.9839769Z  label_type = WORKFLOW_LABEL_LF_CANARY 2024-08-06T20:02:55.9840407Z  2024-08-06T20:02:55.9840953Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, label_type) 2024-08-06T20:02:55.9841595Z  2024-08-06T20:02:55.9842048Z if __name__ == "__main__": 2024-08-06T20:02:55.9842534Z  main() 2024-08-06T20:02:55.9842883Z EOF 2024-08-06T20:02:55.9843302Z  2024-08-06T20:02:55.9843703Z cat runner_determinator.py 2024-08-06T20:02:56.0146645Z shell: /usr/bin/bash -e {0} 2024-08-06T20:02:56.0147166Z env: 2024-08-06T20:02:56.0147923Z GITHUB_TOKEN: *** 2024-08-06T20:02:56.0148386Z ISSUE_NUMBER: 5132 2024-08-06T20:02:56.0148808Z TRIGGERING_ACTOR: drisspg 2024-08-06T20:02:56.0149513Z ISSUE_OWNER: drisspg 2024-08-06T20:02:56.0149974Z ##[endgroup] 2024-08-06T20:02:56.0548679Z # flake8: noqa: G004 2024-08-06T20:02:56.0549012Z 2024-08-06T20:02:56.0549178Z import logging 2024-08-06T20:02:56.0549592Z import os 2024-08-06T20:02:56.0551391Z from argparse import ArgumentParser 2024-08-06T20:02:56.0552024Z from logging import LogRecord 2024-08-06T20:02:56.0552537Z from typing import Any, Iterable 2024-08-06T20:02:56.0553002Z 2024-08-06T20:02:56.0553190Z from github import Auth, Github 2024-08-06T20:02:56.0553725Z from github.Issue import Issue 2024-08-06T20:02:56.0554035Z 2024-08-06T20:02:56.0554041Z 2024-08-06T20:02:56.0554305Z WORKFLOW_LABEL_META = "" # use meta runners 2024-08-06T20:02:56.0555117Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2024-08-06T20:02:56.0556108Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2024-08-06T20:02:56.0556764Z 2024-08-06T20:02:56.0557021Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2024-08-06T20:02:56.0557900Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2024-08-06T20:02:56.0558306Z 2024-08-06T20:02:56.0558311Z 2024-08-06T20:02:56.0558520Z class ColorFormatter(logging.Formatter): 2024-08-06T20:02:56.0559222Z """Color codes the log messages based on the log level""" 2024-08-06T20:02:56.0559766Z 2024-08-06T20:02:56.0559925Z COLORS = { 2024-08-06T20:02:56.0560374Z "WARNING": "\033[33m", # Yellow 2024-08-06T20:02:56.0560939Z "ERROR": "\033[31m", # Red 2024-08-06T20:02:56.0561509Z "CRITICAL": "\033[31m", # Red 2024-08-06T20:02:56.0562072Z "INFO": "\033[0m", # Reset 2024-08-06T20:02:56.0562618Z "DEBUG": "\033[0m", # Reset 2024-08-06T20:02:56.0563157Z } 2024-08-06T20:02:56.0563646Z 2024-08-06T20:02:56.0563933Z def format(self, record: LogRecord) -> str: 2024-08-06T20:02:56.0564780Z log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2024-08-06T20:02:56.0565776Z record.msg = f"{log_color}{record.msg}\033[0m" 2024-08-06T20:02:56.0566403Z return super().format(record) 2024-08-06T20:02:56.0566788Z 2024-08-06T20:02:56.0566793Z 2024-08-06T20:02:56.0566984Z handler = logging.StreamHandler() 2024-08-06T20:02:56.0567915Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2024-08-06T20:02:56.0568522Z 2024-08-06T20:02:56.0568777Z log = logging.getLogger(os.path.basename(__file__)) 2024-08-06T20:02:56.0569428Z log.addHandler(handler) 2024-08-06T20:02:56.0569992Z log.setLevel(logging.INFO) 2024-08-06T20:02:56.0570279Z 2024-08-06T20:02:56.0570284Z 2024-08-06T20:02:56.0570596Z def set_github_output(key: str, value: str) -> None: 2024-08-06T20:02:56.0571218Z """ 2024-08-06T20:02:56.0571851Z Defines outputs of the github action that invokes this script 2024-08-06T20:02:56.0572513Z """ 2024-08-06T20:02:56.0572892Z if not GITHUB_OUTPUT: 2024-08-06T20:02:56.0574345Z # See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ for deprecation notice 2024-08-06T20:02:56.0575706Z log.warning( 2024-08-06T20:02:56.0576680Z "No env var found for GITHUB_OUTPUT, you must be running this code locally. Falling back to the deprecated print method." 2024-08-06T20:02:56.0577863Z ) 2024-08-06T20:02:56.0601291Z print(f"::set-output name={key}::{value}") 2024-08-06T20:02:56.0602058Z return 2024-08-06T20:02:56.0602287Z 2024-08-06T20:02:56.0602499Z with open(GITHUB_OUTPUT, "a") as f: 2024-08-06T20:02:56.0603204Z log.info(f"Setting output: {key}='{value}'") 2024-08-06T20:02:56.0603908Z f.write(f"{key}={value}\n") 2024-08-06T20:02:56.0604243Z 2024-08-06T20:02:56.0604249Z 2024-08-06T20:02:56.0604468Z def parse_args() -> Any: 2024-08-06T20:02:56.0605082Z parser = ArgumentParser("Get dynamic rollout settings") 2024-08-06T20:02:56.0606182Z parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2024-08-06T20:02:56.0607020Z parser.add_argument( 2024-08-06T20:02:56.0607765Z "--github-issue-repo", 2024-08-06T20:02:56.0608361Z type=str, 2024-08-06T20:02:56.0608772Z required=False, 2024-08-06T20:02:56.0609290Z default="pytorch/test-infra", 2024-08-06T20:02:56.0609964Z help="GitHub repo to get the issue", 2024-08-06T20:02:56.0610510Z ) 2024-08-06T20:02:56.0610891Z parser.add_argument( 2024-08-06T20:02:56.0611450Z "--github-repo", 2024-08-06T20:02:56.0611870Z type=str, 2024-08-06T20:02:56.0612274Z required=True, 2024-08-06T20:02:56.0612843Z help="GitHub repo where CI is running", 2024-08-06T20:02:56.0613387Z ) 2024-08-06T20:02:56.0613761Z parser.add_argument( 2024-08-06T20:02:56.0614568Z "--github-issue", type=int, required=True, help="GitHub issue number" 2024-08-06T20:02:56.0615273Z ) 2024-08-06T20:02:56.0615648Z parser.add_argument( 2024-08-06T20:02:56.0616485Z "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2024-08-06T20:02:56.0617234Z ) 2024-08-06T20:02:56.0617606Z parser.add_argument( 2024-08-06T20:02:56.0618445Z "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2024-08-06T20:02:56.0619193Z ) 2024-08-06T20:02:56.0619566Z parser.add_argument( 2024-08-06T20:02:56.0620425Z "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2024-08-06T20:02:56.0621201Z ) 2024-08-06T20:02:56.0621577Z parser.add_argument( 2024-08-06T20:02:56.0622167Z "--github-ref-type", 2024-08-06T20:02:56.0622619Z type=str, 2024-08-06T20:02:56.0623046Z required=True, 2024-08-06T20:02:56.0623630Z help="Current GitHub ref type, branch or tag", 2024-08-06T20:02:56.0624383Z ) 2024-08-06T20:02:56.0624619Z 2024-08-06T20:02:56.0624812Z return parser.parse_args() 2024-08-06T20:02:56.0625123Z 2024-08-06T20:02:56.0625128Z 2024-08-06T20:02:56.0625531Z def get_gh_client(github_token: str) -> Github: 2024-08-06T20:02:56.0626182Z auth = Auth.Token(github_token) 2024-08-06T20:02:56.0626687Z return Github(auth=auth) 2024-08-06T20:02:56.0627012Z 2024-08-06T20:02:56.0627017Z 2024-08-06T20:02:56.0627454Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: 2024-08-06T20:02:56.0628185Z repo = gh.get_repo(repo) 2024-08-06T20:02:56.0628667Z return repo.get_issue(number=issue_num) 2024-08-06T20:02:56.0629089Z 2024-08-06T20:02:56.0629094Z 2024-08-06T20:02:56.0629338Z def get_potential_pr_author( 2024-08-06T20:02:56.0630014Z gh: Github, repo: str, username: str, ref_type: str, ref_name: str 2024-08-06T20:02:56.0630724Z ) -> str: 2024-08-06T20:02:56.0631713Z # If the trigger was a new tag added by a bot, this is a ciflow case 2024-08-06T20:02:56.0632685Z # Fetch the actual username from the original PR. The PR number is 2024-08-06T20:02:56.0633550Z # embedded in the tag name: ciflow// 2024-08-06T20:02:56.0634438Z if username == "pytorch-bot[bot]" and ref_type == "tag": 2024-08-06T20:02:56.0635165Z split_tag = ref_name.split("/") 2024-08-06T20:02:56.0635679Z if ( 2024-08-06T20:02:56.0636154Z len(split_tag) == 3 2024-08-06T20:02:56.0636691Z and split_tag[0] == "ciflow" 2024-08-06T20:02:56.0637219Z and split_tag[2].isnumeric() 2024-08-06T20:02:56.0637822Z ): 2024-08-06T20:02:56.0638222Z pr_number = split_tag[2] 2024-08-06T20:02:56.0638734Z try: 2024-08-06T20:02:56.0639274Z repository = gh.get_repo(repo) 2024-08-06T20:02:56.0639958Z pull = repository.get_pull(number=int(pr_number)) 2024-08-06T20:02:56.0640598Z except Exception as e: 2024-08-06T20:02:56.0641235Z raise Exception( # noqa: TRY002 2024-08-06T20:02:56.0641992Z f"issue with pull request {pr_number} from repo {repository}" 2024-08-06T20:02:56.0642716Z ) from e 2024-08-06T20:02:56.0643225Z return pull.user.login 2024-08-06T20:02:56.0644027Z # In all other cases, return the original input username 2024-08-06T20:02:56.0644729Z return username 2024-08-06T20:02:56.0644965Z 2024-08-06T20:02:56.0644971Z 2024-08-06T20:02:56.0645319Z def is_exception_branch(branch: str) -> bool: 2024-08-06T20:02:56.0646138Z return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2024-08-06T20:02:56.0646750Z 2024-08-06T20:02:56.0646755Z 2024-08-06T20:02:56.0647290Z def get_workflow_type(issue: Issue, workflow_requestors: Iterable[str]) -> str: 2024-08-06T20:02:56.0648134Z try: 2024-08-06T20:02:56.0648651Z first_comment = issue.get_comments()[0].body.strip("\n\t ") 2024-08-06T20:02:56.0649171Z 2024-08-06T20:02:56.0649380Z if first_comment[0] == "!": 2024-08-06T20:02:56.0650194Z log.info("LF Workflows are disabled for everyone. Using meta runners.") 2024-08-06T20:02:56.0650968Z return WORKFLOW_LABEL_META 2024-08-06T20:02:56.0651539Z elif first_comment[0] == "*": 2024-08-06T20:02:56.0652339Z log.info("LF Workflows are enabled for everyone. Using LF runners.") 2024-08-06T20:02:56.0653102Z return WORKFLOW_LABEL_LF 2024-08-06T20:02:56.0653628Z else: 2024-08-06T20:02:56.0654101Z all_opted_in_users = { 2024-08-06T20:02:56.0654779Z usr_raw.strip("\n\t@ ") for usr_raw in first_comment.split() 2024-08-06T20:02:56.0655482Z } 2024-08-06T20:02:56.0655961Z opted_in_requestors = { 2024-08-06T20:02:56.0656642Z usr for usr in workflow_requestors if usr in all_opted_in_users 2024-08-06T20:02:56.0657366Z } 2024-08-06T20:02:56.0657828Z if opted_in_requestors: 2024-08-06T20:02:56.0658333Z log.info( 2024-08-06T20:02:56.0659323Z f"LF Workflows are enabled for {', '.join(opted_in_requestors)}. Using LF runners." 2024-08-06T20:02:56.0660250Z ) 2024-08-06T20:02:56.0660652Z return WORKFLOW_LABEL_LF 2024-08-06T20:02:56.0661203Z else: 2024-08-06T20:02:56.0661683Z log.info( 2024-08-06T20:02:56.0662503Z f"LF Workflows are disabled for {', '.join(workflow_requestors)}. Using meta runners." 2024-08-06T20:02:56.0663366Z ) 2024-08-06T20:02:56.0663880Z return WORKFLOW_LABEL_META 2024-08-06T20:02:56.0664254Z 2024-08-06T20:02:56.0664427Z except Exception as e: 2024-08-06T20:02:56.0664901Z log.error( 2024-08-06T20:02:56.0665725Z f"Failed to get determine workflow type. Falling back to meta runners. Exception: {e}" 2024-08-06T20:02:56.0666560Z ) 2024-08-06T20:02:56.0666972Z return WORKFLOW_LABEL_META 2024-08-06T20:02:56.0667296Z 2024-08-06T20:02:56.0667307Z 2024-08-06T20:02:56.0667595Z def main() -> None: 2024-08-06T20:02:56.0667991Z args = parse_args() 2024-08-06T20:02:56.0668287Z 2024-08-06T20:02:56.0668726Z if args.github_ref_type == "branch" and is_exception_branch(args.github_branch): 2024-08-06T20:02:56.0669931Z log.info(f"Exception branch: '{args.github_branch}', using meta runners") 2024-08-06T20:02:56.0670961Z label_type = WORKFLOW_LABEL_META 2024-08-06T20:02:56.0671518Z else: 2024-08-06T20:02:56.0671970Z try: 2024-08-06T20:02:56.0672412Z gh = get_gh_client(args.github_token) 2024-08-06T20:02:56.0673345Z # The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2024-08-06T20:02:56.0674423Z issue = get_issue(gh, args.github_issue_repo, args.github_issue) 2024-08-06T20:02:56.0675225Z username = get_potential_pr_author( 2024-08-06T20:02:56.0675768Z gh, 2024-08-06T20:02:56.0676261Z args.github_repo, 2024-08-06T20:02:56.0676802Z args.github_actor, 2024-08-06T20:02:56.0677293Z args.github_ref_type, 2024-08-06T20:02:56.0677928Z args.github_branch, 2024-08-06T20:02:56.0678459Z ) 2024-08-06T20:02:56.0679010Z label_type = get_workflow_type( 2024-08-06T20:02:56.0679674Z issue, 2024-08-06T20:02:56.0680114Z ( 2024-08-06T20:02:56.0680517Z args.github_issue_owner, 2024-08-06T20:02:56.0681157Z username, 2024-08-06T20:02:56.0681618Z ), 2024-08-06T20:02:56.0681982Z ) 2024-08-06T20:02:56.0682462Z except Exception as e: 2024-08-06T20:02:56.0682953Z log.error( 2024-08-06T20:02:56.0683608Z f"Failed to get issue. Falling back to meta runners. Exception: {e}" 2024-08-06T20:02:56.0684474Z ) 2024-08-06T20:02:56.0684900Z label_type = WORKFLOW_LABEL_META 2024-08-06T20:02:56.0685284Z 2024-08-06T20:02:56.0685490Z # For Canary builds use canary runners 2024-08-06T20:02:56.0686547Z if args.github_repo == "pytorch/pytorch-canary" and label_type == WORKFLOW_LABEL_LF: 2024-08-06T20:02:56.0687451Z label_type = WORKFLOW_LABEL_LF_CANARY 2024-08-06T20:02:56.0687835Z 2024-08-06T20:02:56.0688113Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, label_type) 2024-08-06T20:02:56.0688704Z 2024-08-06T20:02:56.0688872Z if __name__ == "__main__": 2024-08-06T20:02:56.0689331Z main() 2024-08-06T20:02:56.0869910Z ##[group]Run python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2024-08-06T20:02:56.0871681Z python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2024-08-06T20:02:56.0905421Z shell: /usr/bin/bash -e {0} 2024-08-06T20:02:56.0905851Z env: 2024-08-06T20:02:56.0906551Z GITHUB_TOKEN: *** 2024-08-06T20:02:56.0906988Z ISSUE_NUMBER: 5132 2024-08-06T20:02:56.0907372Z TRIGGERING_ACTOR: drisspg 2024-08-06T20:02:56.0907894Z ISSUE_OWNER: drisspg 2024-08-06T20:02:56.0908510Z ##[endgroup] 2024-08-06T20:02:57.4107166Z Defaulting to user installation because normal site-packages is not writeable 2024-08-06T20:02:58.2183282Z Collecting urllib3==1.26.18 2024-08-06T20:02:58.2769306Z Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB) 2024-08-06T20:02:58.3048002Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.8/143.8 KB 5.5 MB/s eta 0:00:00 2024-08-06T20:02:58.3451727Z Collecting PyGithub==2.3.0 2024-08-06T20:02:58.3567535Z Downloading PyGithub-2.3.0-py3-none-any.whl (354 kB) 2024-08-06T20:02:58.3975311Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 354.4/354.4 KB 8.9 MB/s eta 0:00:00 2024-08-06T20:02:58.4613060Z Collecting pynacl>=1.4.0 2024-08-06T20:02:58.4719927Z Downloading PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (856 kB) 2024-08-06T20:02:58.5410296Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 856.7/856.7 KB 12.7 MB/s eta 0:00:00 2024-08-06T20:02:58.5804388Z Collecting pyjwt[crypto]>=2.4.0 2024-08-06T20:02:58.5907691Z Downloading PyJWT-2.9.0-py3-none-any.whl (22 kB) 2024-08-06T20:02:58.5943614Z Requirement already satisfied: requests>=2.14.0 in /usr/lib/python3/dist-packages (from PyGithub==2.3.0) (2.25.1) 2024-08-06T20:02:58.6214173Z Collecting Deprecated 2024-08-06T20:02:58.6316677Z Downloading Deprecated-1.2.14-py2.py3-none-any.whl (9.6 kB) 2024-08-06T20:02:58.6688035Z Collecting typing-extensions>=4.0.0 2024-08-06T20:02:58.6793505Z Downloading typing_extensions-4.12.2-py3-none-any.whl (37 kB) 2024-08-06T20:02:58.6933567Z Requirement already satisfied: cryptography>=3.4.0 in /usr/lib/python3/dist-packages (from pyjwt[crypto]>=2.4.0->PyGithub==2.3.0) (3.4.8) 2024-08-06T20:02:58.9258059Z Collecting cffi>=1.4.1 2024-08-06T20:02:58.9379359Z Downloading cffi-1.17.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (445 kB) 2024-08-06T20:02:58.9682494Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 445.9/445.9 KB 15.6 MB/s eta 0:00:00 2024-08-06T20:02:59.1284881Z Collecting wrapt<2,>=1.10 2024-08-06T20:02:59.1388798Z Downloading wrapt-1.16.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (80 kB) 2024-08-06T20:02:59.1464743Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 80.3/80.3 KB 12.4 MB/s eta 0:00:00 2024-08-06T20:02:59.1694356Z Collecting pycparser 2024-08-06T20:02:59.1795148Z Downloading pycparser-2.22-py3-none-any.whl (117 kB) 2024-08-06T20:02:59.1880114Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.6/117.6 KB 16.6 MB/s eta 0:00:00 2024-08-06T20:02:59.4697749Z Installing collected packages: wrapt, urllib3, typing-extensions, pyjwt, pycparser, Deprecated, cffi, pynacl, PyGithub 2024-08-06T20:02:59.9372861Z Successfully installed Deprecated-1.2.14 PyGithub-2.3.0 cffi-1.17.0 pycparser-2.22 pyjwt-2.9.0 pynacl-1.5.0 typing-extensions-4.12.2 urllib3-1.26.18 wrapt-1.16.0 2024-08-06T20:03:00.0129354Z ##[group]Run curr_branch="gh/drisspg/23/head" 2024-08-06T20:03:00.0129969Z curr_branch="gh/drisspg/23/head" 2024-08-06T20:03:00.0130382Z curr_ref_type="branch" 2024-08-06T20:03:00.0131039Z echo "Current branch is '$curr_branch'" 2024-08-06T20:03:00.0131483Z  2024-08-06T20:03:00.0131788Z python3 runner_determinator.py \ 2024-08-06T20:03:00.0132377Z  --github-token "$GITHUB_TOKEN" \ 2024-08-06T20:03:00.0132860Z  --github-issue "$ISSUE_NUMBER" \ 2024-08-06T20:03:00.0133274Z  --github-branch "$curr_branch" \ 2024-08-06T20:03:00.0133853Z  --github-actor "$TRIGGERING_ACTOR" \ 2024-08-06T20:03:00.0134343Z  --github-issue-owner "$ISSUE_OWNER" \ 2024-08-06T20:03:00.0134817Z  --github-ref-type "$curr_ref_type" \ 2024-08-06T20:03:00.0135395Z  --github-repo "$GITHUB_REPOSITORY" 2024-08-06T20:03:00.0169894Z shell: /usr/bin/bash -e {0} 2024-08-06T20:03:00.0170536Z env: 2024-08-06T20:03:00.0171154Z GITHUB_TOKEN: *** 2024-08-06T20:03:00.0171617Z ISSUE_NUMBER: 5132 2024-08-06T20:03:00.0171991Z TRIGGERING_ACTOR: drisspg 2024-08-06T20:03:00.0172533Z ISSUE_OWNER: drisspg 2024-08-06T20:03:00.0172996Z ##[endgroup] 2024-08-06T20:03:00.0231220Z Current branch is 'gh/drisspg/23/head' 2024-08-06T20:03:01.5943667Z INFO : LF Workflows are disabled for drisspg, drisspg. Using meta runners. 2024-08-06T20:03:01.5945004Z INFO : Setting output: label-type='' 2024-08-06T20:03:01.6322764Z Evaluate and set job outputs 2024-08-06T20:03:01.6334006Z Cleaning up orphan processes