2025-08-14T20:43:46.2938137Z Current runner version: '2.327.1' 2025-08-14T20:43:46.2969396Z ##[group]Runner Image Provisioner 2025-08-14T20:43:46.2970548Z Hosted Compute Agent 2025-08-14T20:43:46.2971364Z Version: 20250812.370 2025-08-14T20:43:46.2972412Z Commit: 4a2b2bf7520004e3e907c2150c8cabe342a3da32 2025-08-14T20:43:46.2973800Z Build Date: 2025-08-12T16:08:14Z 2025-08-14T20:43:46.2974773Z ##[endgroup] 2025-08-14T20:43:46.2975710Z ##[group]Operating System 2025-08-14T20:43:46.2976644Z Ubuntu 2025-08-14T20:43:46.2977322Z 24.04.2 2025-08-14T20:43:46.2978167Z LTS 2025-08-14T20:43:46.2978928Z ##[endgroup] 2025-08-14T20:43:46.2979647Z ##[group]Runner Image 2025-08-14T20:43:46.2980630Z Image: ubuntu-24.04 2025-08-14T20:43:46.2981456Z Version: 20250804.2.0 2025-08-14T20:43:46.2983104Z Included Software: https://github.com/actions/runner-images/blob/ubuntu24/20250804.2/images/ubuntu/Ubuntu2404-Readme.md 2025-08-14T20:43:46.2985951Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu24%2F20250804.2 2025-08-14T20:43:46.2987550Z ##[endgroup] 2025-08-14T20:43:46.2992045Z ##[group]GITHUB_TOKEN Permissions 2025-08-14T20:43:46.2995358Z Actions: read 2025-08-14T20:43:46.2996263Z Attestations: read 2025-08-14T20:43:46.2997066Z Checks: read 2025-08-14T20:43:46.2997796Z Contents: read 2025-08-14T20:43:46.2998748Z Deployments: read 2025-08-14T20:43:46.2999510Z Discussions: read 2025-08-14T20:43:46.3000324Z Issues: read 2025-08-14T20:43:46.3001158Z Metadata: read 2025-08-14T20:43:46.3001969Z Models: read 2025-08-14T20:43:46.3002704Z Packages: read 2025-08-14T20:43:46.3003743Z Pages: read 2025-08-14T20:43:46.3004584Z PullRequests: read 2025-08-14T20:43:46.3005461Z RepositoryProjects: read 2025-08-14T20:43:46.3006455Z SecurityEvents: read 2025-08-14T20:43:46.3007343Z Statuses: read 2025-08-14T20:43:46.3008167Z ##[endgroup] 2025-08-14T20:43:46.3011467Z Secret source: Actions 2025-08-14T20:43:46.3012751Z Prepare workflow directory 2025-08-14T20:43:46.3723317Z Prepare all required actions 2025-08-14T20:43:46.3803824Z Uses: pytorch/pytorch/.github/workflows/_runner-determinator.yml@refs/heads/main (1fc683cf17c8c673044538d10266c00f92987be2) 2025-08-14T20:43:46.3811233Z ##[group] Inputs 2025-08-14T20:43:46.3812154Z check_experiments: 2025-08-14T20:43:46.3813057Z opt_out_experiments: 2025-08-14T20:43:46.3814422Z triggering_actor: pytorchmergebot 2025-08-14T20:43:46.3815393Z issue_owner: 2025-08-14T20:43:46.3816152Z curr_branch: main 2025-08-14T20:43:46.3817271Z curr_ref_type: branch 2025-08-14T20:43:46.3818116Z issue_number: 5132 2025-08-14T20:43:46.3818929Z ##[endgroup] 2025-08-14T20:43:46.3819968Z Complete job name: get-label-type / runner-determinator 2025-08-14T20:43:46.4668531Z ##[group]Run cat < runner_determinator.py 2025-08-14T20:43:46.4671750Z cat < runner_determinator.py 2025-08-14T20:43:46.4673021Z # flake8: noqa: G004 2025-08-14T20:43:46.4674119Z  2025-08-14T20:43:46.4675246Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-08-14T20:43:46.4677254Z # must be kept in sync. You can do it easily by running the following command: 2025-08-14T20:43:46.4678783Z # python .github/scripts/update_runner_determinator.py 2025-08-14T20:43:46.4680071Z  2025-08-14T20:43:46.4680786Z """ 2025-08-14T20:43:46.4681923Z This runner determinator is used to determine which set of runners to run a 2025-08-14T20:43:46.4683958Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-08-14T20:43:46.4686189Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-08-14T20:43:46.4687935Z of which runners should be used to run which job. 2025-08-14T20:43:46.4689008Z  2025-08-14T20:43:46.4690117Z The configuration has two parts, the settings and a list of opted-in users, 2025-08-14T20:43:46.4691814Z separated by a line containing "---". If the line is not present, the 2025-08-14T20:43:46.4694126Z settings are considered to be empty with only the second part, the user 2025-08-14T20:43:46.4695611Z list, defined. 2025-08-14T20:43:46.4696358Z  2025-08-14T20:43:46.4697576Z The first part is a YAML block that defines the rollout settings. This can be 2025-08-14T20:43:46.4699343Z used to define any settings that are needed to determine which runners to use. 2025-08-14T20:43:46.4701087Z It's fields are defined by the RolloutSettings class below. 2025-08-14T20:43:46.4702359Z  2025-08-14T20:43:46.4703831Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-08-14T20:43:46.4705566Z The user list is also a comma separated list of additional features or 2025-08-14T20:43:46.4707027Z experiments which the user could be opted in to. 2025-08-14T20:43:46.4708115Z  2025-08-14T20:43:46.4709074Z The user list has the following rules: 2025-08-14T20:43:46.4710117Z  2025-08-14T20:43:46.4711181Z - Users are GitHub usernames, which must start with the @ prefix 2025-08-14T20:43:46.4712728Z - Each user is also a comma-separated list of features/experiments to enable 2025-08-14T20:43:46.4714474Z - A "#" prefix opts the user out of all experiments 2025-08-14T20:43:46.4715485Z  2025-08-14T20:43:46.4716382Z Example config: 2025-08-14T20:43:46.4717431Z  # A list of experiments that can be opted into. 2025-08-14T20:43:46.4718758Z  # This defines the behavior they'll induce when opted into. 2025-08-14T20:43:46.4720124Z  # Expected syntax is: 2025-08-14T20:43:46.4721450Z  # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-08-14T20:43:46.4723271Z  # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-08-14T20:43:46.4725105Z  2025-08-14T20:43:46.4725818Z  experiments: 2025-08-14T20:43:46.4726658Z  lf: 2025-08-14T20:43:46.4727603Z  rollout_percent: 25 2025-08-14T20:43:46.4728631Z  all_branches: false 2025-08-14T20:43:46.4729541Z  default: true 2025-08-14T20:43:46.4730534Z  --- 2025-08-14T20:43:46.4731312Z  2025-08-14T20:43:46.4732065Z  # Opt-ins: 2025-08-14T20:43:46.4733677Z  # Users can opt into the LF fleet by adding their GitHub username to this list 2025-08-14T20:43:46.4735665Z  # and specifying experiments to enable in a comma-separated list. 2025-08-14T20:43:46.4737163Z  # To always opt out of an experiment, prefix it with a "-". 2025-08-14T20:43:46.4738684Z  # Experiments should be from the above list. 2025-08-14T20:43:46.4739747Z  2025-08-14T20:43:46.4740527Z  @User1,-lf,split_build 2025-08-14T20:43:46.4741562Z  @User2,lf 2025-08-14T20:43:46.4742469Z  @User3,split_build 2025-08-14T20:43:46.4743780Z """ 2025-08-14T20:43:46.4744535Z  2025-08-14T20:43:46.4745233Z import json 2025-08-14T20:43:46.4746053Z import logging 2025-08-14T20:43:46.4747167Z import os 2025-08-14T20:43:46.4747926Z import random 2025-08-14T20:43:46.4748708Z import re 2025-08-14T20:43:46.4749629Z import sys 2025-08-14T20:43:46.4750595Z from argparse import ArgumentParser 2025-08-14T20:43:46.4751832Z from collections.abc import Iterable 2025-08-14T20:43:46.4752880Z from functools import cache 2025-08-14T20:43:46.4754142Z from logging import LogRecord 2025-08-14T20:43:46.4755143Z from typing import Any, NamedTuple 2025-08-14T20:43:46.4756398Z from urllib.request import Request, urlopen 2025-08-14T20:43:46.4757446Z  2025-08-14T20:43:46.4758451Z import yaml 2025-08-14T20:43:46.4759607Z from github import Auth, Github 2025-08-14T20:43:46.4760567Z from github.Issue import Issue 2025-08-14T20:43:46.4761673Z  2025-08-14T20:43:46.4762397Z  2025-08-14T20:43:46.4763313Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-08-14T20:43:46.4764804Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-08-14T20:43:46.4766673Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-08-14T20:43:46.4768033Z  2025-08-14T20:43:46.4769030Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-08-14T20:43:46.4770262Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-08-14T20:43:46.4771263Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-08-14T20:43:46.4772597Z OPT_OUT_LABEL = "no-runner-experiments" 2025-08-14T20:43:46.4773889Z  2025-08-14T20:43:46.4774632Z SETTING_EXPERIMENTS = "experiments" 2025-08-14T20:43:46.4775747Z  2025-08-14T20:43:46.4776518Z LF_FLEET_EXPERIMENT = "lf" 2025-08-14T20:43:46.4777520Z CANARY_FLEET_SUFFIX = ".c" 2025-08-14T20:43:46.4871967Z  2025-08-14T20:43:46.4872684Z  2025-08-14T20:43:46.4879134Z class Experiment(NamedTuple): 2025-08-14T20:43:46.4880169Z  rollout_perc: float = ( 2025-08-14T20:43:46.4881369Z  0 # Percentage of workflows to experiment on when user is not opted-in. 2025-08-14T20:43:46.4882587Z  ) 2025-08-14T20:43:46.4883281Z  all_branches: bool = ( 2025-08-14T20:43:46.4884816Z  False # If True, the experiment is also enabled on the exception branches 2025-08-14T20:43:46.4886079Z  ) 2025-08-14T20:43:46.4886762Z  default: bool = ( 2025-08-14T20:43:46.4887824Z  True # If True, the experiment is enabled by default for all queries 2025-08-14T20:43:46.4888968Z  ) 2025-08-14T20:43:46.4889593Z  2025-08-14T20:43:46.4890240Z  # Add more fields as needed 2025-08-14T20:43:46.4891059Z  2025-08-14T20:43:46.4891666Z  2025-08-14T20:43:46.4892326Z class Settings(NamedTuple): 2025-08-14T20:43:46.4893153Z  """ 2025-08-14T20:43:46.4894370Z  Settings for the experiments that can be opted into. 2025-08-14T20:43:46.4895429Z  """ 2025-08-14T20:43:46.4896077Z  2025-08-14T20:43:46.4896764Z  experiments: dict[str, Experiment] = {} 2025-08-14T20:43:46.4897680Z  2025-08-14T20:43:46.4898498Z  2025-08-14T20:43:46.4899268Z class ColorFormatter(logging.Formatter): 2025-08-14T20:43:46.4900410Z  """Color codes the log messages based on the log level""" 2025-08-14T20:43:46.4901462Z  2025-08-14T20:43:46.4902062Z  COLORS = { 2025-08-14T20:43:46.4902829Z  "WARNING": "\033[33m", # Yellow 2025-08-14T20:43:46.4904978Z  "ERROR": "\033[31m", # Red 2025-08-14T20:43:46.4905886Z  "CRITICAL": "\033[31m", # Red 2025-08-14T20:43:46.4906803Z  "INFO": "\033[0m", # Reset 2025-08-14T20:43:46.4907706Z  "DEBUG": "\033[0m", # Reset 2025-08-14T20:43:46.4908546Z  } 2025-08-14T20:43:46.4909147Z  2025-08-14T20:43:46.4909897Z  def format(self, record: LogRecord) -> str: 2025-08-14T20:43:46.4911275Z  log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-08-14T20:43:46.4912708Z  record.msg = f"{log_color}{record.msg}\033[0m" 2025-08-14T20:43:46.4914019Z  return super().format(record) 2025-08-14T20:43:46.4914935Z  2025-08-14T20:43:46.4915536Z  2025-08-14T20:43:46.4916209Z handler = logging.StreamHandler() 2025-08-14T20:43:46.4917531Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-08-14T20:43:46.4919134Z  2025-08-14T20:43:46.4919959Z log = logging.getLogger(os.path.basename(__file__)) 2025-08-14T20:43:46.4921068Z log.addHandler(handler) 2025-08-14T20:43:46.4921942Z log.setLevel(logging.INFO) 2025-08-14T20:43:46.4922766Z  2025-08-14T20:43:46.4923526Z  2025-08-14T20:43:46.4924326Z def set_github_output(key: str, value: str) -> None: 2025-08-14T20:43:46.4925328Z  """ 2025-08-14T20:43:46.4926255Z  Defines outputs of the github action that invokes this script 2025-08-14T20:43:46.4927391Z  """ 2025-08-14T20:43:46.4928091Z  if not GITHUB_OUTPUT: 2025-08-14T20:43:46.4930103Z  # See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ for deprecation notice 2025-08-14T20:43:46.4932154Z  log.warning( 2025-08-14T20:43:46.4933971Z  "No env var found for GITHUB_OUTPUT, you must be running this code locally. Falling back to the deprecated print method." 2025-08-14T20:43:46.4935636Z  ) 2025-08-14T20:43:46.4936434Z  print(f"::set-output name={key}::{value}") 2025-08-14T20:43:46.4937413Z  return 2025-08-14T20:43:46.4938150Z  2025-08-14T20:43:46.4938866Z  with open(GITHUB_OUTPUT, "a") as f: 2025-08-14T20:43:46.4939930Z  log.info(f"Setting output: {key}='{value}'") 2025-08-14T20:43:46.4940955Z  f.write(f"{key}={value}\n") 2025-08-14T20:43:46.4941836Z  2025-08-14T20:43:46.4942467Z  2025-08-14T20:43:46.4943602Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-08-14T20:43:46.4944770Z  return frozenset( 2025-08-14T20:43:46.4945898Z  filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-08-14T20:43:46.4947066Z  ) 2025-08-14T20:43:46.4947697Z  2025-08-14T20:43:46.4948268Z  2025-08-14T20:43:46.4948897Z def parse_args() -> Any: 2025-08-14T20:43:46.4949947Z  parser = ArgumentParser("Get dynamic rollout settings") 2025-08-14T20:43:46.4951540Z  parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-08-14T20:43:46.4952972Z  parser.add_argument( 2025-08-14T20:43:46.4954105Z  "--github-issue-repo", 2025-08-14T20:43:46.4955023Z  type=str, 2025-08-14T20:43:46.4955843Z  required=False, 2025-08-14T20:43:46.4956977Z  default="pytorch/test-infra", 2025-08-14T20:43:46.4958098Z  help="GitHub repo to get the issue", 2025-08-14T20:43:46.4959046Z  ) 2025-08-14T20:43:46.4959741Z  parser.add_argument( 2025-08-14T20:43:46.4960621Z  "--github-repo", 2025-08-14T20:43:46.4961493Z  type=str, 2025-08-14T20:43:46.4962285Z  required=True, 2025-08-14T20:43:46.4963182Z  help="GitHub repo where CI is running", 2025-08-14T20:43:46.4964328Z  ) 2025-08-14T20:43:46.4965018Z  parser.add_argument( 2025-08-14T20:43:46.4966185Z  "--github-issue", type=int, required=True, help="GitHub issue number" 2025-08-14T20:43:46.4967379Z  ) 2025-08-14T20:43:46.4968054Z  parser.add_argument( 2025-08-14T20:43:46.4969211Z  "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-08-14T20:43:46.4970423Z  ) 2025-08-14T20:43:46.4971082Z  parser.add_argument( 2025-08-14T20:43:46.4972266Z  "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-08-14T20:43:46.4973666Z  ) 2025-08-14T20:43:46.4974383Z  parser.add_argument( 2025-08-14T20:43:46.4975646Z  "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-08-14T20:43:46.4977247Z  ) 2025-08-14T20:43:46.4977967Z  parser.add_argument( 2025-08-14T20:43:46.4978806Z  "--github-ref-type", 2025-08-14T20:43:46.4979639Z  type=str, 2025-08-14T20:43:46.4980388Z  required=True, 2025-08-14T20:43:46.4981322Z  help="Current GitHub ref type, branch or tag", 2025-08-14T20:43:46.4982291Z  ) 2025-08-14T20:43:46.4982986Z  parser.add_argument( 2025-08-14T20:43:46.4984190Z  "--eligible-experiments", 2025-08-14T20:43:46.4985195Z  type=_str_comma_separated_to_set, 2025-08-14T20:43:46.4986128Z  required=False, 2025-08-14T20:43:46.4986916Z  default="", 2025-08-14T20:43:46.4988470Z  help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-08-14T20:43:46.4990143Z  ) 2025-08-14T20:43:46.4990867Z  parser.add_argument( 2025-08-14T20:43:46.4991759Z  "--opt-out-experiments", 2025-08-14T20:43:46.4992716Z  type=_str_comma_separated_to_set, 2025-08-14T20:43:46.4993898Z  required=False, 2025-08-14T20:43:46.4994729Z  default="", 2025-08-14T20:43:46.4995485Z  help=( 2025-08-14T20:43:46.4996707Z  "comma separated list of experiments to opt-out of. If unset, no opt-outs will occur. " 2025-08-14T20:43:46.4998761Z  "If the same experiment is listed both here and in '--eligible-experiments' opt-out will take priority." 2025-08-14T20:43:46.5000237Z  ), 2025-08-14T20:43:46.5000898Z  ) 2025-08-14T20:43:46.5001606Z  parser.add_argument( 2025-08-14T20:43:46.5002472Z  "--pr-number", 2025-08-14T20:43:46.5003294Z  type=str, 2025-08-14T20:43:46.5004315Z  required=False, 2025-08-14T20:43:46.5005146Z  default="", 2025-08-14T20:43:46.5006098Z  help="the optional PR number where this is run", 2025-08-14T20:43:46.5007116Z  ) 2025-08-14T20:43:46.5007778Z  2025-08-14T20:43:46.5008460Z  return parser.parse_args() 2025-08-14T20:43:46.5009340Z  2025-08-14T20:43:46.5009945Z  2025-08-14T20:43:46.5011018Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-08-14T20:43:46.5012616Z  auth = Auth.Token(github_token) 2025-08-14T20:43:46.5013767Z  return Github(auth=auth) 2025-08-14T20:43:46.5014591Z  2025-08-14T20:43:46.5015178Z  2025-08-14T20:43:46.5016366Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-08-14T20:43:46.5017853Z  repo = gh.get_repo(repo) 2025-08-14T20:43:46.5018814Z  return repo.get_issue(number=issue_num) 2025-08-14T20:43:46.5019728Z  2025-08-14T20:43:46.5020346Z  2025-08-14T20:43:46.5020998Z def get_potential_pr_author( 2025-08-14T20:43:46.5022185Z  github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-08-14T20:43:46.5023697Z ) -> str: 2025-08-14T20:43:46.5024673Z  # If the trigger was a new tag added by a bot, this is a ciflow case 2025-08-14T20:43:46.5026140Z  # Fetch the actual username from the original PR. The PR number is 2025-08-14T20:43:46.5027511Z  # embedded in the tag name: ciflow// 2025-08-14T20:43:46.5028540Z  2025-08-14T20:43:46.5029236Z  gh = get_gh_client(github_token) 2025-08-14T20:43:46.5030139Z  2025-08-14T20:43:46.5030961Z  if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-08-14T20:43:46.5032099Z  split_tag = ref_name.split("/") 2025-08-14T20:43:46.5033276Z  if ( 2025-08-14T20:43:46.5034220Z  len(split_tag) == 3 2025-08-14T20:43:46.5035095Z  and split_tag[0] == "ciflow" 2025-08-14T20:43:46.5036074Z  and split_tag[2].isnumeric() 2025-08-14T20:43:46.5036942Z  ): 2025-08-14T20:43:46.5037651Z  pr_number = split_tag[2] 2025-08-14T20:43:46.5038537Z  try: 2025-08-14T20:43:46.5039337Z  repository = gh.get_repo(repo) 2025-08-14T20:43:46.5040438Z  pull = repository.get_pull(number=int(pr_number)) 2025-08-14T20:43:46.5041567Z  except Exception as e: 2025-08-14T20:43:46.5042542Z  raise Exception( # noqa: TRY002 2025-08-14T20:43:46.5044018Z  f"issue with pull request {pr_number} from repo {repository}" 2025-08-14T20:43:46.5045238Z  ) from e 2025-08-14T20:43:46.5046366Z  return pull.user.login # type: ignore[no-any-return] 2025-08-14T20:43:46.5047674Z  # In all other cases, return the original input username 2025-08-14T20:43:46.5048804Z  return username 2025-08-14T20:43:46.5049601Z  2025-08-14T20:43:46.5050201Z  2025-08-14T20:43:46.5050935Z def is_exception_branch(branch: str) -> bool: 2025-08-14T20:43:46.5051910Z  """ 2025-08-14T20:43:46.5053111Z  Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-08-14T20:43:46.5054705Z  """ 2025-08-14T20:43:46.5055707Z  return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-08-14T20:43:46.5056856Z  2025-08-14T20:43:46.5057430Z  2025-08-14T20:43:46.5058170Z def load_yaml(yaml_text: str) -> Any: 2025-08-14T20:43:46.5059067Z  try: 2025-08-14T20:43:46.5059861Z  data = yaml.safe_load(yaml_text) 2025-08-14T20:43:46.5060807Z  return data 2025-08-14T20:43:46.5061711Z  except yaml.YAMLError: 2025-08-14T20:43:46.5062697Z  log.exception("Error loading YAML") 2025-08-14T20:43:46.5063950Z  raise 2025-08-14T20:43:46.5064643Z  2025-08-14T20:43:46.5065221Z  2025-08-14T20:43:46.5066314Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-08-14T20:43:46.5067722Z  """ 2025-08-14T20:43:46.5069163Z  Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-08-14T20:43:46.5070532Z  2025-08-14T20:43:46.5071479Z  If the issue body contains "---" then the text above that is the settings 2025-08-14T20:43:46.5072852Z  and the text below is the list of opted in users. 2025-08-14T20:43:46.5074042Z  2025-08-14T20:43:46.5075066Z  If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-08-14T20:43:46.5076338Z  """ 2025-08-14T20:43:46.5077173Z  rollout_state_parts = rollout_state.split("---") 2025-08-14T20:43:46.5078283Z  if len(rollout_state_parts) >= 2: 2025-08-14T20:43:46.5079409Z  return rollout_state_parts[0], rollout_state_parts[1] 2025-08-14T20:43:46.5080449Z  else: 2025-08-14T20:43:46.5081145Z  return "", rollout_state 2025-08-14T20:43:46.5081984Z  2025-08-14T20:43:46.5082583Z  2025-08-14T20:43:46.5083308Z class UserOptins(dict[str, list[str]]): 2025-08-14T20:43:46.5084428Z  """ 2025-08-14T20:43:46.5085365Z  Dictionary of users with a list of features they have opted into 2025-08-14T20:43:46.5086475Z  """ 2025-08-14T20:43:46.5087085Z  2025-08-14T20:43:46.5087663Z  2025-08-14T20:43:46.5088836Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-08-14T20:43:46.5090025Z  """ 2025-08-14T20:43:46.5091357Z  Parse the user opt-in text into a key value pair of username and the list of features they have opted into 2025-08-14T20:43:46.5092866Z  2025-08-14T20:43:46.5094483Z  Users are GitHub usernames with the @ prefix. Each user is also a comma-separated list of features/experiments to enable. 2025-08-14T20:43:46.5096285Z  - Example line: "@User1,lf,split_build" 2025-08-14T20:43:46.5097516Z  - A "#" prefix indicates the user is opted out of all experiments 2025-08-14T20:43:46.5098630Z  2025-08-14T20:43:46.5099242Z  2025-08-14T20:43:46.5099854Z  """ 2025-08-14T20:43:46.5100537Z  optins = UserOptins() 2025-08-14T20:43:46.5101460Z  for user in user_optin_text.split("\n"): 2025-08-14T20:43:46.5102458Z  user = user.strip("\r\n\t -") 2025-08-14T20:43:46.5103734Z  if not user or not user.startswith("@"): 2025-08-14T20:43:46.5104785Z  # Not a valid user. Skip 2025-08-14T20:43:46.5105685Z  continue 2025-08-14T20:43:46.5106412Z  2025-08-14T20:43:46.5107012Z  if user: 2025-08-14T20:43:46.5107883Z  usr_name = user.split(",")[0].strip("@") 2025-08-14T20:43:46.5109193Z  optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-08-14T20:43:46.5110357Z  2025-08-14T20:43:46.5111003Z  return optins 2025-08-14T20:43:46.5111778Z  2025-08-14T20:43:46.5112371Z  2025-08-14T20:43:46.5113283Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-08-14T20:43:46.5114760Z  """ 2025-08-14T20:43:46.5115536Z  Check if the experiment name is valid. 2025-08-14T20:43:46.5116644Z  A valid name: 2025-08-14T20:43:46.5118266Z  - Contains only alphanumeric characters and the special characters "_" & "-" 2025-08-14T20:43:46.5119988Z  - The special characters "_" & "-" shouldn't be the first or last characters 2025-08-14T20:43:46.5121302Z  - Cannot contain spaces 2025-08-14T20:43:46.5122118Z  """ 2025-08-14T20:43:46.5122737Z  2025-08-14T20:43:46.5123711Z  valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-08-14T20:43:46.5124945Z  valid = bool(re.match(valid_char_regex, experiment_name)) 2025-08-14T20:43:46.5126319Z  2025-08-14T20:43:46.5126949Z  if valid: 2025-08-14T20:43:46.5127635Z  return True 2025-08-14T20:43:46.5128341Z  2025-08-14T20:43:46.5128940Z  log.error( 2025-08-14T20:43:46.5131440Z  f"Invalid experiment name: {experiment_name}. Experiment names should only contain alphanumeric characters, '_', and '-'. They cannot contain spaces, and the special characters '_' and '-' cannot be the first or last characters." 2025-08-14T20:43:46.5134332Z  ) 2025-08-14T20:43:46.5134990Z  return False 2025-08-14T20:43:46.5135701Z  2025-08-14T20:43:46.5136277Z  2025-08-14T20:43:46.5137251Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-08-14T20:43:46.5138415Z  """ 2025-08-14T20:43:46.5139504Z  Parse the experiments from the issue body into a list of ExperimentSettings 2025-08-14T20:43:46.5140826Z  """ 2025-08-14T20:43:46.5141471Z  try: 2025-08-14T20:43:46.5142136Z  if settings_text: 2025-08-14T20:43:46.5143656Z  # Escape the backtick as well so that we can have the settings in a code block on the GH issue 2025-08-14T20:43:46.5145095Z  # for easy reading 2025-08-14T20:43:46.5146541Z  # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-08-14T20:43:46.5148403Z  # the backtick character in shell commands. 2025-08-14T20:43:46.5149496Z  backtick = chr(96) # backtick character 2025-08-14T20:43:46.5150673Z  settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-08-14T20:43:46.5151841Z  settings = load_yaml(settings_text) 2025-08-14T20:43:46.5152714Z  2025-08-14T20:43:46.5154023Z  # For now we just load experiments. We can expand this if/when we add more settings 2025-08-14T20:43:46.5155344Z  experiments = {} 2025-08-14T20:43:46.5156135Z  2025-08-14T20:43:46.5157109Z  for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-08-14T20:43:46.5158543Z  if not is_valid_experiment_name(exp_name): 2025-08-14T20:43:46.5160484Z  # Exclude invalid experiments from the list. We log an error, but don't raise an exception so that other experiments can still be processed. 2025-08-14T20:43:46.5162303Z  continue 2025-08-14T20:43:46.5163099Z  2025-08-14T20:43:46.5163960Z  valid_settings = {} 2025-08-14T20:43:46.5164914Z  for setting in exp_settings: 2025-08-14T20:43:46.5165921Z  if setting not in Experiment._fields: 2025-08-14T20:43:46.5167043Z  log.warning( 2025-08-14T20:43:46.5168319Z  f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-08-14T20:43:46.5169578Z  ) 2025-08-14T20:43:46.5170363Z  else: 2025-08-14T20:43:46.5171362Z  valid_settings[setting] = exp_settings[setting] 2025-08-14T20:43:46.5172414Z  2025-08-14T20:43:46.5173231Z  experiments[exp_name] = Experiment(**valid_settings) 2025-08-14T20:43:46.5174558Z  return Settings(experiments) 2025-08-14T20:43:46.5175415Z  2025-08-14T20:43:46.5176030Z  except Exception: 2025-08-14T20:43:46.5176898Z  log.exception("Failed to parse settings") 2025-08-14T20:43:46.5177831Z  2025-08-14T20:43:46.5178420Z  return Settings() 2025-08-14T20:43:46.5179168Z  2025-08-14T20:43:46.5179736Z  2025-08-14T20:43:46.5180839Z def parse_settings(rollout_state: str) -> Settings: 2025-08-14T20:43:46.5181987Z  """ 2025-08-14T20:43:46.5182803Z  Parse settings, if any, from the rollout state. 2025-08-14T20:43:46.5184050Z  2025-08-14T20:43:46.5185002Z  If the issue body contains "---" then the text above that is the settings 2025-08-14T20:43:46.5186441Z  and the text below is the list of opted in users. 2025-08-14T20:43:46.5187481Z  2025-08-14T20:43:46.5188579Z  If it doesn't contain "---" then the settings are empty and the default values are used. 2025-08-14T20:43:46.5189935Z  """ 2025-08-14T20:43:46.5191041Z  settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-08-14T20:43:46.5192428Z  return parse_settings_from_text(settings_text) 2025-08-14T20:43:46.5193660Z  2025-08-14T20:43:46.5194284Z  2025-08-14T20:43:46.5195099Z def parse_users(rollout_state: str) -> UserOptins: 2025-08-14T20:43:46.5196195Z  """ 2025-08-14T20:43:46.5196940Z  Parse users from the rollout state. 2025-08-14T20:43:46.5197857Z  2025-08-14T20:43:46.5198479Z  """ 2025-08-14T20:43:46.5199488Z  _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-08-14T20:43:46.5200815Z  return parse_user_opt_in_from_text(users_text) 2025-08-14T20:43:46.5202055Z  2025-08-14T20:43:46.5202647Z  2025-08-14T20:43:46.5203913Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-08-14T20:43:46.5205255Z  """ 2025-08-14T20:43:46.5206005Z  Check if a user is opted into an experiment 2025-08-14T20:43:46.5206916Z  """ 2025-08-14T20:43:46.5207747Z  return experiment_name in user_optins.get(user, []) 2025-08-14T20:43:46.5208736Z  2025-08-14T20:43:46.5209307Z  2025-08-14T20:43:46.5210374Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-08-14T20:43:46.5211726Z  """ 2025-08-14T20:43:46.5212564Z  Check if a user explicitly opted out of an experiment 2025-08-14T20:43:46.5213824Z  """ 2025-08-14T20:43:46.5214768Z  # if the experiment is prefixed with a "-", then it's an opt-out 2025-08-14T20:43:46.5216059Z  experiment_optout = "-" + experiment_name 2025-08-14T20:43:46.5217235Z  if experiment_optout not in user_optins.get(user, []): 2025-08-14T20:43:46.5218328Z  return False 2025-08-14T20:43:46.5219079Z  2025-08-14T20:43:46.5219876Z  if is_user_opted_in(user, user_optins, experiment_name): 2025-08-14T20:43:46.5220906Z  log.warning( 2025-08-14T20:43:46.5222333Z  f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-08-14T20:43:46.5224110Z  ) 2025-08-14T20:43:46.5224748Z  2025-08-14T20:43:46.5225351Z  return True 2025-08-14T20:43:46.5226042Z  2025-08-14T20:43:46.5226628Z  2025-08-14T20:43:46.5227291Z def get_runner_prefix( 2025-08-14T20:43:46.5228123Z  rollout_state: str, 2025-08-14T20:43:46.5229032Z  workflow_requestors: Iterable[str], 2025-08-14T20:43:46.5229995Z  branch: str, 2025-08-14T20:43:46.5230949Z  eligible_experiments: frozenset[str] = frozenset(), 2025-08-14T20:43:46.5232169Z  opt_out_experiments: frozenset[str] = frozenset(), 2025-08-14T20:43:46.5233680Z  is_canary: bool = False, 2025-08-14T20:43:46.5234638Z ) -> str: 2025-08-14T20:43:46.5235456Z  settings = parse_settings(rollout_state) 2025-08-14T20:43:46.5236542Z  user_optins = parse_users(rollout_state) 2025-08-14T20:43:46.5237517Z  2025-08-14T20:43:46.5238482Z  fleet_prefix = "" 2025-08-14T20:43:46.5239366Z  prefixes = [] 2025-08-14T20:43:46.5240595Z  for experiment_name, experiment_settings in settings.experiments.items(): 2025-08-14T20:43:46.5242469Z  if not experiment_settings.all_branches and is_exception_branch(branch): 2025-08-14T20:43:46.5243982Z  log.info( 2025-08-14T20:43:46.5245259Z  f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-08-14T20:43:46.5246673Z  ) 2025-08-14T20:43:46.5247370Z  continue 2025-08-14T20:43:46.5248091Z  2025-08-14T20:43:46.5248723Z  if opt_out_experiments: 2025-08-14T20:43:46.5249746Z  if experiment_name in opt_out_experiments: 2025-08-14T20:43:46.5250917Z  opt_out_exp_list = ", ".join(opt_out_experiments) 2025-08-14T20:43:46.5252129Z  log.info( 2025-08-14T20:43:46.5254031Z  f"Skipping experiment '{experiment_name}', as this workflow has opted-out (opted out experiments are: {opt_out_exp_list})" 2025-08-14T20:43:46.5255781Z  ) 2025-08-14T20:43:46.5256541Z  continue 2025-08-14T20:43:46.5257330Z  2025-08-14T20:43:46.5258408Z  if eligible_experiments: 2025-08-14T20:43:46.5259452Z  if experiment_name not in eligible_experiments: 2025-08-14T20:43:46.5260606Z  exp_list = ", ".join(eligible_experiments) 2025-08-14T20:43:46.5261624Z  log.info( 2025-08-14T20:43:46.5263081Z  f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-08-14T20:43:46.5264766Z  ) 2025-08-14T20:43:46.5265514Z  continue 2025-08-14T20:43:46.5266401Z  elif not experiment_settings.default: 2025-08-14T20:43:46.5267336Z  log.info( 2025-08-14T20:43:46.5268564Z  f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-08-14T20:43:46.5269901Z  ) 2025-08-14T20:43:46.5270640Z  continue 2025-08-14T20:43:46.5271402Z  2025-08-14T20:43:46.5272250Z  # Is any workflow_requestor opted out to this experiment? 2025-08-14T20:43:46.5273570Z  opted_out_users = [ 2025-08-14T20:43:46.5274441Z  requestor 2025-08-14T20:43:46.5275315Z  for requestor in workflow_requestors 2025-08-14T20:43:46.5276518Z  if is_user_opted_out(requestor, user_optins, experiment_name) 2025-08-14T20:43:46.5277617Z  ] 2025-08-14T20:43:46.5278260Z  2025-08-14T20:43:46.5278872Z  if opted_out_users: 2025-08-14T20:43:46.5279729Z  log.info( 2025-08-14T20:43:46.5280853Z  f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-08-14T20:43:46.5282056Z  ) 2025-08-14T20:43:46.5282734Z  continue 2025-08-14T20:43:46.5283664Z  2025-08-14T20:43:46.5284503Z  # Is any workflow_requestor opted in to this experiment? 2025-08-14T20:43:46.5285642Z  opted_in_users = [ 2025-08-14T20:43:46.5286471Z  requestor 2025-08-14T20:43:46.5287328Z  for requestor in workflow_requestors 2025-08-14T20:43:46.5288495Z  if is_user_opted_in(requestor, user_optins, experiment_name) 2025-08-14T20:43:46.5289555Z  ] 2025-08-14T20:43:46.5290186Z  2025-08-14T20:43:46.5290806Z  enabled = False 2025-08-14T20:43:46.5291583Z  if opted_in_users: 2025-08-14T20:43:46.5292661Z  log.info( 2025-08-14T20:43:46.5294027Z  f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-08-14T20:43:46.5295207Z  ) 2025-08-14T20:43:46.5295917Z  enabled = True 2025-08-14T20:43:46.5296706Z  2025-08-14T20:43:46.5297464Z  elif experiment_settings.rollout_perc: 2025-08-14T20:43:46.5298981Z  # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-08-14T20:43:46.5300760Z  if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-08-14T20:43:46.5301946Z  log.info( 2025-08-14T20:43:46.5303754Z  f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-08-14T20:43:46.5305445Z  ) 2025-08-14T20:43:46.5306220Z  enabled = True 2025-08-14T20:43:46.5307026Z  2025-08-14T20:43:46.5307643Z  if enabled: 2025-08-14T20:43:46.5308423Z  label = experiment_name 2025-08-14T20:43:46.5309395Z  if experiment_name == LF_FLEET_EXPERIMENT: 2025-08-14T20:43:46.5310811Z  # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-08-14T20:43:46.5312699Z  # - If it's enabled, then we always list it's prefix first 2025-08-14T20:43:46.5314348Z  # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-08-14T20:43:46.5315591Z  if is_canary: 2025-08-14T20:43:46.5316529Z  label += CANARY_FLEET_SUFFIX 2025-08-14T20:43:46.5317499Z  fleet_prefix = label 2025-08-14T20:43:46.5318395Z  else: 2025-08-14T20:43:46.5319244Z  prefixes.append(label) 2025-08-14T20:43:46.5320171Z  2025-08-14T20:43:46.5320791Z  if len(prefixes) > 1: 2025-08-14T20:43:46.5321599Z  log.error( 2025-08-14T20:43:46.5323632Z  f"Only a fleet and one other experiment can be enabled for a job at any time. Enabling {prefixes[0]} and ignoring the rest, which are {', '.join(prefixes[1:])}" 2025-08-14T20:43:46.5325592Z  ) 2025-08-14T20:43:46.5326346Z  prefixes = prefixes[:1] 2025-08-14T20:43:46.5327354Z  2025-08-14T20:43:46.5328034Z  # Fleet always comes first 2025-08-14T20:43:46.5328910Z  if fleet_prefix: 2025-08-14T20:43:46.5329739Z  prefixes.insert(0, fleet_prefix) 2025-08-14T20:43:46.5330662Z  2025-08-14T20:43:46.5331445Z  return ".".join(prefixes) + "." if prefixes else "" 2025-08-14T20:43:46.5332438Z  2025-08-14T20:43:46.5333034Z  2025-08-14T20:43:46.5334484Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-08-14T20:43:46.5335836Z  """ 2025-08-14T20:43:46.5336882Z  Gets the first comment of the issue, which contains the desired rollout state. 2025-08-14T20:43:46.5338141Z  2025-08-14T20:43:46.5339168Z  The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-08-14T20:43:46.5340415Z  """ 2025-08-14T20:43:46.5341119Z  gh = get_gh_client(github_token) 2025-08-14T20:43:46.5342078Z  issue = get_issue(gh, repo, issue_num) 2025-08-14T20:43:46.5343198Z  return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-08-14T20:43:46.5344461Z  2025-08-14T20:43:46.5345094Z  2025-08-14T20:43:46.5346175Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-08-14T20:43:46.5347791Z  for _ in range(num_retries): 2025-08-14T20:43:46.5348689Z  try: 2025-08-14T20:43:46.5349485Z  req = Request(url=url, headers=headers) 2025-08-14T20:43:46.5350684Z  content = urlopen(req, timeout=5).read().decode("utf-8") 2025-08-14T20:43:46.5351845Z  return json.loads(content) 2025-08-14T20:43:46.5352822Z  except Exception as e: 2025-08-14T20:43:46.5354116Z  log.warning(f"Could not download {url}: {e}") 2025-08-14T20:43:46.5355113Z  2025-08-14T20:43:46.5356109Z  log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-08-14T20:43:46.5357382Z  return {} 2025-08-14T20:43:46.5358167Z  2025-08-14T20:43:46.5358789Z  2025-08-14T20:43:46.5359403Z @cache 2025-08-14T20:43:46.5360525Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-08-14T20:43:46.5361845Z  """ 2025-08-14T20:43:46.5362546Z  Dynamically get PR information 2025-08-14T20:43:46.5363625Z  """ 2025-08-14T20:43:46.5364579Z  github_api = f"https://api.github.com/repos/{github_repo}" 2025-08-14T20:43:46.5365735Z  headers = { 2025-08-14T20:43:46.5366637Z  "Accept": "application/vnd.github.v3+json", 2025-08-14T20:43:46.5368004Z  "Authorization": f"token {github_token}", 2025-08-14T20:43:46.5368933Z  } 2025-08-14T20:43:46.5369738Z  json_response: dict[str, Any] = download_json( 2025-08-14T20:43:46.5370862Z  url=f"{github_api}/issues/{pr_number}", 2025-08-14T20:43:46.5371854Z  headers=headers, 2025-08-14T20:43:46.5372853Z  ) 2025-08-14T20:43:46.5373676Z  2025-08-14T20:43:46.5374318Z  if not json_response: 2025-08-14T20:43:46.5375369Z  log.warning(f"Failed to get the labels for #{pr_number}") 2025-08-14T20:43:46.5376494Z  return {} 2025-08-14T20:43:46.5377244Z  2025-08-14T20:43:46.5377862Z  return json_response 2025-08-14T20:43:46.5378654Z  2025-08-14T20:43:46.5379218Z  2025-08-14T20:43:46.5380230Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-08-14T20:43:46.5381540Z  """ 2025-08-14T20:43:46.5382534Z  Dynamically get the latest list of labels from the pull request 2025-08-14T20:43:46.5383991Z  """ 2025-08-14T20:43:46.5384910Z  pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-08-14T20:43:46.5385963Z  return { 2025-08-14T20:43:46.5387039Z  label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-08-14T20:43:46.5388284Z  } 2025-08-14T20:43:46.5388937Z  2025-08-14T20:43:46.5389554Z  2025-08-14T20:43:46.5390211Z def main() -> None: 2025-08-14T20:43:46.5391049Z  args = parse_args() 2025-08-14T20:43:46.5391833Z  2025-08-14T20:43:46.5392555Z  runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-08-14T20:43:46.5393679Z  2025-08-14T20:43:46.5394313Z  # Check if the PR is opt-out 2025-08-14T20:43:46.5395166Z  if args.pr_number: 2025-08-14T20:43:46.5396373Z  labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-08-14T20:43:46.5397645Z  if OPT_OUT_LABEL in labels: 2025-08-14T20:43:46.5398490Z  log.info( 2025-08-14T20:43:46.5399700Z  f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-08-14T20:43:46.5400992Z  ) 2025-08-14T20:43:46.5401964Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-08-14T20:43:46.5403168Z  sys.exit() 2025-08-14T20:43:46.5404426Z  2025-08-14T20:43:46.5405044Z  try: 2025-08-14T20:43:46.5405832Z  rollout_state = get_rollout_state_from_issue( 2025-08-14T20:43:46.5407055Z  args.github_token, args.github_issue_repo, args.github_issue 2025-08-14T20:43:46.5408218Z  ) 2025-08-14T20:43:46.5408899Z  2025-08-14T20:43:46.5409634Z  username = get_potential_pr_author( 2025-08-14T20:43:46.5410613Z  args.github_token, 2025-08-14T20:43:46.5411537Z  args.github_repo, 2025-08-14T20:43:46.5412449Z  args.github_actor, 2025-08-14T20:43:46.5413605Z  args.github_ref_type, 2025-08-14T20:43:46.5414561Z  args.github_branch, 2025-08-14T20:43:46.5415394Z  ) 2025-08-14T20:43:46.5416041Z  2025-08-14T20:43:46.5416907Z  is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-08-14T20:43:46.5418012Z  2025-08-14T20:43:46.5418735Z  runner_label_prefix = get_runner_prefix( 2025-08-14T20:43:46.5419698Z  rollout_state, 2025-08-14T20:43:46.5420591Z  (args.github_issue_owner, username), 2025-08-14T20:43:46.5421584Z  args.github_branch, 2025-08-14T20:43:46.5422784Z  args.eligible_experiments, 2025-08-14T20:43:46.5424041Z  args.opt_out_experiments, 2025-08-14T20:43:46.5424977Z  is_canary, 2025-08-14T20:43:46.5425732Z  ) 2025-08-14T20:43:46.5426374Z  2025-08-14T20:43:46.5426989Z  except Exception as e: 2025-08-14T20:43:46.5427803Z  log.error( 2025-08-14T20:43:46.5429023Z  f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-08-14T20:43:46.5430374Z  ) 2025-08-14T20:43:46.5431083Z  2025-08-14T20:43:46.5432035Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-08-14T20:43:46.5433197Z  2025-08-14T20:43:46.5434229Z  2025-08-14T20:43:46.5434638Z if __name__ == "__main__": 2025-08-14T20:43:46.5435123Z  main() 2025-08-14T20:43:46.5435503Z  2025-08-14T20:43:46.5435833Z EOF 2025-08-14T20:43:46.5436202Z  2025-08-14T20:43:46.5436579Z cat runner_determinator.py 2025-08-14T20:43:46.6661584Z shell: /usr/bin/bash -e {0} 2025-08-14T20:43:46.6662494Z env: 2025-08-14T20:43:46.6663135Z GITHUB_TOKEN: *** 2025-08-14T20:43:46.6663695Z ISSUE_NUMBER: 5132 2025-08-14T20:43:46.6664114Z TRIGGERING_ACTOR: pytorchmergebot 2025-08-14T20:43:46.6664580Z ISSUE_OWNER: 2025-08-14T20:43:46.6664955Z CHECK_EXPERIMENTS: 2025-08-14T20:43:46.6665350Z OPT_OUT_EXPERIMENTS: 2025-08-14T20:43:46.6665742Z PR_NUMBER: 2025-08-14T20:43:46.6666092Z ##[endgroup] 2025-08-14T20:43:46.6876106Z # flake8: noqa: G004 2025-08-14T20:43:46.6876415Z 2025-08-14T20:43:46.6876817Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-08-14T20:43:46.6877703Z # must be kept in sync. You can do it easily by running the following command: 2025-08-14T20:43:46.6878439Z # python .github/scripts/update_runner_determinator.py 2025-08-14T20:43:46.6878852Z 2025-08-14T20:43:46.6878994Z """ 2025-08-14T20:43:46.6879527Z This runner determinator is used to determine which set of runners to run a 2025-08-14T20:43:46.6880338Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-08-14T20:43:46.6881193Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-08-14T20:43:46.6881942Z of which runners should be used to run which job. 2025-08-14T20:43:46.6882317Z 2025-08-14T20:43:46.6882677Z The configuration has two parts, the settings and a list of opted-in users, 2025-08-14T20:43:46.6883921Z separated by a line containing "---". If the line is not present, the 2025-08-14T20:43:46.6884750Z settings are considered to be empty with only the second part, the user 2025-08-14T20:43:46.6885393Z list, defined. 2025-08-14T20:43:46.6885598Z 2025-08-14T20:43:46.6885934Z The first part is a YAML block that defines the rollout settings. This can be 2025-08-14T20:43:46.6886774Z used to define any settings that are needed to determine which runners to use. 2025-08-14T20:43:46.6887544Z It's fields are defined by the RolloutSettings class below. 2025-08-14T20:43:46.6887957Z 2025-08-14T20:43:46.6888297Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-08-14T20:43:46.6889108Z The user list is also a comma separated list of additional features or 2025-08-14T20:43:46.6889779Z experiments which the user could be opted in to. 2025-08-14T20:43:46.6890149Z 2025-08-14T20:43:46.6890333Z The user list has the following rules: 2025-08-14T20:43:46.6890652Z 2025-08-14T20:43:46.6890946Z - Users are GitHub usernames, which must start with the @ prefix 2025-08-14T20:43:46.6891742Z - Each user is also a comma-separated list of features/experiments to enable 2025-08-14T20:43:46.6892440Z - A "#" prefix opts the user out of all experiments 2025-08-14T20:43:46.6892803Z 2025-08-14T20:43:46.6892959Z Example config: 2025-08-14T20:43:46.6893585Z # A list of experiments that can be opted into. 2025-08-14T20:43:46.6894398Z # This defines the behavior they'll induce when opted into. 2025-08-14T20:43:46.6894989Z # Expected syntax is: 2025-08-14T20:43:46.6895581Z # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-08-14T20:43:46.6896485Z # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-08-14T20:43:46.6897045Z 2025-08-14T20:43:46.6897209Z experiments: 2025-08-14T20:43:46.6897564Z lf: 2025-08-14T20:43:46.6897916Z rollout_percent: 25 2025-08-14T20:43:46.6898338Z all_branches: false 2025-08-14T20:43:46.6898760Z default: true 2025-08-14T20:43:46.6899128Z --- 2025-08-14T20:43:46.6899318Z 2025-08-14T20:43:46.6899469Z # Opt-ins: 2025-08-14T20:43:46.6900002Z # Users can opt into the LF fleet by adding their GitHub username to this list 2025-08-14T20:43:46.6900806Z # and specifying experiments to enable in a comma-separated list. 2025-08-14T20:43:46.6901524Z # To always opt out of an experiment, prefix it with a "-". 2025-08-14T20:43:46.6902128Z # Experiments should be from the above list. 2025-08-14T20:43:46.6902474Z 2025-08-14T20:43:46.6902651Z @User1,-lf,split_build 2025-08-14T20:43:46.6903044Z @User2,lf 2025-08-14T20:43:46.6903594Z @User3,split_build 2025-08-14T20:43:46.6903989Z """ 2025-08-14T20:43:46.6904168Z 2025-08-14T20:43:46.6904319Z import json 2025-08-14T20:43:46.6904655Z import logging 2025-08-14T20:43:46.6905008Z import os 2025-08-14T20:43:46.6905335Z import random 2025-08-14T20:43:46.6905682Z import re 2025-08-14T20:43:46.6906014Z import sys 2025-08-14T20:43:46.6906395Z from argparse import ArgumentParser 2025-08-14T20:43:46.6906890Z from collections.abc import Iterable 2025-08-14T20:43:46.6907374Z from functools import cache 2025-08-14T20:43:46.6907807Z from logging import LogRecord 2025-08-14T20:43:46.6908259Z from typing import Any, NamedTuple 2025-08-14T20:43:46.6908752Z from urllib.request import Request, urlopen 2025-08-14T20:43:46.6909098Z 2025-08-14T20:43:46.6909254Z import yaml 2025-08-14T20:43:46.6909616Z from github import Auth, Github 2025-08-14T20:43:46.6910066Z from github.Issue import Issue 2025-08-14T20:43:46.6910347Z 2025-08-14T20:43:46.6910354Z 2025-08-14T20:43:46.6910553Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-08-14T20:43:46.6911190Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-08-14T20:43:46.6911976Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-08-14T20:43:46.6912490Z 2025-08-14T20:43:46.6912706Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-08-14T20:43:46.6913630Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-08-14T20:43:46.6914153Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-08-14T20:43:46.6914665Z OPT_OUT_LABEL = "no-runner-experiments" 2025-08-14T20:43:46.6914985Z 2025-08-14T20:43:46.6915170Z SETTING_EXPERIMENTS = "experiments" 2025-08-14T20:43:46.6915471Z 2025-08-14T20:43:46.6915653Z LF_FLEET_EXPERIMENT = "lf" 2025-08-14T20:43:46.6916086Z CANARY_FLEET_SUFFIX = ".c" 2025-08-14T20:43:46.6916346Z 2025-08-14T20:43:46.6916352Z 2025-08-14T20:43:46.6916526Z class Experiment(NamedTuple): 2025-08-14T20:43:46.6916964Z rollout_perc: float = ( 2025-08-14T20:43:46.6917547Z 0 # Percentage of workflows to experiment on when user is not opted-in. 2025-08-14T20:43:46.6918180Z ) 2025-08-14T20:43:46.6918520Z all_branches: bool = ( 2025-08-14T20:43:46.6919107Z False # If True, the experiment is also enabled on the exception branches 2025-08-14T20:43:46.6919721Z ) 2025-08-14T20:43:46.6920051Z default: bool = ( 2025-08-14T20:43:46.6920595Z True # If True, the experiment is enabled by default for all queries 2025-08-14T20:43:46.6921184Z ) 2025-08-14T20:43:46.6921358Z 2025-08-14T20:43:46.6921528Z # Add more fields as needed 2025-08-14T20:43:46.6921809Z 2025-08-14T20:43:46.6921815Z 2025-08-14T20:43:46.6921983Z class Settings(NamedTuple): 2025-08-14T20:43:46.6922392Z """ 2025-08-14T20:43:46.6922943Z Settings for the experiments that can be opted into. 2025-08-14T20:43:46.6923685Z """ 2025-08-14T20:43:46.6923880Z 2025-08-14T20:43:46.6924072Z experiments: dict[str, Experiment] = {} 2025-08-14T20:43:46.6924414Z 2025-08-14T20:43:46.6924420Z 2025-08-14T20:43:46.6924616Z class ColorFormatter(logging.Formatter): 2025-08-14T20:43:46.6925187Z """Color codes the log messages based on the log level""" 2025-08-14T20:43:46.6925594Z 2025-08-14T20:43:46.6925743Z COLORS = { 2025-08-14T20:43:46.6926117Z "WARNING": "\033[33m", # Yellow 2025-08-14T20:43:46.6926574Z "ERROR": "\033[31m", # Red 2025-08-14T20:43:46.6927031Z "CRITICAL": "\033[31m", # Red 2025-08-14T20:43:46.6927485Z "INFO": "\033[0m", # Reset 2025-08-14T20:43:46.6927927Z "DEBUG": "\033[0m", # Reset 2025-08-14T20:43:46.6928349Z } 2025-08-14T20:43:46.6928526Z 2025-08-14T20:43:46.6928726Z def format(self, record: LogRecord) -> str: 2025-08-14T20:43:46.6929444Z log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-08-14T20:43:46.6930170Z record.msg = f"{log_color}{record.msg}\033[0m" 2025-08-14T20:43:46.6930709Z return super().format(record) 2025-08-14T20:43:46.6931012Z 2025-08-14T20:43:46.6931020Z 2025-08-14T20:43:46.6931201Z handler = logging.StreamHandler() 2025-08-14T20:43:46.6931849Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-08-14T20:43:46.6932348Z 2025-08-14T20:43:46.6932573Z log = logging.getLogger(os.path.basename(__file__)) 2025-08-14T20:43:46.6933113Z log.addHandler(handler) 2025-08-14T20:43:46.6933639Z log.setLevel(logging.INFO) 2025-08-14T20:43:46.6933908Z 2025-08-14T20:43:46.6933914Z 2025-08-14T20:43:46.6934145Z def set_github_output(key: str, value: str) -> None: 2025-08-14T20:43:46.6934661Z """ 2025-08-14T20:43:46.6935124Z Defines outputs of the github action that invokes this script 2025-08-14T20:43:46.6935699Z """ 2025-08-14T20:43:46.6936034Z if not GITHUB_OUTPUT: 2025-08-14T20:43:46.6937034Z # See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ for deprecation notice 2025-08-14T20:43:46.6938053Z log.warning( 2025-08-14T20:43:46.6938834Z "No env var found for GITHUB_OUTPUT, you must be running this code locally. Falling back to the deprecated print method." 2025-08-14T20:43:46.6939677Z ) 2025-08-14T20:43:46.6949386Z print(f"::set-output name={key}::{value}") 2025-08-14T20:43:46.6949956Z return 2025-08-14T20:43:46.6950171Z 2025-08-14T20:43:46.6950538Z with open(GITHUB_OUTPUT, "a") as f: 2025-08-14T20:43:46.6951098Z log.info(f"Setting output: {key}='{value}'") 2025-08-14T20:43:46.6951626Z f.write(f"{key}={value}\n") 2025-08-14T20:43:46.6951932Z 2025-08-14T20:43:46.6951939Z 2025-08-14T20:43:46.6952221Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-08-14T20:43:46.6952804Z return frozenset( 2025-08-14T20:43:46.6953661Z filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-08-14T20:43:46.6954314Z ) 2025-08-14T20:43:46.6954495Z 2025-08-14T20:43:46.6954503Z 2025-08-14T20:43:46.6954676Z def parse_args() -> Any: 2025-08-14T20:43:46.6955191Z parser = ArgumentParser("Get dynamic rollout settings") 2025-08-14T20:43:46.6955984Z parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-08-14T20:43:46.6956706Z parser.add_argument( 2025-08-14T20:43:46.6957132Z "--github-issue-repo", 2025-08-14T20:43:46.6957551Z type=str, 2025-08-14T20:43:46.6957934Z required=False, 2025-08-14T20:43:46.6958346Z default="pytorch/test-infra", 2025-08-14T20:43:46.6958838Z help="GitHub repo to get the issue", 2025-08-14T20:43:46.6959299Z ) 2025-08-14T20:43:46.6959640Z parser.add_argument( 2025-08-14T20:43:46.6960038Z "--github-repo", 2025-08-14T20:43:46.6960430Z type=str, 2025-08-14T20:43:46.6960787Z required=True, 2025-08-14T20:43:46.6961364Z help="GitHub repo where CI is running", 2025-08-14T20:43:46.6961846Z ) 2025-08-14T20:43:46.6962183Z parser.add_argument( 2025-08-14T20:43:46.6962744Z "--github-issue", type=int, required=True, help="GitHub issue number" 2025-08-14T20:43:46.6963537Z ) 2025-08-14T20:43:46.6963896Z parser.add_argument( 2025-08-14T20:43:46.6964468Z "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-08-14T20:43:46.6965080Z ) 2025-08-14T20:43:46.6965414Z parser.add_argument( 2025-08-14T20:43:46.6966011Z "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-08-14T20:43:46.6966640Z ) 2025-08-14T20:43:46.6966989Z parser.add_argument( 2025-08-14T20:43:46.6967590Z "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-08-14T20:43:46.6968236Z ) 2025-08-14T20:43:46.6968569Z parser.add_argument( 2025-08-14T20:43:46.6968973Z "--github-ref-type", 2025-08-14T20:43:46.6969389Z type=str, 2025-08-14T20:43:46.6969743Z required=True, 2025-08-14T20:43:46.6970190Z help="Current GitHub ref type, branch or tag", 2025-08-14T20:43:46.6970685Z ) 2025-08-14T20:43:46.6971017Z parser.add_argument( 2025-08-14T20:43:46.6971435Z "--eligible-experiments", 2025-08-14T20:43:46.6971907Z type=_str_comma_separated_to_set, 2025-08-14T20:43:46.6972404Z required=False, 2025-08-14T20:43:46.6972784Z default="", 2025-08-14T20:43:46.6973686Z help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-08-14T20:43:46.6974533Z ) 2025-08-14T20:43:46.6974869Z parser.add_argument( 2025-08-14T20:43:46.6975284Z "--opt-out-experiments", 2025-08-14T20:43:46.6975745Z type=_str_comma_separated_to_set, 2025-08-14T20:43:46.6976214Z required=False, 2025-08-14T20:43:46.6976596Z default="", 2025-08-14T20:43:46.6976951Z help=( 2025-08-14T20:43:46.6977569Z "comma separated list of experiments to opt-out of. If unset, no opt-outs will occur. " 2025-08-14T20:43:46.6978610Z "If the same experiment is listed both here and in '--eligible-experiments' opt-out will take priority." 2025-08-14T20:43:46.6979369Z ), 2025-08-14T20:43:46.6979697Z ) 2025-08-14T20:43:46.6980031Z parser.add_argument( 2025-08-14T20:43:46.6980437Z "--pr-number", 2025-08-14T20:43:46.6980812Z type=str, 2025-08-14T20:43:46.7028190Z required=False, 2025-08-14T20:43:46.7028680Z default="", 2025-08-14T20:43:46.7029369Z help="the optional PR number where this is run", 2025-08-14T20:43:46.7029909Z ) 2025-08-14T20:43:46.7030108Z 2025-08-14T20:43:46.7030287Z return parser.parse_args() 2025-08-14T20:43:46.7030570Z 2025-08-14T20:43:46.7030576Z 2025-08-14T20:43:46.7030961Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-08-14T20:43:46.7031664Z auth = Auth.Token(github_token) 2025-08-14T20:43:46.7032140Z return Github(auth=auth) 2025-08-14T20:43:46.7032410Z 2025-08-14T20:43:46.7032417Z 2025-08-14T20:43:46.7032842Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-08-14T20:43:46.7033864Z repo = gh.get_repo(repo) 2025-08-14T20:43:46.7034345Z return repo.get_issue(number=issue_num) 2025-08-14T20:43:46.7034677Z 2025-08-14T20:43:46.7034683Z 2025-08-14T20:43:46.7034858Z def get_potential_pr_author( 2025-08-14T20:43:46.7035460Z github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-08-14T20:43:46.7036080Z ) -> str: 2025-08-14T20:43:46.7036559Z # If the trigger was a new tag added by a bot, this is a ciflow case 2025-08-14T20:43:46.7037299Z # Fetch the actual username from the original PR. The PR number is 2025-08-14T20:43:46.7037982Z # embedded in the tag name: ciflow// 2025-08-14T20:43:46.7038361Z 2025-08-14T20:43:46.7038688Z gh = get_gh_client(github_token) 2025-08-14T20:43:46.7038998Z 2025-08-14T20:43:46.7039248Z if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-08-14T20:43:46.7039822Z split_tag = ref_name.split("/") 2025-08-14T20:43:46.7040279Z if ( 2025-08-14T20:43:46.7040630Z len(split_tag) == 3 2025-08-14T20:43:46.7041065Z and split_tag[0] == "ciflow" 2025-08-14T20:43:46.7041548Z and split_tag[2].isnumeric() 2025-08-14T20:43:46.7041994Z ): 2025-08-14T20:43:46.7042347Z pr_number = split_tag[2] 2025-08-14T20:43:46.7042785Z try: 2025-08-14T20:43:46.7043178Z repository = gh.get_repo(repo) 2025-08-14T20:43:46.7043894Z pull = repository.get_pull(number=int(pr_number)) 2025-08-14T20:43:46.7044446Z except Exception as e: 2025-08-14T20:43:46.7044919Z raise Exception( # noqa: TRY002 2025-08-14T20:43:46.7045537Z f"issue with pull request {pr_number} from repo {repository}" 2025-08-14T20:43:46.7046130Z ) from e 2025-08-14T20:43:46.7046614Z return pull.user.login # type: ignore[no-any-return] 2025-08-14T20:43:46.7047256Z # In all other cases, return the original input username 2025-08-14T20:43:46.7047795Z return username 2025-08-14T20:43:46.7048015Z 2025-08-14T20:43:46.7048021Z 2025-08-14T20:43:46.7048229Z def is_exception_branch(branch: str) -> bool: 2025-08-14T20:43:46.7048720Z """ 2025-08-14T20:43:46.7049301Z Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-08-14T20:43:46.7050018Z """ 2025-08-14T20:43:46.7050519Z return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-08-14T20:43:46.7050999Z 2025-08-14T20:43:46.7051006Z 2025-08-14T20:43:46.7051188Z def load_yaml(yaml_text: str) -> Any: 2025-08-14T20:43:46.7051642Z try: 2025-08-14T20:43:46.7051992Z data = yaml.safe_load(yaml_text) 2025-08-14T20:43:46.7052464Z return data 2025-08-14T20:43:46.7052838Z except yaml.YAMLError: 2025-08-14T20:43:46.7053282Z log.exception("Error loading YAML") 2025-08-14T20:43:46.7053862Z raise 2025-08-14T20:43:46.7054068Z 2025-08-14T20:43:46.7054074Z 2025-08-14T20:43:46.7054457Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-08-14T20:43:46.7055134Z """ 2025-08-14T20:43:46.7055697Z Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-08-14T20:43:46.7056254Z 2025-08-14T20:43:46.7056707Z If the issue body contains "---" then the text above that is the settings 2025-08-14T20:43:46.7057411Z and the text below is the list of opted in users. 2025-08-14T20:43:46.7057794Z 2025-08-14T20:43:46.7058139Z If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-08-14T20:43:46.7058776Z """ 2025-08-14T20:43:46.7059179Z rollout_state_parts = rollout_state.split("---") 2025-08-14T20:43:46.7059732Z if len(rollout_state_parts) >= 2: 2025-08-14T20:43:46.7060280Z return rollout_state_parts[0], rollout_state_parts[1] 2025-08-14T20:43:46.7060812Z else: 2025-08-14T20:43:46.7061152Z return "", rollout_state 2025-08-14T20:43:46.7061431Z 2025-08-14T20:43:46.7061444Z 2025-08-14T20:43:46.7061625Z class UserOptins(dict[str, list[str]]): 2025-08-14T20:43:46.7062080Z """ 2025-08-14T20:43:46.7062552Z Dictionary of users with a list of features they have opted into 2025-08-14T20:43:46.7063135Z """ 2025-08-14T20:43:46.7063317Z 2025-08-14T20:43:46.7063473Z 2025-08-14T20:43:46.7063841Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-08-14T20:43:46.7064451Z """ 2025-08-14T20:43:46.7065092Z Parse the user opt-in text into a key value pair of username and the list of features they have opted into 2025-08-14T20:43:46.7065738Z 2025-08-14T20:43:46.7066305Z Users are GitHub usernames with the @ prefix. Each user is also a comma-separated list of features/experiments to enable. 2025-08-14T20:43:46.7067380Z - Example line: "@User1,lf,split_build" 2025-08-14T20:43:46.7068012Z - A "#" prefix indicates the user is opted out of all experiments 2025-08-14T20:43:46.7068449Z 2025-08-14T20:43:46.7068455Z 2025-08-14T20:43:46.7068603Z """ 2025-08-14T20:43:46.7068935Z optins = UserOptins() 2025-08-14T20:43:46.7069381Z for user in user_optin_text.split("\n"): 2025-08-14T20:43:46.7069884Z user = user.strip("\r\n\t -") 2025-08-14T20:43:46.7070386Z if not user or not user.startswith("@"): 2025-08-14T20:43:46.7070893Z # Not a valid user. Skip 2025-08-14T20:43:46.7071344Z continue 2025-08-14T20:43:46.7071570Z 2025-08-14T20:43:46.7071726Z if user: 2025-08-14T20:43:46.7072125Z usr_name = user.split(",")[0].strip("@") 2025-08-14T20:43:46.7072763Z optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-08-14T20:43:46.7073212Z 2025-08-14T20:43:46.7073486Z return optins 2025-08-14T20:43:46.7073710Z 2025-08-14T20:43:46.7073717Z 2025-08-14T20:43:46.7073989Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-08-14T20:43:46.7074526Z """ 2025-08-14T20:43:46.7074892Z Check if the experiment name is valid. 2025-08-14T20:43:46.7075361Z A valid name: 2025-08-14T20:43:46.7075946Z - Contains only alphanumeric characters and the special characters "_" & "-" 2025-08-14T20:43:46.7076812Z - The special characters "_" & "-" shouldn't be the first or last characters 2025-08-14T20:43:46.7077460Z - Cannot contain spaces 2025-08-14T20:43:46.7077883Z """ 2025-08-14T20:43:46.7078060Z 2025-08-14T20:43:46.7078301Z valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-08-14T20:43:46.7078949Z valid = bool(re.match(valid_char_regex, experiment_name)) 2025-08-14T20:43:46.7079351Z 2025-08-14T20:43:46.7079498Z if valid: 2025-08-14T20:43:46.7079845Z return True 2025-08-14T20:43:46.7080066Z 2025-08-14T20:43:46.7080221Z log.error( 2025-08-14T20:43:46.7081541Z f"Invalid experiment name: {experiment_name}. Experiment names should only contain alphanumeric characters, '_', and '-'. They cannot contain spaces, and the special characters '_' and '-' cannot be the first or last characters." 2025-08-14T20:43:46.7082996Z ) 2025-08-14T20:43:46.7083322Z return False 2025-08-14T20:43:46.7083637Z 2025-08-14T20:43:46.7083644Z 2025-08-14T20:43:46.7083922Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-08-14T20:43:46.7084492Z """ 2025-08-14T20:43:46.7085150Z Parse the experiments from the issue body into a list of ExperimentSettings 2025-08-14T20:43:46.7085813Z """ 2025-08-14T20:43:46.7086133Z try: 2025-08-14T20:43:46.7086475Z if settings_text: 2025-08-14T20:43:46.7087135Z # Escape the backtick as well so that we can have the settings in a code block on the GH issue 2025-08-14T20:43:46.7087853Z # for easy reading 2025-08-14T20:43:46.7088579Z # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-08-14T20:43:46.7089378Z # the backtick character in shell commands. 2025-08-14T20:43:46.7089931Z backtick = chr(96) # backtick character 2025-08-14T20:43:46.7090534Z settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-08-14T20:43:46.7091143Z settings = load_yaml(settings_text) 2025-08-14T20:43:46.7091477Z 2025-08-14T20:43:46.7091855Z # For now we just load experiments. We can expand this if/when we add more settings 2025-08-14T20:43:46.7092532Z experiments = {} 2025-08-14T20:43:46.7092796Z 2025-08-14T20:43:46.7093149Z for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-08-14T20:43:46.7093954Z if not is_valid_experiment_name(exp_name): 2025-08-14T20:43:46.7094971Z # Exclude invalid experiments from the list. We log an error, but don't raise an exception so that other experiments can still be processed. 2025-08-14T20:43:46.7096042Z continue 2025-08-14T20:43:46.7096305Z 2025-08-14T20:43:46.7096467Z valid_settings = {} 2025-08-14T20:43:46.7096941Z for setting in exp_settings: 2025-08-14T20:43:46.7097453Z if setting not in Experiment._fields: 2025-08-14T20:43:46.7097957Z log.warning( 2025-08-14T20:43:46.7098599Z f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-08-14T20:43:46.7099255Z ) 2025-08-14T20:43:46.7099635Z else: 2025-08-14T20:43:46.7100101Z valid_settings[setting] = exp_settings[setting] 2025-08-14T20:43:46.7100484Z 2025-08-14T20:43:46.7100745Z experiments[exp_name] = Experiment(**valid_settings) 2025-08-14T20:43:46.7101312Z return Settings(experiments) 2025-08-14T20:43:46.7101644Z 2025-08-14T20:43:46.7101808Z except Exception: 2025-08-14T20:43:46.7102234Z log.exception("Failed to parse settings") 2025-08-14T20:43:46.7102589Z 2025-08-14T20:43:46.7102741Z return Settings() 2025-08-14T20:43:46.7102968Z 2025-08-14T20:43:46.7102974Z 2025-08-14T20:43:46.7103201Z def parse_settings(rollout_state: str) -> Settings: 2025-08-14T20:43:46.7103830Z """ 2025-08-14T20:43:46.7104236Z Parse settings, if any, from the rollout state. 2025-08-14T20:43:46.7104599Z 2025-08-14T20:43:46.7104915Z If the issue body contains "---" then the text above that is the settings 2025-08-14T20:43:46.7105612Z and the text below is the list of opted in users. 2025-08-14T20:43:46.7105977Z 2025-08-14T20:43:46.7106346Z If it doesn't contain "---" then the settings are empty and the default values are used. 2025-08-14T20:43:46.7107008Z """ 2025-08-14T20:43:46.7107504Z settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-08-14T20:43:46.7108196Z return parse_settings_from_text(settings_text) 2025-08-14T20:43:46.7108553Z 2025-08-14T20:43:46.7108559Z 2025-08-14T20:43:46.7108787Z def parse_users(rollout_state: str) -> UserOptins: 2025-08-14T20:43:46.7109289Z """ 2025-08-14T20:43:46.7109644Z Parse users from the rollout state. 2025-08-14T20:43:46.7109961Z 2025-08-14T20:43:46.7110104Z """ 2025-08-14T20:43:46.7110581Z _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-08-14T20:43:46.7111245Z return parse_user_opt_in_from_text(users_text) 2025-08-14T20:43:46.7111614Z 2025-08-14T20:43:46.7111620Z 2025-08-14T20:43:46.7112113Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-08-14T20:43:46.7112795Z """ 2025-08-14T20:43:46.7113166Z Check if a user is opted into an experiment 2025-08-14T20:43:46.7113794Z """ 2025-08-14T20:43:46.7114198Z return experiment_name in user_optins.get(user, []) 2025-08-14T20:43:46.7114580Z 2025-08-14T20:43:46.7114592Z 2025-08-14T20:43:46.7114973Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-08-14T20:43:46.7115650Z """ 2025-08-14T20:43:46.7116068Z Check if a user explicitly opted out of an experiment 2025-08-14T20:43:46.7116592Z """ 2025-08-14T20:43:46.7117042Z # if the experiment is prefixed with a "-", then it's an opt-out 2025-08-14T20:43:46.7117668Z experiment_optout = "-" + experiment_name 2025-08-14T20:43:46.7118244Z if experiment_optout not in user_optins.get(user, []): 2025-08-14T20:43:46.7118782Z return False 2025-08-14T20:43:46.7119004Z 2025-08-14T20:43:46.7119256Z if is_user_opted_in(user, user_optins, experiment_name): 2025-08-14T20:43:46.7119793Z log.warning( 2025-08-14T20:43:46.7120512Z f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-08-14T20:43:46.7121294Z ) 2025-08-14T20:43:46.7121477Z 2025-08-14T20:43:46.7121632Z return True 2025-08-14T20:43:46.7121987Z 2025-08-14T20:43:46.7121994Z 2025-08-14T20:43:46.7122152Z def get_runner_prefix( 2025-08-14T20:43:46.7122547Z rollout_state: str, 2025-08-14T20:43:46.7122953Z workflow_requestors: Iterable[str], 2025-08-14T20:43:46.7123578Z branch: str, 2025-08-14T20:43:46.7124027Z eligible_experiments: frozenset[str] = frozenset(), 2025-08-14T20:43:46.7124622Z opt_out_experiments: frozenset[str] = frozenset(), 2025-08-14T20:43:46.7125151Z is_canary: bool = False, 2025-08-14T20:43:46.7125552Z ) -> str: 2025-08-14T20:43:46.7125935Z settings = parse_settings(rollout_state) 2025-08-14T20:43:46.7126469Z user_optins = parse_users(rollout_state) 2025-08-14T20:43:46.7126806Z 2025-08-14T20:43:46.7126961Z fleet_prefix = "" 2025-08-14T20:43:46.7127339Z prefixes = [] 2025-08-14T20:43:46.7127909Z for experiment_name, experiment_settings in settings.experiments.items(): 2025-08-14T20:43:46.7128757Z if not experiment_settings.all_branches and is_exception_branch(branch): 2025-08-14T20:43:46.7129430Z log.info( 2025-08-14T20:43:46.7130039Z f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-08-14T20:43:46.7130719Z ) 2025-08-14T20:43:46.7131061Z continue 2025-08-14T20:43:46.7131286Z 2025-08-14T20:43:46.7131456Z if opt_out_experiments: 2025-08-14T20:43:46.7131941Z if experiment_name in opt_out_experiments: 2025-08-14T20:43:46.7132523Z opt_out_exp_list = ", ".join(opt_out_experiments) 2025-08-14T20:43:46.7133056Z log.info( 2025-08-14T20:43:46.7134311Z f"Skipping experiment '{experiment_name}', as this workflow has opted-out (opted out experiments are: {opt_out_exp_list})" 2025-08-14T20:43:46.7135195Z ) 2025-08-14T20:43:46.7135558Z continue 2025-08-14T20:43:46.7135798Z 2025-08-14T20:43:46.7135971Z if eligible_experiments: 2025-08-14T20:43:46.7136469Z if experiment_name not in eligible_experiments: 2025-08-14T20:43:46.7137041Z exp_list = ", ".join(eligible_experiments) 2025-08-14T20:43:46.7137539Z log.info( 2025-08-14T20:43:46.7138242Z f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-08-14T20:43:46.7138996Z ) 2025-08-14T20:43:46.7139356Z continue 2025-08-14T20:43:46.7139777Z elif not experiment_settings.default: 2025-08-14T20:43:46.7140264Z log.info( 2025-08-14T20:43:46.7140985Z f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-08-14T20:43:46.7141695Z ) 2025-08-14T20:43:46.7142031Z continue 2025-08-14T20:43:46.7142248Z 2025-08-14T20:43:46.7142496Z # Is any workflow_requestor opted out to this experiment? 2025-08-14T20:43:46.7143051Z opted_out_users = [ 2025-08-14T20:43:46.7143572Z requestor 2025-08-14T20:43:46.7143998Z for requestor in workflow_requestors 2025-08-14T20:43:46.7144608Z if is_user_opted_out(requestor, user_optins, experiment_name) 2025-08-14T20:43:46.7145165Z ] 2025-08-14T20:43:46.7145351Z 2025-08-14T20:43:46.7145514Z if opted_out_users: 2025-08-14T20:43:46.7145916Z log.info( 2025-08-14T20:43:46.7146465Z f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-08-14T20:43:46.7147090Z ) 2025-08-14T20:43:46.7147421Z continue 2025-08-14T20:43:46.7147636Z 2025-08-14T20:43:46.7147883Z # Is any workflow_requestor opted in to this experiment? 2025-08-14T20:43:46.7148429Z opted_in_users = [ 2025-08-14T20:43:46.7148825Z requestor 2025-08-14T20:43:46.7149229Z for requestor in workflow_requestors 2025-08-14T20:43:46.7149818Z if is_user_opted_in(requestor, user_optins, experiment_name) 2025-08-14T20:43:46.7150370Z ] 2025-08-14T20:43:46.7150683Z 2025-08-14T20:43:46.7150833Z enabled = False 2025-08-14T20:43:46.7151214Z if opted_in_users: 2025-08-14T20:43:46.7151599Z log.info( 2025-08-14T20:43:46.7152138Z f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-08-14T20:43:46.7152749Z ) 2025-08-14T20:43:46.7153090Z enabled = True 2025-08-14T20:43:46.7153444Z 2025-08-14T20:43:46.7153653Z elif experiment_settings.rollout_perc: 2025-08-14T20:43:46.7154414Z # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-08-14T20:43:46.7155251Z if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-08-14T20:43:46.7155825Z log.info( 2025-08-14T20:43:46.7156604Z f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-08-14T20:43:46.7157433Z ) 2025-08-14T20:43:46.7157794Z enabled = True 2025-08-14T20:43:46.7158059Z 2025-08-14T20:43:46.7158215Z if enabled: 2025-08-14T20:43:46.7158590Z label = experiment_name 2025-08-14T20:43:46.7159081Z if experiment_name == LF_FLEET_EXPERIMENT: 2025-08-14T20:43:46.7159820Z # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-08-14T20:43:46.7160616Z # - If it's enabled, then we always list it's prefix first 2025-08-14T20:43:46.7161304Z # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-08-14T20:43:46.7161900Z if is_canary: 2025-08-14T20:43:46.7162339Z label += CANARY_FLEET_SUFFIX 2025-08-14T20:43:46.7162831Z fleet_prefix = label 2025-08-14T20:43:46.7163272Z else: 2025-08-14T20:43:46.7163751Z prefixes.append(label) 2025-08-14T20:43:46.7164072Z 2025-08-14T20:43:46.7164235Z if len(prefixes) > 1: 2025-08-14T20:43:46.7164633Z log.error( 2025-08-14T20:43:46.7165562Z f"Only a fleet and one other experiment can be enabled for a job at any time. Enabling {prefixes[0]} and ignoring the rest, which are {', '.join(prefixes[1:])}" 2025-08-14T20:43:46.7166566Z ) 2025-08-14T20:43:46.7166904Z prefixes = prefixes[:1] 2025-08-14T20:43:46.7167178Z 2025-08-14T20:43:46.7167352Z # Fleet always comes first 2025-08-14T20:43:46.7167765Z if fleet_prefix: 2025-08-14T20:43:46.7168169Z prefixes.insert(0, fleet_prefix) 2025-08-14T20:43:46.7168487Z 2025-08-14T20:43:46.7168843Z return ".".join(prefixes) + "." if prefixes else "" 2025-08-14T20:43:46.7169225Z 2025-08-14T20:43:46.7169232Z 2025-08-14T20:43:46.7169630Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-08-14T20:43:46.7170322Z """ 2025-08-14T20:43:46.7170843Z Gets the first comment of the issue, which contains the desired rollout state. 2025-08-14T20:43:46.7171354Z 2025-08-14T20:43:46.7171702Z The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-08-14T20:43:46.7172328Z """ 2025-08-14T20:43:46.7172678Z gh = get_gh_client(github_token) 2025-08-14T20:43:46.7173153Z issue = get_issue(gh, repo, issue_num) 2025-08-14T20:43:46.7173838Z return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-08-14T20:43:46.7174233Z 2025-08-14T20:43:46.7174239Z 2025-08-14T20:43:46.7174610Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-08-14T20:43:46.7175282Z for _ in range(num_retries): 2025-08-14T20:43:46.7175711Z try: 2025-08-14T20:43:46.7176088Z req = Request(url=url, headers=headers) 2025-08-14T20:43:46.7176686Z content = urlopen(req, timeout=5).read().decode("utf-8") 2025-08-14T20:43:46.7177249Z return json.loads(content) 2025-08-14T20:43:46.7177719Z except Exception as e: 2025-08-14T20:43:46.7178205Z log.warning(f"Could not download {url}: {e}") 2025-08-14T20:43:46.7178692Z 2025-08-14T20:43:46.7179034Z log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-08-14T20:43:46.7179672Z return {} 2025-08-14T20:43:46.7179866Z 2025-08-14T20:43:46.7179873Z 2025-08-14T20:43:46.7180013Z @cache 2025-08-14T20:43:46.7180564Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-08-14T20:43:46.7181228Z """ 2025-08-14T20:43:46.7181581Z Dynamically get PR information 2025-08-14T20:43:46.7182022Z """ 2025-08-14T20:43:46.7182459Z github_api = f"https://api.github.com/repos/{github_repo}" 2025-08-14T20:43:46.7183019Z headers = { 2025-08-14T20:43:46.7183522Z "Accept": "application/vnd.github.v3+json", 2025-08-14T20:43:46.7184073Z "Authorization": f"token {github_token}", 2025-08-14T20:43:46.7184546Z } 2025-08-14T20:43:46.7184924Z json_response: dict[str, Any] = download_json( 2025-08-14T20:43:46.7185466Z url=f"{github_api}/issues/{pr_number}", 2025-08-14T20:43:46.7185955Z headers=headers, 2025-08-14T20:43:46.7186331Z ) 2025-08-14T20:43:46.7186507Z 2025-08-14T20:43:46.7186667Z if not json_response: 2025-08-14T20:43:46.7187173Z log.warning(f"Failed to get the labels for #{pr_number}") 2025-08-14T20:43:46.7187713Z return {} 2025-08-14T20:43:46.7187921Z 2025-08-14T20:43:46.7188083Z return json_response 2025-08-14T20:43:46.7188326Z 2025-08-14T20:43:46.7188332Z 2025-08-14T20:43:46.7188694Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-08-14T20:43:46.7189347Z """ 2025-08-14T20:43:46.7189810Z Dynamically get the latest list of labels from the pull request 2025-08-14T20:43:46.7190396Z """ 2025-08-14T20:43:46.7190819Z pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-08-14T20:43:46.7191356Z return { 2025-08-14T20:43:46.7191883Z label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-08-14T20:43:46.7192517Z } 2025-08-14T20:43:46.7192701Z 2025-08-14T20:43:46.7192708Z 2025-08-14T20:43:46.7192863Z def main() -> None: 2025-08-14T20:43:46.7193233Z args = parse_args() 2025-08-14T20:43:46.7193586Z 2025-08-14T20:43:46.7193787Z runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-08-14T20:43:46.7194142Z 2025-08-14T20:43:46.7194316Z # Check if the PR is opt-out 2025-08-14T20:43:46.7194743Z if args.pr_number: 2025-08-14T20:43:46.7195332Z labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-08-14T20:43:46.7196122Z if OPT_OUT_LABEL in labels: 2025-08-14T20:43:46.7196575Z log.info( 2025-08-14T20:43:46.7197190Z f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-08-14T20:43:46.7197875Z ) 2025-08-14T20:43:46.7198360Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-08-14T20:43:46.7198960Z sys.exit() 2025-08-14T20:43:46.7199194Z 2025-08-14T20:43:46.7199341Z try: 2025-08-14T20:43:46.7199721Z rollout_state = get_rollout_state_from_issue( 2025-08-14T20:43:46.7200359Z args.github_token, args.github_issue_repo, args.github_issue 2025-08-14T20:43:46.7200929Z ) 2025-08-14T20:43:46.7201112Z 2025-08-14T20:43:46.7201294Z username = get_potential_pr_author( 2025-08-14T20:43:46.7201777Z args.github_token, 2025-08-14T20:43:46.7202207Z args.github_repo, 2025-08-14T20:43:46.7202629Z args.github_actor, 2025-08-14T20:43:46.7203059Z args.github_ref_type, 2025-08-14T20:43:46.7203611Z args.github_branch, 2025-08-14T20:43:46.7204013Z ) 2025-08-14T20:43:46.7204196Z 2025-08-14T20:43:46.7204456Z is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-08-14T20:43:46.7204864Z 2025-08-14T20:43:46.7205056Z runner_label_prefix = get_runner_prefix( 2025-08-14T20:43:46.7205554Z rollout_state, 2025-08-14T20:43:46.7206120Z (args.github_issue_owner, username), 2025-08-14T20:43:46.7206613Z args.github_branch, 2025-08-14T20:43:46.7207053Z args.eligible_experiments, 2025-08-14T20:43:46.7207529Z args.opt_out_experiments, 2025-08-14T20:43:46.7207979Z is_canary, 2025-08-14T20:43:46.7208340Z ) 2025-08-14T20:43:46.7208521Z 2025-08-14T20:43:46.7208693Z except Exception as e: 2025-08-14T20:43:46.7209084Z log.error( 2025-08-14T20:43:46.7209679Z f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-08-14T20:43:46.7210358Z ) 2025-08-14T20:43:46.7210545Z 2025-08-14T20:43:46.7210839Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-08-14T20:43:46.7211285Z 2025-08-14T20:43:46.7211292Z 2025-08-14T20:43:46.7211456Z if __name__ == "__main__": 2025-08-14T20:43:46.7211843Z main() 2025-08-14T20:43:46.7212025Z 2025-08-14T20:43:46.7296732Z ##[group]Run python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-08-14T20:43:46.7297536Z python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-08-14T20:43:46.7335779Z shell: /usr/bin/bash -e {0} 2025-08-14T20:43:46.7336199Z env: 2025-08-14T20:43:46.7336736Z GITHUB_TOKEN: *** 2025-08-14T20:43:46.7337105Z ISSUE_NUMBER: 5132 2025-08-14T20:43:46.7337497Z TRIGGERING_ACTOR: pytorchmergebot 2025-08-14T20:43:46.7337963Z ISSUE_OWNER: 2025-08-14T20:43:46.7338315Z CHECK_EXPERIMENTS: 2025-08-14T20:43:46.7338702Z OPT_OUT_EXPERIMENTS: 2025-08-14T20:43:46.7339076Z PR_NUMBER: 2025-08-14T20:43:46.7339409Z ##[endgroup] 2025-08-14T20:43:47.9198443Z Defaulting to user installation because normal site-packages is not writeable 2025-08-14T20:43:48.7440459Z Collecting urllib3==1.26.18 2025-08-14T20:43:48.7773006Z Downloading urllib3-1.26.18-py2.py3-none-any.whl.metadata (48 kB) 2025-08-14T20:43:48.8006585Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 kB 4.3 MB/s eta 0:00:00 2025-08-14T20:43:48.8220409Z Collecting PyGithub==2.3.0 2025-08-14T20:43:48.8255515Z Downloading PyGithub-2.3.0-py3-none-any.whl.metadata (3.8 kB) 2025-08-14T20:43:48.8666027Z Collecting pynacl>=1.4.0 (from PyGithub==2.3.0) 2025-08-14T20:43:48.8707760Z Downloading PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl.metadata (8.6 kB) 2025-08-14T20:43:48.8750416Z Requirement already satisfied: requests>=2.14.0 in /usr/lib/python3/dist-packages (from PyGithub==2.3.0) (2.31.0) 2025-08-14T20:43:48.8766678Z Requirement already satisfied: pyjwt>=2.4.0 in /usr/lib/python3/dist-packages (from pyjwt[crypto]>=2.4.0->PyGithub==2.3.0) (2.7.0) 2025-08-14T20:43:48.8780961Z Requirement already satisfied: typing-extensions>=4.0.0 in /usr/lib/python3/dist-packages (from PyGithub==2.3.0) (4.10.0) 2025-08-14T20:43:48.9036237Z Collecting Deprecated (from PyGithub==2.3.0) 2025-08-14T20:43:48.9073544Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl.metadata (5.7 kB) 2025-08-14T20:43:48.9348214Z Requirement already satisfied: cryptography>=3.4.0 in /usr/lib/python3/dist-packages (from pyjwt[crypto]>=2.4.0->PyGithub==2.3.0) (41.0.7) 2025-08-14T20:43:49.0499822Z Collecting cffi>=1.4.1 (from pynacl>=1.4.0->PyGithub==2.3.0) 2025-08-14T20:43:49.0533732Z Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.5 kB) 2025-08-14T20:43:49.1656787Z Collecting wrapt<2,>=1.10 (from Deprecated->PyGithub==2.3.0) 2025-08-14T20:43:49.1690103Z Downloading wrapt-1.17.3-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.metadata (6.4 kB) 2025-08-14T20:43:49.1869742Z Collecting pycparser (from cffi>=1.4.1->pynacl>=1.4.0->PyGithub==2.3.0) 2025-08-14T20:43:49.1901089Z Downloading pycparser-2.22-py3-none-any.whl.metadata (943 bytes) 2025-08-14T20:43:49.2126445Z Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB) 2025-08-14T20:43:49.2209471Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.8/143.8 kB 20.9 MB/s eta 0:00:00 2025-08-14T20:43:49.2245058Z Downloading PyGithub-2.3.0-py3-none-any.whl (354 kB) 2025-08-14T20:43:49.2345602Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 354.4/354.4 kB 41.1 MB/s eta 0:00:00 2025-08-14T20:43:49.2377988Z Downloading PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (856 kB) 2025-08-14T20:43:49.2551306Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 856.7/856.7 kB 54.1 MB/s eta 0:00:00 2025-08-14T20:43:49.2584090Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl (10.0 kB) 2025-08-14T20:43:49.2635957Z Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479 kB) 2025-08-14T20:43:49.2724471Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 479.4/479.4 kB 64.7 MB/s eta 0:00:00 2025-08-14T20:43:49.2760364Z Downloading wrapt-1.17.3-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (88 kB) 2025-08-14T20:43:49.2805995Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 88.0/88.0 kB 25.6 MB/s eta 0:00:00 2025-08-14T20:43:49.2835344Z Downloading pycparser-2.22-py3-none-any.whl (117 kB) 2025-08-14T20:43:49.2876974Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.6/117.6 kB 41.7 MB/s eta 0:00:00 2025-08-14T20:43:49.6117940Z Installing collected packages: wrapt, urllib3, pycparser, Deprecated, cffi, pynacl, PyGithub 2025-08-14T20:43:50.1409084Z Successfully installed Deprecated-1.2.18 PyGithub-2.3.0 cffi-1.17.1 pycparser-2.22 pynacl-1.5.0 urllib3-1.26.18 wrapt-1.17.3 2025-08-14T20:43:50.2164263Z ##[group]Run curr_branch="main" 2025-08-14T20:43:50.2164646Z curr_branch="main" 2025-08-14T20:43:50.2164879Z curr_ref_type="branch" 2025-08-14T20:43:50.2165146Z echo "Current branch is '$curr_branch'" 2025-08-14T20:43:50.2165392Z  2025-08-14T20:43:50.2165583Z python3 runner_determinator.py \ 2025-08-14T20:43:50.2165861Z  --github-token "$GITHUB_TOKEN" \ 2025-08-14T20:43:50.2166131Z  --github-issue "$ISSUE_NUMBER" \ 2025-08-14T20:43:50.2166390Z  --github-branch "$curr_branch" \ 2025-08-14T20:43:50.2166697Z  --github-actor "$TRIGGERING_ACTOR" \ 2025-08-14T20:43:50.2166984Z  --github-issue-owner "$ISSUE_OWNER" \ 2025-08-14T20:43:50.2167259Z  --github-ref-type "$curr_ref_type" \ 2025-08-14T20:43:50.2167531Z  --github-repo "$GITHUB_REPOSITORY" \ 2025-08-14T20:43:50.2167830Z  --eligible-experiments "$CHECK_EXPERIMENTS" \ 2025-08-14T20:43:50.2168199Z  --opt-out-experiments "$OPT_OUT_EXPERIMENTS" \ 2025-08-14T20:43:50.2168490Z  --pr-number "${PR_NUMBER}" 2025-08-14T20:43:50.2210068Z shell: /usr/bin/bash -e {0} 2025-08-14T20:43:50.2210301Z env: 2025-08-14T20:43:50.2210884Z GITHUB_TOKEN: *** 2025-08-14T20:43:50.2211079Z ISSUE_NUMBER: 5132 2025-08-14T20:43:50.2211293Z TRIGGERING_ACTOR: pytorchmergebot 2025-08-14T20:43:50.2211530Z ISSUE_OWNER: 2025-08-14T20:43:50.2211713Z CHECK_EXPERIMENTS: 2025-08-14T20:43:50.2211899Z OPT_OUT_EXPERIMENTS: 2025-08-14T20:43:50.2212092Z PR_NUMBER: 2025-08-14T20:43:50.2212267Z ##[endgroup] 2025-08-14T20:43:50.2268814Z Current branch is 'main' 2025-08-14T20:43:51.7057678Z INFO : Branch main is an exception branch. Not enabling experiment ephemeral. 2025-08-14T20:43:51.7059095Z INFO : Branch main is an exception branch. Not enabling experiment wincanary. 2025-08-14T20:43:51.7059742Z INFO : Setting output: label-type='' 2025-08-14T20:43:51.7388124Z Evaluate and set job outputs 2025-08-14T20:43:51.7395464Z Cleaning up orphan processes