2025-03-14T03:51:43.2360765Z Current runner version: '2.322.0' 2025-03-14T03:51:43.2386192Z ##[group]Operating System 2025-03-14T03:51:43.2386985Z Ubuntu 2025-03-14T03:51:43.2387470Z 24.04.2 2025-03-14T03:51:43.2388063Z LTS 2025-03-14T03:51:43.2388525Z ##[endgroup] 2025-03-14T03:51:43.2388998Z ##[group]Runner Image 2025-03-14T03:51:43.2389632Z Image: ubuntu-24.04 2025-03-14T03:51:43.2390148Z Version: 20250309.1.0 2025-03-14T03:51:43.2391226Z Included Software: https://github.com/actions/runner-images/blob/ubuntu24/20250309.1/images/ubuntu/Ubuntu2404-Readme.md 2025-03-14T03:51:43.2392879Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu24%2F20250309.1 2025-03-14T03:51:43.2393818Z ##[endgroup] 2025-03-14T03:51:43.2394350Z ##[group]Runner Image Provisioner 2025-03-14T03:51:43.2394965Z 2.0.422.1 2025-03-14T03:51:43.2395458Z ##[endgroup] 2025-03-14T03:51:43.2396497Z ##[group]GITHUB_TOKEN Permissions 2025-03-14T03:51:43.2398262Z Contents: read 2025-03-14T03:51:43.2398889Z Metadata: read 2025-03-14T03:51:43.2399614Z ##[endgroup] 2025-03-14T03:51:43.2403235Z Secret source: Actions 2025-03-14T03:51:43.2404193Z Prepare workflow directory 2025-03-14T03:51:43.2895356Z Prepare all required actions 2025-03-14T03:51:43.2950716Z Uses: pytorch/pytorch/.github/workflows/_runner-determinator.yml@refs/heads/main (aed0b7a742a2d7b7901790622829cbd2135049a4) 2025-03-14T03:51:43.2956349Z ##[group] Inputs 2025-03-14T03:51:43.2956949Z check_experiments: 2025-03-14T03:51:43.2957670Z triggering_actor: pytorchmergebot 2025-03-14T03:51:43.2958308Z issue_owner: 2025-03-14T03:51:43.2958862Z curr_branch: main 2025-03-14T03:51:43.2959406Z curr_ref_type: branch 2025-03-14T03:51:43.2959969Z issue_number: 5132 2025-03-14T03:51:43.2960537Z ##[endgroup] 2025-03-14T03:51:43.2961257Z Complete job name: before-test / get-label-type / runner-determinator 2025-03-14T03:51:43.8967790Z ##[group]Run cat < runner_determinator.py 2025-03-14T03:51:43.8969568Z cat < runner_determinator.py 2025-03-14T03:51:43.8970190Z # flake8: noqa: G004 2025-03-14T03:51:43.8970716Z  2025-03-14T03:51:43.8971454Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-03-14T03:51:43.8972659Z # must be kept in sync. You can do it easily by running the following command: 2025-03-14T03:51:43.8973558Z # python .github/scripts/update_runner_determinator.py 2025-03-14T03:51:43.8974232Z  2025-03-14T03:51:43.8974625Z """ 2025-03-14T03:51:43.8975298Z This runner determinator is used to determine which set of runners to run a 2025-03-14T03:51:43.8976279Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-03-14T03:51:43.8977340Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-03-14T03:51:43.8978291Z of which runners should be used to run which job. 2025-03-14T03:51:43.8978919Z  2025-03-14T03:51:43.8979587Z The configuration has two parts, the settings and a list of opted-in users, 2025-03-14T03:51:43.8980609Z separated by a line containing "---". If the line is not present, the 2025-03-14T03:51:43.8981594Z settings are considered to be empty with only the second part, the user 2025-03-14T03:51:43.8982368Z list, defined. 2025-03-14T03:51:43.8982944Z  2025-03-14T03:51:43.8983573Z The first part is a YAML block that defines the rollout settings. This can be 2025-03-14T03:51:43.8984599Z used to define any settings that are needed to determine which runners to use. 2025-03-14T03:51:43.8985537Z It's fields are defined by the RolloutSettings class below. 2025-03-14T03:51:43.8986215Z  2025-03-14T03:51:43.8986858Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-03-14T03:51:43.8987838Z The user list is also a comma separated list of additional features or 2025-03-14T03:51:43.8988957Z experiments which the user could be opted in to. 2025-03-14T03:51:43.8989593Z  2025-03-14T03:51:43.8990063Z The user list has the following rules: 2025-03-14T03:51:43.8990647Z  2025-03-14T03:51:43.8991280Z - Users are GitHub usernames, which must start with the @ prefix 2025-03-14T03:51:43.8992302Z - Each user is also a comma-separated list of features/experiments to enable 2025-03-14T03:51:43.8993509Z - A "#" prefix opts the user out of all experiments 2025-03-14T03:51:43.8994365Z  2025-03-14T03:51:43.8994994Z Example config: 2025-03-14T03:51:43.8995581Z  # A list of experiments that can be opted into. 2025-03-14T03:51:43.8996357Z  # This defines the behavior they'll induce when opted into. 2025-03-14T03:51:43.8997077Z  # Expected syntax is: 2025-03-14T03:51:43.8997838Z  # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-03-14T03:51:43.8998926Z  # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-03-14T03:51:43.8999751Z  2025-03-14T03:51:43.9000159Z  experiments: 2025-03-14T03:51:43.9000628Z  lf: 2025-03-14T03:51:43.9001094Z  rollout_percent: 25 2025-03-14T03:51:43.9001675Z  all_branches: false 2025-03-14T03:51:43.9002217Z  default: true 2025-03-14T03:51:43.9002870Z  --- 2025-03-14T03:51:43.9003287Z  2025-03-14T03:51:43.9003686Z  # Opt-ins: 2025-03-14T03:51:43.9004365Z  # Users can opt into the LF fleet by adding their GitHub username to this list 2025-03-14T03:51:43.9005547Z  # and specifying experiments to enable in a comma-separated list. 2025-03-14T03:51:43.9006436Z  # To always opt out of an experiment, prefix it with a "-". 2025-03-14T03:51:43.9007186Z  # Experiments should be from the above list. 2025-03-14T03:51:43.9007793Z  2025-03-14T03:51:43.9008202Z  @User1,-lf,split_build 2025-03-14T03:51:43.9008735Z  @User2,lf 2025-03-14T03:51:43.9009206Z  @User3,split_build 2025-03-14T03:51:43.9009730Z """ 2025-03-14T03:51:43.9010133Z  2025-03-14T03:51:43.9010538Z import json 2025-03-14T03:51:43.9010999Z import logging 2025-03-14T03:51:43.9011467Z import os 2025-03-14T03:51:43.9011913Z import random 2025-03-14T03:51:43.9012372Z import re 2025-03-14T03:51:43.9012927Z import sys 2025-03-14T03:51:43.9013441Z from argparse import ArgumentParser 2025-03-14T03:51:43.9014075Z from collections.abc import Iterable 2025-03-14T03:51:43.9014684Z from functools import cache 2025-03-14T03:51:43.9015254Z from logging import LogRecord 2025-03-14T03:51:43.9015839Z from typing import Any, NamedTuple 2025-03-14T03:51:43.9016495Z from urllib.request import Request, urlopen 2025-03-14T03:51:43.9017102Z  2025-03-14T03:51:43.9017504Z import yaml 2025-03-14T03:51:43.9017992Z from github import Auth, Github 2025-03-14T03:51:43.9018572Z from github.Issue import Issue 2025-03-14T03:51:43.9019110Z  2025-03-14T03:51:43.9019497Z  2025-03-14T03:51:43.9019973Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-03-14T03:51:43.9020765Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-03-14T03:51:43.9021741Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-03-14T03:51:43.9022622Z  2025-03-14T03:51:43.9023135Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-03-14T03:51:43.9023790Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-03-14T03:51:43.9024406Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-03-14T03:51:43.9025228Z OPT_OUT_LABEL = "no-runner-experiments" 2025-03-14T03:51:43.9025811Z  2025-03-14T03:51:43.9026251Z SETTING_EXPERIMENTS = "experiments" 2025-03-14T03:51:43.9026813Z  2025-03-14T03:51:43.9027232Z LF_FLEET_EXPERIMENT = "lf" 2025-03-14T03:51:43.9027782Z CANARY_FLEET_SUFFIX = ".c" 2025-03-14T03:51:43.9028291Z  2025-03-14T03:51:43.9028677Z  2025-03-14T03:51:43.9029105Z class Experiment(NamedTuple): 2025-03-14T03:51:43.9029674Z  rollout_perc: float = ( 2025-03-14T03:51:43.9030428Z  0 # Percentage of workflows to experiment on when user is not opted-in. 2025-03-14T03:51:43.9031224Z  ) 2025-03-14T03:51:43.9031658Z  all_branches: bool = ( 2025-03-14T03:51:43.9032405Z  False # If True, the experiment is also enabled on the exception branches 2025-03-14T03:51:43.9033489Z  ) 2025-03-14T03:51:43.9033938Z  default: bool = ( 2025-03-14T03:51:43.9034643Z  True # If True, the experiment is enabled by default for all queries 2025-03-14T03:51:43.9035358Z  ) 2025-03-14T03:51:43.9035771Z  2025-03-14T03:51:43.9036197Z  # Add more fields as needed 2025-03-14T03:51:43.9036731Z  2025-03-14T03:51:43.9037119Z  2025-03-14T03:51:43.9037536Z class Settings(NamedTuple): 2025-03-14T03:51:43.9038066Z  """ 2025-03-14T03:51:43.9038619Z  Settings for the experiments that can be opted into. 2025-03-14T03:51:43.9039267Z  """ 2025-03-14T03:51:43.9039674Z  2025-03-14T03:51:43.9040129Z  experiments: dict[str, Experiment] = {} 2025-03-14T03:51:43.9040706Z  2025-03-14T03:51:43.9041268Z  2025-03-14T03:51:43.9041749Z class ColorFormatter(logging.Formatter): 2025-03-14T03:51:43.9042661Z  """Color codes the log messages based on the log level""" 2025-03-14T03:51:43.9043341Z  2025-03-14T03:51:43.9043745Z  COLORS = { 2025-03-14T03:51:43.9044237Z  "WARNING": "\033[33m", # Yellow 2025-03-14T03:51:43.9044827Z  "ERROR": "\033[31m", # Red 2025-03-14T03:51:43.9045397Z  "CRITICAL": "\033[31m", # Red 2025-03-14T03:51:43.9045976Z  "INFO": "\033[0m", # Reset 2025-03-14T03:51:43.9046559Z  "DEBUG": "\033[0m", # Reset 2025-03-14T03:51:43.9047110Z  } 2025-03-14T03:51:43.9047529Z  2025-03-14T03:51:43.9048013Z  def format(self, record: LogRecord) -> str: 2025-03-14T03:51:43.9048880Z  log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-03-14T03:51:43.9049757Z  record.msg = f"{log_color}{record.msg}\033[0m" 2025-03-14T03:51:43.9050419Z  return super().format(record) 2025-03-14T03:51:43.9050971Z  2025-03-14T03:51:43.9051354Z  2025-03-14T03:51:43.9051805Z handler = logging.StreamHandler() 2025-03-14T03:51:43.9052754Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-03-14T03:51:43.9053557Z  2025-03-14T03:51:43.9054068Z log = logging.getLogger(os.path.basename(__file__)) 2025-03-14T03:51:43.9054732Z log.addHandler(handler) 2025-03-14T03:51:43.9055274Z log.setLevel(logging.INFO) 2025-03-14T03:51:43.9055793Z  2025-03-14T03:51:43.9056187Z  2025-03-14T03:51:43.9056704Z def set_github_output(key: str, value: str) -> None: 2025-03-14T03:51:43.9057356Z  """ 2025-03-14T03:51:43.9057972Z  Defines outputs of the github action that invokes this script 2025-03-14T03:51:43.9058695Z  """ 2025-03-14T03:51:43.9059138Z  if not GITHUB_OUTPUT: 2025-03-14T03:51:43.9060322Z  # See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ for deprecation notice 2025-03-14T03:51:43.9061661Z  log.warning( 2025-03-14T03:51:43.9062720Z  "No env var found for GITHUB_OUTPUT, you must be running this code locally. Falling back to the deprecated print method." 2025-03-14T03:51:43.9063716Z  ) 2025-03-14T03:51:43.9064229Z  print(f"::set-output name={key}::{value}") 2025-03-14T03:51:43.9064845Z  return 2025-03-14T03:51:43.9065298Z  2025-03-14T03:51:43.9065741Z  with open(GITHUB_OUTPUT, "a") as f: 2025-03-14T03:51:43.9066406Z  log.info(f"Setting output: {key}='{value}'") 2025-03-14T03:51:43.9067048Z  f.write(f"{key}={value}\n") 2025-03-14T03:51:43.9067598Z  2025-03-14T03:51:43.9067997Z  2025-03-14T03:51:43.9068573Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-03-14T03:51:43.9069301Z  return frozenset( 2025-03-14T03:51:43.9070027Z  filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-03-14T03:51:43.9070783Z  ) 2025-03-14T03:51:43.9071196Z  2025-03-14T03:51:43.9071581Z  2025-03-14T03:51:43.9072006Z def parse_args() -> Any: 2025-03-14T03:51:43.9073000Z  parser = ArgumentParser("Get dynamic rollout settings") 2025-03-14T03:51:43.9074084Z  parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-03-14T03:51:43.9074943Z  parser.add_argument( 2025-03-14T03:51:43.9075490Z  "--github-issue-repo", 2025-03-14T03:51:43.9076058Z  type=str, 2025-03-14T03:51:43.9076553Z  required=False, 2025-03-14T03:51:43.9077251Z  default="pytorch/test-infra", 2025-03-14T03:51:43.9077898Z  help="GitHub repo to get the issue", 2025-03-14T03:51:43.9078477Z  ) 2025-03-14T03:51:43.9078910Z  parser.add_argument( 2025-03-14T03:51:43.9079438Z  "--github-repo", 2025-03-14T03:51:43.9079959Z  type=str, 2025-03-14T03:51:43.9080450Z  required=True, 2025-03-14T03:51:43.9081020Z  help="GitHub repo where CI is running", 2025-03-14T03:51:43.9081610Z  ) 2025-03-14T03:51:43.9082045Z  parser.add_argument( 2025-03-14T03:51:43.9082877Z  "--github-issue", type=int, required=True, help="GitHub issue number" 2025-03-14T03:51:43.9083616Z  ) 2025-03-14T03:51:43.9084053Z  parser.add_argument( 2025-03-14T03:51:43.9084798Z  "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-03-14T03:51:43.9085554Z  ) 2025-03-14T03:51:43.9085992Z  parser.add_argument( 2025-03-14T03:51:43.9086750Z  "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-03-14T03:51:43.9087527Z  ) 2025-03-14T03:51:43.9087965Z  parser.add_argument( 2025-03-14T03:51:43.9088744Z  "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-03-14T03:51:43.9089518Z  ) 2025-03-14T03:51:43.9089953Z  parser.add_argument( 2025-03-14T03:51:43.9090494Z  "--github-ref-type", 2025-03-14T03:51:43.9091029Z  type=str, 2025-03-14T03:51:43.9091517Z  required=True, 2025-03-14T03:51:43.9092116Z  help="Current GitHub ref type, branch or tag", 2025-03-14T03:51:43.9092841Z  ) 2025-03-14T03:51:43.9093279Z  parser.add_argument( 2025-03-14T03:51:43.9093831Z  "--eligible-experiments", 2025-03-14T03:51:43.9094444Z  type=_str_comma_separated_to_set, 2025-03-14T03:51:43.9095037Z  required=False, 2025-03-14T03:51:43.9095542Z  default="", 2025-03-14T03:51:43.9096890Z  help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-03-14T03:51:43.9097918Z  ) 2025-03-14T03:51:43.9098354Z  parser.add_argument( 2025-03-14T03:51:43.9098887Z  "--pr-number", 2025-03-14T03:51:43.9099396Z  type=str, 2025-03-14T03:51:43.9099883Z  required=False, 2025-03-14T03:51:43.9100397Z  default="", 2025-03-14T03:51:43.9100980Z  help="the optional PR number where this is run", 2025-03-14T03:51:43.9101648Z  ) 2025-03-14T03:51:43.9102059Z  2025-03-14T03:51:43.9102579Z  return parser.parse_args() 2025-03-14T03:51:43.9103125Z  2025-03-14T03:51:43.9103522Z  2025-03-14T03:51:43.9104229Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-03-14T03:51:43.9105092Z  auth = Auth.Token(github_token) 2025-03-14T03:51:43.9105699Z  return Github(auth=auth) 2025-03-14T03:51:43.9106230Z  2025-03-14T03:51:43.9106616Z  2025-03-14T03:51:43.9107342Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-03-14T03:51:43.9108231Z  repo = gh.get_repo(repo) 2025-03-14T03:51:43.9108827Z  return repo.get_issue(number=issue_num) 2025-03-14T03:51:43.9109417Z  2025-03-14T03:51:43.9109801Z  2025-03-14T03:51:43.9110224Z def get_potential_pr_author( 2025-03-14T03:51:43.9110976Z  github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-03-14T03:51:43.9111733Z ) -> str: 2025-03-14T03:51:43.9112593Z  # If the trigger was a new tag added by a bot, this is a ciflow case 2025-03-14T03:51:43.9113543Z  # Fetch the actual username from the original PR. The PR number is 2025-03-14T03:51:43.9114411Z  # embedded in the tag name: ciflow// 2025-03-14T03:51:43.9115061Z  2025-03-14T03:51:43.9115497Z  gh = get_gh_client(github_token) 2025-03-14T03:51:43.9116050Z  2025-03-14T03:51:43.9116583Z  if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-03-14T03:51:43.9117295Z  split_tag = ref_name.split("/") 2025-03-14T03:51:43.9117866Z  if ( 2025-03-14T03:51:43.9118331Z  len(split_tag) == 3 2025-03-14T03:51:43.9118905Z  and split_tag[0] == "ciflow" 2025-03-14T03:51:43.9119496Z  and split_tag[2].isnumeric() 2025-03-14T03:51:43.9120048Z  ): 2025-03-14T03:51:43.9120533Z  pr_number = split_tag[2] 2025-03-14T03:51:43.9121089Z  try: 2025-03-14T03:51:43.9121613Z  repository = gh.get_repo(repo) 2025-03-14T03:51:43.9122316Z  pull = repository.get_pull(number=int(pr_number)) 2025-03-14T03:51:43.9123113Z  except Exception as e: 2025-03-14T03:51:43.9123713Z  raise Exception( # noqa: TRY002 2025-03-14T03:51:43.9124459Z  f"issue with pull request {pr_number} from repo {repository}" 2025-03-14T03:51:43.9125171Z  ) from e 2025-03-14T03:51:43.9125811Z  return pull.user.login # type: ignore[no-any-return] 2025-03-14T03:51:43.9126590Z  # In all other cases, return the original input username 2025-03-14T03:51:43.9127254Z  return username 2025-03-14T03:51:43.9127729Z  2025-03-14T03:51:43.9128101Z  2025-03-14T03:51:43.9128582Z def is_exception_branch(branch: str) -> bool: 2025-03-14T03:51:43.9129181Z  """ 2025-03-14T03:51:43.9129915Z  Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-03-14T03:51:43.9130902Z  """ 2025-03-14T03:51:43.9131522Z  return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-03-14T03:51:43.9132253Z  2025-03-14T03:51:43.9132732Z  2025-03-14T03:51:43.9133168Z def load_yaml(yaml_text: str) -> Any: 2025-03-14T03:51:43.9133725Z  try: 2025-03-14T03:51:43.9134183Z  data = yaml.safe_load(yaml_text) 2025-03-14T03:51:43.9134753Z  return data 2025-03-14T03:51:43.9135255Z  except yaml.YAMLError: 2025-03-14T03:51:43.9135834Z  log.exception("Error loading YAML") 2025-03-14T03:51:43.9136404Z  raise 2025-03-14T03:51:43.9136843Z  2025-03-14T03:51:43.9137213Z  2025-03-14T03:51:43.9137898Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-03-14T03:51:43.9138708Z  """ 2025-03-14T03:51:43.9139419Z  Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-03-14T03:51:43.9140252Z  2025-03-14T03:51:43.9140850Z  If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:43.9141701Z  and the text below is the list of opted in users. 2025-03-14T03:51:43.9142322Z  2025-03-14T03:51:43.9143063Z  If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-03-14T03:51:43.9143834Z  """ 2025-03-14T03:51:43.9144361Z  rollout_state_parts = rollout_state.split("---") 2025-03-14T03:51:43.9145023Z  if len(rollout_state_parts) >= 2: 2025-03-14T03:51:43.9145897Z  return rollout_state_parts[0], rollout_state_parts[1] 2025-03-14T03:51:43.9146566Z  else: 2025-03-14T03:51:43.9147018Z  return "", rollout_state 2025-03-14T03:51:43.9147543Z  2025-03-14T03:51:43.9147923Z  2025-03-14T03:51:43.9148369Z class UserOptins(dict[str, list[str]]): 2025-03-14T03:51:43.9148935Z  """ 2025-03-14T03:51:43.9149541Z  Dictionary of users with a list of features they have opted into 2025-03-14T03:51:43.9150251Z  """ 2025-03-14T03:51:43.9150647Z  2025-03-14T03:51:43.9151028Z  2025-03-14T03:51:43.9151617Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-03-14T03:51:43.9152346Z  """ 2025-03-14T03:51:43.9153253Z  Parse the user opt-in text into a key value pair of username and the list of features they have opted into 2025-03-14T03:51:43.9154164Z  2025-03-14T03:51:43.9155038Z  Users are GitHub usernames with the @ prefix. Each user is also a comma-separated list of features/experiments to enable. 2025-03-14T03:51:43.9156116Z  - Example line: "@User1,lf,split_build" 2025-03-14T03:51:43.9156897Z  - A "#" prefix indicates the user is opted out of all experiments 2025-03-14T03:51:43.9157598Z  2025-03-14T03:51:43.9157974Z  2025-03-14T03:51:43.9158355Z  """ 2025-03-14T03:51:43.9158780Z  optins = UserOptins() 2025-03-14T03:51:43.9159363Z  for user in user_optin_text.split("\n"): 2025-03-14T03:51:43.9160006Z  user = user.strip("\r\n\t -") 2025-03-14T03:51:43.9160640Z  if not user or not user.startswith("@"): 2025-03-14T03:51:43.9161268Z  # Not a valid user. Skip 2025-03-14T03:51:43.9161814Z  continue 2025-03-14T03:51:43.9162285Z  2025-03-14T03:51:43.9162769Z  if user: 2025-03-14T03:51:43.9163313Z  usr_name = user.split(",")[0].strip("@") 2025-03-14T03:51:43.9164088Z  optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-03-14T03:51:43.9164791Z  2025-03-14T03:51:43.9165349Z  return optins 2025-03-14T03:51:43.9165815Z  2025-03-14T03:51:43.9166190Z  2025-03-14T03:51:43.9166745Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-03-14T03:51:43.9167422Z  """ 2025-03-14T03:51:43.9167898Z  Check if the experiment name is valid. 2025-03-14T03:51:43.9168486Z  A valid name: 2025-03-14T03:51:43.9169238Z  - Contains only alphanumeric characters and the special characters "_" & "-" 2025-03-14T03:51:43.9170259Z  - The special characters "_" & "-" shouldn't be the first or last characters 2025-03-14T03:51:43.9171044Z  - Cannot contain spaces 2025-03-14T03:51:43.9171565Z  """ 2025-03-14T03:51:43.9171980Z  2025-03-14T03:51:43.9172592Z  valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-03-14T03:51:43.9173398Z  valid = bool(re.match(valid_char_regex, experiment_name)) 2025-03-14T03:51:43.9174082Z  2025-03-14T03:51:43.9174467Z  if valid: 2025-03-14T03:51:43.9174927Z  return True 2025-03-14T03:51:43.9175393Z  2025-03-14T03:51:43.9175781Z  log.error( 2025-03-14T03:51:43.9177355Z  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-03-14T03:51:43.9179002Z  ) 2025-03-14T03:51:43.9179408Z  return False 2025-03-14T03:51:43.9179859Z  2025-03-14T03:51:43.9180227Z  2025-03-14T03:51:43.9180923Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-03-14T03:51:43.9181634Z  """ 2025-03-14T03:51:43.9182299Z  Parse the experiments from the issue body into a list of ExperimentSettings 2025-03-14T03:51:43.9183194Z  """ 2025-03-14T03:51:43.9183606Z  try: 2025-03-14T03:51:43.9184032Z  if settings_text: 2025-03-14T03:51:43.9184866Z  # Escape the backtick as well so that we can have the settings in a code block on the GH issue 2025-03-14T03:51:43.9185731Z  # for easy reading 2025-03-14T03:51:43.9186620Z  # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-03-14T03:51:43.9187621Z  # the backtick character in shell commands. 2025-03-14T03:51:43.9188305Z  backtick = chr(96) # backtick character 2025-03-14T03:51:43.9189050Z  settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-03-14T03:51:43.9189800Z  settings = load_yaml(settings_text) 2025-03-14T03:51:43.9190361Z  2025-03-14T03:51:43.9191013Z  # For now we just load experiments. We can expand this if/when we add more settings 2025-03-14T03:51:43.9191843Z  experiments = {} 2025-03-14T03:51:43.9192354Z  2025-03-14T03:51:43.9193079Z  for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-03-14T03:51:43.9193921Z  if not is_valid_experiment_name(exp_name): 2025-03-14T03:51:43.9195136Z  # 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-03-14T03:51:43.9196258Z  continue 2025-03-14T03:51:43.9196756Z  2025-03-14T03:51:43.9197176Z  valid_settings = {} 2025-03-14T03:51:43.9197778Z  for setting in exp_settings: 2025-03-14T03:51:43.9198419Z  if setting not in Experiment._fields: 2025-03-14T03:51:43.9199057Z  log.warning( 2025-03-14T03:51:43.9200005Z  f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-03-14T03:51:43.9200800Z  ) 2025-03-14T03:51:43.9201342Z  else: 2025-03-14T03:51:43.9201959Z  valid_settings[setting] = exp_settings[setting] 2025-03-14T03:51:43.9202693Z  2025-03-14T03:51:43.9203228Z  experiments[exp_name] = Experiment(**valid_settings) 2025-03-14T03:51:43.9203934Z  return Settings(experiments) 2025-03-14T03:51:43.9204489Z  2025-03-14T03:51:43.9204894Z  except Exception: 2025-03-14T03:51:43.9205469Z  log.exception("Failed to parse settings") 2025-03-14T03:51:43.9206071Z  2025-03-14T03:51:43.9206462Z  return Settings() 2025-03-14T03:51:43.9206942Z  2025-03-14T03:51:43.9207317Z  2025-03-14T03:51:43.9207831Z def parse_settings(rollout_state: str) -> Settings: 2025-03-14T03:51:43.9208473Z  """ 2025-03-14T03:51:43.9208987Z  Parse settings, if any, from the rollout state. 2025-03-14T03:51:43.9209597Z  2025-03-14T03:51:43.9210193Z  If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:43.9211051Z  and the text below is the list of opted in users. 2025-03-14T03:51:43.9211684Z  2025-03-14T03:51:43.9212349Z  If it doesn't contain "---" then the settings are empty and the default values are used. 2025-03-14T03:51:43.9213244Z  """ 2025-03-14T03:51:43.9213890Z  settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:43.9214866Z  return parse_settings_from_text(settings_text) 2025-03-14T03:51:43.9215488Z  2025-03-14T03:51:43.9215874Z  2025-03-14T03:51:43.9216374Z def parse_users(rollout_state: str) -> UserOptins: 2025-03-14T03:51:43.9217018Z  """ 2025-03-14T03:51:43.9217485Z  Parse users from the rollout state. 2025-03-14T03:51:43.9218048Z  2025-03-14T03:51:43.9218429Z  """ 2025-03-14T03:51:43.9219040Z  _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:43.9219869Z  return parse_user_opt_in_from_text(users_text) 2025-03-14T03:51:43.9220474Z  2025-03-14T03:51:43.9220853Z  2025-03-14T03:51:43.9221534Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:43.9222355Z  """ 2025-03-14T03:51:43.9222953Z  Check if a user is opted into an experiment 2025-03-14T03:51:43.9223558Z  """ 2025-03-14T03:51:43.9224098Z  return experiment_name in user_optins.get(user, []) 2025-03-14T03:51:43.9224740Z  2025-03-14T03:51:43.9225121Z  2025-03-14T03:51:43.9225809Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:43.9226640Z  """ 2025-03-14T03:51:43.9227184Z  Check if a user explicitly opted out of an experiment 2025-03-14T03:51:43.9227832Z  """ 2025-03-14T03:51:43.9228423Z  # if the experiment is prefixed with a "-", then it's an opt-out 2025-03-14T03:51:43.9229209Z  experiment_optout = "-" + experiment_name 2025-03-14T03:51:43.9229928Z  if experiment_optout not in user_optins.get(user, []): 2025-03-14T03:51:43.9230595Z  return False 2025-03-14T03:51:43.9231062Z  2025-03-14T03:51:43.9231586Z  if is_user_opted_in(user, user_optins, experiment_name): 2025-03-14T03:51:43.9232257Z  log.warning( 2025-03-14T03:51:43.9233261Z  f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-03-14T03:51:43.9234327Z  ) 2025-03-14T03:51:43.9234746Z  2025-03-14T03:51:43.9235139Z  return True 2025-03-14T03:51:43.9235595Z  2025-03-14T03:51:43.9235969Z  2025-03-14T03:51:43.9236366Z def get_runner_prefix( 2025-03-14T03:51:43.9236880Z  rollout_state: str, 2025-03-14T03:51:43.9237433Z  workflow_requestors: Iterable[str], 2025-03-14T03:51:43.9238015Z  branch: str, 2025-03-14T03:51:43.9238596Z  eligible_experiments: frozenset[str] = frozenset(), 2025-03-14T03:51:43.9239259Z  is_canary: bool = False, 2025-03-14T03:51:43.9239779Z ) -> str: 2025-03-14T03:51:43.9240281Z  settings = parse_settings(rollout_state) 2025-03-14T03:51:43.9240934Z  user_optins = parse_users(rollout_state) 2025-03-14T03:51:43.9241499Z  2025-03-14T03:51:43.9241893Z  fleet_prefix = "" 2025-03-14T03:51:43.9242396Z  prefixes = [] 2025-03-14T03:51:43.9243227Z  for experiment_name, experiment_settings in settings.experiments.items(): 2025-03-14T03:51:43.9244268Z  if not experiment_settings.all_branches and is_exception_branch(branch): 2025-03-14T03:51:43.9245049Z  log.info( 2025-03-14T03:51:43.9245821Z  f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-03-14T03:51:43.9246643Z  ) 2025-03-14T03:51:43.9247095Z  continue 2025-03-14T03:51:43.9247561Z  2025-03-14T03:51:43.9247974Z  if eligible_experiments: 2025-03-14T03:51:43.9248759Z  if experiment_name not in eligible_experiments: 2025-03-14T03:51:43.9249483Z  exp_list = ", ".join(eligible_experiments) 2025-03-14T03:51:43.9250097Z  log.info( 2025-03-14T03:51:43.9250984Z  f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-03-14T03:51:43.9251894Z  ) 2025-03-14T03:51:43.9252384Z  continue 2025-03-14T03:51:43.9253058Z  elif not experiment_settings.default: 2025-03-14T03:51:43.9253647Z  log.info( 2025-03-14T03:51:43.9254411Z  f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-03-14T03:51:43.9255273Z  ) 2025-03-14T03:51:43.9255730Z  continue 2025-03-14T03:51:43.9256200Z  2025-03-14T03:51:43.9256722Z  # Is any workflow_requestor opted out to this experiment? 2025-03-14T03:51:43.9257413Z  opted_out_users = [ 2025-03-14T03:51:43.9257941Z  requestor 2025-03-14T03:51:43.9258490Z  for requestor in workflow_requestors 2025-03-14T03:51:43.9259252Z  if is_user_opted_out(requestor, user_optins, experiment_name) 2025-03-14T03:51:43.9259939Z  ] 2025-03-14T03:51:43.9260350Z  2025-03-14T03:51:43.9260749Z  if opted_out_users: 2025-03-14T03:51:43.9261275Z  log.info( 2025-03-14T03:51:43.9261988Z  f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-03-14T03:51:43.9262844Z  ) 2025-03-14T03:51:43.9263287Z  continue 2025-03-14T03:51:43.9263753Z  2025-03-14T03:51:43.9264269Z  # Is any workflow_requestor opted in to this experiment? 2025-03-14T03:51:43.9264944Z  opted_in_users = [ 2025-03-14T03:51:43.9265477Z  requestor 2025-03-14T03:51:43.9266019Z  for requestor in workflow_requestors 2025-03-14T03:51:43.9266761Z  if is_user_opted_in(requestor, user_optins, experiment_name) 2025-03-14T03:51:43.9267701Z  ] 2025-03-14T03:51:43.9268115Z  2025-03-14T03:51:43.9268520Z  enabled = False 2025-03-14T03:51:43.9269040Z  if opted_in_users: 2025-03-14T03:51:43.9269550Z  log.info( 2025-03-14T03:51:43.9270255Z  f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-03-14T03:51:43.9271012Z  ) 2025-03-14T03:51:43.9271488Z  enabled = True 2025-03-14T03:51:43.9271993Z  2025-03-14T03:51:43.9272549Z  elif experiment_settings.rollout_perc: 2025-03-14T03:51:43.9273538Z  # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-03-14T03:51:43.9274569Z  if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-03-14T03:51:43.9275292Z  log.info( 2025-03-14T03:51:43.9276276Z  f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-03-14T03:51:43.9277274Z  ) 2025-03-14T03:51:43.9277753Z  enabled = True 2025-03-14T03:51:43.9278268Z  2025-03-14T03:51:43.9278666Z  if enabled: 2025-03-14T03:51:43.9279185Z  label = experiment_name 2025-03-14T03:51:43.9279817Z  if experiment_name == LF_FLEET_EXPERIMENT: 2025-03-14T03:51:43.9280730Z  # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-03-14T03:51:43.9282394Z  # - If it's enabled, then we always list it's prefix first 2025-03-14T03:51:43.9283745Z  # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-03-14T03:51:43.9284653Z  if is_canary: 2025-03-14T03:51:43.9285423Z  label += CANARY_FLEET_SUFFIX 2025-03-14T03:51:43.9286066Z  fleet_prefix = label 2025-03-14T03:51:43.9286830Z  else: 2025-03-14T03:51:43.9287518Z  prefixes.append(label) 2025-03-14T03:51:43.9288104Z  2025-03-14T03:51:43.9288518Z  if len(prefixes) > 1: 2025-03-14T03:51:43.9289036Z  log.error( 2025-03-14T03:51:43.9290183Z  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-03-14T03:51:43.9291366Z  ) 2025-03-14T03:51:43.9291811Z  prefixes = prefixes[:1] 2025-03-14T03:51:43.9292350Z  2025-03-14T03:51:43.9292923Z  # Fleet always comes first 2025-03-14T03:51:43.9293471Z  if fleet_prefix: 2025-03-14T03:51:43.9293999Z  prefixes.insert(0, fleet_prefix) 2025-03-14T03:51:43.9294556Z  2025-03-14T03:51:43.9295057Z  return ".".join(prefixes) + "." if prefixes else "" 2025-03-14T03:51:43.9295695Z  2025-03-14T03:51:43.9296069Z  2025-03-14T03:51:43.9296772Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-03-14T03:51:43.9297617Z  """ 2025-03-14T03:51:43.9298277Z  Gets the first comment of the issue, which contains the desired rollout state. 2025-03-14T03:51:43.9299044Z  2025-03-14T03:51:43.9299673Z  The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-03-14T03:51:43.9300436Z  """ 2025-03-14T03:51:43.9300896Z  gh = get_gh_client(github_token) 2025-03-14T03:51:43.9301546Z  issue = get_issue(gh, repo, issue_num) 2025-03-14T03:51:43.9302259Z  return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-03-14T03:51:43.9303206Z  2025-03-14T03:51:43.9303581Z  2025-03-14T03:51:43.9304227Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-03-14T03:51:43.9305043Z  for _ in range(num_retries): 2025-03-14T03:51:43.9305566Z  try: 2025-03-14T03:51:43.9306064Z  req = Request(url=url, headers=headers) 2025-03-14T03:51:43.9306787Z  content = urlopen(req, timeout=5).read().decode("utf-8") 2025-03-14T03:51:43.9307502Z  return json.loads(content) 2025-03-14T03:51:43.9308089Z  except Exception as e: 2025-03-14T03:51:43.9308724Z  log.warning(f"Could not download {url}: {e}") 2025-03-14T03:51:43.9309334Z  2025-03-14T03:51:43.9309967Z  log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-03-14T03:51:43.9310738Z  return {} 2025-03-14T03:51:43.9311179Z  2025-03-14T03:51:43.9311550Z  2025-03-14T03:51:43.9311923Z @cache 2025-03-14T03:51:43.9312729Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-03-14T03:51:43.9313551Z  """ 2025-03-14T03:51:43.9314011Z  Dynamically get PR information 2025-03-14T03:51:43.9384358Z  """ 2025-03-14T03:51:43.9385058Z  github_api = f"https://api.github.com/repos/{github_repo}" 2025-03-14T03:51:43.9385846Z  headers = { 2025-03-14T03:51:43.9386435Z  "Accept": "application/vnd.github.v3+json", 2025-03-14T03:51:43.9387121Z  "Authorization": f"token {github_token}", 2025-03-14T03:51:43.9387745Z  } 2025-03-14T03:51:43.9388466Z  json_response: dict[str, Any] = download_json( 2025-03-14T03:51:43.9389178Z  url=f"{github_api}/issues/{pr_number}", 2025-03-14T03:51:43.9389790Z  headers=headers, 2025-03-14T03:51:43.9390285Z  ) 2025-03-14T03:51:43.9390686Z  2025-03-14T03:51:43.9391089Z  if not json_response: 2025-03-14T03:51:43.9391762Z  log.warning(f"Failed to get the labels for #{pr_number}") 2025-03-14T03:51:43.9392594Z  return {} 2025-03-14T03:51:43.9393061Z  2025-03-14T03:51:43.9393471Z  return json_response 2025-03-14T03:51:43.9393980Z  2025-03-14T03:51:43.9394351Z  2025-03-14T03:51:43.9395008Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-03-14T03:51:43.9395792Z  """ 2025-03-14T03:51:43.9396396Z  Dynamically get the latest list of labels from the pull request 2025-03-14T03:51:43.9397108Z  """ 2025-03-14T03:51:43.9397662Z  pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-03-14T03:51:43.9398325Z  return { 2025-03-14T03:51:43.9398983Z  label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-03-14T03:51:43.9399732Z  } 2025-03-14T03:51:43.9400131Z  2025-03-14T03:51:43.9400511Z  2025-03-14T03:51:43.9400914Z def main() -> None: 2025-03-14T03:51:43.9401451Z  args = parse_args() 2025-03-14T03:51:43.9401944Z  2025-03-14T03:51:43.9402409Z  runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-03-14T03:51:43.9403093Z  2025-03-14T03:51:43.9403510Z  # Check if the PR is opt-out 2025-03-14T03:51:43.9404067Z  if args.pr_number: 2025-03-14T03:51:43.9404810Z  labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-03-14T03:51:43.9405630Z  if OPT_OUT_LABEL in labels: 2025-03-14T03:51:43.9406182Z  log.info( 2025-03-14T03:51:43.9406964Z  f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-03-14T03:51:43.9407926Z  ) 2025-03-14T03:51:43.9408561Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:43.9409281Z  sys.exit() 2025-03-14T03:51:43.9409761Z  2025-03-14T03:51:43.9410135Z  try: 2025-03-14T03:51:43.9410638Z  rollout_state = get_rollout_state_from_issue( 2025-03-14T03:51:43.9411416Z  args.github_token, args.github_issue_repo, args.github_issue 2025-03-14T03:51:43.9412097Z  ) 2025-03-14T03:51:43.9412736Z  2025-03-14T03:51:43.9413271Z  username = get_potential_pr_author( 2025-03-14T03:51:43.9413888Z  args.github_token, 2025-03-14T03:51:43.9414474Z  args.github_repo, 2025-03-14T03:51:43.9415028Z  args.github_actor, 2025-03-14T03:51:43.9415594Z  args.github_ref_type, 2025-03-14T03:51:43.9416161Z  args.github_branch, 2025-03-14T03:51:43.9416713Z  ) 2025-03-14T03:51:43.9417120Z  2025-03-14T03:51:43.9417657Z  is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-03-14T03:51:43.9418326Z  2025-03-14T03:51:43.9418790Z  runner_label_prefix = get_runner_prefix( 2025-03-14T03:51:43.9419398Z  rollout_state, 2025-03-14T03:51:43.9419975Z  (args.github_issue_owner, username), 2025-03-14T03:51:43.9420589Z  args.github_branch, 2025-03-14T03:51:43.9421173Z  args.eligible_experiments, 2025-03-14T03:51:43.9421748Z  is_canary, 2025-03-14T03:51:43.9422395Z  ) 2025-03-14T03:51:43.9423386Z  2025-03-14T03:51:43.9423799Z  except Exception as e: 2025-03-14T03:51:43.9424320Z  log.error( 2025-03-14T03:51:43.9425102Z  f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-03-14T03:51:43.9425917Z  ) 2025-03-14T03:51:43.9426322Z  2025-03-14T03:51:43.9426902Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:43.9427603Z  2025-03-14T03:51:43.9427975Z  2025-03-14T03:51:43.9428374Z if __name__ == "__main__": 2025-03-14T03:51:43.9428878Z  main() 2025-03-14T03:51:43.9429299Z  2025-03-14T03:51:43.9429665Z EOF 2025-03-14T03:51:43.9430055Z  2025-03-14T03:51:43.9430465Z cat runner_determinator.py 2025-03-14T03:51:43.9956177Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:43.9957095Z env: 2025-03-14T03:51:43.9957879Z GITHUB_TOKEN: *** 2025-03-14T03:51:43.9958334Z ISSUE_NUMBER: 5132 2025-03-14T03:51:43.9958815Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:43.9959342Z ISSUE_OWNER: 2025-03-14T03:51:43.9959786Z CHECK_EXPERIMENTS: 2025-03-14T03:51:43.9960235Z PR_NUMBER: 2025-03-14T03:51:43.9960642Z ##[endgroup] 2025-03-14T03:51:44.0179616Z # flake8: noqa: G004 2025-03-14T03:51:44.0179971Z 2025-03-14T03:51:44.0180414Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-03-14T03:51:44.0181392Z # must be kept in sync. You can do it easily by running the following command: 2025-03-14T03:51:44.0182222Z # python .github/scripts/update_runner_determinator.py 2025-03-14T03:51:44.0182948Z 2025-03-14T03:51:44.0183125Z """ 2025-03-14T03:51:44.0183725Z This runner determinator is used to determine which set of runners to run a 2025-03-14T03:51:44.0184636Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-03-14T03:51:44.0185591Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-03-14T03:51:44.0186438Z of which runners should be used to run which job. 2025-03-14T03:51:44.0186843Z 2025-03-14T03:51:44.0187497Z The configuration has two parts, the settings and a list of opted-in users, 2025-03-14T03:51:44.0188418Z separated by a line containing "---". If the line is not present, the 2025-03-14T03:51:44.0189312Z settings are considered to be empty with only the second part, the user 2025-03-14T03:51:44.0190017Z list, defined. 2025-03-14T03:51:44.0190252Z 2025-03-14T03:51:44.0190628Z The first part is a YAML block that defines the rollout settings. This can be 2025-03-14T03:51:44.0191578Z used to define any settings that are needed to determine which runners to use. 2025-03-14T03:51:44.0192676Z It's fields are defined by the RolloutSettings class below. 2025-03-14T03:51:44.0193168Z 2025-03-14T03:51:44.0193570Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-03-14T03:51:44.0194470Z The user list is also a comma separated list of additional features or 2025-03-14T03:51:44.0195214Z experiments which the user could be opted in to. 2025-03-14T03:51:44.0195630Z 2025-03-14T03:51:44.0195843Z The user list has the following rules: 2025-03-14T03:51:44.0196202Z 2025-03-14T03:51:44.0196521Z - Users are GitHub usernames, which must start with the @ prefix 2025-03-14T03:51:44.0197399Z - Each user is also a comma-separated list of features/experiments to enable 2025-03-14T03:51:44.0198178Z - A "#" prefix opts the user out of all experiments 2025-03-14T03:51:44.0198578Z 2025-03-14T03:51:44.0198760Z Example config: 2025-03-14T03:51:44.0199221Z # A list of experiments that can be opted into. 2025-03-14T03:51:44.0199910Z # This defines the behavior they'll induce when opted into. 2025-03-14T03:51:44.0200557Z # Expected syntax is: 2025-03-14T03:51:44.0201218Z # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-03-14T03:51:44.0202356Z # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-03-14T03:51:44.0203251Z 2025-03-14T03:51:44.0203440Z experiments: 2025-03-14T03:51:44.0203846Z lf: 2025-03-14T03:51:44.0204252Z rollout_percent: 25 2025-03-14T03:51:44.0204725Z all_branches: false 2025-03-14T03:51:44.0205192Z default: true 2025-03-14T03:51:44.0205609Z --- 2025-03-14T03:51:44.0205815Z 2025-03-14T03:51:44.0205986Z # Opt-ins: 2025-03-14T03:51:44.0206613Z # Users can opt into the LF fleet by adding their GitHub username to this list 2025-03-14T03:51:44.0207495Z # and specifying experiments to enable in a comma-separated list. 2025-03-14T03:51:44.0208295Z # To always opt out of an experiment, prefix it with a "-". 2025-03-14T03:51:44.0208961Z # Experiments should be from the above list. 2025-03-14T03:51:44.0209352Z 2025-03-14T03:51:44.0209541Z @User1,-lf,split_build 2025-03-14T03:51:44.0209996Z @User2,lf 2025-03-14T03:51:44.0210400Z @User3,split_build 2025-03-14T03:51:44.0210820Z """ 2025-03-14T03:51:44.0211017Z 2025-03-14T03:51:44.0211188Z import json 2025-03-14T03:51:44.0211575Z import logging 2025-03-14T03:51:44.0211983Z import os 2025-03-14T03:51:44.0212367Z import random 2025-03-14T03:51:44.0212981Z import re 2025-03-14T03:51:44.0213356Z import sys 2025-03-14T03:51:44.0213779Z from argparse import ArgumentParser 2025-03-14T03:51:44.0214356Z from collections.abc import Iterable 2025-03-14T03:51:44.0214908Z from functools import cache 2025-03-14T03:51:44.0215399Z from logging import LogRecord 2025-03-14T03:51:44.0215926Z from typing import Any, NamedTuple 2025-03-14T03:51:44.0216479Z from urllib.request import Request, urlopen 2025-03-14T03:51:44.0216859Z 2025-03-14T03:51:44.0217030Z import yaml 2025-03-14T03:51:44.0217453Z from github import Auth, Github 2025-03-14T03:51:44.0217964Z from github.Issue import Issue 2025-03-14T03:51:44.0218285Z 2025-03-14T03:51:44.0218292Z 2025-03-14T03:51:44.0218531Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-03-14T03:51:44.0219240Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-03-14T03:51:44.0220125Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-03-14T03:51:44.0220878Z 2025-03-14T03:51:44.0221118Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-03-14T03:51:44.0221715Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-03-14T03:51:44.0222242Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-03-14T03:51:44.0222973Z OPT_OUT_LABEL = "no-runner-experiments" 2025-03-14T03:51:44.0223339Z 2025-03-14T03:51:44.0223548Z SETTING_EXPERIMENTS = "experiments" 2025-03-14T03:51:44.0223880Z 2025-03-14T03:51:44.0224077Z LF_FLEET_EXPERIMENT = "lf" 2025-03-14T03:51:44.0224548Z CANARY_FLEET_SUFFIX = ".c" 2025-03-14T03:51:44.0224838Z 2025-03-14T03:51:44.0224845Z 2025-03-14T03:51:44.0225040Z class Experiment(NamedTuple): 2025-03-14T03:51:44.0225536Z rollout_perc: float = ( 2025-03-14T03:51:44.0226200Z 0 # Percentage of workflows to experiment on when user is not opted-in. 2025-03-14T03:51:44.0226893Z ) 2025-03-14T03:51:44.0227272Z all_branches: bool = ( 2025-03-14T03:51:44.0227918Z False # If True, the experiment is also enabled on the exception branches 2025-03-14T03:51:44.0228618Z ) 2025-03-14T03:51:44.0228997Z default: bool = ( 2025-03-14T03:51:44.0229588Z True # If True, the experiment is enabled by default for all queries 2025-03-14T03:51:44.0230248Z ) 2025-03-14T03:51:44.0230456Z 2025-03-14T03:51:44.0230644Z # Add more fields as needed 2025-03-14T03:51:44.0230962Z 2025-03-14T03:51:44.0230969Z 2025-03-14T03:51:44.0231162Z class Settings(NamedTuple): 2025-03-14T03:51:44.0231620Z """ 2025-03-14T03:51:44.0232091Z Settings for the experiments that can be opted into. 2025-03-14T03:51:44.0232804Z """ 2025-03-14T03:51:44.0233016Z 2025-03-14T03:51:44.0233232Z experiments: dict[str, Experiment] = {} 2025-03-14T03:51:44.0233609Z 2025-03-14T03:51:44.0233616Z 2025-03-14T03:51:44.0233963Z class ColorFormatter(logging.Formatter): 2025-03-14T03:51:44.0234614Z """Color codes the log messages based on the log level""" 2025-03-14T03:51:44.0235054Z 2025-03-14T03:51:44.0235228Z COLORS = { 2025-03-14T03:51:44.0235645Z "WARNING": "\033[33m", # Yellow 2025-03-14T03:51:44.0236162Z "ERROR": "\033[31m", # Red 2025-03-14T03:51:44.0236670Z "CRITICAL": "\033[31m", # Red 2025-03-14T03:51:44.0237183Z "INFO": "\033[0m", # Reset 2025-03-14T03:51:44.0237685Z "DEBUG": "\033[0m", # Reset 2025-03-14T03:51:44.0238169Z } 2025-03-14T03:51:44.0238368Z 2025-03-14T03:51:44.0238591Z def format(self, record: LogRecord) -> str: 2025-03-14T03:51:44.0239358Z log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-03-14T03:51:44.0240152Z record.msg = f"{log_color}{record.msg}\033[0m" 2025-03-14T03:51:44.0240749Z return super().format(record) 2025-03-14T03:51:44.0241111Z 2025-03-14T03:51:44.0241118Z 2025-03-14T03:51:44.0241332Z handler = logging.StreamHandler() 2025-03-14T03:51:44.0242063Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-03-14T03:51:44.0242763Z 2025-03-14T03:51:44.0243029Z log = logging.getLogger(os.path.basename(__file__)) 2025-03-14T03:51:44.0243640Z log.addHandler(handler) 2025-03-14T03:51:44.0244101Z log.setLevel(logging.INFO) 2025-03-14T03:51:44.0244395Z 2025-03-14T03:51:44.0244409Z 2025-03-14T03:51:44.0244673Z def set_github_output(key: str, value: str) -> None: 2025-03-14T03:51:44.0245256Z """ 2025-03-14T03:51:44.0245776Z Defines outputs of the github action that invokes this script 2025-03-14T03:51:44.0246417Z """ 2025-03-14T03:51:44.0246803Z if not GITHUB_OUTPUT: 2025-03-14T03:51:44.0247896Z # See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ for deprecation notice 2025-03-14T03:51:44.0249031Z log.warning( 2025-03-14T03:51:44.0249912Z "No env var found for GITHUB_OUTPUT, you must be running this code locally. Falling back to the deprecated print method." 2025-03-14T03:51:44.0250866Z ) 2025-03-14T03:51:44.0260631Z print(f"::set-output name={key}::{value}") 2025-03-14T03:51:44.0261462Z return 2025-03-14T03:51:44.0261705Z 2025-03-14T03:51:44.0261916Z with open(GITHUB_OUTPUT, "a") as f: 2025-03-14T03:51:44.0262684Z log.info(f"Setting output: {key}='{value}'") 2025-03-14T03:51:44.0263278Z f.write(f"{key}={value}\n") 2025-03-14T03:51:44.0263617Z 2025-03-14T03:51:44.0263626Z 2025-03-14T03:51:44.0263939Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-03-14T03:51:44.0264593Z return frozenset( 2025-03-14T03:51:44.0265226Z filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-03-14T03:51:44.0265930Z ) 2025-03-14T03:51:44.0266133Z 2025-03-14T03:51:44.0266140Z 2025-03-14T03:51:44.0266342Z def parse_args() -> Any: 2025-03-14T03:51:44.0266918Z parser = ArgumentParser("Get dynamic rollout settings") 2025-03-14T03:51:44.0267843Z parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-03-14T03:51:44.0268643Z parser.add_argument( 2025-03-14T03:51:44.0269119Z "--github-issue-repo", 2025-03-14T03:51:44.0269598Z type=str, 2025-03-14T03:51:44.0270005Z required=False, 2025-03-14T03:51:44.0270480Z default="pytorch/test-infra", 2025-03-14T03:51:44.0271026Z help="GitHub repo to get the issue", 2025-03-14T03:51:44.0271567Z ) 2025-03-14T03:51:44.0271946Z parser.add_argument( 2025-03-14T03:51:44.0272404Z "--github-repo", 2025-03-14T03:51:44.0273001Z type=str, 2025-03-14T03:51:44.0273418Z required=True, 2025-03-14T03:51:44.0273897Z help="GitHub repo where CI is running", 2025-03-14T03:51:44.0274432Z ) 2025-03-14T03:51:44.0274818Z parser.add_argument( 2025-03-14T03:51:44.0275437Z "--github-issue", type=int, required=True, help="GitHub issue number" 2025-03-14T03:51:44.0276242Z ) 2025-03-14T03:51:44.0276636Z parser.add_argument( 2025-03-14T03:51:44.0277288Z "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-03-14T03:51:44.0277987Z ) 2025-03-14T03:51:44.0278369Z parser.add_argument( 2025-03-14T03:51:44.0279015Z "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-03-14T03:51:44.0279726Z ) 2025-03-14T03:51:44.0280100Z parser.add_argument( 2025-03-14T03:51:44.0280758Z "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-03-14T03:51:44.0281483Z ) 2025-03-14T03:51:44.0281863Z parser.add_argument( 2025-03-14T03:51:44.0282327Z "--github-ref-type", 2025-03-14T03:51:44.0282937Z type=str, 2025-03-14T03:51:44.0283347Z required=True, 2025-03-14T03:51:44.0283848Z help="Current GitHub ref type, branch or tag", 2025-03-14T03:51:44.0284410Z ) 2025-03-14T03:51:44.0284793Z parser.add_argument( 2025-03-14T03:51:44.0285270Z "--eligible-experiments", 2025-03-14T03:51:44.0285789Z type=_str_comma_separated_to_set, 2025-03-14T03:51:44.0286332Z required=False, 2025-03-14T03:51:44.0286771Z default="", 2025-03-14T03:51:44.0287636Z help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-03-14T03:51:44.0288602Z ) 2025-03-14T03:51:44.0288984Z parser.add_argument( 2025-03-14T03:51:44.0289457Z "--pr-number", 2025-03-14T03:51:44.0289901Z type=str, 2025-03-14T03:51:44.0290321Z required=False, 2025-03-14T03:51:44.0290754Z default="", 2025-03-14T03:51:44.0291241Z help="the optional PR number where this is run", 2025-03-14T03:51:44.0291809Z ) 2025-03-14T03:51:44.0292018Z 2025-03-14T03:51:44.0292218Z return parser.parse_args() 2025-03-14T03:51:44.0292661Z 2025-03-14T03:51:44.0292668Z 2025-03-14T03:51:44.0293109Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-03-14T03:51:44.0293896Z auth = Auth.Token(github_token) 2025-03-14T03:51:44.0294413Z return Github(auth=auth) 2025-03-14T03:51:44.0294720Z 2025-03-14T03:51:44.0294860Z 2025-03-14T03:51:44.0295334Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-03-14T03:51:44.0296166Z repo = gh.get_repo(repo) 2025-03-14T03:51:44.0296684Z return repo.get_issue(number=issue_num) 2025-03-14T03:51:44.0297057Z 2025-03-14T03:51:44.0297064Z 2025-03-14T03:51:44.0297267Z def get_potential_pr_author( 2025-03-14T03:51:44.0297924Z github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-03-14T03:51:44.0298609Z ) -> str: 2025-03-14T03:51:44.0299137Z # If the trigger was a new tag added by a bot, this is a ciflow case 2025-03-14T03:51:44.0299959Z # Fetch the actual username from the original PR. The PR number is 2025-03-14T03:51:44.0300715Z # embedded in the tag name: ciflow// 2025-03-14T03:51:44.0301139Z 2025-03-14T03:51:44.0301342Z gh = get_gh_client(github_token) 2025-03-14T03:51:44.0301682Z 2025-03-14T03:51:44.0301958Z if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-03-14T03:51:44.0302750Z split_tag = ref_name.split("/") 2025-03-14T03:51:44.0303276Z if ( 2025-03-14T03:51:44.0303682Z len(split_tag) == 3 2025-03-14T03:51:44.0304189Z and split_tag[0] == "ciflow" 2025-03-14T03:51:44.0304725Z and split_tag[2].isnumeric() 2025-03-14T03:51:44.0305230Z ): 2025-03-14T03:51:44.0305634Z pr_number = split_tag[2] 2025-03-14T03:51:44.0306525Z try: 2025-03-14T03:51:44.0307342Z repository = gh.get_repo(repo) 2025-03-14T03:51:44.0308563Z pull = repository.get_pull(number=int(pr_number)) 2025-03-14T03:51:44.0309816Z except Exception as e: 2025-03-14T03:51:44.0310840Z raise Exception( # noqa: TRY002 2025-03-14T03:51:44.0312157Z f"issue with pull request {pr_number} from repo {repository}" 2025-03-14T03:51:44.0313456Z ) from e 2025-03-14T03:51:44.0314325Z return pull.user.login # type: ignore[no-any-return] 2025-03-14T03:51:44.0315487Z # In all other cases, return the original input username 2025-03-14T03:51:44.0316535Z return username 2025-03-14T03:51:44.0316978Z 2025-03-14T03:51:44.0316988Z 2025-03-14T03:51:44.0317407Z def is_exception_branch(branch: str) -> bool: 2025-03-14T03:51:44.0317983Z """ 2025-03-14T03:51:44.0318637Z Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-03-14T03:51:44.0319414Z """ 2025-03-14T03:51:44.0319967Z return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-03-14T03:51:44.0320495Z 2025-03-14T03:51:44.0320506Z 2025-03-14T03:51:44.0320705Z def load_yaml(yaml_text: str) -> Any: 2025-03-14T03:51:44.0321212Z try: 2025-03-14T03:51:44.0321623Z data = yaml.safe_load(yaml_text) 2025-03-14T03:51:44.0322140Z return data 2025-03-14T03:51:44.0322816Z except yaml.YAMLError: 2025-03-14T03:51:44.0323340Z log.exception("Error loading YAML") 2025-03-14T03:51:44.0323881Z raise 2025-03-14T03:51:44.0324102Z 2025-03-14T03:51:44.0324109Z 2025-03-14T03:51:44.0324537Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-03-14T03:51:44.0325289Z """ 2025-03-14T03:51:44.0325904Z Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-03-14T03:51:44.0326518Z 2025-03-14T03:51:44.0326867Z If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:44.0327621Z and the text below is the list of opted in users. 2025-03-14T03:51:44.0328032Z 2025-03-14T03:51:44.0328412Z If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-03-14T03:51:44.0329116Z """ 2025-03-14T03:51:44.0329571Z rollout_state_parts = rollout_state.split("---") 2025-03-14T03:51:44.0330176Z if len(rollout_state_parts) >= 2: 2025-03-14T03:51:44.0330787Z return rollout_state_parts[0], rollout_state_parts[1] 2025-03-14T03:51:44.0331557Z else: 2025-03-14T03:51:44.0331951Z return "", rollout_state 2025-03-14T03:51:44.0332261Z 2025-03-14T03:51:44.0332268Z 2025-03-14T03:51:44.0332710Z class UserOptins(dict[str, list[str]]): 2025-03-14T03:51:44.0333244Z """ 2025-03-14T03:51:44.0333793Z Dictionary of users with a list of features they have opted into 2025-03-14T03:51:44.0334450Z """ 2025-03-14T03:51:44.0334658Z 2025-03-14T03:51:44.0334665Z 2025-03-14T03:51:44.0335005Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-03-14T03:51:44.0335677Z """ 2025-03-14T03:51:44.0336390Z Parse the user opt-in text into a key value pair of username and the list of features they have opted into 2025-03-14T03:51:44.0337105Z 2025-03-14T03:51:44.0337745Z Users are GitHub usernames with the @ prefix. Each user is also a comma-separated list of features/experiments to enable. 2025-03-14T03:51:44.0338754Z - Example line: "@User1,lf,split_build" 2025-03-14T03:51:44.0339454Z - A "#" prefix indicates the user is opted out of all experiments 2025-03-14T03:51:44.0339940Z 2025-03-14T03:51:44.0339947Z 2025-03-14T03:51:44.0340117Z """ 2025-03-14T03:51:44.0340508Z optins = UserOptins() 2025-03-14T03:51:44.0341016Z for user in user_optin_text.split("\n"): 2025-03-14T03:51:44.0341585Z user = user.strip("\r\n\t -") 2025-03-14T03:51:44.0342145Z if not user or not user.startswith("@"): 2025-03-14T03:51:44.0342895Z # Not a valid user. Skip 2025-03-14T03:51:44.0343400Z continue 2025-03-14T03:51:44.0343651Z 2025-03-14T03:51:44.0343827Z if user: 2025-03-14T03:51:44.0344264Z usr_name = user.split(",")[0].strip("@") 2025-03-14T03:51:44.0344982Z optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-03-14T03:51:44.0345628Z 2025-03-14T03:51:44.0345817Z return optins 2025-03-14T03:51:44.0346075Z 2025-03-14T03:51:44.0346082Z 2025-03-14T03:51:44.0346376Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-03-14T03:51:44.0346998Z """ 2025-03-14T03:51:44.0347407Z Check if the experiment name is valid. 2025-03-14T03:51:44.0347940Z A valid name: 2025-03-14T03:51:44.0348582Z - Contains only alphanumeric characters and the special characters "_" & "-" 2025-03-14T03:51:44.0349528Z - The special characters "_" & "-" shouldn't be the first or last characters 2025-03-14T03:51:44.0350252Z - Cannot contain spaces 2025-03-14T03:51:44.0350722Z """ 2025-03-14T03:51:44.0350923Z 2025-03-14T03:51:44.0351193Z valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-03-14T03:51:44.0351923Z valid = bool(re.match(valid_char_regex, experiment_name)) 2025-03-14T03:51:44.0352381Z 2025-03-14T03:51:44.0352748Z if valid: 2025-03-14T03:51:44.0353168Z return True 2025-03-14T03:51:44.0353415Z 2025-03-14T03:51:44.0353595Z log.error( 2025-03-14T03:51:44.0355053Z 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-03-14T03:51:44.0356649Z ) 2025-03-14T03:51:44.0357021Z return False 2025-03-14T03:51:44.0357269Z 2025-03-14T03:51:44.0357276Z 2025-03-14T03:51:44.0357585Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-03-14T03:51:44.0358220Z """ 2025-03-14T03:51:44.0358825Z Parse the experiments from the issue body into a list of ExperimentSettings 2025-03-14T03:51:44.0359568Z """ 2025-03-14T03:51:44.0359929Z try: 2025-03-14T03:51:44.0360310Z if settings_text: 2025-03-14T03:51:44.0361044Z # Escape the backtick as well so that we can have the settings in a code block on the GH issue 2025-03-14T03:51:44.0361857Z # for easy reading 2025-03-14T03:51:44.0362850Z # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-03-14T03:51:44.0363951Z # the backtick character in shell commands. 2025-03-14T03:51:44.0364577Z backtick = chr(96) # backtick character 2025-03-14T03:51:44.0365256Z settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-03-14T03:51:44.0365929Z settings = load_yaml(settings_text) 2025-03-14T03:51:44.0366303Z 2025-03-14T03:51:44.0366720Z # For now we just load experiments. We can expand this if/when we add more settings 2025-03-14T03:51:44.0367487Z experiments = {} 2025-03-14T03:51:44.0367786Z 2025-03-14T03:51:44.0368149Z for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-03-14T03:51:44.0368915Z if not is_valid_experiment_name(exp_name): 2025-03-14T03:51:44.0370042Z # 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-03-14T03:51:44.0371110Z continue 2025-03-14T03:51:44.0371404Z 2025-03-14T03:51:44.0371602Z valid_settings = {} 2025-03-14T03:51:44.0372133Z for setting in exp_settings: 2025-03-14T03:51:44.0372912Z if setting not in Experiment._fields: 2025-03-14T03:51:44.0373488Z log.warning( 2025-03-14T03:51:44.0374207Z f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-03-14T03:51:44.0374937Z ) 2025-03-14T03:51:44.0375374Z else: 2025-03-14T03:51:44.0375893Z valid_settings[setting] = exp_settings[setting] 2025-03-14T03:51:44.0376346Z 2025-03-14T03:51:44.0376639Z experiments[exp_name] = Experiment(**valid_settings) 2025-03-14T03:51:44.0377445Z return Settings(experiments) 2025-03-14T03:51:44.0377818Z 2025-03-14T03:51:44.0378010Z except Exception: 2025-03-14T03:51:44.0378513Z log.exception("Failed to parse settings") 2025-03-14T03:51:44.0378920Z 2025-03-14T03:51:44.0379102Z return Settings() 2025-03-14T03:51:44.0379364Z 2025-03-14T03:51:44.0379372Z 2025-03-14T03:51:44.0379625Z def parse_settings(rollout_state: str) -> Settings: 2025-03-14T03:51:44.0380200Z """ 2025-03-14T03:51:44.0380635Z Parse settings, if any, from the rollout state. 2025-03-14T03:51:44.0381042Z 2025-03-14T03:51:44.0381405Z If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:44.0382175Z and the text below is the list of opted in users. 2025-03-14T03:51:44.0382755Z 2025-03-14T03:51:44.0383226Z If it doesn't contain "---" then the settings are empty and the default values are used. 2025-03-14T03:51:44.0383980Z """ 2025-03-14T03:51:44.0384552Z settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:44.0385323Z return parse_settings_from_text(settings_text) 2025-03-14T03:51:44.0385731Z 2025-03-14T03:51:44.0385737Z 2025-03-14T03:51:44.0386003Z def parse_users(rollout_state: str) -> UserOptins: 2025-03-14T03:51:44.0386571Z """ 2025-03-14T03:51:44.0386967Z Parse users from the rollout state. 2025-03-14T03:51:44.0387327Z 2025-03-14T03:51:44.0387491Z """ 2025-03-14T03:51:44.0388023Z _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:44.0388770Z return parse_user_opt_in_from_text(users_text) 2025-03-14T03:51:44.0389170Z 2025-03-14T03:51:44.0389177Z 2025-03-14T03:51:44.0389605Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:44.0390367Z """ 2025-03-14T03:51:44.0390787Z Check if a user is opted into an experiment 2025-03-14T03:51:44.0391334Z """ 2025-03-14T03:51:44.0391794Z return experiment_name in user_optins.get(user, []) 2025-03-14T03:51:44.0392220Z 2025-03-14T03:51:44.0392228Z 2025-03-14T03:51:44.0392852Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:44.0393790Z """ 2025-03-14T03:51:44.0394262Z Check if a user explicitly opted out of an experiment 2025-03-14T03:51:44.0394843Z """ 2025-03-14T03:51:44.0395369Z # if the experiment is prefixed with a "-", then it's an opt-out 2025-03-14T03:51:44.0396068Z experiment_optout = "-" + experiment_name 2025-03-14T03:51:44.0396719Z if experiment_optout not in user_optins.get(user, []): 2025-03-14T03:51:44.0397330Z return False 2025-03-14T03:51:44.0397585Z 2025-03-14T03:51:44.0397862Z if is_user_opted_in(user, user_optins, experiment_name): 2025-03-14T03:51:44.0398477Z log.warning( 2025-03-14T03:51:44.0399288Z f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-03-14T03:51:44.0400191Z ) 2025-03-14T03:51:44.0400405Z 2025-03-14T03:51:44.0400585Z return True 2025-03-14T03:51:44.0400820Z 2025-03-14T03:51:44.0400827Z 2025-03-14T03:51:44.0401013Z def get_runner_prefix( 2025-03-14T03:51:44.0401462Z rollout_state: str, 2025-03-14T03:51:44.0401928Z workflow_requestors: Iterable[str], 2025-03-14T03:51:44.0402633Z branch: str, 2025-03-14T03:51:44.0403156Z eligible_experiments: frozenset[str] = frozenset(), 2025-03-14T03:51:44.0403761Z is_canary: bool = False, 2025-03-14T03:51:44.0404233Z ) -> str: 2025-03-14T03:51:44.0404669Z settings = parse_settings(rollout_state) 2025-03-14T03:51:44.0405259Z user_optins = parse_users(rollout_state) 2025-03-14T03:51:44.0405630Z 2025-03-14T03:51:44.0405815Z fleet_prefix = "" 2025-03-14T03:51:44.0406244Z prefixes = [] 2025-03-14T03:51:44.0406914Z for experiment_name, experiment_settings in settings.experiments.items(): 2025-03-14T03:51:44.0407861Z if not experiment_settings.all_branches and is_exception_branch(branch): 2025-03-14T03:51:44.0408726Z log.info( 2025-03-14T03:51:44.0409430Z f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-03-14T03:51:44.0410208Z ) 2025-03-14T03:51:44.0410593Z continue 2025-03-14T03:51:44.0410852Z 2025-03-14T03:51:44.0411047Z if eligible_experiments: 2025-03-14T03:51:44.0411608Z if experiment_name not in eligible_experiments: 2025-03-14T03:51:44.0412245Z exp_list = ", ".join(eligible_experiments) 2025-03-14T03:51:44.0413068Z log.info( 2025-03-14T03:51:44.0413864Z f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-03-14T03:51:44.0414718Z ) 2025-03-14T03:51:44.0415125Z continue 2025-03-14T03:51:44.0415603Z elif not experiment_settings.default: 2025-03-14T03:51:44.0416139Z log.info( 2025-03-14T03:51:44.0416799Z f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-03-14T03:51:44.0417552Z ) 2025-03-14T03:51:44.0417939Z continue 2025-03-14T03:51:44.0418186Z 2025-03-14T03:51:44.0418473Z # Is any workflow_requestor opted out to this experiment? 2025-03-14T03:51:44.0419101Z opted_out_users = [ 2025-03-14T03:51:44.0419558Z requestor 2025-03-14T03:51:44.0420010Z for requestor in workflow_requestors 2025-03-14T03:51:44.0420691Z if is_user_opted_out(requestor, user_optins, experiment_name) 2025-03-14T03:51:44.0421326Z ] 2025-03-14T03:51:44.0421536Z 2025-03-14T03:51:44.0421726Z if opted_out_users: 2025-03-14T03:51:44.0422183Z log.info( 2025-03-14T03:51:44.0422942Z f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-03-14T03:51:44.0423657Z ) 2025-03-14T03:51:44.0424049Z continue 2025-03-14T03:51:44.0424298Z 2025-03-14T03:51:44.0424586Z # Is any workflow_requestor opted in to this experiment? 2025-03-14T03:51:44.0425209Z opted_in_users = [ 2025-03-14T03:51:44.0425654Z requestor 2025-03-14T03:51:44.0426275Z for requestor in workflow_requestors 2025-03-14T03:51:44.0426954Z if is_user_opted_in(requestor, user_optins, experiment_name) 2025-03-14T03:51:44.0427598Z ] 2025-03-14T03:51:44.0427805Z 2025-03-14T03:51:44.0427988Z enabled = False 2025-03-14T03:51:44.0428433Z if opted_in_users: 2025-03-14T03:51:44.0428890Z log.info( 2025-03-14T03:51:44.0429515Z f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-03-14T03:51:44.0430221Z ) 2025-03-14T03:51:44.0430638Z enabled = True 2025-03-14T03:51:44.0430927Z 2025-03-14T03:51:44.0431158Z elif experiment_settings.rollout_perc: 2025-03-14T03:51:44.0432017Z # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-03-14T03:51:44.0433084Z if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-03-14T03:51:44.0433761Z log.info( 2025-03-14T03:51:44.0434648Z f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-03-14T03:51:44.0435618Z ) 2025-03-14T03:51:44.0436033Z enabled = True 2025-03-14T03:51:44.0436342Z 2025-03-14T03:51:44.0436514Z if enabled: 2025-03-14T03:51:44.0436947Z label = experiment_name 2025-03-14T03:51:44.0437510Z if experiment_name == LF_FLEET_EXPERIMENT: 2025-03-14T03:51:44.0438345Z # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-03-14T03:51:44.0439230Z # - If it's enabled, then we always list it's prefix first 2025-03-14T03:51:44.0440116Z # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-03-14T03:51:44.0440810Z if is_canary: 2025-03-14T03:51:44.0441306Z label += CANARY_FLEET_SUFFIX 2025-03-14T03:51:44.0441863Z fleet_prefix = label 2025-03-14T03:51:44.0442367Z else: 2025-03-14T03:51:44.0442916Z prefixes.append(label) 2025-03-14T03:51:44.0443294Z 2025-03-14T03:51:44.0443486Z if len(prefixes) > 1: 2025-03-14T03:51:44.0443950Z log.error( 2025-03-14T03:51:44.0445015Z 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-03-14T03:51:44.0446177Z ) 2025-03-14T03:51:44.0446569Z prefixes = prefixes[:1] 2025-03-14T03:51:44.0446886Z 2025-03-14T03:51:44.0447077Z # Fleet always comes first 2025-03-14T03:51:44.0447556Z if fleet_prefix: 2025-03-14T03:51:44.0448021Z prefixes.insert(0, fleet_prefix) 2025-03-14T03:51:44.0448384Z 2025-03-14T03:51:44.0448652Z return ".".join(prefixes) + "." if prefixes else "" 2025-03-14T03:51:44.0449070Z 2025-03-14T03:51:44.0449077Z 2025-03-14T03:51:44.0449532Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-03-14T03:51:44.0450318Z """ 2025-03-14T03:51:44.0450917Z Gets the first comment of the issue, which contains the desired rollout state. 2025-03-14T03:51:44.0451498Z 2025-03-14T03:51:44.0451883Z The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-03-14T03:51:44.0452708Z """ 2025-03-14T03:51:44.0453107Z gh = get_gh_client(github_token) 2025-03-14T03:51:44.0453656Z issue = get_issue(gh, repo, issue_num) 2025-03-14T03:51:44.0454300Z return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-03-14T03:51:44.0454753Z 2025-03-14T03:51:44.0454761Z 2025-03-14T03:51:44.0455169Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-03-14T03:51:44.0455939Z for _ in range(num_retries): 2025-03-14T03:51:44.0456451Z try: 2025-03-14T03:51:44.0456893Z req = Request(url=url, headers=headers) 2025-03-14T03:51:44.0457565Z content = urlopen(req, timeout=5).read().decode("utf-8") 2025-03-14T03:51:44.0458622Z return json.loads(content) 2025-03-14T03:51:44.0459171Z except Exception as e: 2025-03-14T03:51:44.0459721Z log.warning(f"Could not download {url}: {e}") 2025-03-14T03:51:44.0460129Z 2025-03-14T03:51:44.0460521Z log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-03-14T03:51:44.0461249Z return {} 2025-03-14T03:51:44.0461475Z 2025-03-14T03:51:44.0461481Z 2025-03-14T03:51:44.0461648Z @cache 2025-03-14T03:51:44.0462282Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-03-14T03:51:44.0463189Z """ 2025-03-14T03:51:44.0463594Z Dynamically get PR information 2025-03-14T03:51:44.0464089Z """ 2025-03-14T03:51:44.0464598Z github_api = f"https://api.github.com/repos/{github_repo}" 2025-03-14T03:51:44.0465236Z headers = { 2025-03-14T03:51:44.0465707Z "Accept": "application/vnd.github.v3+json", 2025-03-14T03:51:44.0466332Z "Authorization": f"token {github_token}", 2025-03-14T03:51:44.0466886Z } 2025-03-14T03:51:44.0467315Z json_response: dict[str, Any] = download_json( 2025-03-14T03:51:44.0467932Z url=f"{github_api}/issues/{pr_number}", 2025-03-14T03:51:44.0468486Z headers=headers, 2025-03-14T03:51:44.0469191Z ) 2025-03-14T03:51:44.0469425Z 2025-03-14T03:51:44.0469622Z if not json_response: 2025-03-14T03:51:44.0470207Z log.warning(f"Failed to get the labels for #{pr_number}") 2025-03-14T03:51:44.0470843Z return {} 2025-03-14T03:51:44.0471092Z 2025-03-14T03:51:44.0471275Z return json_response 2025-03-14T03:51:44.0471551Z 2025-03-14T03:51:44.0471557Z 2025-03-14T03:51:44.0471971Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-03-14T03:51:44.0472988Z """ 2025-03-14T03:51:44.0473560Z Dynamically get the latest list of labels from the pull request 2025-03-14T03:51:44.0474225Z """ 2025-03-14T03:51:44.0474717Z pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-03-14T03:51:44.0475354Z return { 2025-03-14T03:51:44.0475952Z label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-03-14T03:51:44.0476667Z } 2025-03-14T03:51:44.0476870Z 2025-03-14T03:51:44.0476876Z 2025-03-14T03:51:44.0477054Z def main() -> None: 2025-03-14T03:51:44.0477487Z args = parse_args() 2025-03-14T03:51:44.0477764Z 2025-03-14T03:51:44.0477989Z runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-03-14T03:51:44.0478375Z 2025-03-14T03:51:44.0478578Z # Check if the PR is opt-out 2025-03-14T03:51:44.0479086Z if args.pr_number: 2025-03-14T03:51:44.0479743Z labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-03-14T03:51:44.0480511Z if OPT_OUT_LABEL in labels: 2025-03-14T03:51:44.0481019Z log.info( 2025-03-14T03:51:44.0481720Z f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-03-14T03:51:44.0482600Z ) 2025-03-14T03:51:44.0483161Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:44.0483837Z sys.exit() 2025-03-14T03:51:44.0484105Z 2025-03-14T03:51:44.0484276Z try: 2025-03-14T03:51:44.0484723Z rollout_state = get_rollout_state_from_issue( 2025-03-14T03:51:44.0485434Z args.github_token, args.github_issue_repo, args.github_issue 2025-03-14T03:51:44.0486087Z ) 2025-03-14T03:51:44.0486296Z 2025-03-14T03:51:44.0486504Z username = get_potential_pr_author( 2025-03-14T03:51:44.0487060Z args.github_token, 2025-03-14T03:51:44.0487547Z args.github_repo, 2025-03-14T03:51:44.0488034Z args.github_actor, 2025-03-14T03:51:44.0488526Z args.github_ref_type, 2025-03-14T03:51:44.0489029Z args.github_branch, 2025-03-14T03:51:44.0489497Z ) 2025-03-14T03:51:44.0489706Z 2025-03-14T03:51:44.0489996Z is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-03-14T03:51:44.0490620Z 2025-03-14T03:51:44.0490846Z runner_label_prefix = get_runner_prefix( 2025-03-14T03:51:44.0491408Z rollout_state, 2025-03-14T03:51:44.0491898Z (args.github_issue_owner, username), 2025-03-14T03:51:44.0492552Z args.github_branch, 2025-03-14T03:51:44.0493074Z args.eligible_experiments, 2025-03-14T03:51:44.0493597Z is_canary, 2025-03-14T03:51:44.0494013Z ) 2025-03-14T03:51:44.0494221Z 2025-03-14T03:51:44.0494408Z except Exception as e: 2025-03-14T03:51:44.0494879Z log.error( 2025-03-14T03:51:44.0495567Z f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-03-14T03:51:44.0496350Z ) 2025-03-14T03:51:44.0496557Z 2025-03-14T03:51:44.0496900Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:44.0497398Z 2025-03-14T03:51:44.0497405Z 2025-03-14T03:51:44.0497597Z if __name__ == "__main__": 2025-03-14T03:51:44.0498046Z main() 2025-03-14T03:51:44.0498262Z 2025-03-14T03:51:44.0587287Z ##[group]Run python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-03-14T03:51:44.0588199Z python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-03-14T03:51:44.0635150Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:44.0635635Z env: 2025-03-14T03:51:44.0636269Z GITHUB_TOKEN: *** 2025-03-14T03:51:44.0636697Z ISSUE_NUMBER: 5132 2025-03-14T03:51:44.0637148Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:44.0637660Z ISSUE_OWNER: 2025-03-14T03:51:44.0638059Z CHECK_EXPERIMENTS: 2025-03-14T03:51:44.0638488Z PR_NUMBER: 2025-03-14T03:51:44.0638874Z ##[endgroup] 2025-03-14T03:51:44.4632692Z Defaulting to user installation because normal site-packages is not writeable 2025-03-14T03:51:45.0157702Z Collecting urllib3==1.26.18 2025-03-14T03:51:45.0670359Z Downloading urllib3-1.26.18-py2.py3-none-any.whl.metadata (48 kB) 2025-03-14T03:51:45.0876893Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 kB 4.1 MB/s eta 0:00:00 2025-03-14T03:51:45.1159752Z Collecting PyGithub==2.3.0 2025-03-14T03:51:45.1253644Z Downloading PyGithub-2.3.0-py3-none-any.whl.metadata (3.8 kB) 2025-03-14T03:51:45.1730151Z Collecting pynacl>=1.4.0 (from PyGithub==2.3.0) 2025-03-14T03:51:45.1804726Z 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-03-14T03:51:45.1851093Z Requirement already satisfied: requests>=2.14.0 in /usr/lib/python3/dist-packages (from PyGithub==2.3.0) (2.31.0) 2025-03-14T03:51:45.1869274Z 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-03-14T03:51:45.1883929Z Requirement already satisfied: typing-extensions>=4.0.0 in /usr/lib/python3/dist-packages (from PyGithub==2.3.0) (4.10.0) 2025-03-14T03:51:45.2188514Z Collecting Deprecated (from PyGithub==2.3.0) 2025-03-14T03:51:45.2269816Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl.metadata (5.7 kB) 2025-03-14T03:51:45.2502057Z 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-03-14T03:51:45.3694724Z Collecting cffi>=1.4.1 (from pynacl>=1.4.0->PyGithub==2.3.0) 2025-03-14T03:51:45.3774836Z Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.5 kB) 2025-03-14T03:51:45.4953032Z Collecting wrapt<2,>=1.10 (from Deprecated->PyGithub==2.3.0) 2025-03-14T03:51:45.5027759Z Downloading wrapt-1.17.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.4 kB) 2025-03-14T03:51:45.5257874Z Collecting pycparser (from cffi>=1.4.1->pynacl>=1.4.0->PyGithub==2.3.0) 2025-03-14T03:51:45.5333485Z Downloading pycparser-2.22-py3-none-any.whl.metadata (943 bytes) 2025-03-14T03:51:45.5605018Z Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB) 2025-03-14T03:51:45.5701855Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.8/143.8 kB 17.3 MB/s eta 0:00:00 2025-03-14T03:51:45.5776642Z Downloading PyGithub-2.3.0-py3-none-any.whl (354 kB) 2025-03-14T03:51:45.5881551Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 354.4/354.4 kB 39.0 MB/s eta 0:00:00 2025-03-14T03:51:45.5959558Z Downloading PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (856 kB) 2025-03-14T03:51:45.6070086Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 856.7/856.7 kB 88.2 MB/s eta 0:00:00 2025-03-14T03:51:45.6141448Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl (10.0 kB) 2025-03-14T03:51:45.6239263Z Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479 kB) 2025-03-14T03:51:45.6305274Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 479.4/479.4 kB 92.8 MB/s eta 0:00:00 2025-03-14T03:51:45.6377566Z Downloading wrapt-1.17.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (89 kB) 2025-03-14T03:51:45.6419181Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 89.2/89.2 kB 30.2 MB/s eta 0:00:00 2025-03-14T03:51:45.6491960Z Downloading pycparser-2.22-py3-none-any.whl (117 kB) 2025-03-14T03:51:45.6538420Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.6/117.6 kB 37.8 MB/s eta 0:00:00 2025-03-14T03:51:45.9523848Z Installing collected packages: wrapt, urllib3, pycparser, Deprecated, cffi, pynacl, PyGithub 2025-03-14T03:51:46.4951329Z 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.2 2025-03-14T03:51:46.6020173Z ##[group]Run curr_branch="main" 2025-03-14T03:51:46.6020497Z curr_branch="main" 2025-03-14T03:51:46.6020730Z curr_ref_type="branch" 2025-03-14T03:51:46.6020992Z echo "Current branch is '$curr_branch'" 2025-03-14T03:51:46.6021265Z  2025-03-14T03:51:46.6021468Z python3 runner_determinator.py \ 2025-03-14T03:51:46.6021757Z  --github-token "$GITHUB_TOKEN" \ 2025-03-14T03:51:46.6022045Z  --github-issue "$ISSUE_NUMBER" \ 2025-03-14T03:51:46.6022364Z  --github-branch "$curr_branch" \ 2025-03-14T03:51:46.6022867Z  --github-actor "$TRIGGERING_ACTOR" \ 2025-03-14T03:51:46.6023165Z  --github-issue-owner "$ISSUE_OWNER" \ 2025-03-14T03:51:46.6023453Z  --github-ref-type "$curr_ref_type" \ 2025-03-14T03:51:46.6023731Z  --github-repo "$GITHUB_REPOSITORY" \ 2025-03-14T03:51:46.6024037Z  --eligible-experiments "$CHECK_EXPERIMENTS" \ 2025-03-14T03:51:46.6024374Z  --pr-number "${PR_NUMBER}" 2025-03-14T03:51:46.6074094Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:46.6074357Z env: 2025-03-14T03:51:46.6075139Z GITHUB_TOKEN: *** 2025-03-14T03:51:46.6075338Z ISSUE_NUMBER: 5132 2025-03-14T03:51:46.6075556Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:46.6075795Z ISSUE_OWNER: 2025-03-14T03:51:46.6075980Z CHECK_EXPERIMENTS: 2025-03-14T03:51:46.6076172Z PR_NUMBER: 2025-03-14T03:51:46.6076347Z ##[endgroup] 2025-03-14T03:51:46.6149645Z Current branch is 'main' 2025-03-14T03:51:47.9090924Z INFO : Based on rollout percentage of 50%, enabling experiment lf. 2025-03-14T03:51:47.9092116Z INFO : Branch main is an exception branch. Not enabling experiment ephemeral. 2025-03-14T03:51:47.9095023Z INFO : Setting output: label-type='lf.' 2025-03-14T03:51:47.9403680Z Evaluate and set job outputs 2025-03-14T03:51:47.9410027Z Set output 'label-type' 2025-03-14T03:51:47.9411986Z Cleaning up orphan processes