2024-08-08T20:08:55.1170924Z Current runner version: '2.317.0' 2024-08-08T20:08:55.1192983Z ##[group]Operating System 2024-08-08T20:08:55.1193709Z Ubuntu 2024-08-08T20:08:55.1194055Z 22.04.4 2024-08-08T20:08:55.1194363Z LTS 2024-08-08T20:08:55.1194768Z ##[endgroup] 2024-08-08T20:08:55.1195109Z ##[group]Runner Image 2024-08-08T20:08:55.1195555Z Image: ubuntu-22.04 2024-08-08T20:08:55.1196016Z Version: 20240804.1.0 2024-08-08T20:08:55.1197046Z Included Software: https://github.com/actions/runner-images/blob/ubuntu22/20240804.1/images/ubuntu/Ubuntu2204-Readme.md 2024-08-08T20:08:55.1198429Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu22%2F20240804.1 2024-08-08T20:08:55.1199364Z ##[endgroup] 2024-08-08T20:08:55.1199776Z ##[group]Runner Image Provisioner 2024-08-08T20:08:55.1200217Z 2.0.374.1 2024-08-08T20:08:55.1200612Z ##[endgroup] 2024-08-08T20:08:55.1202800Z ##[group]GITHUB_TOKEN Permissions 2024-08-08T20:08:55.1204378Z Actions: read 2024-08-08T20:08:55.1205094Z Attestations: read 2024-08-08T20:08:55.1205650Z Checks: read 2024-08-08T20:08:55.1206033Z Contents: read 2024-08-08T20:08:55.1206374Z Deployments: read 2024-08-08T20:08:55.1206837Z Discussions: read 2024-08-08T20:08:55.1207226Z Issues: read 2024-08-08T20:08:55.1207709Z Metadata: read 2024-08-08T20:08:55.1208448Z Packages: read 2024-08-08T20:08:55.1209059Z Pages: read 2024-08-08T20:08:55.1209598Z PullRequests: read 2024-08-08T20:08:55.1210385Z RepositoryProjects: read 2024-08-08T20:08:55.1211104Z SecurityEvents: read 2024-08-08T20:08:55.1211591Z Statuses: read 2024-08-08T20:08:55.1212118Z ##[endgroup] 2024-08-08T20:08:55.1215092Z Secret source: Actions 2024-08-08T20:08:55.1215634Z Prepare workflow directory 2024-08-08T20:08:55.2119703Z Prepare all required actions 2024-08-08T20:08:55.2282371Z Uses: pytorch/pytorch/.github/workflows/_runner-determinator.yml@refs/tags/ciflow/trunk/132710 (b9d86fa89636e301796d4201f36d86c73f6e49bc) 2024-08-08T20:08:55.2287251Z ##[group] Inputs 2024-08-08T20:08:55.2287893Z triggering_actor: pytorch-bot[bot] 2024-08-08T20:08:55.2288412Z issue_owner: 2024-08-08T20:08:55.2288887Z curr_branch: ciflow/trunk/132710 2024-08-08T20:08:55.2289536Z curr_ref_type: tag 2024-08-08T20:08:55.2289911Z issue_number: 5132 2024-08-08T20:08:55.2290325Z ##[endgroup] 2024-08-08T20:08:55.2291275Z Complete job name: get-label-type / runner-determinator 2024-08-08T20:08:55.3179101Z ##[group]Run cat < runner_determinator.py 2024-08-08T20:08:55.3181071Z cat < runner_determinator.py 2024-08-08T20:08:55.3182304Z # flake8: noqa: G004 2024-08-08T20:08:55.3183052Z  2024-08-08T20:08:55.3183685Z import logging 2024-08-08T20:08:55.3184586Z import os 2024-08-08T20:08:55.3185766Z from argparse import ArgumentParser 2024-08-08T20:08:55.3186776Z from logging import LogRecord 2024-08-08T20:08:55.3187905Z from typing import Any, Iterable 2024-08-08T20:08:55.3188843Z  2024-08-08T20:08:55.3189638Z from github import Auth, Github 2024-08-08T20:08:55.3190716Z from github.Issue import Issue 2024-08-08T20:08:55.3191644Z  2024-08-08T20:08:55.3192276Z  2024-08-08T20:08:55.3193197Z WORKFLOW_LABEL_META = "" # use meta runners 2024-08-08T20:08:55.3194721Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2024-08-08T20:08:55.3196490Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2024-08-08T20:08:55.3197799Z  2024-08-08T20:08:55.3198586Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2024-08-08T20:08:55.3199895Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2024-08-08T20:08:55.3200833Z  2024-08-08T20:08:55.3201467Z  2024-08-08T20:08:55.3202076Z class ColorFormatter(logging.Formatter): 2024-08-08T20:08:55.3202859Z  """Color codes the log messages based on the log level""" 2024-08-08T20:08:55.3203594Z  2024-08-08T20:08:55.3203975Z  COLORS = { 2024-08-08T20:08:55.3204933Z  "WARNING": "\033[33m", # Yellow 2024-08-08T20:08:55.3205587Z  "ERROR": "\033[31m", # Red 2024-08-08T20:08:55.3206167Z  "CRITICAL": "\033[31m", # Red 2024-08-08T20:08:55.3206764Z  "INFO": "\033[0m", # Reset 2024-08-08T20:08:55.3207373Z  "DEBUG": "\033[0m", # Reset 2024-08-08T20:08:55.3207907Z  } 2024-08-08T20:08:55.3208290Z  2024-08-08T20:08:55.3208781Z  def format(self, record: LogRecord) -> str: 2024-08-08T20:08:55.3209715Z  log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2024-08-08T20:08:55.3210683Z  record.msg = f"{log_color}{record.msg}\033[0m" 2024-08-08T20:08:55.3211451Z  return super().format(record) 2024-08-08T20:08:55.3211971Z  2024-08-08T20:08:55.3212302Z  2024-08-08T20:08:55.3212769Z handler = logging.StreamHandler() 2024-08-08T20:08:55.3213606Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2024-08-08T20:08:55.3214403Z  2024-08-08T20:08:55.3214969Z log = logging.getLogger(os.path.basename(__file__)) 2024-08-08T20:08:55.3215628Z log.addHandler(handler) 2024-08-08T20:08:55.3216148Z log.setLevel(logging.INFO) 2024-08-08T20:08:55.3216697Z  2024-08-08T20:08:55.3217014Z  2024-08-08T20:08:55.3217515Z def set_github_output(key: str, value: str) -> None: 2024-08-08T20:08:55.3218264Z  """ 2024-08-08T20:08:55.3218835Z  Defines outputs of the github action that invokes this script 2024-08-08T20:08:55.3219554Z  """ 2024-08-08T20:08:55.3220034Z  if not GITHUB_OUTPUT: 2024-08-08T20:08:55.3221385Z  # See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ for deprecation notice 2024-08-08T20:08:55.3222711Z  log.warning( 2024-08-08T20:08:55.3223889Z  "No env var found for GITHUB_OUTPUT, you must be running this code locally. Falling back to the deprecated print method." 2024-08-08T20:08:55.3225296Z  ) 2024-08-08T20:08:55.3225972Z  print(f"::set-output name={key}::{value}") 2024-08-08T20:08:55.3226727Z  return 2024-08-08T20:08:55.3227136Z  2024-08-08T20:08:55.3227558Z  with open(GITHUB_OUTPUT, "a") as f: 2024-08-08T20:08:55.3228312Z  log.info(f"Setting output: {key}='{value}'") 2024-08-08T20:08:55.3228973Z  f.write(f"{key}={value}\n") 2024-08-08T20:08:55.3229476Z  2024-08-08T20:08:55.3229883Z  2024-08-08T20:08:55.3230256Z def parse_args() -> Any: 2024-08-08T20:08:55.3231025Z  parser = ArgumentParser("Get dynamic rollout settings") 2024-08-08T20:08:55.3232130Z  parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2024-08-08T20:08:55.3233017Z  parser.add_argument( 2024-08-08T20:08:55.3233562Z  "--github-issue-repo", 2024-08-08T20:08:55.3234156Z  type=str, 2024-08-08T20:08:55.3234587Z  required=False, 2024-08-08T20:08:55.3235141Z  default="pytorch/test-infra", 2024-08-08T20:08:55.3235841Z  help="GitHub repo to get the issue", 2024-08-08T20:08:55.3236396Z  ) 2024-08-08T20:08:55.3236780Z  parser.add_argument( 2024-08-08T20:08:55.3237343Z  "--github-repo", 2024-08-08T20:08:55.3237807Z  type=str, 2024-08-08T20:08:55.3238248Z  required=True, 2024-08-08T20:08:55.3238871Z  help="GitHub repo where CI is running", 2024-08-08T20:08:55.3239435Z  ) 2024-08-08T20:08:55.3239822Z  parser.add_argument( 2024-08-08T20:08:55.3240648Z  "--github-issue", type=int, required=True, help="GitHub issue number" 2024-08-08T20:08:55.3241571Z  ) 2024-08-08T20:08:55.3241958Z  parser.add_argument( 2024-08-08T20:08:55.3242809Z  "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2024-08-08T20:08:55.3243561Z  ) 2024-08-08T20:08:55.3243949Z  parser.add_argument( 2024-08-08T20:08:55.3244808Z  "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2024-08-08T20:08:55.3245596Z  ) 2024-08-08T20:08:55.3245945Z  parser.add_argument( 2024-08-08T20:08:55.3246824Z  "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2024-08-08T20:08:55.3247639Z  ) 2024-08-08T20:08:55.3248004Z  parser.add_argument( 2024-08-08T20:08:55.3248570Z  "--github-ref-type", 2024-08-08T20:08:55.3249099Z  type=str, 2024-08-08T20:08:55.3249532Z  required=True, 2024-08-08T20:08:55.3250199Z  help="Current GitHub ref type, branch or tag", 2024-08-08T20:08:55.3250826Z  ) 2024-08-08T20:08:55.3251161Z  2024-08-08T20:08:55.3251621Z  return parser.parse_args() 2024-08-08T20:08:55.3252137Z  2024-08-08T20:08:55.3252450Z  2024-08-08T20:08:55.3252990Z def get_gh_client(github_token: str) -> Github: 2024-08-08T20:08:55.3253669Z  auth = Auth.Token(github_token) 2024-08-08T20:08:55.3254199Z  return Github(auth=auth) 2024-08-08T20:08:55.3254779Z  2024-08-08T20:08:55.3255133Z  2024-08-08T20:08:55.3255652Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: 2024-08-08T20:08:55.3256447Z  repo = gh.get_repo(repo) 2024-08-08T20:08:55.3257051Z  return repo.get_issue(number=issue_num) 2024-08-08T20:08:55.3257602Z  2024-08-08T20:08:55.3257994Z  2024-08-08T20:08:55.3258385Z def get_potential_pr_author( 2024-08-08T20:08:55.3259081Z  gh: Github, repo: str, username: str, ref_type: str, ref_name: str 2024-08-08T20:08:55.3259876Z ) -> str: 2024-08-08T20:08:55.3260660Z  # If the trigger was a new tag added by a bot, this is a ciflow case 2024-08-08T20:08:55.3261743Z  # Fetch the actual username from the original PR. The PR number is 2024-08-08T20:08:55.3262658Z  # embedded in the tag name: ciflow// 2024-08-08T20:08:55.3263492Z  if username == "pytorch-bot[bot]" and ref_type == "tag": 2024-08-08T20:08:55.3264294Z  split_tag = ref_name.split("/") 2024-08-08T20:08:55.3265208Z  if ( 2024-08-08T20:08:55.3265659Z  len(split_tag) == 3 2024-08-08T20:08:55.3266313Z  and split_tag[0] == "ciflow" 2024-08-08T20:08:55.3266917Z  and split_tag[2].isnumeric() 2024-08-08T20:08:55.3267476Z  ): 2024-08-08T20:08:55.3267997Z  pr_number = split_tag[2] 2024-08-08T20:08:55.3268507Z  try: 2024-08-08T20:08:55.3269017Z  repository = gh.get_repo(repo) 2024-08-08T20:08:55.3269858Z  pull = repository.get_pull(number=int(pr_number)) 2024-08-08T20:08:55.3270570Z  except Exception as e: 2024-08-08T20:08:55.3271158Z  raise Exception( # noqa: TRY002 2024-08-08T20:08:55.3272052Z  f"issue with pull request {pr_number} from repo {repository}" 2024-08-08T20:08:55.3272803Z  ) from e 2024-08-08T20:08:55.3273291Z  return pull.user.login 2024-08-08T20:08:55.3274086Z  # In all other cases, return the original input username 2024-08-08T20:08:55.3274778Z  return username 2024-08-08T20:08:55.3275181Z  2024-08-08T20:08:55.3275784Z  2024-08-08T20:08:55.3276242Z def is_exception_branch(branch: str) -> bool: 2024-08-08T20:08:55.3277095Z  return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2024-08-08T20:08:55.3277958Z  2024-08-08T20:08:55.3278294Z  2024-08-08T20:08:55.3278937Z def get_workflow_type(issue: Issue, workflow_requestors: Iterable[str]) -> str: 2024-08-08T20:08:55.3279813Z  try: 2024-08-08T20:08:55.3280396Z  first_comment = issue.get_comments()[0].body.strip("\n\t ") 2024-08-08T20:08:55.3281103Z  2024-08-08T20:08:55.3281510Z  if first_comment[0] == "!": 2024-08-08T20:08:55.3282352Z  log.info("LF Workflows are disabled for everyone. Using meta runners.") 2024-08-08T20:08:55.3283207Z  return WORKFLOW_LABEL_META 2024-08-08T20:08:55.3283834Z  elif first_comment[0] == "*": 2024-08-08T20:08:55.3284664Z  log.info("LF Workflows are enabled for everyone. Using LF runners.") 2024-08-08T20:08:55.3285522Z  return WORKFLOW_LABEL_LF 2024-08-08T20:08:55.3286104Z  else: 2024-08-08T20:08:55.3286577Z  all_opted_in_users = { 2024-08-08T20:08:55.3287330Z  usr_raw.strip("\n\t@ ") for usr_raw in first_comment.split() 2024-08-08T20:08:55.3288118Z  } 2024-08-08T20:08:55.3288562Z  opted_in_requestors = { 2024-08-08T20:08:55.3289376Z  usr for usr in workflow_requestors if usr in all_opted_in_users 2024-08-08T20:08:55.3290204Z  } 2024-08-08T20:08:55.3290620Z  if opted_in_requestors: 2024-08-08T20:08:55.3291159Z  log.info( 2024-08-08T20:08:55.3292063Z  f"LF Workflows are enabled for {', '.join(opted_in_requestors)}. Using LF runners." 2024-08-08T20:08:55.3292881Z  ) 2024-08-08T20:08:55.3293397Z  return WORKFLOW_LABEL_LF 2024-08-08T20:08:55.3294038Z  else: 2024-08-08T20:08:55.3294439Z  log.info( 2024-08-08T20:08:55.3295417Z  f"LF Workflows are disabled for {', '.join(workflow_requestors)}. Using meta runners." 2024-08-08T20:08:55.3296395Z  ) 2024-08-08T20:08:55.3296886Z  return WORKFLOW_LABEL_META 2024-08-08T20:08:55.3297420Z  2024-08-08T20:08:55.3297858Z  except Exception as e: 2024-08-08T20:08:55.3298358Z  log.error( 2024-08-08T20:08:55.3299175Z  f"Failed to get determine workflow type. Falling back to meta runners. Exception: {e}" 2024-08-08T20:08:55.3300122Z  ) 2024-08-08T20:08:55.3300577Z  return WORKFLOW_LABEL_META 2024-08-08T20:08:55.3301078Z  2024-08-08T20:08:55.3301479Z  2024-08-08T20:08:55.3301838Z def main() -> None: 2024-08-08T20:08:55.3302287Z  args = parse_args() 2024-08-08T20:08:55.3302821Z  2024-08-08T20:08:55.3303498Z  if args.github_ref_type == "branch" and is_exception_branch(args.github_branch): 2024-08-08T20:08:55.3304589Z  log.info(f"Exception branch: '{args.github_branch}', using meta runners") 2024-08-08T20:08:55.3305811Z  label_type = WORKFLOW_LABEL_META 2024-08-08T20:08:55.3306397Z  else: 2024-08-08T20:08:55.3306749Z  try: 2024-08-08T20:08:55.3307316Z  gh = get_gh_client(args.github_token) 2024-08-08T20:08:55.3308273Z  # The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2024-08-08T20:08:55.3309332Z  issue = get_issue(gh, args.github_issue_repo, args.github_issue) 2024-08-08T20:08:55.3310196Z  username = get_potential_pr_author( 2024-08-08T20:08:55.3310982Z  gh, 2024-08-08T20:08:55.3311465Z  args.github_repo, 2024-08-08T20:08:55.3312089Z  args.github_actor, 2024-08-08T20:08:55.3312666Z  args.github_ref_type, 2024-08-08T20:08:55.3313272Z  args.github_branch, 2024-08-08T20:08:55.3313887Z  ) 2024-08-08T20:08:55.3314368Z  label_type = get_workflow_type( 2024-08-08T20:08:55.3314908Z  issue, 2024-08-08T20:08:55.3315459Z  ( 2024-08-08T20:08:55.3315959Z  args.github_issue_owner, 2024-08-08T20:08:55.3316510Z  username, 2024-08-08T20:08:55.3317092Z  ), 2024-08-08T20:08:55.3317523Z  ) 2024-08-08T20:08:55.3317947Z  except Exception as e: 2024-08-08T20:08:55.3318537Z  log.error( 2024-08-08T20:08:55.3319295Z  f"Failed to get issue. Falling back to meta runners. Exception: {e}" 2024-08-08T20:08:55.3320051Z  ) 2024-08-08T20:08:55.3320591Z  label_type = WORKFLOW_LABEL_META 2024-08-08T20:08:55.3321147Z  2024-08-08T20:08:55.3321561Z  # For Canary builds use canary runners 2024-08-08T20:08:55.3322580Z  if args.github_repo == "pytorch/pytorch-canary" and label_type == WORKFLOW_LABEL_LF: 2024-08-08T20:08:55.3323532Z  label_type = WORKFLOW_LABEL_LF_CANARY 2024-08-08T20:08:55.3324184Z  2024-08-08T20:08:55.3324674Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, label_type) 2024-08-08T20:08:55.3325354Z  2024-08-08T20:08:55.3325779Z if __name__ == "__main__": 2024-08-08T20:08:55.3326235Z  main() 2024-08-08T20:08:55.3326636Z EOF 2024-08-08T20:08:55.3327046Z  2024-08-08T20:08:55.3327387Z cat runner_determinator.py 2024-08-08T20:08:55.3703351Z shell: /usr/bin/bash -e {0} 2024-08-08T20:08:55.3703836Z env: 2024-08-08T20:08:55.3704426Z GITHUB_TOKEN: *** 2024-08-08T20:08:55.3705292Z ISSUE_NUMBER: 5132 2024-08-08T20:08:55.3705750Z TRIGGERING_ACTOR: pytorch-bot[bot] 2024-08-08T20:08:55.3706467Z ISSUE_OWNER: 2024-08-08T20:08:55.3706970Z ##[endgroup] 2024-08-08T20:08:55.4119525Z # flake8: noqa: G004 2024-08-08T20:08:55.4119854Z 2024-08-08T20:08:55.4120118Z import logging 2024-08-08T20:08:55.4120511Z import os 2024-08-08T20:08:55.4121770Z from argparse import ArgumentParser 2024-08-08T20:08:55.4122463Z from logging import LogRecord 2024-08-08T20:08:55.4122924Z from typing import Any, Iterable 2024-08-08T20:08:55.4123278Z 2024-08-08T20:08:55.4123456Z from github import Auth, Github 2024-08-08T20:08:55.4124050Z from github.Issue import Issue 2024-08-08T20:08:55.4124353Z 2024-08-08T20:08:55.4124357Z 2024-08-08T20:08:55.4124583Z WORKFLOW_LABEL_META = "" # use meta runners 2024-08-08T20:08:55.4125308Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2024-08-08T20:08:55.4126331Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2024-08-08T20:08:55.4126942Z 2024-08-08T20:08:55.4127181Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2024-08-08T20:08:55.4127953Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2024-08-08T20:08:55.4128422Z 2024-08-08T20:08:55.4128427Z 2024-08-08T20:08:55.4128619Z class ColorFormatter(logging.Formatter): 2024-08-08T20:08:55.4129276Z """Color codes the log messages based on the log level""" 2024-08-08T20:08:55.4129749Z 2024-08-08T20:08:55.4129881Z COLORS = { 2024-08-08T20:08:55.4130340Z "WARNING": "\033[33m", # Yellow 2024-08-08T20:08:55.4130885Z "ERROR": "\033[31m", # Red 2024-08-08T20:08:55.4131349Z "CRITICAL": "\033[31m", # Red 2024-08-08T20:08:55.4131933Z "INFO": "\033[0m", # Reset 2024-08-08T20:08:55.4132437Z "DEBUG": "\033[0m", # Reset 2024-08-08T20:08:55.4133083Z } 2024-08-08T20:08:55.4133363Z 2024-08-08T20:08:55.4133626Z def format(self, record: LogRecord) -> str: 2024-08-08T20:08:55.4134456Z log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2024-08-08T20:08:55.4135309Z record.msg = f"{log_color}{record.msg}\033[0m" 2024-08-08T20:08:55.4135956Z return super().format(record) 2024-08-08T20:08:55.4136341Z 2024-08-08T20:08:55.4136346Z 2024-08-08T20:08:55.4136518Z handler = logging.StreamHandler() 2024-08-08T20:08:55.4137316Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2024-08-08T20:08:55.4137964Z 2024-08-08T20:08:55.4138221Z log = logging.getLogger(os.path.basename(__file__)) 2024-08-08T20:08:55.4138829Z log.addHandler(handler) 2024-08-08T20:08:55.4139293Z log.setLevel(logging.INFO) 2024-08-08T20:08:55.4139634Z 2024-08-08T20:08:55.4139638Z 2024-08-08T20:08:55.4139941Z def set_github_output(key: str, value: str) -> None: 2024-08-08T20:08:55.4140521Z """ 2024-08-08T20:08:55.4141032Z Defines outputs of the github action that invokes this script 2024-08-08T20:08:55.4141740Z """ 2024-08-08T20:08:55.4142087Z if not GITHUB_OUTPUT: 2024-08-08T20:08:55.4143401Z # See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ for deprecation notice 2024-08-08T20:08:55.4145034Z log.warning( 2024-08-08T20:08:55.4145978Z "No env var found for GITHUB_OUTPUT, you must be running this code locally. Falling back to the deprecated print method." 2024-08-08T20:08:55.4147033Z ) 2024-08-08T20:08:55.4169232Z print(f"::set-output name={key}::{value}") 2024-08-08T20:08:55.4169858Z return 2024-08-08T20:08:55.4170112Z 2024-08-08T20:08:55.4170286Z with open(GITHUB_OUTPUT, "a") as f: 2024-08-08T20:08:55.4171041Z log.info(f"Setting output: {key}='{value}'") 2024-08-08T20:08:55.4171631Z f.write(f"{key}={value}\n") 2024-08-08T20:08:55.4171970Z 2024-08-08T20:08:55.4171975Z 2024-08-08T20:08:55.4172166Z def parse_args() -> Any: 2024-08-08T20:08:55.4172814Z parser = ArgumentParser("Get dynamic rollout settings") 2024-08-08T20:08:55.4173835Z parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2024-08-08T20:08:55.4174623Z parser.add_argument( 2024-08-08T20:08:55.4175367Z "--github-issue-repo", 2024-08-08T20:08:55.4175873Z type=str, 2024-08-08T20:08:55.4176219Z required=False, 2024-08-08T20:08:55.4176796Z default="pytorch/test-infra", 2024-08-08T20:08:55.4177389Z help="GitHub repo to get the issue", 2024-08-08T20:08:55.4177871Z ) 2024-08-08T20:08:55.4178285Z parser.add_argument( 2024-08-08T20:08:55.4178770Z "--github-repo", 2024-08-08T20:08:55.4179154Z type=str, 2024-08-08T20:08:55.4179615Z required=True, 2024-08-08T20:08:55.4180082Z help="GitHub repo where CI is running", 2024-08-08T20:08:55.4180578Z ) 2024-08-08T20:08:55.4181006Z parser.add_argument( 2024-08-08T20:08:55.4181706Z "--github-issue", type=int, required=True, help="GitHub issue number" 2024-08-08T20:08:55.4182364Z ) 2024-08-08T20:08:55.4182793Z parser.add_argument( 2024-08-08T20:08:55.4183528Z "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2024-08-08T20:08:55.4184221Z ) 2024-08-08T20:08:55.4184648Z parser.add_argument( 2024-08-08T20:08:55.4185723Z "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2024-08-08T20:08:55.4186434Z ) 2024-08-08T20:08:55.4186888Z parser.add_argument( 2024-08-08T20:08:55.4187654Z "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2024-08-08T20:08:55.4188385Z ) 2024-08-08T20:08:55.4188815Z parser.add_argument( 2024-08-08T20:08:55.4189292Z "--github-ref-type", 2024-08-08T20:08:55.4189715Z type=str, 2024-08-08T20:08:55.4190157Z required=True, 2024-08-08T20:08:55.4190664Z help="Current GitHub ref type, branch or tag", 2024-08-08T20:08:55.4191403Z ) 2024-08-08T20:08:55.4191686Z 2024-08-08T20:08:55.4191847Z return parser.parse_args() 2024-08-08T20:08:55.4192163Z 2024-08-08T20:08:55.4192168Z 2024-08-08T20:08:55.4192488Z def get_gh_client(github_token: str) -> Github: 2024-08-08T20:08:55.4193165Z auth = Auth.Token(github_token) 2024-08-08T20:08:55.4193637Z return Github(auth=auth) 2024-08-08T20:08:55.4193949Z 2024-08-08T20:08:55.4193954Z 2024-08-08T20:08:55.4194319Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: 2024-08-08T20:08:55.4195052Z repo = gh.get_repo(repo) 2024-08-08T20:08:55.4195511Z return repo.get_issue(number=issue_num) 2024-08-08T20:08:55.4195930Z 2024-08-08T20:08:55.4195935Z 2024-08-08T20:08:55.4196089Z def get_potential_pr_author( 2024-08-08T20:08:55.4196776Z gh: Github, repo: str, username: str, ref_type: str, ref_name: str 2024-08-08T20:08:55.4197457Z ) -> str: 2024-08-08T20:08:55.4198017Z # If the trigger was a new tag added by a bot, this is a ciflow case 2024-08-08T20:08:55.4198987Z # Fetch the actual username from the original PR. The PR number is 2024-08-08T20:08:55.4199807Z # embedded in the tag name: ciflow// 2024-08-08T20:08:55.4200601Z if username == "pytorch-bot[bot]" and ref_type == "tag": 2024-08-08T20:08:55.4201341Z split_tag = ref_name.split("/") 2024-08-08T20:08:55.4201817Z if ( 2024-08-08T20:08:55.4202203Z len(split_tag) == 3 2024-08-08T20:08:55.4202746Z and split_tag[0] == "ciflow" 2024-08-08T20:08:55.4203269Z and split_tag[2].isnumeric() 2024-08-08T20:08:55.4203760Z ): 2024-08-08T20:08:55.4204188Z pr_number = split_tag[2] 2024-08-08T20:08:55.4204713Z try: 2024-08-08T20:08:55.4205139Z repository = gh.get_repo(repo) 2024-08-08T20:08:55.4205870Z pull = repository.get_pull(number=int(pr_number)) 2024-08-08T20:08:55.4206527Z except Exception as e: 2024-08-08T20:08:55.4207069Z raise Exception( # noqa: TRY002 2024-08-08T20:08:55.4207868Z f"issue with pull request {pr_number} from repo {repository}" 2024-08-08T20:08:55.4208579Z ) from e 2024-08-08T20:08:55.4208973Z return pull.user.login 2024-08-08T20:08:55.4209812Z # In all other cases, return the original input username 2024-08-08T20:08:55.4210451Z return username 2024-08-08T20:08:55.4210679Z 2024-08-08T20:08:55.4210684Z 2024-08-08T20:08:55.4210937Z def is_exception_branch(branch: str) -> bool: 2024-08-08T20:08:55.4211835Z return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2024-08-08T20:08:55.4212412Z 2024-08-08T20:08:55.4212417Z 2024-08-08T20:08:55.4212917Z def get_workflow_type(issue: Issue, workflow_requestors: Iterable[str]) -> str: 2024-08-08T20:08:55.4213641Z try: 2024-08-08T20:08:55.4214220Z first_comment = issue.get_comments()[0].body.strip("\n\t ") 2024-08-08T20:08:55.4214710Z 2024-08-08T20:08:55.4214904Z if first_comment[0] == "!": 2024-08-08T20:08:55.4215636Z log.info("LF Workflows are disabled for everyone. Using meta runners.") 2024-08-08T20:08:55.4216449Z return WORKFLOW_LABEL_META 2024-08-08T20:08:55.4216974Z elif first_comment[0] == "*": 2024-08-08T20:08:55.4217701Z log.info("LF Workflows are enabled for everyone. Using LF runners.") 2024-08-08T20:08:55.4218464Z return WORKFLOW_LABEL_LF 2024-08-08T20:08:55.4218946Z else: 2024-08-08T20:08:55.4219332Z all_opted_in_users = { 2024-08-08T20:08:55.4220022Z usr_raw.strip("\n\t@ ") for usr_raw in first_comment.split() 2024-08-08T20:08:55.4220680Z } 2024-08-08T20:08:55.4221068Z opted_in_requestors = { 2024-08-08T20:08:55.4221779Z usr for usr in workflow_requestors if usr in all_opted_in_users 2024-08-08T20:08:55.4222456Z } 2024-08-08T20:08:55.4222841Z if opted_in_requestors: 2024-08-08T20:08:55.4223492Z log.info( 2024-08-08T20:08:55.4224324Z f"LF Workflows are enabled for {', '.join(opted_in_requestors)}. Using LF runners." 2024-08-08T20:08:55.4225366Z ) 2024-08-08T20:08:55.4225827Z return WORKFLOW_LABEL_LF 2024-08-08T20:08:55.4226355Z else: 2024-08-08T20:08:55.4226745Z log.info( 2024-08-08T20:08:55.4227603Z f"LF Workflows are disabled for {', '.join(workflow_requestors)}. Using meta runners." 2024-08-08T20:08:55.4228432Z ) 2024-08-08T20:08:55.4228832Z return WORKFLOW_LABEL_META 2024-08-08T20:08:55.4229186Z 2024-08-08T20:08:55.4229404Z except Exception as e: 2024-08-08T20:08:55.4229855Z log.error( 2024-08-08T20:08:55.4230574Z f"Failed to get determine workflow type. Falling back to meta runners. Exception: {e}" 2024-08-08T20:08:55.4231442Z ) 2024-08-08T20:08:55.4231807Z return WORKFLOW_LABEL_META 2024-08-08T20:08:55.4232132Z 2024-08-08T20:08:55.4232136Z 2024-08-08T20:08:55.4232338Z def main() -> None: 2024-08-08T20:08:55.4232783Z args = parse_args() 2024-08-08T20:08:55.4233073Z 2024-08-08T20:08:55.4233476Z if args.github_ref_type == "branch" and is_exception_branch(args.github_branch): 2024-08-08T20:08:55.4234576Z log.info(f"Exception branch: '{args.github_branch}', using meta runners") 2024-08-08T20:08:55.4235441Z label_type = WORKFLOW_LABEL_META 2024-08-08T20:08:55.4235911Z else: 2024-08-08T20:08:55.4236242Z try: 2024-08-08T20:08:55.4236728Z gh = get_gh_client(args.github_token) 2024-08-08T20:08:55.4237596Z # The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2024-08-08T20:08:55.4238580Z issue = get_issue(gh, args.github_issue_repo, args.github_issue) 2024-08-08T20:08:55.4239381Z username = get_potential_pr_author( 2024-08-08T20:08:55.4239883Z gh, 2024-08-08T20:08:55.4240295Z args.github_repo, 2024-08-08T20:08:55.4240843Z args.github_actor, 2024-08-08T20:08:55.4241302Z args.github_ref_type, 2024-08-08T20:08:55.4241844Z args.github_branch, 2024-08-08T20:08:55.4242383Z ) 2024-08-08T20:08:55.4242901Z label_type = get_workflow_type( 2024-08-08T20:08:55.4243453Z issue, 2024-08-08T20:08:55.4243910Z ( 2024-08-08T20:08:55.4244304Z args.github_issue_owner, 2024-08-08T20:08:55.4244832Z username, 2024-08-08T20:08:55.4245319Z ), 2024-08-08T20:08:55.4245664Z ) 2024-08-08T20:08:55.4246034Z except Exception as e: 2024-08-08T20:08:55.4246548Z log.error( 2024-08-08T20:08:55.4247168Z f"Failed to get issue. Falling back to meta runners. Exception: {e}" 2024-08-08T20:08:55.4247875Z ) 2024-08-08T20:08:55.4248336Z label_type = WORKFLOW_LABEL_META 2024-08-08T20:08:55.4248727Z 2024-08-08T20:08:55.4248906Z # For Canary builds use canary runners 2024-08-08T20:08:55.4249812Z if args.github_repo == "pytorch/pytorch-canary" and label_type == WORKFLOW_LABEL_LF: 2024-08-08T20:08:55.4250754Z label_type = WORKFLOW_LABEL_LF_CANARY 2024-08-08T20:08:55.4251130Z 2024-08-08T20:08:55.4251396Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, label_type) 2024-08-08T20:08:55.4251887Z 2024-08-08T20:08:55.4252029Z if __name__ == "__main__": 2024-08-08T20:08:55.4252527Z main() 2024-08-08T20:08:55.4424127Z ##[group]Run python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2024-08-08T20:08:55.4425481Z python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2024-08-08T20:08:55.4484726Z shell: /usr/bin/bash -e {0} 2024-08-08T20:08:55.4485214Z env: 2024-08-08T20:08:55.4485800Z GITHUB_TOKEN: *** 2024-08-08T20:08:55.4486253Z ISSUE_NUMBER: 5132 2024-08-08T20:08:55.4486718Z TRIGGERING_ACTOR: pytorch-bot[bot] 2024-08-08T20:08:55.4487236Z ISSUE_OWNER: 2024-08-08T20:08:55.4487858Z ##[endgroup] 2024-08-08T20:08:57.2558245Z Defaulting to user installation because normal site-packages is not writeable 2024-08-08T20:08:58.1414656Z Collecting urllib3==1.26.18 2024-08-08T20:08:58.2285637Z Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB) 2024-08-08T20:08:58.2692785Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.8/143.8 KB 3.8 MB/s eta 0:00:00 2024-08-08T20:08:58.3003816Z Collecting PyGithub==2.3.0 2024-08-08T20:08:58.3196647Z Downloading PyGithub-2.3.0-py3-none-any.whl (354 kB) 2024-08-08T20:08:58.3477086Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 354.4/354.4 KB 13.2 MB/s eta 0:00:00 2024-08-08T20:08:58.3878430Z Collecting Deprecated 2024-08-08T20:08:58.4071812Z Downloading Deprecated-1.2.14-py2.py3-none-any.whl (9.6 kB) 2024-08-08T20:08:58.4101765Z Requirement already satisfied: requests>=2.14.0 in /usr/lib/python3/dist-packages (from PyGithub==2.3.0) (2.25.1) 2024-08-08T20:08:58.4421045Z Collecting pynacl>=1.4.0 2024-08-08T20:08:58.4622113Z 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-08T20:08:58.4896409Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 856.7/856.7 KB 33.1 MB/s eta 0:00:00 2024-08-08T20:08:58.5145107Z Collecting pyjwt[crypto]>=2.4.0 2024-08-08T20:08:58.5336889Z Downloading PyJWT-2.9.0-py3-none-any.whl (22 kB) 2024-08-08T20:08:58.5691407Z Collecting typing-extensions>=4.0.0 2024-08-08T20:08:58.5884757Z Downloading typing_extensions-4.12.2-py3-none-any.whl (37 kB) 2024-08-08T20:08:58.6015858Z 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-08T20:08:58.8070409Z Collecting cffi>=1.4.1 2024-08-08T20:08:58.8265409Z Downloading cffi-1.17.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (445 kB) 2024-08-08T20:08:58.8339581Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 445.9/445.9 KB 81.7 MB/s eta 0:00:00 2024-08-08T20:08:58.9860279Z Collecting wrapt<2,>=1.10 2024-08-08T20:08:59.0056406Z 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-08T20:08:59.0095241Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 80.3/80.3 KB 33.0 MB/s eta 0:00:00 2024-08-08T20:08:59.0245637Z Collecting pycparser 2024-08-08T20:08:59.0442826Z Downloading pycparser-2.22-py3-none-any.whl (117 kB) 2024-08-08T20:08:59.0499251Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.6/117.6 KB 37.5 MB/s eta 0:00:00 2024-08-08T20:08:59.3052853Z Installing collected packages: wrapt, urllib3, typing-extensions, pyjwt, pycparser, Deprecated, cffi, pynacl, PyGithub 2024-08-08T20:08:59.7642955Z 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-08T20:08:59.8323797Z ##[group]Run curr_branch="ciflow/trunk/132710" 2024-08-08T20:08:59.8324553Z curr_branch="ciflow/trunk/132710" 2024-08-08T20:08:59.8325018Z curr_ref_type="tag" 2024-08-08T20:08:59.8325446Z echo "Current branch is '$curr_branch'" 2024-08-08T20:08:59.8325985Z  2024-08-08T20:08:59.8326331Z python3 runner_determinator.py \ 2024-08-08T20:08:59.8326785Z  --github-token "$GITHUB_TOKEN" \ 2024-08-08T20:08:59.8327341Z  --github-issue "$ISSUE_NUMBER" \ 2024-08-08T20:08:59.8327795Z  --github-branch "$curr_branch" \ 2024-08-08T20:08:59.8328285Z  --github-actor "$TRIGGERING_ACTOR" \ 2024-08-08T20:08:59.8328871Z  --github-issue-owner "$ISSUE_OWNER" \ 2024-08-08T20:08:59.8329376Z  --github-ref-type "$curr_ref_type" \ 2024-08-08T20:08:59.8329830Z  --github-repo "$GITHUB_REPOSITORY" 2024-08-08T20:08:59.8395726Z shell: /usr/bin/bash -e {0} 2024-08-08T20:08:59.8396355Z env: 2024-08-08T20:08:59.8397108Z GITHUB_TOKEN: *** 2024-08-08T20:08:59.8397432Z ISSUE_NUMBER: 5132 2024-08-08T20:08:59.8397922Z TRIGGERING_ACTOR: pytorch-bot[bot] 2024-08-08T20:08:59.8398572Z ISSUE_OWNER: 2024-08-08T20:08:59.8398869Z ##[endgroup] 2024-08-08T20:08:59.8480255Z Current branch is 'ciflow/trunk/132710' 2024-08-08T20:09:02.1857343Z INFO : LF Workflows are disabled for , drisspg. Using meta runners. 2024-08-08T20:09:02.1858890Z INFO : Setting output: label-type='' 2024-08-08T20:09:02.2243271Z Evaluate and set job outputs 2024-08-08T20:09:02.2254691Z Cleaning up orphan processes