2025-08-26T19:31:43.6674635Z Current runner version: '2.328.0' 2025-08-26T19:31:43.6697126Z ##[group]Runner Image Provisioner 2025-08-26T19:31:43.6697935Z Hosted Compute Agent 2025-08-26T19:31:43.6698432Z Version: 20250825.382 2025-08-26T19:31:43.6699150Z Commit: 7109f2abf901479dac39397456e363ac0cca0730 2025-08-26T19:31:43.6699835Z Build Date: 2025-08-25T22:55:50Z 2025-08-26T19:31:43.6700414Z ##[endgroup] 2025-08-26T19:31:43.6700979Z ##[group]Operating System 2025-08-26T19:31:43.6701539Z Ubuntu 2025-08-26T19:31:43.6701984Z 24.04.2 2025-08-26T19:31:43.6702498Z LTS 2025-08-26T19:31:43.6702952Z ##[endgroup] 2025-08-26T19:31:43.6703440Z ##[group]Runner Image 2025-08-26T19:31:43.6704025Z Image: ubuntu-24.04 2025-08-26T19:31:43.6704502Z Version: 20250818.1.0 2025-08-26T19:31:43.6705496Z Included Software: https://github.com/actions/runner-images/blob/ubuntu24/20250818.1/images/ubuntu/Ubuntu2404-Readme.md 2025-08-26T19:31:43.6707248Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu24%2F20250818.1 2025-08-26T19:31:43.6708244Z ##[endgroup] 2025-08-26T19:31:43.6709339Z ##[group]GITHUB_TOKEN Permissions 2025-08-26T19:31:43.6711444Z Contents: read 2025-08-26T19:31:43.6712059Z Metadata: read 2025-08-26T19:31:43.6712552Z Packages: read 2025-08-26T19:31:43.6713043Z ##[endgroup] 2025-08-26T19:31:43.6714962Z Secret source: Actions 2025-08-26T19:31:43.6715929Z Prepare workflow directory 2025-08-26T19:31:43.7263101Z Prepare all required actions 2025-08-26T19:31:43.7319359Z Uses: pytorch/pytorch/.github/workflows/_runner-determinator.yml@refs/heads/main (262640fd220236042fbf4443cc163c8838c84c3d) 2025-08-26T19:31:43.7323955Z ##[group] Inputs 2025-08-26T19:31:43.7324674Z check_experiments: 2025-08-26T19:31:43.7325227Z opt_out_experiments: 2025-08-26T19:31:43.7326112Z triggering_actor: pytorchmergebot 2025-08-26T19:31:43.7326679Z issue_owner: 2025-08-26T19:31:43.7327308Z curr_branch: main 2025-08-26T19:31:43.7327980Z curr_ref_type: branch 2025-08-26T19:31:43.7328478Z issue_number: 5132 2025-08-26T19:31:43.7329111Z ##[endgroup] 2025-08-26T19:31:43.7329685Z Complete job name: get-label-type / runner-determinator 2025-08-26T19:31:43.7910718Z ##[group]Run cat < runner_determinator.py 2025-08-26T19:31:43.7913057Z cat < runner_determinator.py 2025-08-26T19:31:43.7913769Z # flake8: noqa: G004 2025-08-26T19:31:43.7914419Z  2025-08-26T19:31:43.7915143Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-08-26T19:31:43.7916517Z # must be kept in sync. You can do it easily by running the following command: 2025-08-26T19:31:43.7917425Z # python .github/scripts/update_runner_determinator.py 2025-08-26T19:31:43.7918111Z  2025-08-26T19:31:43.7918547Z """ 2025-08-26T19:31:43.7919257Z This runner determinator is used to determine which set of runners to run a 2025-08-26T19:31:43.7920235Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-08-26T19:31:43.7921422Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-08-26T19:31:43.7922355Z of which runners should be used to run which job. 2025-08-26T19:31:43.7922992Z  2025-08-26T19:31:43.7923729Z The configuration has two parts, the settings and a list of opted-in users, 2025-08-26T19:31:43.7924702Z separated by a line containing "---". If the line is not present, the 2025-08-26T19:31:43.7925917Z settings are considered to be empty with only the second part, the user 2025-08-26T19:31:43.7926853Z list, defined. 2025-08-26T19:31:43.7927355Z  2025-08-26T19:31:43.7927996Z The first part is a YAML block that defines the rollout settings. This can be 2025-08-26T19:31:43.7929052Z used to define any settings that are needed to determine which runners to use. 2025-08-26T19:31:43.7930003Z It's fields are defined by the RolloutSettings class below. 2025-08-26T19:31:43.7930910Z  2025-08-26T19:31:43.7931664Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-08-26T19:31:43.7932640Z The user list is also a comma separated list of additional features or 2025-08-26T19:31:43.7933461Z experiments which the user could be opted in to. 2025-08-26T19:31:43.7934152Z  2025-08-26T19:31:43.7934600Z The user list has the following rules: 2025-08-26T19:31:43.7935199Z  2025-08-26T19:31:43.7936161Z - Users are GitHub usernames, which must start with the @ prefix 2025-08-26T19:31:43.7937102Z - Each user is also a comma-separated list of features/experiments to enable 2025-08-26T19:31:43.7937969Z - A "#" prefix opts the user out of all experiments 2025-08-26T19:31:43.7938604Z  2025-08-26T19:31:43.7939068Z Example config: 2025-08-26T19:31:43.7939627Z  # A list of experiments that can be opted into. 2025-08-26T19:31:43.7940481Z  # This defines the behavior they'll induce when opted into. 2025-08-26T19:31:43.7941227Z  # Expected syntax is: 2025-08-26T19:31:43.7941961Z  # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-08-26T19:31:43.7943427Z  # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-08-26T19:31:43.7944886Z  2025-08-26T19:31:43.7945886Z  experiments: 2025-08-26T19:31:43.7947043Z  lf: 2025-08-26T19:31:43.7947869Z  rollout_percent: 25 2025-08-26T19:31:43.7948950Z  all_branches: false 2025-08-26T19:31:43.7949885Z  default: true 2025-08-26T19:31:43.7951042Z  --- 2025-08-26T19:31:43.7951854Z  2025-08-26T19:31:43.7952701Z  # Opt-ins: 2025-08-26T19:31:43.7954131Z  # Users can opt into the LF fleet by adding their GitHub username to this list 2025-08-26T19:31:43.7956503Z  # and specifying experiments to enable in a comma-separated list. 2025-08-26T19:31:43.7958006Z  # To always opt out of an experiment, prefix it with a "-". 2025-08-26T19:31:43.7959393Z  # Experiments should be from the above list. 2025-08-26T19:31:43.7960509Z  2025-08-26T19:31:43.7961270Z  @User1,-lf,split_build 2025-08-26T19:31:43.7962415Z  @User2,lf 2025-08-26T19:31:43.7963183Z  @User3,split_build 2025-08-26T19:31:43.7963706Z """ 2025-08-26T19:31:43.7964231Z  2025-08-26T19:31:43.7964654Z import json 2025-08-26T19:31:43.7965192Z import logging 2025-08-26T19:31:43.7966072Z import os 2025-08-26T19:31:43.7966568Z import random 2025-08-26T19:31:43.7967076Z import re 2025-08-26T19:31:43.7967572Z import sys 2025-08-26T19:31:43.7968161Z from argparse import ArgumentParser 2025-08-26T19:31:43.7968803Z from collections.abc import Iterable 2025-08-26T19:31:43.7969477Z from functools import cache 2025-08-26T19:31:43.7970092Z from logging import LogRecord 2025-08-26T19:31:43.7970674Z from typing import Any, NamedTuple 2025-08-26T19:31:43.7971378Z from urllib.request import Request, urlopen 2025-08-26T19:31:43.7971984Z  2025-08-26T19:31:43.7972462Z import yaml 2025-08-26T19:31:43.7972932Z from github import Auth, Github 2025-08-26T19:31:43.7973604Z from github.Issue import Issue 2025-08-26T19:31:43.7974168Z  2025-08-26T19:31:43.7974551Z  2025-08-26T19:31:43.7975175Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-08-26T19:31:43.7976185Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-08-26T19:31:43.7977149Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-08-26T19:31:43.7978212Z  2025-08-26T19:31:43.7978794Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-08-26T19:31:43.7979480Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-08-26T19:31:43.7980197Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-08-26T19:31:43.7980879Z OPT_OUT_LABEL = "no-runner-experiments" 2025-08-26T19:31:43.7981463Z  2025-08-26T19:31:43.7982003Z SETTING_EXPERIMENTS = "experiments" 2025-08-26T19:31:43.7982560Z  2025-08-26T19:31:43.7983021Z LF_FLEET_EXPERIMENT = "lf" 2025-08-26T19:31:43.7983801Z CANARY_FLEET_SUFFIX = ".c" 2025-08-26T19:31:43.7984315Z  2025-08-26T19:31:43.7984748Z  2025-08-26T19:31:43.7985222Z class Experiment(NamedTuple): 2025-08-26T19:31:43.7986069Z  rollout_perc: float = ( 2025-08-26T19:31:43.7986831Z  0 # Percentage of workflows to experiment on when user is not opted-in. 2025-08-26T19:31:43.7987684Z  ) 2025-08-26T19:31:43.7988192Z  all_branches: bool = ( 2025-08-26T19:31:43.7988927Z  False # If True, the experiment is also enabled on the exception branches 2025-08-26T19:31:43.7989721Z  ) 2025-08-26T19:31:43.7990172Z  default: bool = ( 2025-08-26T19:31:43.7991199Z  True # If True, the experiment is enabled by default for all queries 2025-08-26T19:31:43.7991874Z  ) 2025-08-26T19:31:43.7992428Z  2025-08-26T19:31:43.7992918Z  # Add more fields as needed 2025-08-26T19:31:43.7993438Z  2025-08-26T19:31:43.7993928Z  2025-08-26T19:31:43.7994361Z class Settings(NamedTuple): 2025-08-26T19:31:43.7994941Z  """ 2025-08-26T19:31:43.7995575Z  Settings for the experiments that can be opted into. 2025-08-26T19:31:43.7996537Z  """ 2025-08-26T19:31:43.7996983Z  2025-08-26T19:31:43.7997554Z  experiments: dict[str, Experiment] = {} 2025-08-26T19:31:43.7998173Z  2025-08-26T19:31:43.7998743Z  2025-08-26T19:31:43.7999341Z class ColorFormatter(logging.Formatter): 2025-08-26T19:31:43.8000056Z  """Color codes the log messages based on the log level""" 2025-08-26T19:31:43.8000761Z  2025-08-26T19:31:43.8001213Z  COLORS = { 2025-08-26T19:31:43.8001768Z  "WARNING": "\033[33m", # Yellow 2025-08-26T19:31:43.8002423Z  "ERROR": "\033[31m", # Red 2025-08-26T19:31:43.8003028Z  "CRITICAL": "\033[31m", # Red 2025-08-26T19:31:43.8003648Z  "INFO": "\033[0m", # Reset 2025-08-26T19:31:43.8004213Z  "DEBUG": "\033[0m", # Reset 2025-08-26T19:31:43.8004812Z  } 2025-08-26T19:31:43.8005248Z  2025-08-26T19:31:43.8006052Z  def format(self, record: LogRecord) -> str: 2025-08-26T19:31:43.8006978Z  log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-08-26T19:31:43.8007848Z  record.msg = f"{log_color}{record.msg}\033[0m" 2025-08-26T19:31:43.8008535Z  return super().format(record) 2025-08-26T19:31:43.8009070Z  2025-08-26T19:31:43.8009568Z  2025-08-26T19:31:43.8010043Z handler = logging.StreamHandler() 2025-08-26T19:31:43.8010868Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-08-26T19:31:43.8011730Z  2025-08-26T19:31:43.8012247Z log = logging.getLogger(os.path.basename(__file__)) 2025-08-26T19:31:43.8012919Z log.addHandler(handler) 2025-08-26T19:31:43.8013522Z log.setLevel(logging.INFO) 2025-08-26T19:31:43.8014105Z  2025-08-26T19:31:43.8014795Z  2025-08-26T19:31:43.8016085Z def set_github_output(key: str, value: str) -> None: 2025-08-26T19:31:43.8017134Z  """ 2025-08-26T19:31:43.8018117Z  Defines outputs of the github action that invokes this script 2025-08-26T19:31:43.8019628Z  """ 2025-08-26T19:31:43.8020393Z  if not GITHUB_OUTPUT: 2025-08-26T19:31:43.8022410Z  # See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ for deprecation notice 2025-08-26T19:31:43.8024589Z  log.warning( 2025-08-26T19:31:43.8026389Z  "No env var found for GITHUB_OUTPUT, you must be running this code locally. Falling back to the deprecated print method." 2025-08-26T19:31:43.8028156Z  ) 2025-08-26T19:31:43.8029078Z  print(f"::set-output name={key}::{value}") 2025-08-26T19:31:43.8030219Z  return 2025-08-26T19:31:43.8031005Z  2025-08-26T19:31:43.8031925Z  with open(GITHUB_OUTPUT, "a") as f: 2025-08-26T19:31:43.8033250Z  log.info(f"Setting output: {key}='{value}'") 2025-08-26T19:31:43.8034392Z  f.write(f"{key}={value}\n") 2025-08-26T19:31:43.8035553Z  2025-08-26T19:31:43.8036580Z  2025-08-26T19:31:43.8037707Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-08-26T19:31:43.8038979Z  return frozenset( 2025-08-26T19:31:43.8040414Z  filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-08-26T19:31:43.8041785Z  ) 2025-08-26T19:31:43.8042545Z  2025-08-26T19:31:43.8043510Z  2025-08-26T19:31:43.8044224Z def parse_args() -> Any: 2025-08-26T19:31:43.8045457Z  parser = ArgumentParser("Get dynamic rollout settings") 2025-08-26T19:31:43.8047655Z  parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-08-26T19:31:43.8049165Z  parser.add_argument( 2025-08-26T19:31:43.8050302Z  "--github-issue-repo", 2025-08-26T19:31:43.8051403Z  type=str, 2025-08-26T19:31:43.8052355Z  required=False, 2025-08-26T19:31:43.8053563Z  default="pytorch/test-infra", 2025-08-26T19:31:43.8054951Z  help="GitHub repo to get the issue", 2025-08-26T19:31:43.8056198Z  ) 2025-08-26T19:31:43.8056897Z  parser.add_argument( 2025-08-26T19:31:43.8058102Z  "--github-repo", 2025-08-26T19:31:43.8059048Z  type=str, 2025-08-26T19:31:43.8060052Z  required=True, 2025-08-26T19:31:43.8061233Z  help="GitHub repo where CI is running", 2025-08-26T19:31:43.8062313Z  ) 2025-08-26T19:31:43.8063064Z  parser.add_argument( 2025-08-26T19:31:43.8064542Z  "--github-issue", type=int, required=True, help="GitHub issue number" 2025-08-26T19:31:43.8066105Z  ) 2025-08-26T19:31:43.8066913Z  parser.add_argument( 2025-08-26T19:31:43.8068433Z  "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-08-26T19:31:43.8069750Z  ) 2025-08-26T19:31:43.8070649Z  parser.add_argument( 2025-08-26T19:31:43.8072113Z  "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-08-26T19:31:43.8073548Z  ) 2025-08-26T19:31:43.8074395Z  parser.add_argument( 2025-08-26T19:31:43.8139621Z  "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-08-26T19:31:43.8140890Z  ) 2025-08-26T19:31:43.8141527Z  parser.add_argument( 2025-08-26T19:31:43.8142349Z  "--github-ref-type", 2025-08-26T19:31:43.8143254Z  type=str, 2025-08-26T19:31:43.8143993Z  required=True, 2025-08-26T19:31:43.8144923Z  help="Current GitHub ref type, branch or tag", 2025-08-26T19:31:43.8146108Z  ) 2025-08-26T19:31:43.8146781Z  parser.add_argument( 2025-08-26T19:31:43.8147928Z  "--eligible-experiments", 2025-08-26T19:31:43.8148985Z  type=_str_comma_separated_to_set, 2025-08-26T19:31:43.8150007Z  required=False, 2025-08-26T19:31:43.8150862Z  default="", 2025-08-26T19:31:43.8152436Z  help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-08-26T19:31:43.8154063Z  ) 2025-08-26T19:31:43.8154681Z  parser.add_argument( 2025-08-26T19:31:43.8155535Z  "--opt-out-experiments", 2025-08-26T19:31:43.8156771Z  type=_str_comma_separated_to_set, 2025-08-26T19:31:43.8157670Z  required=False, 2025-08-26T19:31:43.8158428Z  default="", 2025-08-26T19:31:43.8159173Z  help=( 2025-08-26T19:31:43.8160490Z  "comma separated list of experiments to opt-out of. If unset, no opt-outs will occur. " 2025-08-26T19:31:43.8162529Z  "If the same experiment is listed both here and in '--eligible-experiments' opt-out will take priority." 2025-08-26T19:31:43.8163998Z  ), 2025-08-26T19:31:43.8164637Z  ) 2025-08-26T19:31:43.8165269Z  parser.add_argument( 2025-08-26T19:31:43.8166268Z  "--pr-number", 2025-08-26T19:31:43.8167044Z  type=str, 2025-08-26T19:31:43.8167758Z  required=False, 2025-08-26T19:31:43.8168529Z  default="", 2025-08-26T19:31:43.8169420Z  help="the optional PR number where this is run", 2025-08-26T19:31:43.8170374Z  ) 2025-08-26T19:31:43.8170965Z  2025-08-26T19:31:43.8171591Z  return parser.parse_args() 2025-08-26T19:31:43.8172382Z  2025-08-26T19:31:43.8172957Z  2025-08-26T19:31:43.8173990Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-08-26T19:31:43.8175530Z  auth = Auth.Token(github_token) 2025-08-26T19:31:43.8176639Z  return Github(auth=auth) 2025-08-26T19:31:43.8177424Z  2025-08-26T19:31:43.8177982Z  2025-08-26T19:31:43.8179067Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-08-26T19:31:43.8180475Z  repo = gh.get_repo(repo) 2025-08-26T19:31:43.8181381Z  return repo.get_issue(number=issue_num) 2025-08-26T19:31:43.8182253Z  2025-08-26T19:31:43.8182840Z  2025-08-26T19:31:43.8183452Z def get_potential_pr_author( 2025-08-26T19:31:43.8184600Z  github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-08-26T19:31:43.8185954Z ) -> str: 2025-08-26T19:31:43.8186895Z  # If the trigger was a new tag added by a bot, this is a ciflow case 2025-08-26T19:31:43.8188279Z  # Fetch the actual username from the original PR. The PR number is 2025-08-26T19:31:43.8189618Z  # embedded in the tag name: ciflow// 2025-08-26T19:31:43.8190601Z  2025-08-26T19:31:43.8191235Z  gh = get_gh_client(github_token) 2025-08-26T19:31:43.8192187Z  2025-08-26T19:31:43.8192968Z  if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-08-26T19:31:43.8194028Z  split_tag = ref_name.split("/") 2025-08-26T19:31:43.8194900Z  if ( 2025-08-26T19:31:43.8196361Z  len(split_tag) == 3 2025-08-26T19:31:43.8197321Z  and split_tag[0] == "ciflow" 2025-08-26T19:31:43.8198242Z  and split_tag[2].isnumeric() 2025-08-26T19:31:43.8199097Z  ): 2025-08-26T19:31:43.8199785Z  pr_number = split_tag[2] 2025-08-26T19:31:43.8200627Z  try: 2025-08-26T19:31:43.8201423Z  repository = gh.get_repo(repo) 2025-08-26T19:31:43.8202728Z  pull = repository.get_pull(number=int(pr_number)) 2025-08-26T19:31:43.8203777Z  except Exception as e: 2025-08-26T19:31:43.8204699Z  raise Exception( # noqa: TRY002 2025-08-26T19:31:43.8206057Z  f"issue with pull request {pr_number} from repo {repository}" 2025-08-26T19:31:43.8207159Z  ) from e 2025-08-26T19:31:43.8208153Z  return pull.user.login # type: ignore[no-any-return] 2025-08-26T19:31:43.8209366Z  # In all other cases, return the original input username 2025-08-26T19:31:43.8210397Z  return username 2025-08-26T19:31:43.8211124Z  2025-08-26T19:31:43.8211676Z  2025-08-26T19:31:43.8212370Z def is_exception_branch(branch: str) -> bool: 2025-08-26T19:31:43.8213279Z  """ 2025-08-26T19:31:43.8214421Z  Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-08-26T19:31:43.8215967Z  """ 2025-08-26T19:31:43.8216945Z  return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-08-26T19:31:43.8218076Z  2025-08-26T19:31:43.8218625Z  2025-08-26T19:31:43.8219274Z def load_yaml(yaml_text: str) -> Any: 2025-08-26T19:31:43.8220235Z  try: 2025-08-26T19:31:43.8220919Z  data = yaml.safe_load(yaml_text) 2025-08-26T19:31:43.8221771Z  return data 2025-08-26T19:31:43.8222534Z  except yaml.YAMLError: 2025-08-26T19:31:43.8223427Z  log.exception("Error loading YAML") 2025-08-26T19:31:43.8224317Z  raise 2025-08-26T19:31:43.8224955Z  2025-08-26T19:31:43.8225504Z  2025-08-26T19:31:43.8226771Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-08-26T19:31:43.8228120Z  """ 2025-08-26T19:31:43.8229420Z  Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-08-26T19:31:43.8230717Z  2025-08-26T19:31:43.8231629Z  If the issue body contains "---" then the text above that is the settings 2025-08-26T19:31:43.8232959Z  and the text below is the list of opted in users. 2025-08-26T19:31:43.8233905Z  2025-08-26T19:31:43.8234866Z  If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-08-26T19:31:43.8236260Z  """ 2025-08-26T19:31:43.8237057Z  rollout_state_parts = rollout_state.split("---") 2025-08-26T19:31:43.8238070Z  if len(rollout_state_parts) >= 2: 2025-08-26T19:31:43.8239152Z  return rollout_state_parts[0], rollout_state_parts[1] 2025-08-26T19:31:43.8240182Z  else: 2025-08-26T19:31:43.8240852Z  return "", rollout_state 2025-08-26T19:31:43.8241658Z  2025-08-26T19:31:43.8242229Z  2025-08-26T19:31:43.8242923Z class UserOptins(dict[str, list[str]]): 2025-08-26T19:31:43.8243794Z  """ 2025-08-26T19:31:43.8244700Z  Dictionary of users with a list of features they have opted into 2025-08-26T19:31:43.8245993Z  """ 2025-08-26T19:31:43.8246611Z  2025-08-26T19:31:43.8247162Z  2025-08-26T19:31:43.8248044Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-08-26T19:31:43.8249187Z  """ 2025-08-26T19:31:43.8250439Z  Parse the user opt-in text into a key value pair of username and the list of features they have opted into 2025-08-26T19:31:43.8251882Z  2025-08-26T19:31:43.8253343Z  Users are GitHub usernames with the @ prefix. Each user is also a comma-separated list of features/experiments to enable. 2025-08-26T19:31:43.8255056Z  - Example line: "@User1,lf,split_build" 2025-08-26T19:31:43.8256661Z  - A "#" prefix indicates the user is opted out of all experiments 2025-08-26T19:31:43.8257726Z  2025-08-26T19:31:43.8258298Z  2025-08-26T19:31:43.8258841Z  """ 2025-08-26T19:31:43.8259486Z  optins = UserOptins() 2025-08-26T19:31:43.8260358Z  for user in user_optin_text.split("\n"): 2025-08-26T19:31:43.8261331Z  user = user.strip("\r\n\t -") 2025-08-26T19:31:43.8262299Z  if not user or not user.startswith("@"): 2025-08-26T19:31:43.8263239Z  # Not a valid user. Skip 2025-08-26T19:31:43.8264096Z  continue 2025-08-26T19:31:43.8264816Z  2025-08-26T19:31:43.8265390Z  if user: 2025-08-26T19:31:43.8266375Z  usr_name = user.split(",")[0].strip("@") 2025-08-26T19:31:43.8267561Z  optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-08-26T19:31:43.8268677Z  2025-08-26T19:31:43.8269261Z  return optins 2025-08-26T19:31:43.8269943Z  2025-08-26T19:31:43.8270493Z  2025-08-26T19:31:43.8271346Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-08-26T19:31:43.8272383Z  """ 2025-08-26T19:31:43.8273076Z  Check if the experiment name is valid. 2025-08-26T19:31:43.8273974Z  A valid name: 2025-08-26T19:31:43.8275135Z  - Contains only alphanumeric characters and the special characters "_" & "-" 2025-08-26T19:31:43.8276951Z  - The special characters "_" & "-" shouldn't be the first or last characters 2025-08-26T19:31:43.8278182Z  - Cannot contain spaces 2025-08-26T19:31:43.8278982Z  """ 2025-08-26T19:31:43.8279570Z  2025-08-26T19:31:43.8280358Z  valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-08-26T19:31:43.8281583Z  valid = bool(re.match(valid_char_regex, experiment_name)) 2025-08-26T19:31:43.8282784Z  2025-08-26T19:31:43.8283405Z  if valid: 2025-08-26T19:31:43.8284081Z  return True 2025-08-26T19:31:43.8284777Z  2025-08-26T19:31:43.8285340Z  log.error( 2025-08-26T19:31:43.8288052Z  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-26T19:31:43.8290706Z  ) 2025-08-26T19:31:43.8291327Z  return False 2025-08-26T19:31:43.8291991Z  2025-08-26T19:31:43.8292540Z  2025-08-26T19:31:43.8293414Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-08-26T19:31:43.8294486Z  """ 2025-08-26T19:31:43.8295500Z  Parse the experiments from the issue body into a list of ExperimentSettings 2025-08-26T19:31:43.8297058Z  """ 2025-08-26T19:31:43.8297673Z  try: 2025-08-26T19:31:43.8298294Z  if settings_text: 2025-08-26T19:31:43.8299589Z  # Escape the backtick as well so that we can have the settings in a code block on the GH issue 2025-08-26T19:31:43.8300950Z  # for easy reading 2025-08-26T19:31:43.8302339Z  # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-08-26T19:31:43.8303880Z  # the backtick character in shell commands. 2025-08-26T19:31:43.8304911Z  backtick = chr(96) # backtick character 2025-08-26T19:31:43.8306275Z  settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-08-26T19:31:43.8307434Z  settings = load_yaml(settings_text) 2025-08-26T19:31:43.8308290Z  2025-08-26T19:31:43.8309620Z  # For now we just load experiments. We can expand this if/when we add more settings 2025-08-26T19:31:43.8310855Z  experiments = {} 2025-08-26T19:31:43.8311621Z  2025-08-26T19:31:43.8312577Z  for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-08-26T19:31:43.8313874Z  if not is_valid_experiment_name(exp_name): 2025-08-26T19:31:43.8315969Z  # 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-26T19:31:43.8317754Z  continue 2025-08-26T19:31:43.8318525Z  2025-08-26T19:31:43.8319166Z  valid_settings = {} 2025-08-26T19:31:43.8320046Z  for setting in exp_settings: 2025-08-26T19:31:43.8321002Z  if setting not in Experiment._fields: 2025-08-26T19:31:43.8321975Z  log.warning( 2025-08-26T19:31:43.8323214Z  f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-08-26T19:31:43.8324413Z  ) 2025-08-26T19:31:43.8325174Z  else: 2025-08-26T19:31:43.8326336Z  valid_settings[setting] = exp_settings[setting] 2025-08-26T19:31:43.8327397Z  2025-08-26T19:31:43.8328203Z  experiments[exp_name] = Experiment(**valid_settings) 2025-08-26T19:31:43.8329284Z  return Settings(experiments) 2025-08-26T19:31:43.8330128Z  2025-08-26T19:31:43.8330763Z  except Exception: 2025-08-26T19:31:43.8331723Z  log.exception("Failed to parse settings") 2025-08-26T19:31:43.8332653Z  2025-08-26T19:31:43.8333231Z  return Settings() 2025-08-26T19:31:43.8333942Z  2025-08-26T19:31:43.8334498Z  2025-08-26T19:31:43.8335496Z def parse_settings(rollout_state: str) -> Settings: 2025-08-26T19:31:43.8336765Z  """ 2025-08-26T19:31:43.8337563Z  Parse settings, if any, from the rollout state. 2025-08-26T19:31:43.8338483Z  2025-08-26T19:31:43.8339375Z  If the issue body contains "---" then the text above that is the settings 2025-08-26T19:31:43.8340717Z  and the text below is the list of opted in users. 2025-08-26T19:31:43.8341640Z  2025-08-26T19:31:43.8342638Z  If it doesn't contain "---" then the settings are empty and the default values are used. 2025-08-26T19:31:43.8343879Z  """ 2025-08-26T19:31:43.8344850Z  settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-08-26T19:31:43.8346363Z  return parse_settings_from_text(settings_text) 2025-08-26T19:31:43.8347307Z  2025-08-26T19:31:43.8347882Z  2025-08-26T19:31:43.8348638Z def parse_users(rollout_state: str) -> UserOptins: 2025-08-26T19:31:43.8349590Z  """ 2025-08-26T19:31:43.8350291Z  Parse users from the rollout state. 2025-08-26T19:31:43.8351141Z  2025-08-26T19:31:43.8351682Z  """ 2025-08-26T19:31:43.8352604Z  _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-08-26T19:31:43.8353976Z  return parse_user_opt_in_from_text(users_text) 2025-08-26T19:31:43.8354892Z  2025-08-26T19:31:43.8355435Z  2025-08-26T19:31:43.8356697Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-08-26T19:31:43.8357975Z  """ 2025-08-26T19:31:43.8358707Z  Check if a user is opted into an experiment 2025-08-26T19:31:43.8359662Z  """ 2025-08-26T19:31:43.8360498Z  return experiment_name in user_optins.get(user, []) 2025-08-26T19:31:43.8361688Z  2025-08-26T19:31:43.8362255Z  2025-08-26T19:31:43.8363330Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-08-26T19:31:43.8364616Z  """ 2025-08-26T19:31:43.8365426Z  Check if a user explicitly opted out of an experiment 2025-08-26T19:31:43.8366640Z  """ 2025-08-26T19:31:43.8367523Z  # if the experiment is prefixed with a "-", then it's an opt-out 2025-08-26T19:31:43.8368734Z  experiment_optout = "-" + experiment_name 2025-08-26T19:31:43.8369867Z  if experiment_optout not in user_optins.get(user, []): 2025-08-26T19:31:43.8370876Z  return False 2025-08-26T19:31:43.8371575Z  2025-08-26T19:31:43.8372361Z  if is_user_opted_in(user, user_optins, experiment_name): 2025-08-26T19:31:43.8373384Z  log.warning( 2025-08-26T19:31:43.8374794Z  f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-08-26T19:31:43.8376483Z  ) 2025-08-26T19:31:43.8377100Z  2025-08-26T19:31:43.8377680Z  return True 2025-08-26T19:31:43.8378368Z  2025-08-26T19:31:43.8378912Z  2025-08-26T19:31:43.8379496Z def get_runner_prefix( 2025-08-26T19:31:43.8380259Z  rollout_state: str, 2025-08-26T19:31:43.8381114Z  workflow_requestors: Iterable[str], 2025-08-26T19:31:43.8382002Z  branch: str, 2025-08-26T19:31:43.8382883Z  eligible_experiments: frozenset[str] = frozenset(), 2025-08-26T19:31:43.8384055Z  opt_out_experiments: frozenset[str] = frozenset(), 2025-08-26T19:31:43.8385046Z  is_canary: bool = False, 2025-08-26T19:31:43.8386014Z ) -> str: 2025-08-26T19:31:43.8386745Z  settings = parse_settings(rollout_state) 2025-08-26T19:31:43.8387753Z  user_optins = parse_users(rollout_state) 2025-08-26T19:31:43.8388630Z  2025-08-26T19:31:43.8389407Z  fleet_prefix = "" 2025-08-26T19:31:43.8390165Z  prefixes = [] 2025-08-26T19:31:43.8391323Z  for experiment_name, experiment_settings in settings.experiments.items(): 2025-08-26T19:31:43.8392950Z  if not experiment_settings.all_branches and is_exception_branch(branch): 2025-08-26T19:31:43.8394177Z  log.info( 2025-08-26T19:31:43.8395369Z  f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-08-26T19:31:43.8396853Z  ) 2025-08-26T19:31:43.8397523Z  continue 2025-08-26T19:31:43.8398225Z  2025-08-26T19:31:43.8398833Z  if opt_out_experiments: 2025-08-26T19:31:43.8399780Z  if experiment_name in opt_out_experiments: 2025-08-26T19:31:43.8400893Z  opt_out_exp_list = ", ".join(opt_out_experiments) 2025-08-26T19:31:43.8401902Z  log.info( 2025-08-26T19:31:43.8403505Z  f"Skipping experiment '{experiment_name}', as this workflow has opted-out (opted out experiments are: {opt_out_exp_list})" 2025-08-26T19:31:43.8405170Z  ) 2025-08-26T19:31:43.8406068Z  continue 2025-08-26T19:31:43.8406822Z  2025-08-26T19:31:43.8407448Z  if eligible_experiments: 2025-08-26T19:31:43.8408428Z  if experiment_name not in eligible_experiments: 2025-08-26T19:31:43.8409514Z  exp_list = ", ".join(eligible_experiments) 2025-08-26T19:31:43.8410467Z  log.info( 2025-08-26T19:31:43.8411827Z  f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-08-26T19:31:43.8413238Z  ) 2025-08-26T19:31:43.8414171Z  continue 2025-08-26T19:31:43.8415034Z  elif not experiment_settings.default: 2025-08-26T19:31:43.8416149Z  log.info( 2025-08-26T19:31:43.8417335Z  f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-08-26T19:31:43.8418565Z  ) 2025-08-26T19:31:43.8419235Z  continue 2025-08-26T19:31:43.8419947Z  2025-08-26T19:31:43.8420721Z  # Is any workflow_requestor opted out to this experiment? 2025-08-26T19:31:43.8421763Z  opted_out_users = [ 2025-08-26T19:31:43.8422580Z  requestor 2025-08-26T19:31:43.8423400Z  for requestor in workflow_requestors 2025-08-26T19:31:43.8424543Z  if is_user_opted_out(requestor, user_optins, experiment_name) 2025-08-26T19:31:43.8425780Z  ] 2025-08-26T19:31:43.8426435Z  2025-08-26T19:31:43.8427019Z  if opted_out_users: 2025-08-26T19:31:43.8427862Z  log.info( 2025-08-26T19:31:43.8428973Z  f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-08-26T19:31:43.8430148Z  ) 2025-08-26T19:31:43.8430807Z  continue 2025-08-26T19:31:43.8431513Z  2025-08-26T19:31:43.8432320Z  # Is any workflow_requestor opted in to this experiment? 2025-08-26T19:31:43.8433340Z  opted_in_users = [ 2025-08-26T19:31:43.8434124Z  requestor 2025-08-26T19:31:43.8434947Z  for requestor in workflow_requestors 2025-08-26T19:31:43.8436309Z  if is_user_opted_in(requestor, user_optins, experiment_name) 2025-08-26T19:31:43.8437351Z  ] 2025-08-26T19:31:43.8437963Z  2025-08-26T19:31:43.8438566Z  enabled = False 2025-08-26T19:31:43.8439342Z  if opted_in_users: 2025-08-26T19:31:43.8440328Z  log.info( 2025-08-26T19:31:43.8441415Z  f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-08-26T19:31:43.8442572Z  ) 2025-08-26T19:31:43.8443238Z  enabled = True 2025-08-26T19:31:43.8443986Z  2025-08-26T19:31:43.8444675Z  elif experiment_settings.rollout_perc: 2025-08-26T19:31:43.8446262Z  # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-08-26T19:31:43.8447873Z  if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-08-26T19:31:43.8448966Z  log.info( 2025-08-26T19:31:43.8450466Z  f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-08-26T19:31:43.8452061Z  ) 2025-08-26T19:31:43.8452788Z  enabled = True 2025-08-26T19:31:43.8453576Z  2025-08-26T19:31:43.8454157Z  if enabled: 2025-08-26T19:31:43.8454934Z  label = experiment_name 2025-08-26T19:31:43.8456081Z  if experiment_name == LF_FLEET_EXPERIMENT: 2025-08-26T19:31:43.8457491Z  # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-08-26T19:31:43.8458991Z  # - If it's enabled, then we always list it's prefix first 2025-08-26T19:31:43.8460283Z  # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-08-26T19:31:43.8461432Z  if is_canary: 2025-08-26T19:31:43.8462292Z  label += CANARY_FLEET_SUFFIX 2025-08-26T19:31:43.8463208Z  fleet_prefix = label 2025-08-26T19:31:43.8464324Z  else: 2025-08-26T19:31:43.8465154Z  prefixes.append(label) 2025-08-26T19:31:43.8466222Z  2025-08-26T19:31:43.8466835Z  if len(prefixes) > 1: 2025-08-26T19:31:43.8467626Z  log.error( 2025-08-26T19:31:43.8469393Z  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-26T19:31:43.8471288Z  ) 2025-08-26T19:31:43.8471970Z  prefixes = prefixes[:1] 2025-08-26T19:31:43.8472758Z  2025-08-26T19:31:43.8473386Z  # Fleet always comes first 2025-08-26T19:31:43.8474212Z  if fleet_prefix: 2025-08-26T19:31:43.8475010Z  prefixes.insert(0, fleet_prefix) 2025-08-26T19:31:43.8476049Z  2025-08-26T19:31:43.8476800Z  return ".".join(prefixes) + "." if prefixes else "" 2025-08-26T19:31:43.8477782Z  2025-08-26T19:31:43.8478332Z  2025-08-26T19:31:43.8479402Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-08-26T19:31:43.8480719Z  """ 2025-08-26T19:31:43.8481728Z  Gets the first comment of the issue, which contains the desired rollout state. 2025-08-26T19:31:43.8482903Z  2025-08-26T19:31:43.8483874Z  The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-08-26T19:31:43.8485054Z  """ 2025-08-26T19:31:43.8485917Z  gh = get_gh_client(github_token) 2025-08-26T19:31:43.8486896Z  issue = get_issue(gh, repo, issue_num) 2025-08-26T19:31:43.8487984Z  return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-08-26T19:31:43.8488994Z  2025-08-26T19:31:43.8489567Z  2025-08-26T19:31:43.8490563Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-08-26T19:31:43.8492060Z  for _ in range(num_retries): 2025-08-26T19:31:43.8492938Z  try: 2025-08-26T19:31:43.8493685Z  req = Request(url=url, headers=headers) 2025-08-26T19:31:43.8494796Z  content = urlopen(req, timeout=5).read().decode("utf-8") 2025-08-26T19:31:43.8496134Z  return json.loads(content) 2025-08-26T19:31:43.8497025Z  except Exception as e: 2025-08-26T19:31:43.8497966Z  log.warning(f"Could not download {url}: {e}") 2025-08-26T19:31:43.8498907Z  2025-08-26T19:31:43.8499913Z  log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-08-26T19:31:43.8501113Z  return {} 2025-08-26T19:31:43.8501775Z  2025-08-26T19:31:43.8502333Z  2025-08-26T19:31:43.8502889Z @cache 2025-08-26T19:31:43.8503961Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-08-26T19:31:43.8505260Z  """ 2025-08-26T19:31:43.8506135Z  Dynamically get PR information 2025-08-26T19:31:43.8506956Z  """ 2025-08-26T19:31:43.8507806Z  github_api = f"https://api.github.com/repos/{github_repo}" 2025-08-26T19:31:43.8508877Z  headers = { 2025-08-26T19:31:43.8509706Z  "Accept": "application/vnd.github.v3+json", 2025-08-26T19:31:43.8510733Z  "Authorization": f"token {github_token}", 2025-08-26T19:31:43.8511629Z  } 2025-08-26T19:31:43.8512382Z  json_response: dict[str, Any] = download_json( 2025-08-26T19:31:43.8513393Z  url=f"{github_api}/issues/{pr_number}", 2025-08-26T19:31:43.8514313Z  headers=headers, 2025-08-26T19:31:43.8515060Z  ) 2025-08-26T19:31:43.8515833Z  2025-08-26T19:31:43.8516431Z  if not json_response: 2025-08-26T19:31:43.8517710Z  log.warning(f"Failed to get the labels for #{pr_number}") 2025-08-26T19:31:43.8518775Z  return {} 2025-08-26T19:31:43.8519446Z  2025-08-26T19:31:43.8520032Z  return json_response 2025-08-26T19:31:43.8520786Z  2025-08-26T19:31:43.8521342Z  2025-08-26T19:31:43.8522325Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-08-26T19:31:43.8523526Z  """ 2025-08-26T19:31:43.8524456Z  Dynamically get the latest list of labels from the pull request 2025-08-26T19:31:43.8525541Z  """ 2025-08-26T19:31:43.8526557Z  pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-08-26T19:31:43.8527660Z  return { 2025-08-26T19:31:43.8528766Z  label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-08-26T19:31:43.8529915Z  } 2025-08-26T19:31:43.8530520Z  2025-08-26T19:31:43.8531081Z  2025-08-26T19:31:43.8531661Z def main() -> None: 2025-08-26T19:31:43.8532394Z  args = parse_args() 2025-08-26T19:31:43.8533145Z  2025-08-26T19:31:43.8533850Z  runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-08-26T19:31:43.8534739Z  2025-08-26T19:31:43.8535344Z  # Check if the PR is opt-out 2025-08-26T19:31:43.8536388Z  if args.pr_number: 2025-08-26T19:31:43.8537533Z  labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-08-26T19:31:43.8538796Z  if OPT_OUT_LABEL in labels: 2025-08-26T19:31:43.8539657Z  log.info( 2025-08-26T19:31:43.8540864Z  f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-08-26T19:31:43.8542144Z  ) 2025-08-26T19:31:43.8543138Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-08-26T19:31:43.8544291Z  sys.exit() 2025-08-26T19:31:43.8545203Z  2025-08-26T19:31:43.8545984Z  try: 2025-08-26T19:31:43.8546745Z  rollout_state = get_rollout_state_from_issue( 2025-08-26T19:31:43.8547957Z  args.github_token, args.github_issue_repo, args.github_issue 2025-08-26T19:31:43.8549036Z  ) 2025-08-26T19:31:43.8549659Z  2025-08-26T19:31:43.8550314Z  username = get_potential_pr_author( 2025-08-26T19:31:43.8551202Z  args.github_token, 2025-08-26T19:31:43.8552058Z  args.github_repo, 2025-08-26T19:31:43.8552886Z  args.github_actor, 2025-08-26T19:31:43.8553732Z  args.github_ref_type, 2025-08-26T19:31:43.8554577Z  args.github_branch, 2025-08-26T19:31:43.8555384Z  ) 2025-08-26T19:31:43.8556184Z  2025-08-26T19:31:43.8556998Z  is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-08-26T19:31:43.8558023Z  2025-08-26T19:31:43.8558729Z  runner_label_prefix = get_runner_prefix( 2025-08-26T19:31:43.8559652Z  rollout_state, 2025-08-26T19:31:43.8560497Z  (args.github_issue_owner, username), 2025-08-26T19:31:43.8561419Z  args.github_branch, 2025-08-26T19:31:43.8562303Z  args.eligible_experiments, 2025-08-26T19:31:43.8563217Z  args.opt_out_experiments, 2025-08-26T19:31:43.8564062Z  is_canary, 2025-08-26T19:31:43.8564802Z  ) 2025-08-26T19:31:43.8565423Z  2025-08-26T19:31:43.8566213Z  except Exception as e: 2025-08-26T19:31:43.8567004Z  log.error( 2025-08-26T19:31:43.8568166Z  f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-08-26T19:31:43.8569692Z  ) 2025-08-26T19:31:43.8570312Z  2025-08-26T19:31:43.8571182Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-08-26T19:31:43.8572303Z  2025-08-26T19:31:43.8572851Z  2025-08-26T19:31:43.8573425Z if __name__ == "__main__": 2025-08-26T19:31:43.8574184Z  main() 2025-08-26T19:31:43.8574826Z  2025-08-26T19:31:43.8575371Z EOF 2025-08-26T19:31:43.8576142Z  2025-08-26T19:31:43.8576739Z cat runner_determinator.py 2025-08-26T19:31:43.9005096Z shell: /usr/bin/bash -e {0} 2025-08-26T19:31:43.9006533Z env: 2025-08-26T19:31:43.9007510Z GITHUB_TOKEN: *** 2025-08-26T19:31:43.9008188Z ISSUE_NUMBER: 5132 2025-08-26T19:31:43.9008884Z TRIGGERING_ACTOR: pytorchmergebot 2025-08-26T19:31:43.9009656Z ISSUE_OWNER: 2025-08-26T19:31:43.9010290Z CHECK_EXPERIMENTS: 2025-08-26T19:31:43.9010975Z OPT_OUT_EXPERIMENTS: 2025-08-26T19:31:43.9011659Z PR_NUMBER: 2025-08-26T19:31:43.9012241Z ##[endgroup] 2025-08-26T19:31:43.9284679Z # flake8: noqa: G004 2025-08-26T19:31:43.9285004Z 2025-08-26T19:31:43.9285414Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-08-26T19:31:43.9286709Z # must be kept in sync. You can do it easily by running the following command: 2025-08-26T19:31:43.9287486Z # python .github/scripts/update_runner_determinator.py 2025-08-26T19:31:43.9287897Z 2025-08-26T19:31:43.9288046Z """ 2025-08-26T19:31:43.9288613Z This runner determinator is used to determine which set of runners to run a 2025-08-26T19:31:43.9289471Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-08-26T19:31:43.9290320Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-08-26T19:31:43.9291067Z of which runners should be used to run which job. 2025-08-26T19:31:43.9291430Z 2025-08-26T19:31:43.9291794Z The configuration has two parts, the settings and a list of opted-in users, 2025-08-26T19:31:43.9292822Z separated by a line containing "---". If the line is not present, the 2025-08-26T19:31:43.9293638Z settings are considered to be empty with only the second part, the user 2025-08-26T19:31:43.9294272Z list, defined. 2025-08-26T19:31:43.9294482Z 2025-08-26T19:31:43.9294820Z The first part is a YAML block that defines the rollout settings. This can be 2025-08-26T19:31:43.9296327Z used to define any settings that are needed to determine which runners to use. 2025-08-26T19:31:43.9297124Z It's fields are defined by the RolloutSettings class below. 2025-08-26T19:31:43.9297535Z 2025-08-26T19:31:43.9297881Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-08-26T19:31:43.9298723Z The user list is also a comma separated list of additional features or 2025-08-26T19:31:43.9299450Z experiments which the user could be opted in to. 2025-08-26T19:31:43.9300095Z 2025-08-26T19:31:43.9300301Z The user list has the following rules: 2025-08-26T19:31:43.9300644Z 2025-08-26T19:31:43.9300944Z - Users are GitHub usernames, which must start with the @ prefix 2025-08-26T19:31:43.9301787Z - Each user is also a comma-separated list of features/experiments to enable 2025-08-26T19:31:43.9302585Z - A "#" prefix opts the user out of all experiments 2025-08-26T19:31:43.9302974Z 2025-08-26T19:31:43.9303133Z Example config: 2025-08-26T19:31:43.9303556Z # A list of experiments that can be opted into. 2025-08-26T19:31:43.9304201Z # This defines the behavior they'll induce when opted into. 2025-08-26T19:31:43.9304787Z # Expected syntax is: 2025-08-26T19:31:43.9305377Z # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-08-26T19:31:43.9306805Z # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-08-26T19:31:43.9307368Z 2025-08-26T19:31:43.9307523Z experiments: 2025-08-26T19:31:43.9307888Z lf: 2025-08-26T19:31:43.9308238Z rollout_percent: 25 2025-08-26T19:31:43.9308869Z all_branches: false 2025-08-26T19:31:43.9309290Z default: true 2025-08-26T19:31:43.9309689Z --- 2025-08-26T19:31:43.9309879Z 2025-08-26T19:31:43.9310047Z # Opt-ins: 2025-08-26T19:31:43.9310601Z # Users can opt into the LF fleet by adding their GitHub username to this list 2025-08-26T19:31:43.9311409Z # and specifying experiments to enable in a comma-separated list. 2025-08-26T19:31:43.9312128Z # To always opt out of an experiment, prefix it with a "-". 2025-08-26T19:31:43.9312732Z # Experiments should be from the above list. 2025-08-26T19:31:43.9313080Z 2025-08-26T19:31:43.9313252Z @User1,-lf,split_build 2025-08-26T19:31:43.9313651Z @User2,lf 2025-08-26T19:31:43.9314003Z @User3,split_build 2025-08-26T19:31:43.9314367Z """ 2025-08-26T19:31:43.9314559Z 2025-08-26T19:31:43.9314714Z import json 2025-08-26T19:31:43.9315051Z import logging 2025-08-26T19:31:43.9315401Z import os 2025-08-26T19:31:43.9316062Z import random 2025-08-26T19:31:43.9316508Z import re 2025-08-26T19:31:43.9316845Z import sys 2025-08-26T19:31:43.9317220Z from argparse import ArgumentParser 2025-08-26T19:31:43.9317710Z from collections.abc import Iterable 2025-08-26T19:31:43.9318184Z from functools import cache 2025-08-26T19:31:43.9318625Z from logging import LogRecord 2025-08-26T19:31:43.9319069Z from typing import Any, NamedTuple 2025-08-26T19:31:43.9319562Z from urllib.request import Request, urlopen 2025-08-26T19:31:43.9319906Z 2025-08-26T19:31:43.9320057Z import yaml 2025-08-26T19:31:43.9320417Z from github import Auth, Github 2025-08-26T19:31:43.9320862Z from github.Issue import Issue 2025-08-26T19:31:43.9321140Z 2025-08-26T19:31:43.9321147Z 2025-08-26T19:31:43.9321346Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-08-26T19:31:43.9321986Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-08-26T19:31:43.9322785Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-08-26T19:31:43.9323300Z 2025-08-26T19:31:43.9323519Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-08-26T19:31:43.9324194Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-08-26T19:31:43.9324674Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-08-26T19:31:43.9325189Z OPT_OUT_LABEL = "no-runner-experiments" 2025-08-26T19:31:43.9325512Z 2025-08-26T19:31:43.9326031Z SETTING_EXPERIMENTS = "experiments" 2025-08-26T19:31:43.9326382Z 2025-08-26T19:31:43.9326567Z LF_FLEET_EXPERIMENT = "lf" 2025-08-26T19:31:43.9326996Z CANARY_FLEET_SUFFIX = ".c" 2025-08-26T19:31:43.9327256Z 2025-08-26T19:31:43.9327262Z 2025-08-26T19:31:43.9327437Z class Experiment(NamedTuple): 2025-08-26T19:31:43.9327883Z rollout_perc: float = ( 2025-08-26T19:31:43.9328479Z 0 # Percentage of workflows to experiment on when user is not opted-in. 2025-08-26T19:31:43.9329106Z ) 2025-08-26T19:31:43.9329438Z all_branches: bool = ( 2025-08-26T19:31:43.9330015Z False # If True, the experiment is also enabled on the exception branches 2025-08-26T19:31:43.9330638Z ) 2025-08-26T19:31:43.9330970Z default: bool = ( 2025-08-26T19:31:43.9331494Z True # If True, the experiment is enabled by default for all queries 2025-08-26T19:31:43.9332090Z ) 2025-08-26T19:31:43.9332263Z 2025-08-26T19:31:43.9332427Z # Add more fields as needed 2025-08-26T19:31:43.9332704Z 2025-08-26T19:31:43.9332710Z 2025-08-26T19:31:43.9332884Z class Settings(NamedTuple): 2025-08-26T19:31:43.9333292Z """ 2025-08-26T19:31:43.9333714Z Settings for the experiments that can be opted into. 2025-08-26T19:31:43.9334243Z """ 2025-08-26T19:31:43.9334423Z 2025-08-26T19:31:43.9334612Z experiments: dict[str, Experiment] = {} 2025-08-26T19:31:43.9334952Z 2025-08-26T19:31:43.9334958Z 2025-08-26T19:31:43.9335154Z class ColorFormatter(logging.Formatter): 2025-08-26T19:31:43.9335905Z """Color codes the log messages based on the log level""" 2025-08-26T19:31:43.9336317Z 2025-08-26T19:31:43.9336470Z COLORS = { 2025-08-26T19:31:43.9336837Z "WARNING": "\033[33m", # Yellow 2025-08-26T19:31:43.9337448Z "ERROR": "\033[31m", # Red 2025-08-26T19:31:43.9337912Z "CRITICAL": "\033[31m", # Red 2025-08-26T19:31:43.9338367Z "INFO": "\033[0m", # Reset 2025-08-26T19:31:43.9338814Z "DEBUG": "\033[0m", # Reset 2025-08-26T19:31:43.9339240Z } 2025-08-26T19:31:43.9339421Z 2025-08-26T19:31:43.9339622Z def format(self, record: LogRecord) -> str: 2025-08-26T19:31:43.9340317Z log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-08-26T19:31:43.9341026Z record.msg = f"{log_color}{record.msg}\033[0m" 2025-08-26T19:31:43.9341564Z return super().format(record) 2025-08-26T19:31:43.9341871Z 2025-08-26T19:31:43.9341878Z 2025-08-26T19:31:43.9342058Z handler = logging.StreamHandler() 2025-08-26T19:31:43.9342729Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-08-26T19:31:43.9343241Z 2025-08-26T19:31:43.9343473Z log = logging.getLogger(os.path.basename(__file__)) 2025-08-26T19:31:43.9344010Z log.addHandler(handler) 2025-08-26T19:31:43.9344421Z log.setLevel(logging.INFO) 2025-08-26T19:31:43.9344679Z 2025-08-26T19:31:43.9344686Z 2025-08-26T19:31:43.9344916Z def set_github_output(key: str, value: str) -> None: 2025-08-26T19:31:43.9345434Z """ 2025-08-26T19:31:43.9346107Z Defines outputs of the github action that invokes this script 2025-08-26T19:31:43.9346697Z """ 2025-08-26T19:31:43.9347030Z if not GITHUB_OUTPUT: 2025-08-26T19:31:43.9348023Z # See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ for deprecation notice 2025-08-26T19:31:43.9349051Z log.warning( 2025-08-26T19:31:43.9349826Z "No env var found for GITHUB_OUTPUT, you must be running this code locally. Falling back to the deprecated print method." 2025-08-26T19:31:43.9350675Z ) 2025-08-26T19:31:43.9360711Z print(f"::set-output name={key}::{value}") 2025-08-26T19:31:43.9361286Z return 2025-08-26T19:31:43.9361519Z 2025-08-26T19:31:43.9361886Z with open(GITHUB_OUTPUT, "a") as f: 2025-08-26T19:31:43.9362468Z log.info(f"Setting output: {key}='{value}'") 2025-08-26T19:31:43.9363007Z f.write(f"{key}={value}\n") 2025-08-26T19:31:43.9363307Z 2025-08-26T19:31:43.9363314Z 2025-08-26T19:31:43.9363607Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-08-26T19:31:43.9364208Z return frozenset( 2025-08-26T19:31:43.9364785Z filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-08-26T19:31:43.9365425Z ) 2025-08-26T19:31:43.9365798Z 2025-08-26T19:31:43.9365808Z 2025-08-26T19:31:43.9366038Z def parse_args() -> Any: 2025-08-26T19:31:43.9366580Z parser = ArgumentParser("Get dynamic rollout settings") 2025-08-26T19:31:43.9367402Z parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-08-26T19:31:43.9368123Z parser.add_argument( 2025-08-26T19:31:43.9368543Z "--github-issue-repo", 2025-08-26T19:31:43.9368967Z type=str, 2025-08-26T19:31:43.9369386Z required=False, 2025-08-26T19:31:43.9369796Z default="pytorch/test-infra", 2025-08-26T19:31:43.9370299Z help="GitHub repo to get the issue", 2025-08-26T19:31:43.9370764Z ) 2025-08-26T19:31:43.9371101Z parser.add_argument( 2025-08-26T19:31:43.9371500Z "--github-repo", 2025-08-26T19:31:43.9371882Z type=str, 2025-08-26T19:31:43.9372239Z required=True, 2025-08-26T19:31:43.9372649Z help="GitHub repo where CI is running", 2025-08-26T19:31:43.9373128Z ) 2025-08-26T19:31:43.9373458Z parser.add_argument( 2025-08-26T19:31:43.9374015Z "--github-issue", type=int, required=True, help="GitHub issue number" 2025-08-26T19:31:43.9374626Z ) 2025-08-26T19:31:43.9374961Z parser.add_argument( 2025-08-26T19:31:43.9375530Z "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-08-26T19:31:43.9376384Z ) 2025-08-26T19:31:43.9376873Z parser.add_argument( 2025-08-26T19:31:43.9377467Z "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-08-26T19:31:43.9378103Z ) 2025-08-26T19:31:43.9378429Z parser.add_argument( 2025-08-26T19:31:43.9379029Z "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-08-26T19:31:43.9379673Z ) 2025-08-26T19:31:43.9380005Z parser.add_argument( 2025-08-26T19:31:43.9380424Z "--github-ref-type", 2025-08-26T19:31:43.9380834Z type=str, 2025-08-26T19:31:43.9381184Z required=True, 2025-08-26T19:31:43.9381626Z help="Current GitHub ref type, branch or tag", 2025-08-26T19:31:43.9382125Z ) 2025-08-26T19:31:43.9382453Z parser.add_argument( 2025-08-26T19:31:43.9382867Z "--eligible-experiments", 2025-08-26T19:31:43.9383327Z type=_str_comma_separated_to_set, 2025-08-26T19:31:43.9383807Z required=False, 2025-08-26T19:31:43.9384180Z default="", 2025-08-26T19:31:43.9384977Z help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-08-26T19:31:43.9386060Z ) 2025-08-26T19:31:43.9386402Z parser.add_argument( 2025-08-26T19:31:43.9386816Z "--opt-out-experiments", 2025-08-26T19:31:43.9387278Z type=_str_comma_separated_to_set, 2025-08-26T19:31:43.9387750Z required=False, 2025-08-26T19:31:43.9388125Z default="", 2025-08-26T19:31:43.9388480Z help=( 2025-08-26T19:31:43.9389086Z "comma separated list of experiments to opt-out of. If unset, no opt-outs will occur. " 2025-08-26T19:31:43.9390135Z "If the same experiment is listed both here and in '--eligible-experiments' opt-out will take priority." 2025-08-26T19:31:43.9390892Z ), 2025-08-26T19:31:43.9391212Z ) 2025-08-26T19:31:43.9391541Z parser.add_argument( 2025-08-26T19:31:43.9391945Z "--pr-number", 2025-08-26T19:31:43.9392318Z type=str, 2025-08-26T19:31:43.9392689Z required=False, 2025-08-26T19:31:43.9393071Z default="", 2025-08-26T19:31:43.9393624Z help="the optional PR number where this is run", 2025-08-26T19:31:43.9394150Z ) 2025-08-26T19:31:43.9394326Z 2025-08-26T19:31:43.9394501Z return parser.parse_args() 2025-08-26T19:31:43.9394790Z 2025-08-26T19:31:43.9394797Z 2025-08-26T19:31:43.9395172Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-08-26T19:31:43.9395975Z auth = Auth.Token(github_token) 2025-08-26T19:31:43.9396437Z return Github(auth=auth) 2025-08-26T19:31:43.9396707Z 2025-08-26T19:31:43.9396714Z 2025-08-26T19:31:43.9397134Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-08-26T19:31:43.9397859Z repo = gh.get_repo(repo) 2025-08-26T19:31:43.9398314Z return repo.get_issue(number=issue_num) 2025-08-26T19:31:43.9398643Z 2025-08-26T19:31:43.9398649Z 2025-08-26T19:31:43.9398820Z def get_potential_pr_author( 2025-08-26T19:31:43.9399414Z github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-08-26T19:31:43.9400037Z ) -> str: 2025-08-26T19:31:43.9400500Z # If the trigger was a new tag added by a bot, this is a ciflow case 2025-08-26T19:31:43.9401237Z # Fetch the actual username from the original PR. The PR number is 2025-08-26T19:31:43.9401912Z # embedded in the tag name: ciflow// 2025-08-26T19:31:43.9402299Z 2025-08-26T19:31:43.9402475Z gh = get_gh_client(github_token) 2025-08-26T19:31:43.9402777Z 2025-08-26T19:31:43.9403023Z if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-08-26T19:31:43.9403599Z split_tag = ref_name.split("/") 2025-08-26T19:31:43.9404055Z if ( 2025-08-26T19:31:43.9404398Z len(split_tag) == 3 2025-08-26T19:31:43.9404850Z and split_tag[0] == "ciflow" 2025-08-26T19:31:43.9405328Z and split_tag[2].isnumeric() 2025-08-26T19:31:43.9405978Z ): 2025-08-26T19:31:43.9406471Z pr_number = split_tag[2] 2025-08-26T19:31:43.9406915Z try: 2025-08-26T19:31:43.9407300Z repository = gh.get_repo(repo) 2025-08-26T19:31:43.9407864Z pull = repository.get_pull(number=int(pr_number)) 2025-08-26T19:31:43.9408406Z except Exception as e: 2025-08-26T19:31:43.9408874Z raise Exception( # noqa: TRY002 2025-08-26T19:31:43.9409483Z f"issue with pull request {pr_number} from repo {repository}" 2025-08-26T19:31:43.9410058Z ) from e 2025-08-26T19:31:43.9410551Z return pull.user.login # type: ignore[no-any-return] 2025-08-26T19:31:43.9411188Z # In all other cases, return the original input username 2025-08-26T19:31:43.9411725Z return username 2025-08-26T19:31:43.9411938Z 2025-08-26T19:31:43.9411945Z 2025-08-26T19:31:43.9412160Z def is_exception_branch(branch: str) -> bool: 2025-08-26T19:31:43.9412644Z """ 2025-08-26T19:31:43.9413233Z Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-08-26T19:31:43.9413947Z """ 2025-08-26T19:31:43.9414452Z return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-08-26T19:31:43.9414928Z 2025-08-26T19:31:43.9414935Z 2025-08-26T19:31:43.9415114Z def load_yaml(yaml_text: str) -> Any: 2025-08-26T19:31:43.9415568Z try: 2025-08-26T19:31:43.9416024Z data = yaml.safe_load(yaml_text) 2025-08-26T19:31:43.9416492Z return data 2025-08-26T19:31:43.9416870Z except yaml.YAMLError: 2025-08-26T19:31:43.9417312Z log.exception("Error loading YAML") 2025-08-26T19:31:43.9417774Z raise 2025-08-26T19:31:43.9417967Z 2025-08-26T19:31:43.9417973Z 2025-08-26T19:31:43.9418357Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-08-26T19:31:43.9419040Z """ 2025-08-26T19:31:43.9419599Z Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-08-26T19:31:43.9420160Z 2025-08-26T19:31:43.9420596Z If the issue body contains "---" then the text above that is the settings 2025-08-26T19:31:43.9421296Z and the text below is the list of opted in users. 2025-08-26T19:31:43.9421664Z 2025-08-26T19:31:43.9422008Z If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-08-26T19:31:43.9422655Z """ 2025-08-26T19:31:43.9423049Z rollout_state_parts = rollout_state.split("---") 2025-08-26T19:31:43.9423598Z if len(rollout_state_parts) >= 2: 2025-08-26T19:31:43.9424140Z return rollout_state_parts[0], rollout_state_parts[1] 2025-08-26T19:31:43.9424674Z else: 2025-08-26T19:31:43.9476485Z return "", rollout_state 2025-08-26T19:31:43.9477165Z 2025-08-26T19:31:43.9477178Z 2025-08-26T19:31:43.9477567Z class UserOptins(dict[str, list[str]]): 2025-08-26T19:31:43.9478325Z """ 2025-08-26T19:31:43.9478848Z Dictionary of users with a list of features they have opted into 2025-08-26T19:31:43.9479466Z """ 2025-08-26T19:31:43.9479666Z 2025-08-26T19:31:43.9479677Z 2025-08-26T19:31:43.9480008Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-08-26T19:31:43.9480625Z """ 2025-08-26T19:31:43.9481285Z Parse the user opt-in text into a key value pair of username and the list of features they have opted into 2025-08-26T19:31:43.9481932Z 2025-08-26T19:31:43.9482517Z Users are GitHub usernames with the @ prefix. Each user is also a comma-separated list of features/experiments to enable. 2025-08-26T19:31:43.9483442Z - Example line: "@User1,lf,split_build" 2025-08-26T19:31:43.9484068Z - A "#" prefix indicates the user is opted out of all experiments 2025-08-26T19:31:43.9484519Z 2025-08-26T19:31:43.9484531Z 2025-08-26T19:31:43.9484680Z """ 2025-08-26T19:31:43.9485020Z optins = UserOptins() 2025-08-26T19:31:43.9485484Z for user in user_optin_text.split("\n"): 2025-08-26T19:31:43.9486430Z user = user.strip("\r\n\t -") 2025-08-26T19:31:43.9487197Z if not user or not user.startswith("@"): 2025-08-26T19:31:43.9487834Z # Not a valid user. Skip 2025-08-26T19:31:43.9488278Z continue 2025-08-26T19:31:43.9488501Z 2025-08-26T19:31:43.9488653Z if user: 2025-08-26T19:31:43.9489051Z usr_name = user.split(",")[0].strip("@") 2025-08-26T19:31:43.9489691Z optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-08-26T19:31:43.9490139Z 2025-08-26T19:31:43.9490295Z return optins 2025-08-26T19:31:43.9490518Z 2025-08-26T19:31:43.9490524Z 2025-08-26T19:31:43.9490784Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-08-26T19:31:43.9491347Z """ 2025-08-26T19:31:43.9491703Z Check if the experiment name is valid. 2025-08-26T19:31:43.9492180Z A valid name: 2025-08-26T19:31:43.9492759Z - Contains only alphanumeric characters and the special characters "_" & "-" 2025-08-26T19:31:43.9493637Z - The special characters "_" & "-" shouldn't be the first or last characters 2025-08-26T19:31:43.9494298Z - Cannot contain spaces 2025-08-26T19:31:43.9494715Z """ 2025-08-26T19:31:43.9494896Z 2025-08-26T19:31:43.9495141Z valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-08-26T19:31:43.9495977Z valid = bool(re.match(valid_char_regex, experiment_name)) 2025-08-26T19:31:43.9496395Z 2025-08-26T19:31:43.9496552Z if valid: 2025-08-26T19:31:43.9496890Z return True 2025-08-26T19:31:43.9497199Z 2025-08-26T19:31:43.9497458Z log.error( 2025-08-26T19:31:43.9499252Z 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-26T19:31:43.9501204Z ) 2025-08-26T19:31:43.9501652Z return False 2025-08-26T19:31:43.9501971Z 2025-08-26T19:31:43.9501978Z 2025-08-26T19:31:43.9502276Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-08-26T19:31:43.9502865Z """ 2025-08-26T19:31:43.9503571Z Parse the experiments from the issue body into a list of ExperimentSettings 2025-08-26T19:31:43.9504253Z """ 2025-08-26T19:31:43.9504578Z try: 2025-08-26T19:31:43.9504912Z if settings_text: 2025-08-26T19:31:43.9505583Z # Escape the backtick as well so that we can have the settings in a code block on the GH issue 2025-08-26T19:31:43.9506518Z # for easy reading 2025-08-26T19:31:43.9507266Z # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-08-26T19:31:43.9508091Z # the backtick character in shell commands. 2025-08-26T19:31:43.9508656Z backtick = chr(96) # backtick character 2025-08-26T19:31:43.9509267Z settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-08-26T19:31:43.9509879Z settings = load_yaml(settings_text) 2025-08-26T19:31:43.9510218Z 2025-08-26T19:31:43.9510605Z # For now we just load experiments. We can expand this if/when we add more settings 2025-08-26T19:31:43.9511302Z experiments = {} 2025-08-26T19:31:43.9511576Z 2025-08-26T19:31:43.9511935Z for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-08-26T19:31:43.9512629Z if not is_valid_experiment_name(exp_name): 2025-08-26T19:31:43.9513654Z # 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-26T19:31:43.9514617Z continue 2025-08-26T19:31:43.9514873Z 2025-08-26T19:31:43.9515039Z valid_settings = {} 2025-08-26T19:31:43.9515514Z for setting in exp_settings: 2025-08-26T19:31:43.9516212Z if setting not in Experiment._fields: 2025-08-26T19:31:43.9516726Z log.warning( 2025-08-26T19:31:43.9517383Z f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-08-26T19:31:43.9518197Z ) 2025-08-26T19:31:43.9518601Z else: 2025-08-26T19:31:43.9519069Z valid_settings[setting] = exp_settings[setting] 2025-08-26T19:31:43.9519455Z 2025-08-26T19:31:43.9519714Z experiments[exp_name] = Experiment(**valid_settings) 2025-08-26T19:31:43.9520291Z return Settings(experiments) 2025-08-26T19:31:43.9520619Z 2025-08-26T19:31:43.9520773Z except Exception: 2025-08-26T19:31:43.9521208Z log.exception("Failed to parse settings") 2025-08-26T19:31:43.9521572Z 2025-08-26T19:31:43.9521730Z return Settings() 2025-08-26T19:31:43.9521961Z 2025-08-26T19:31:43.9521967Z 2025-08-26T19:31:43.9522200Z def parse_settings(rollout_state: str) -> Settings: 2025-08-26T19:31:43.9522714Z """ 2025-08-26T19:31:43.9523109Z Parse settings, if any, from the rollout state. 2025-08-26T19:31:43.9523481Z 2025-08-26T19:31:43.9523894Z If the issue body contains "---" then the text above that is the settings 2025-08-26T19:31:43.9524670Z and the text below is the list of opted in users. 2025-08-26T19:31:43.9525052Z 2025-08-26T19:31:43.9525433Z If it doesn't contain "---" then the settings are empty and the default values are used. 2025-08-26T19:31:43.9526369Z """ 2025-08-26T19:31:43.9526887Z settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-08-26T19:31:43.9527591Z return parse_settings_from_text(settings_text) 2025-08-26T19:31:43.9527964Z 2025-08-26T19:31:43.9527971Z 2025-08-26T19:31:43.9528198Z def parse_users(rollout_state: str) -> UserOptins: 2025-08-26T19:31:43.9528699Z """ 2025-08-26T19:31:43.9529063Z Parse users from the rollout state. 2025-08-26T19:31:43.9529384Z 2025-08-26T19:31:43.9529532Z """ 2025-08-26T19:31:43.9530009Z _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-08-26T19:31:43.9530695Z return parse_user_opt_in_from_text(users_text) 2025-08-26T19:31:43.9531061Z 2025-08-26T19:31:43.9531067Z 2025-08-26T19:31:43.9531619Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-08-26T19:31:43.9532313Z """ 2025-08-26T19:31:43.9532680Z Check if a user is opted into an experiment 2025-08-26T19:31:43.9533169Z """ 2025-08-26T19:31:43.9533575Z return experiment_name in user_optins.get(user, []) 2025-08-26T19:31:43.9533965Z 2025-08-26T19:31:43.9533971Z 2025-08-26T19:31:43.9534357Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-08-26T19:31:43.9535038Z """ 2025-08-26T19:31:43.9535472Z Check if a user explicitly opted out of an experiment 2025-08-26T19:31:43.9536260Z """ 2025-08-26T19:31:43.9536721Z # if the experiment is prefixed with a "-", then it's an opt-out 2025-08-26T19:31:43.9537357Z experiment_optout = "-" + experiment_name 2025-08-26T19:31:43.9537952Z if experiment_optout not in user_optins.get(user, []): 2025-08-26T19:31:43.9538504Z return False 2025-08-26T19:31:43.9538728Z 2025-08-26T19:31:43.9538979Z if is_user_opted_in(user, user_optins, experiment_name): 2025-08-26T19:31:43.9539521Z log.warning( 2025-08-26T19:31:43.9540251Z f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-08-26T19:31:43.9541053Z ) 2025-08-26T19:31:43.9541241Z 2025-08-26T19:31:43.9541387Z return True 2025-08-26T19:31:43.9541591Z 2025-08-26T19:31:43.9541597Z 2025-08-26T19:31:43.9541761Z def get_runner_prefix( 2025-08-26T19:31:43.9542149Z rollout_state: str, 2025-08-26T19:31:43.9542565Z workflow_requestors: Iterable[str], 2025-08-26T19:31:43.9543030Z branch: str, 2025-08-26T19:31:43.9543470Z eligible_experiments: frozenset[str] = frozenset(), 2025-08-26T19:31:43.9544071Z opt_out_experiments: frozenset[str] = frozenset(), 2025-08-26T19:31:43.9544607Z is_canary: bool = False, 2025-08-26T19:31:43.9545013Z ) -> str: 2025-08-26T19:31:43.9545540Z settings = parse_settings(rollout_state) 2025-08-26T19:31:43.9546303Z user_optins = parse_users(rollout_state) 2025-08-26T19:31:43.9546657Z 2025-08-26T19:31:43.9546812Z fleet_prefix = "" 2025-08-26T19:31:43.9547197Z prefixes = [] 2025-08-26T19:31:43.9547773Z for experiment_name, experiment_settings in settings.experiments.items(): 2025-08-26T19:31:43.9548646Z if not experiment_settings.all_branches and is_exception_branch(branch): 2025-08-26T19:31:43.9549307Z log.info( 2025-08-26T19:31:43.9549928Z f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-08-26T19:31:43.9550617Z ) 2025-08-26T19:31:43.9550965Z continue 2025-08-26T19:31:43.9551192Z 2025-08-26T19:31:43.9551367Z if opt_out_experiments: 2025-08-26T19:31:43.9551847Z if experiment_name in opt_out_experiments: 2025-08-26T19:31:43.9552427Z opt_out_exp_list = ", ".join(opt_out_experiments) 2025-08-26T19:31:43.9552958Z log.info( 2025-08-26T19:31:43.9553818Z f"Skipping experiment '{experiment_name}', as this workflow has opted-out (opted out experiments are: {opt_out_exp_list})" 2025-08-26T19:31:43.9554720Z ) 2025-08-26T19:31:43.9555079Z continue 2025-08-26T19:31:43.9555318Z 2025-08-26T19:31:43.9555492Z if eligible_experiments: 2025-08-26T19:31:43.9556172Z if experiment_name not in eligible_experiments: 2025-08-26T19:31:43.9556756Z exp_list = ", ".join(eligible_experiments) 2025-08-26T19:31:43.9557254Z log.info( 2025-08-26T19:31:43.9557974Z f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-08-26T19:31:43.9558734Z ) 2025-08-26T19:31:43.9559122Z continue 2025-08-26T19:31:43.9559551Z elif not experiment_settings.default: 2025-08-26T19:31:43.9560086Z log.info( 2025-08-26T19:31:43.9560815Z f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-08-26T19:31:43.9561499Z ) 2025-08-26T19:31:43.9561835Z continue 2025-08-26T19:31:43.9562058Z 2025-08-26T19:31:43.9562314Z # Is any workflow_requestor opted out to this experiment? 2025-08-26T19:31:43.9562891Z opted_out_users = [ 2025-08-26T19:31:43.9563288Z requestor 2025-08-26T19:31:43.9563702Z for requestor in workflow_requestors 2025-08-26T19:31:43.9564316Z if is_user_opted_out(requestor, user_optins, experiment_name) 2025-08-26T19:31:43.9564887Z ] 2025-08-26T19:31:43.9565071Z 2025-08-26T19:31:43.9565238Z if opted_out_users: 2025-08-26T19:31:43.9565825Z log.info( 2025-08-26T19:31:43.9566458Z f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-08-26T19:31:43.9567104Z ) 2025-08-26T19:31:43.9567451Z continue 2025-08-26T19:31:43.9567681Z 2025-08-26T19:31:43.9567929Z # Is any workflow_requestor opted in to this experiment? 2025-08-26T19:31:43.9568482Z opted_in_users = [ 2025-08-26T19:31:43.9568880Z requestor 2025-08-26T19:31:43.9569305Z for requestor in workflow_requestors 2025-08-26T19:31:43.9569915Z if is_user_opted_in(requestor, user_optins, experiment_name) 2025-08-26T19:31:43.9570473Z ] 2025-08-26T19:31:43.9570654Z 2025-08-26T19:31:43.9570809Z enabled = False 2025-08-26T19:31:43.9571202Z if opted_in_users: 2025-08-26T19:31:43.9571608Z log.info( 2025-08-26T19:31:43.9572150Z f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-08-26T19:31:43.9572780Z ) 2025-08-26T19:31:43.9573129Z enabled = True 2025-08-26T19:31:43.9573387Z 2025-08-26T19:31:43.9573585Z elif experiment_settings.rollout_perc: 2025-08-26T19:31:43.9574352Z # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-08-26T19:31:43.9575345Z if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-08-26T19:31:43.9576418Z log.info( 2025-08-26T19:31:43.9577217Z f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-08-26T19:31:43.9578068Z ) 2025-08-26T19:31:43.9578424Z enabled = True 2025-08-26T19:31:43.9578703Z 2025-08-26T19:31:43.9578848Z if enabled: 2025-08-26T19:31:43.9579227Z label = experiment_name 2025-08-26T19:31:43.9579721Z if experiment_name == LF_FLEET_EXPERIMENT: 2025-08-26T19:31:43.9580480Z # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-08-26T19:31:43.9581276Z # - If it's enabled, then we always list it's prefix first 2025-08-26T19:31:43.9581975Z # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-08-26T19:31:43.9582565Z if is_canary: 2025-08-26T19:31:43.9583020Z label += CANARY_FLEET_SUFFIX 2025-08-26T19:31:43.9583519Z fleet_prefix = label 2025-08-26T19:31:43.9583968Z else: 2025-08-26T19:31:43.9584357Z prefixes.append(label) 2025-08-26T19:31:43.9584674Z 2025-08-26T19:31:43.9584834Z if len(prefixes) > 1: 2025-08-26T19:31:43.9585231Z log.error( 2025-08-26T19:31:43.9586308Z 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-26T19:31:43.9587334Z ) 2025-08-26T19:31:43.9587685Z prefixes = prefixes[:1] 2025-08-26T19:31:43.9588100Z 2025-08-26T19:31:43.9588305Z # Fleet always comes first 2025-08-26T19:31:43.9588745Z if fleet_prefix: 2025-08-26T19:31:43.9589147Z prefixes.insert(0, fleet_prefix) 2025-08-26T19:31:43.9589492Z 2025-08-26T19:31:43.9589877Z return ".".join(prefixes) + "." if prefixes else "" 2025-08-26T19:31:43.9590264Z 2025-08-26T19:31:43.9590270Z 2025-08-26T19:31:43.9590680Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-08-26T19:31:43.9591384Z """ 2025-08-26T19:31:43.9591918Z Gets the first comment of the issue, which contains the desired rollout state. 2025-08-26T19:31:43.9592428Z 2025-08-26T19:31:43.9592783Z The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-08-26T19:31:43.9593418Z """ 2025-08-26T19:31:43.9593758Z gh = get_gh_client(github_token) 2025-08-26T19:31:43.9594247Z issue = get_issue(gh, repo, issue_num) 2025-08-26T19:31:43.9594819Z return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-08-26T19:31:43.9595227Z 2025-08-26T19:31:43.9595234Z 2025-08-26T19:31:43.9595598Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-08-26T19:31:43.9596501Z for _ in range(num_retries): 2025-08-26T19:31:43.9596935Z try: 2025-08-26T19:31:43.9597313Z req = Request(url=url, headers=headers) 2025-08-26T19:31:43.9597911Z content = urlopen(req, timeout=5).read().decode("utf-8") 2025-08-26T19:31:43.9598496Z return json.loads(content) 2025-08-26T19:31:43.9598962Z except Exception as e: 2025-08-26T19:31:43.9599453Z log.warning(f"Could not download {url}: {e}") 2025-08-26T19:31:43.9599826Z 2025-08-26T19:31:43.9600176Z log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-08-26T19:31:43.9600820Z return {} 2025-08-26T19:31:43.9601014Z 2025-08-26T19:31:43.9601026Z 2025-08-26T19:31:43.9601164Z @cache 2025-08-26T19:31:43.9601718Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-08-26T19:31:43.9602407Z """ 2025-08-26T19:31:43.9602755Z Dynamically get PR information 2025-08-26T19:31:43.9603355Z """ 2025-08-26T19:31:43.9603803Z github_api = f"https://api.github.com/repos/{github_repo}" 2025-08-26T19:31:43.9604362Z headers = { 2025-08-26T19:31:43.9604779Z "Accept": "application/vnd.github.v3+json", 2025-08-26T19:31:43.9605324Z "Authorization": f"token {github_token}", 2025-08-26T19:31:43.9605930Z } 2025-08-26T19:31:43.9606311Z json_response: dict[str, Any] = download_json( 2025-08-26T19:31:43.9606857Z url=f"{github_api}/issues/{pr_number}", 2025-08-26T19:31:43.9607348Z headers=headers, 2025-08-26T19:31:43.9607734Z ) 2025-08-26T19:31:43.9607917Z 2025-08-26T19:31:43.9608080Z if not json_response: 2025-08-26T19:31:43.9608591Z log.warning(f"Failed to get the labels for #{pr_number}") 2025-08-26T19:31:43.9609147Z return {} 2025-08-26T19:31:43.9609357Z 2025-08-26T19:31:43.9609514Z return json_response 2025-08-26T19:31:43.9609760Z 2025-08-26T19:31:43.9609775Z 2025-08-26T19:31:43.9610141Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-08-26T19:31:43.9610810Z """ 2025-08-26T19:31:43.9611290Z Dynamically get the latest list of labels from the pull request 2025-08-26T19:31:43.9611874Z """ 2025-08-26T19:31:43.9612309Z pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-08-26T19:31:43.9612865Z return { 2025-08-26T19:31:43.9613388Z label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-08-26T19:31:43.9614028Z } 2025-08-26T19:31:43.9614208Z 2025-08-26T19:31:43.9614214Z 2025-08-26T19:31:43.9614367Z def main() -> None: 2025-08-26T19:31:43.9614744Z args = parse_args() 2025-08-26T19:31:43.9614983Z 2025-08-26T19:31:43.9615182Z runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-08-26T19:31:43.9615534Z 2025-08-26T19:31:43.9615929Z # Check if the PR is opt-out 2025-08-26T19:31:43.9616389Z if args.pr_number: 2025-08-26T19:31:43.9616984Z labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-08-26T19:31:43.9617826Z if OPT_OUT_LABEL in labels: 2025-08-26T19:31:43.9618282Z log.info( 2025-08-26T19:31:43.9618918Z f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-08-26T19:31:43.9619617Z ) 2025-08-26T19:31:43.9620115Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-08-26T19:31:43.9620721Z sys.exit() 2025-08-26T19:31:43.9620952Z 2025-08-26T19:31:43.9621095Z try: 2025-08-26T19:31:43.9621487Z rollout_state = get_rollout_state_from_issue( 2025-08-26T19:31:43.9622120Z args.github_token, args.github_issue_repo, args.github_issue 2025-08-26T19:31:43.9622700Z ) 2025-08-26T19:31:43.9622879Z 2025-08-26T19:31:43.9623064Z username = get_potential_pr_author( 2025-08-26T19:31:43.9623563Z args.github_token, 2025-08-26T19:31:43.9623986Z args.github_repo, 2025-08-26T19:31:43.9624419Z args.github_actor, 2025-08-26T19:31:43.9624863Z args.github_ref_type, 2025-08-26T19:31:43.9625310Z args.github_branch, 2025-08-26T19:31:43.9625844Z ) 2025-08-26T19:31:43.9626034Z 2025-08-26T19:31:43.9626288Z is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-08-26T19:31:43.9626700Z 2025-08-26T19:31:43.9626898Z runner_label_prefix = get_runner_prefix( 2025-08-26T19:31:43.9627386Z rollout_state, 2025-08-26T19:31:43.9627820Z (args.github_issue_owner, username), 2025-08-26T19:31:43.9628313Z args.github_branch, 2025-08-26T19:31:43.9628755Z args.eligible_experiments, 2025-08-26T19:31:43.9629239Z args.opt_out_experiments, 2025-08-26T19:31:43.9629681Z is_canary, 2025-08-26T19:31:43.9630052Z ) 2025-08-26T19:31:43.9630232Z 2025-08-26T19:31:43.9630397Z except Exception as e: 2025-08-26T19:31:43.9630800Z log.error( 2025-08-26T19:31:43.9631403Z f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-08-26T19:31:43.9632228Z ) 2025-08-26T19:31:43.9632408Z 2025-08-26T19:31:43.9632705Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-08-26T19:31:43.9633161Z 2025-08-26T19:31:43.9633168Z 2025-08-26T19:31:43.9633324Z if __name__ == "__main__": 2025-08-26T19:31:43.9633712Z main() 2025-08-26T19:31:43.9633896Z 2025-08-26T19:31:43.9725573Z ##[group]Run python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-08-26T19:31:43.9726587Z python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-08-26T19:31:43.9766419Z shell: /usr/bin/bash -e {0} 2025-08-26T19:31:43.9766856Z env: 2025-08-26T19:31:43.9767417Z GITHUB_TOKEN: *** 2025-08-26T19:31:43.9767785Z ISSUE_NUMBER: 5132 2025-08-26T19:31:43.9768191Z TRIGGERING_ACTOR: pytorchmergebot 2025-08-26T19:31:43.9768640Z ISSUE_OWNER: 2025-08-26T19:31:43.9769000Z CHECK_EXPERIMENTS: 2025-08-26T19:31:43.9769388Z OPT_OUT_EXPERIMENTS: 2025-08-26T19:31:43.9769772Z PR_NUMBER: 2025-08-26T19:31:43.9770115Z ##[endgroup] 2025-08-26T19:31:45.2444526Z Defaulting to user installation because normal site-packages is not writeable 2025-08-26T19:31:46.3949571Z Collecting urllib3==1.26.18 2025-08-26T19:31:46.4283199Z Downloading urllib3-1.26.18-py2.py3-none-any.whl.metadata (48 kB) 2025-08-26T19:31:46.4476504Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 kB 4.4 MB/s eta 0:00:00 2025-08-26T19:31:46.4700104Z Collecting PyGithub==2.3.0 2025-08-26T19:31:46.4736843Z Downloading PyGithub-2.3.0-py3-none-any.whl.metadata (3.8 kB) 2025-08-26T19:31:46.5145172Z Collecting pynacl>=1.4.0 (from PyGithub==2.3.0) 2025-08-26T19:31:46.5172607Z 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-26T19:31:46.5215479Z Requirement already satisfied: requests>=2.14.0 in /usr/lib/python3/dist-packages (from PyGithub==2.3.0) (2.31.0) 2025-08-26T19:31:46.5231794Z 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-26T19:31:46.5246270Z Requirement already satisfied: typing-extensions>=4.0.0 in /usr/lib/python3/dist-packages (from PyGithub==2.3.0) (4.10.0) 2025-08-26T19:31:46.5491956Z Collecting Deprecated (from PyGithub==2.3.0) 2025-08-26T19:31:46.5517934Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl.metadata (5.7 kB) 2025-08-26T19:31:46.5741319Z 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-26T19:31:46.6837360Z Collecting cffi>=1.4.1 (from pynacl>=1.4.0->PyGithub==2.3.0) 2025-08-26T19:31:46.6887936Z Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.5 kB) 2025-08-26T19:31:46.8048907Z Collecting wrapt<2,>=1.10 (from Deprecated->PyGithub==2.3.0) 2025-08-26T19:31:46.8079947Z 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-26T19:31:46.8262809Z Collecting pycparser (from cffi>=1.4.1->pynacl>=1.4.0->PyGithub==2.3.0) 2025-08-26T19:31:46.8292542Z Downloading pycparser-2.22-py3-none-any.whl.metadata (943 bytes) 2025-08-26T19:31:46.8569296Z Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB) 2025-08-26T19:31:46.8632688Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.8/143.8 kB 32.2 MB/s eta 0:00:00 2025-08-26T19:31:46.8674865Z Downloading PyGithub-2.3.0-py3-none-any.whl (354 kB) 2025-08-26T19:31:46.8764146Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 354.4/354.4 kB 60.9 MB/s eta 0:00:00 2025-08-26T19:31:46.8796561Z 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-26T19:31:46.8898325Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 856.7/856.7 kB 102.0 MB/s eta 0:00:00 2025-08-26T19:31:46.8932358Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl (10.0 kB) 2025-08-26T19:31:46.8994233Z Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479 kB) 2025-08-26T19:31:46.9068912Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 479.4/479.4 kB 80.4 MB/s eta 0:00:00 2025-08-26T19:31:46.9097631Z 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-26T19:31:46.9178159Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 88.0/88.0 kB 12.1 MB/s eta 0:00:00 2025-08-26T19:31:46.9205370Z Downloading pycparser-2.22-py3-none-any.whl (117 kB) 2025-08-26T19:31:46.9249289Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.6/117.6 kB 38.2 MB/s eta 0:00:00 2025-08-26T19:31:47.2135190Z Installing collected packages: wrapt, urllib3, pycparser, Deprecated, cffi, pynacl, PyGithub 2025-08-26T19:31:47.7400653Z 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-26T19:31:47.8196952Z ##[group]Run curr_branch="main" 2025-08-26T19:31:47.8197278Z curr_branch="main" 2025-08-26T19:31:47.8197583Z curr_ref_type="branch" 2025-08-26T19:31:47.8197826Z echo "Current branch is '$curr_branch'" 2025-08-26T19:31:47.8198099Z  2025-08-26T19:31:47.8198310Z python3 runner_determinator.py \ 2025-08-26T19:31:47.8198592Z  --github-token "$GITHUB_TOKEN" \ 2025-08-26T19:31:47.8198871Z  --github-issue "$ISSUE_NUMBER" \ 2025-08-26T19:31:47.8199135Z  --github-branch "$curr_branch" \ 2025-08-26T19:31:47.8199418Z  --github-actor "$TRIGGERING_ACTOR" \ 2025-08-26T19:31:47.8199703Z  --github-issue-owner "$ISSUE_OWNER" \ 2025-08-26T19:31:47.8199985Z  --github-ref-type "$curr_ref_type" \ 2025-08-26T19:31:47.8200248Z  --github-repo "$GITHUB_REPOSITORY" \ 2025-08-26T19:31:47.8200557Z  --eligible-experiments "$CHECK_EXPERIMENTS" \ 2025-08-26T19:31:47.8200942Z  --opt-out-experiments "$OPT_OUT_EXPERIMENTS" \ 2025-08-26T19:31:47.8201239Z  --pr-number "${PR_NUMBER}" 2025-08-26T19:31:47.8241605Z shell: /usr/bin/bash -e {0} 2025-08-26T19:31:47.8241835Z env: 2025-08-26T19:31:47.8242300Z GITHUB_TOKEN: *** 2025-08-26T19:31:47.8242498Z ISSUE_NUMBER: 5132 2025-08-26T19:31:47.8242706Z TRIGGERING_ACTOR: pytorchmergebot 2025-08-26T19:31:47.8242942Z ISSUE_OWNER: 2025-08-26T19:31:47.8243119Z CHECK_EXPERIMENTS: 2025-08-26T19:31:47.8243305Z OPT_OUT_EXPERIMENTS: 2025-08-26T19:31:47.8243497Z PR_NUMBER: 2025-08-26T19:31:47.8243667Z ##[endgroup] 2025-08-26T19:31:47.8299315Z Current branch is 'main' 2025-08-26T19:31:49.5016322Z INFO : Based on rollout percentage of 75%, enabling experiment lf. 2025-08-26T19:31:49.5017656Z INFO : Branch main is an exception branch. Not enabling experiment ephemeral. 2025-08-26T19:31:49.5018618Z INFO : Branch main is an exception branch. Not enabling experiment wincanary. 2025-08-26T19:31:49.5019378Z INFO : Setting output: label-type='lf.' 2025-08-26T19:31:49.5334144Z Evaluate and set job outputs 2025-08-26T19:31:49.5340557Z Set output 'label-type' 2025-08-26T19:31:49.5342322Z Cleaning up orphan processes