2025-03-14T03:51:42.2830189Z Current runner version: '2.322.0' 2025-03-14T03:51:42.2855239Z ##[group]Operating System 2025-03-14T03:51:42.2856030Z Ubuntu 2025-03-14T03:51:42.2856664Z 24.04.2 2025-03-14T03:51:42.2857163Z LTS 2025-03-14T03:51:42.2857686Z ##[endgroup] 2025-03-14T03:51:42.2858251Z ##[group]Runner Image 2025-03-14T03:51:42.2859047Z Image: ubuntu-24.04 2025-03-14T03:51:42.2859644Z Version: 20250309.1.0 2025-03-14T03:51:42.2860712Z Included Software: https://github.com/actions/runner-images/blob/ubuntu24/20250309.1/images/ubuntu/Ubuntu2404-Readme.md 2025-03-14T03:51:42.2862069Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu24%2F20250309.1 2025-03-14T03:51:42.2863054Z ##[endgroup] 2025-03-14T03:51:42.2863587Z ##[group]Runner Image Provisioner 2025-03-14T03:51:42.2864163Z 2.0.422.1 2025-03-14T03:51:42.2864732Z ##[endgroup] 2025-03-14T03:51:42.2865715Z ##[group]GITHUB_TOKEN Permissions 2025-03-14T03:51:42.2867652Z Contents: read 2025-03-14T03:51:42.2868198Z Metadata: read 2025-03-14T03:51:42.2869208Z ##[endgroup] 2025-03-14T03:51:42.2872790Z Secret source: Actions 2025-03-14T03:51:42.2873727Z Prepare workflow directory 2025-03-14T03:51:42.3362231Z Prepare all required actions 2025-03-14T03:51:42.3416316Z Uses: pytorch/pytorch/.github/workflows/_runner-determinator.yml@refs/heads/main (aed0b7a742a2d7b7901790622829cbd2135049a4) 2025-03-14T03:51:42.3421764Z ##[group] Inputs 2025-03-14T03:51:42.3422485Z check_experiments: 2025-03-14T03:51:42.3423126Z triggering_actor: pytorchmergebot 2025-03-14T03:51:42.3423817Z issue_owner: 2025-03-14T03:51:42.3424362Z curr_branch: main 2025-03-14T03:51:42.3424922Z curr_ref_type: branch 2025-03-14T03:51:42.3425472Z issue_number: 5132 2025-03-14T03:51:42.3426027Z ##[endgroup] 2025-03-14T03:51:42.3426732Z Complete job name: before-test / get-label-type / runner-determinator 2025-03-14T03:51:42.9373256Z ##[group]Run cat < runner_determinator.py 2025-03-14T03:51:42.9374949Z cat < runner_determinator.py 2025-03-14T03:51:42.9375579Z # flake8: noqa: G004 2025-03-14T03:51:42.9376115Z  2025-03-14T03:51:42.9376897Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-03-14T03:51:42.9377936Z # must be kept in sync. You can do it easily by running the following command: 2025-03-14T03:51:42.9378986Z # python .github/scripts/update_runner_determinator.py 2025-03-14T03:51:42.9379682Z  2025-03-14T03:51:42.9380066Z """ 2025-03-14T03:51:42.9380743Z This runner determinator is used to determine which set of runners to run a 2025-03-14T03:51:42.9381724Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-03-14T03:51:42.9382771Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-03-14T03:51:42.9383701Z of which runners should be used to run which job. 2025-03-14T03:51:42.9384326Z  2025-03-14T03:51:42.9384995Z The configuration has two parts, the settings and a list of opted-in users, 2025-03-14T03:51:42.9386015Z separated by a line containing "---". If the line is not present, the 2025-03-14T03:51:42.9387004Z settings are considered to be empty with only the second part, the user 2025-03-14T03:51:42.9387778Z list, defined. 2025-03-14T03:51:42.9388227Z  2025-03-14T03:51:42.9388963Z The first part is a YAML block that defines the rollout settings. This can be 2025-03-14T03:51:42.9389983Z used to define any settings that are needed to determine which runners to use. 2025-03-14T03:51:42.9390918Z It's fields are defined by the RolloutSettings class below. 2025-03-14T03:51:42.9391596Z  2025-03-14T03:51:42.9392250Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-03-14T03:51:42.9393219Z The user list is also a comma separated list of additional features or 2025-03-14T03:51:42.9394301Z experiments which the user could be opted in to. 2025-03-14T03:51:42.9394943Z  2025-03-14T03:51:42.9395416Z The user list has the following rules: 2025-03-14T03:51:42.9396002Z  2025-03-14T03:51:42.9396603Z - Users are GitHub usernames, which must start with the @ prefix 2025-03-14T03:51:42.9397588Z - Each user is also a comma-separated list of features/experiments to enable 2025-03-14T03:51:42.9398706Z - A "#" prefix opts the user out of all experiments 2025-03-14T03:51:42.9399749Z  2025-03-14T03:51:42.9400286Z Example config: 2025-03-14T03:51:42.9400871Z  # A list of experiments that can be opted into. 2025-03-14T03:51:42.9401638Z  # This defines the behavior they'll induce when opted into. 2025-03-14T03:51:42.9402343Z  # Expected syntax is: 2025-03-14T03:51:42.9403105Z  # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-03-14T03:51:42.9404198Z  # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-03-14T03:51:42.9405021Z  2025-03-14T03:51:42.9405432Z  experiments: 2025-03-14T03:51:42.9405911Z  lf: 2025-03-14T03:51:42.9406365Z  rollout_percent: 25 2025-03-14T03:51:42.9406917Z  all_branches: false 2025-03-14T03:51:42.9407451Z  default: true 2025-03-14T03:51:42.9407949Z  --- 2025-03-14T03:51:42.9408377Z  2025-03-14T03:51:42.9408969Z  # Opt-ins: 2025-03-14T03:51:42.9409678Z  # Users can opt into the LF fleet by adding their GitHub username to this list 2025-03-14T03:51:42.9410856Z  # and specifying experiments to enable in a comma-separated list. 2025-03-14T03:51:42.9411760Z  # To always opt out of an experiment, prefix it with a "-". 2025-03-14T03:51:42.9412518Z  # Experiments should be from the above list. 2025-03-14T03:51:42.9413128Z  2025-03-14T03:51:42.9413540Z  @User1,-lf,split_build 2025-03-14T03:51:42.9414078Z  @User2,lf 2025-03-14T03:51:42.9414548Z  @User3,split_build 2025-03-14T03:51:42.9415065Z """ 2025-03-14T03:51:42.9415473Z  2025-03-14T03:51:42.9415879Z import json 2025-03-14T03:51:42.9416342Z import logging 2025-03-14T03:51:42.9416813Z import os 2025-03-14T03:51:42.9417257Z import random 2025-03-14T03:51:42.9417717Z import re 2025-03-14T03:51:42.9418165Z import sys 2025-03-14T03:51:42.9418784Z from argparse import ArgumentParser 2025-03-14T03:51:42.9419421Z from collections.abc import Iterable 2025-03-14T03:51:42.9420040Z from functools import cache 2025-03-14T03:51:42.9420605Z from logging import LogRecord 2025-03-14T03:51:42.9421193Z from typing import Any, NamedTuple 2025-03-14T03:51:42.9421845Z from urllib.request import Request, urlopen 2025-03-14T03:51:42.9422448Z  2025-03-14T03:51:42.9422863Z import yaml 2025-03-14T03:51:42.9423353Z from github import Auth, Github 2025-03-14T03:51:42.9423934Z from github.Issue import Issue 2025-03-14T03:51:42.9424476Z  2025-03-14T03:51:42.9424873Z  2025-03-14T03:51:42.9425359Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-03-14T03:51:42.9426170Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-03-14T03:51:42.9427124Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-03-14T03:51:42.9427902Z  2025-03-14T03:51:42.9428403Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-03-14T03:51:42.9429183Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-03-14T03:51:42.9429800Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-03-14T03:51:42.9430621Z OPT_OUT_LABEL = "no-runner-experiments" 2025-03-14T03:51:42.9431201Z  2025-03-14T03:51:42.9431649Z SETTING_EXPERIMENTS = "experiments" 2025-03-14T03:51:42.9432209Z  2025-03-14T03:51:42.9432628Z LF_FLEET_EXPERIMENT = "lf" 2025-03-14T03:51:42.9433182Z CANARY_FLEET_SUFFIX = ".c" 2025-03-14T03:51:42.9433694Z  2025-03-14T03:51:42.9434083Z  2025-03-14T03:51:42.9434512Z class Experiment(NamedTuple): 2025-03-14T03:51:42.9435084Z  rollout_perc: float = ( 2025-03-14T03:51:42.9435851Z  0 # Percentage of workflows to experiment on when user is not opted-in. 2025-03-14T03:51:42.9436599Z  ) 2025-03-14T03:51:42.9437056Z  all_branches: bool = ( 2025-03-14T03:51:42.9437869Z  False # If True, the experiment is also enabled on the exception branches 2025-03-14T03:51:42.9438873Z  ) 2025-03-14T03:51:42.9439371Z  default: bool = ( 2025-03-14T03:51:42.9440085Z  True # If True, the experiment is enabled by default for all queries 2025-03-14T03:51:42.9440814Z  ) 2025-03-14T03:51:42.9441222Z  2025-03-14T03:51:42.9441657Z  # Add more fields as needed 2025-03-14T03:51:42.9442199Z  2025-03-14T03:51:42.9442589Z  2025-03-14T03:51:42.9443018Z class Settings(NamedTuple): 2025-03-14T03:51:42.9443546Z  """ 2025-03-14T03:51:42.9444100Z  Settings for the experiments that can be opted into. 2025-03-14T03:51:42.9444746Z  """ 2025-03-14T03:51:42.9445156Z  2025-03-14T03:51:42.9445617Z  experiments: dict[str, Experiment] = {} 2025-03-14T03:51:42.9446195Z  2025-03-14T03:51:42.9446747Z  2025-03-14T03:51:42.9447240Z class ColorFormatter(logging.Formatter): 2025-03-14T03:51:42.9447980Z  """Color codes the log messages based on the log level""" 2025-03-14T03:51:42.9448788Z  2025-03-14T03:51:42.9449192Z  COLORS = { 2025-03-14T03:51:42.9449693Z  "WARNING": "\033[33m", # Yellow 2025-03-14T03:51:42.9450279Z  "ERROR": "\033[31m", # Red 2025-03-14T03:51:42.9450852Z  "CRITICAL": "\033[31m", # Red 2025-03-14T03:51:42.9451434Z  "INFO": "\033[0m", # Reset 2025-03-14T03:51:42.9452012Z  "DEBUG": "\033[0m", # Reset 2025-03-14T03:51:42.9452559Z  } 2025-03-14T03:51:42.9452978Z  2025-03-14T03:51:42.9453456Z  def format(self, record: LogRecord) -> str: 2025-03-14T03:51:42.9454306Z  log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-03-14T03:51:42.9455172Z  record.msg = f"{log_color}{record.msg}\033[0m" 2025-03-14T03:51:42.9455826Z  return super().format(record) 2025-03-14T03:51:42.9456389Z  2025-03-14T03:51:42.9456779Z  2025-03-14T03:51:42.9457226Z handler = logging.StreamHandler() 2025-03-14T03:51:42.9458052Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-03-14T03:51:42.9458932Z  2025-03-14T03:51:42.9459460Z log = logging.getLogger(os.path.basename(__file__)) 2025-03-14T03:51:42.9460135Z log.addHandler(handler) 2025-03-14T03:51:42.9460674Z log.setLevel(logging.INFO) 2025-03-14T03:51:42.9461192Z  2025-03-14T03:51:42.9461589Z  2025-03-14T03:51:42.9462113Z def set_github_output(key: str, value: str) -> None: 2025-03-14T03:51:42.9462764Z  """ 2025-03-14T03:51:42.9463372Z  Defines outputs of the github action that invokes this script 2025-03-14T03:51:42.9464093Z  """ 2025-03-14T03:51:42.9464551Z  if not GITHUB_OUTPUT: 2025-03-14T03:51:42.9465743Z  # See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ for deprecation notice 2025-03-14T03:51:42.9467097Z  log.warning( 2025-03-14T03:51:42.9468077Z  "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:42.9469191Z  ) 2025-03-14T03:51:42.9469716Z  print(f"::set-output name={key}::{value}") 2025-03-14T03:51:42.9470330Z  return 2025-03-14T03:51:42.9470782Z  2025-03-14T03:51:42.9471230Z  with open(GITHUB_OUTPUT, "a") as f: 2025-03-14T03:51:42.9471890Z  log.info(f"Setting output: {key}='{value}'") 2025-03-14T03:51:42.9472548Z  f.write(f"{key}={value}\n") 2025-03-14T03:51:42.9473105Z  2025-03-14T03:51:42.9473500Z  2025-03-14T03:51:42.9474082Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-03-14T03:51:42.9474808Z  return frozenset( 2025-03-14T03:51:42.9475540Z  filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-03-14T03:51:42.9476297Z  ) 2025-03-14T03:51:42.9476712Z  2025-03-14T03:51:42.9477144Z  2025-03-14T03:51:42.9477567Z def parse_args() -> Any: 2025-03-14T03:51:42.9478238Z  parser = ArgumentParser("Get dynamic rollout settings") 2025-03-14T03:51:42.9479459Z  parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-03-14T03:51:42.9480412Z  parser.add_argument( 2025-03-14T03:51:42.9480963Z  "--github-issue-repo", 2025-03-14T03:51:42.9481535Z  type=str, 2025-03-14T03:51:42.9482045Z  required=False, 2025-03-14T03:51:42.9482755Z  default="pytorch/test-infra", 2025-03-14T03:51:42.9483470Z  help="GitHub repo to get the issue", 2025-03-14T03:51:42.9484043Z  ) 2025-03-14T03:51:42.9484493Z  parser.add_argument( 2025-03-14T03:51:42.9485027Z  "--github-repo", 2025-03-14T03:51:42.9485551Z  type=str, 2025-03-14T03:51:42.9486045Z  required=True, 2025-03-14T03:51:42.9486608Z  help="GitHub repo where CI is running", 2025-03-14T03:51:42.9487199Z  ) 2025-03-14T03:51:42.9487647Z  parser.add_argument( 2025-03-14T03:51:42.9488382Z  "--github-issue", type=int, required=True, help="GitHub issue number" 2025-03-14T03:51:42.9489244Z  ) 2025-03-14T03:51:42.9489686Z  parser.add_argument( 2025-03-14T03:51:42.9490425Z  "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-03-14T03:51:42.9491188Z  ) 2025-03-14T03:51:42.9491628Z  parser.add_argument( 2025-03-14T03:51:42.9492387Z  "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-03-14T03:51:42.9493153Z  ) 2025-03-14T03:51:42.9493592Z  parser.add_argument( 2025-03-14T03:51:42.9494369Z  "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-03-14T03:51:42.9495156Z  ) 2025-03-14T03:51:42.9495595Z  parser.add_argument( 2025-03-14T03:51:42.9496142Z  "--github-ref-type", 2025-03-14T03:51:42.9496683Z  type=str, 2025-03-14T03:51:42.9497188Z  required=True, 2025-03-14T03:51:42.9497783Z  help="Current GitHub ref type, branch or tag", 2025-03-14T03:51:42.9498398Z  ) 2025-03-14T03:51:42.9498931Z  parser.add_argument( 2025-03-14T03:51:42.9499493Z  "--eligible-experiments", 2025-03-14T03:51:42.9500100Z  type=_str_comma_separated_to_set, 2025-03-14T03:51:42.9500694Z  required=False, 2025-03-14T03:51:42.9501218Z  default="", 2025-03-14T03:51:42.9502318Z  help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-03-14T03:51:42.9503319Z  ) 2025-03-14T03:51:42.9503754Z  parser.add_argument( 2025-03-14T03:51:42.9504280Z  "--pr-number", 2025-03-14T03:51:42.9504792Z  type=str, 2025-03-14T03:51:42.9505282Z  required=False, 2025-03-14T03:51:42.9505806Z  default="", 2025-03-14T03:51:42.9506395Z  help="the optional PR number where this is run", 2025-03-14T03:51:42.9507025Z  ) 2025-03-14T03:51:42.9507436Z  2025-03-14T03:51:42.9507869Z  return parser.parse_args() 2025-03-14T03:51:42.9508408Z  2025-03-14T03:51:42.9508902Z  2025-03-14T03:51:42.9509601Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-03-14T03:51:42.9510469Z  auth = Auth.Token(github_token) 2025-03-14T03:51:42.9511078Z  return Github(auth=auth) 2025-03-14T03:51:42.9511614Z  2025-03-14T03:51:42.9512002Z  2025-03-14T03:51:42.9512731Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-03-14T03:51:42.9513627Z  repo = gh.get_repo(repo) 2025-03-14T03:51:42.9514230Z  return repo.get_issue(number=issue_num) 2025-03-14T03:51:42.9514818Z  2025-03-14T03:51:42.9515212Z  2025-03-14T03:51:42.9515622Z def get_potential_pr_author( 2025-03-14T03:51:42.9516373Z  github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-03-14T03:51:42.9517152Z ) -> str: 2025-03-14T03:51:42.9517891Z  # If the trigger was a new tag added by a bot, this is a ciflow case 2025-03-14T03:51:42.9518916Z  # Fetch the actual username from the original PR. The PR number is 2025-03-14T03:51:42.9519773Z  # embedded in the tag name: ciflow// 2025-03-14T03:51:42.9520414Z  2025-03-14T03:51:42.9520864Z  gh = get_gh_client(github_token) 2025-03-14T03:51:42.9521428Z  2025-03-14T03:51:42.9521956Z  if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-03-14T03:51:42.9522679Z  split_tag = ref_name.split("/") 2025-03-14T03:51:42.9523256Z  if ( 2025-03-14T03:51:42.9523729Z  len(split_tag) == 3 2025-03-14T03:51:42.9524305Z  and split_tag[0] == "ciflow" 2025-03-14T03:51:42.9524912Z  and split_tag[2].isnumeric() 2025-03-14T03:51:42.9525482Z  ): 2025-03-14T03:51:42.9525965Z  pr_number = split_tag[2] 2025-03-14T03:51:42.9526528Z  try: 2025-03-14T03:51:42.9527051Z  repository = gh.get_repo(repo) 2025-03-14T03:51:42.9527755Z  pull = repository.get_pull(number=int(pr_number)) 2025-03-14T03:51:42.9528438Z  except Exception as e: 2025-03-14T03:51:42.9529145Z  raise Exception( # noqa: TRY002 2025-03-14T03:51:42.9529905Z  f"issue with pull request {pr_number} from repo {repository}" 2025-03-14T03:51:42.9530633Z  ) from e 2025-03-14T03:51:42.9531282Z  return pull.user.login # type: ignore[no-any-return] 2025-03-14T03:51:42.9532066Z  # In all other cases, return the original input username 2025-03-14T03:51:42.9532724Z  return username 2025-03-14T03:51:42.9533202Z  2025-03-14T03:51:42.9533580Z  2025-03-14T03:51:42.9534057Z def is_exception_branch(branch: str) -> bool: 2025-03-14T03:51:42.9534653Z  """ 2025-03-14T03:51:42.9535390Z  Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-03-14T03:51:42.9536366Z  """ 2025-03-14T03:51:42.9536997Z  return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-03-14T03:51:42.9537722Z  2025-03-14T03:51:42.9538105Z  2025-03-14T03:51:42.9538534Z def load_yaml(yaml_text: str) -> Any: 2025-03-14T03:51:42.9539196Z  try: 2025-03-14T03:51:42.9539660Z  data = yaml.safe_load(yaml_text) 2025-03-14T03:51:42.9540235Z  return data 2025-03-14T03:51:42.9540739Z  except yaml.YAMLError: 2025-03-14T03:51:42.9541310Z  log.exception("Error loading YAML") 2025-03-14T03:51:42.9541879Z  raise 2025-03-14T03:51:42.9542315Z  2025-03-14T03:51:42.9542693Z  2025-03-14T03:51:42.9543370Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-03-14T03:51:42.9544185Z  """ 2025-03-14T03:51:42.9544895Z  Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-03-14T03:51:42.9545728Z  2025-03-14T03:51:42.9546345Z  If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:42.9547193Z  and the text below is the list of opted in users. 2025-03-14T03:51:42.9547811Z  2025-03-14T03:51:42.9548448Z  If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-03-14T03:51:42.9549318Z  """ 2025-03-14T03:51:42.9549843Z  rollout_state_parts = rollout_state.split("---") 2025-03-14T03:51:42.9550516Z  if len(rollout_state_parts) >= 2: 2025-03-14T03:51:42.9551339Z  return rollout_state_parts[0], rollout_state_parts[1] 2025-03-14T03:51:42.9552012Z  else: 2025-03-14T03:51:42.9552460Z  return "", rollout_state 2025-03-14T03:51:42.9552988Z  2025-03-14T03:51:42.9553371Z  2025-03-14T03:51:42.9553827Z class UserOptins(dict[str, list[str]]): 2025-03-14T03:51:42.9554406Z  """ 2025-03-14T03:51:42.9555011Z  Dictionary of users with a list of features they have opted into 2025-03-14T03:51:42.9555726Z  """ 2025-03-14T03:51:42.9556139Z  2025-03-14T03:51:42.9556515Z  2025-03-14T03:51:42.9557120Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-03-14T03:51:42.9557843Z  """ 2025-03-14T03:51:42.9558758Z  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:42.9559670Z  2025-03-14T03:51:42.9560569Z  Users are GitHub usernames with the @ prefix. Each user is also a comma-separated list of features/experiments to enable. 2025-03-14T03:51:42.9561650Z  - Example line: "@User1,lf,split_build" 2025-03-14T03:51:42.9562412Z  - A "#" prefix indicates the user is opted out of all experiments 2025-03-14T03:51:42.9563109Z  2025-03-14T03:51:42.9563484Z  2025-03-14T03:51:42.9563870Z  """ 2025-03-14T03:51:42.9564307Z  optins = UserOptins() 2025-03-14T03:51:42.9564900Z  for user in user_optin_text.split("\n"): 2025-03-14T03:51:42.9565533Z  user = user.strip("\r\n\t -") 2025-03-14T03:51:42.9566268Z  if not user or not user.startswith("@"): 2025-03-14T03:51:42.9566901Z  # Not a valid user. Skip 2025-03-14T03:51:42.9567457Z  continue 2025-03-14T03:51:42.9567929Z  2025-03-14T03:51:42.9568324Z  if user: 2025-03-14T03:51:42.9568956Z  usr_name = user.split(",")[0].strip("@") 2025-03-14T03:51:42.9569733Z  optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-03-14T03:51:42.9570437Z  2025-03-14T03:51:42.9571012Z  return optins 2025-03-14T03:51:42.9571484Z  2025-03-14T03:51:42.9571857Z  2025-03-14T03:51:42.9572418Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-03-14T03:51:42.9573096Z  """ 2025-03-14T03:51:42.9573579Z  Check if the experiment name is valid. 2025-03-14T03:51:42.9574174Z  A valid name: 2025-03-14T03:51:42.9574928Z  - Contains only alphanumeric characters and the special characters "_" & "-" 2025-03-14T03:51:42.9575960Z  - The special characters "_" & "-" shouldn't be the first or last characters 2025-03-14T03:51:42.9576750Z  - Cannot contain spaces 2025-03-14T03:51:42.9577334Z  """ 2025-03-14T03:51:42.9577752Z  2025-03-14T03:51:42.9578289Z  valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-03-14T03:51:42.9579184Z  valid = bool(re.match(valid_char_regex, experiment_name)) 2025-03-14T03:51:42.9579864Z  2025-03-14T03:51:42.9580265Z  if valid: 2025-03-14T03:51:42.9580733Z  return True 2025-03-14T03:51:42.9581202Z  2025-03-14T03:51:42.9581593Z  log.error( 2025-03-14T03:51:42.9583171Z  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:42.9584800Z  ) 2025-03-14T03:51:42.9585218Z  return False 2025-03-14T03:51:42.9585678Z  2025-03-14T03:51:42.9586052Z  2025-03-14T03:51:42.9586743Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-03-14T03:51:42.9587463Z  """ 2025-03-14T03:51:42.9588146Z  Parse the experiments from the issue body into a list of ExperimentSettings 2025-03-14T03:51:42.9589084Z  """ 2025-03-14T03:51:42.9589493Z  try: 2025-03-14T03:51:42.9589926Z  if settings_text: 2025-03-14T03:51:42.9590766Z  # Escape the backtick as well so that we can have the settings in a code block on the GH issue 2025-03-14T03:51:42.9591641Z  # for easy reading 2025-03-14T03:51:42.9592561Z  # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-03-14T03:51:42.9593555Z  # the backtick character in shell commands. 2025-03-14T03:51:42.9594243Z  backtick = chr(96) # backtick character 2025-03-14T03:51:42.9595001Z  settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-03-14T03:51:42.9595750Z  settings = load_yaml(settings_text) 2025-03-14T03:51:42.9596324Z  2025-03-14T03:51:42.9596992Z  # For now we just load experiments. We can expand this if/when we add more settings 2025-03-14T03:51:42.9597817Z  experiments = {} 2025-03-14T03:51:42.9598346Z  2025-03-14T03:51:42.9599083Z  for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-03-14T03:51:42.9599928Z  if not is_valid_experiment_name(exp_name): 2025-03-14T03:51:42.9601140Z  # 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:42.9602261Z  continue 2025-03-14T03:51:42.9602774Z  2025-03-14T03:51:42.9603209Z  valid_settings = {} 2025-03-14T03:51:42.9603824Z  for setting in exp_settings: 2025-03-14T03:51:42.9604473Z  if setting not in Experiment._fields: 2025-03-14T03:51:42.9605118Z  log.warning( 2025-03-14T03:51:42.9606055Z  f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-03-14T03:51:42.9606862Z  ) 2025-03-14T03:51:42.9607386Z  else: 2025-03-14T03:51:42.9608001Z  valid_settings[setting] = exp_settings[setting] 2025-03-14T03:51:42.9608738Z  2025-03-14T03:51:42.9609282Z  experiments[exp_name] = Experiment(**valid_settings) 2025-03-14T03:51:42.9610007Z  return Settings(experiments) 2025-03-14T03:51:42.9610576Z  2025-03-14T03:51:42.9610989Z  except Exception: 2025-03-14T03:51:42.9611571Z  log.exception("Failed to parse settings") 2025-03-14T03:51:42.9612180Z  2025-03-14T03:51:42.9612584Z  return Settings() 2025-03-14T03:51:42.9613068Z  2025-03-14T03:51:42.9613454Z  2025-03-14T03:51:42.9613972Z def parse_settings(rollout_state: str) -> Settings: 2025-03-14T03:51:42.9614611Z  """ 2025-03-14T03:51:42.9615138Z  Parse settings, if any, from the rollout state. 2025-03-14T03:51:42.9615758Z  2025-03-14T03:51:42.9616363Z  If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:42.9617229Z  and the text below is the list of opted in users. 2025-03-14T03:51:42.9617843Z  2025-03-14T03:51:42.9618507Z  If it doesn't contain "---" then the settings are empty and the default values are used. 2025-03-14T03:51:42.9619407Z  """ 2025-03-14T03:51:42.9620054Z  settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:42.9621105Z  return parse_settings_from_text(settings_text) 2025-03-14T03:51:42.9621726Z  2025-03-14T03:51:42.9622109Z  2025-03-14T03:51:42.9622622Z def parse_users(rollout_state: str) -> UserOptins: 2025-03-14T03:51:42.9623260Z  """ 2025-03-14T03:51:42.9623730Z  Parse users from the rollout state. 2025-03-14T03:51:42.9624290Z  2025-03-14T03:51:42.9624671Z  """ 2025-03-14T03:51:42.9625298Z  _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:42.9626124Z  return parse_user_opt_in_from_text(users_text) 2025-03-14T03:51:42.9626739Z  2025-03-14T03:51:42.9627121Z  2025-03-14T03:51:42.9627805Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:42.9628729Z  """ 2025-03-14T03:51:42.9629233Z  Check if a user is opted into an experiment 2025-03-14T03:51:42.9629837Z  """ 2025-03-14T03:51:42.9630380Z  return experiment_name in user_optins.get(user, []) 2025-03-14T03:51:42.9631017Z  2025-03-14T03:51:42.9631405Z  2025-03-14T03:51:42.9632099Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:42.9632934Z  """ 2025-03-14T03:51:42.9633478Z  Check if a user explicitly opted out of an experiment 2025-03-14T03:51:42.9634117Z  """ 2025-03-14T03:51:42.9634716Z  # if the experiment is prefixed with a "-", then it's an opt-out 2025-03-14T03:51:42.9635496Z  experiment_optout = "-" + experiment_name 2025-03-14T03:51:42.9636226Z  if experiment_optout not in user_optins.get(user, []): 2025-03-14T03:51:42.9636894Z  return False 2025-03-14T03:51:42.9637370Z  2025-03-14T03:51:42.9637895Z  if is_user_opted_in(user, user_optins, experiment_name): 2025-03-14T03:51:42.9638656Z  log.warning( 2025-03-14T03:51:42.9639575Z  f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-03-14T03:51:42.9640658Z  ) 2025-03-14T03:51:42.9641079Z  2025-03-14T03:51:42.9641474Z  return True 2025-03-14T03:51:42.9641928Z  2025-03-14T03:51:42.9642312Z  2025-03-14T03:51:42.9642722Z def get_runner_prefix( 2025-03-14T03:51:42.9643241Z  rollout_state: str, 2025-03-14T03:51:42.9643794Z  workflow_requestors: Iterable[str], 2025-03-14T03:51:42.9644365Z  branch: str, 2025-03-14T03:51:42.9644964Z  eligible_experiments: frozenset[str] = frozenset(), 2025-03-14T03:51:42.9645634Z  is_canary: bool = False, 2025-03-14T03:51:42.9646160Z ) -> str: 2025-03-14T03:51:42.9646659Z  settings = parse_settings(rollout_state) 2025-03-14T03:51:42.9647310Z  user_optins = parse_users(rollout_state) 2025-03-14T03:51:42.9647890Z  2025-03-14T03:51:42.9648296Z  fleet_prefix = "" 2025-03-14T03:51:42.9648908Z  prefixes = [] 2025-03-14T03:51:42.9649650Z  for experiment_name, experiment_settings in settings.experiments.items(): 2025-03-14T03:51:42.9650686Z  if not experiment_settings.all_branches and is_exception_branch(branch): 2025-03-14T03:51:42.9651470Z  log.info( 2025-03-14T03:51:42.9652252Z  f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-03-14T03:51:42.9653077Z  ) 2025-03-14T03:51:42.9653532Z  continue 2025-03-14T03:51:42.9654006Z  2025-03-14T03:51:42.9654429Z  if eligible_experiments: 2025-03-14T03:51:42.9655212Z  if experiment_name not in eligible_experiments: 2025-03-14T03:51:42.9655951Z  exp_list = ", ".join(eligible_experiments) 2025-03-14T03:51:42.9656581Z  log.info( 2025-03-14T03:51:42.9657485Z  f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-03-14T03:51:42.9658389Z  ) 2025-03-14T03:51:42.9658984Z  continue 2025-03-14T03:51:42.9659565Z  elif not experiment_settings.default: 2025-03-14T03:51:42.9660169Z  log.info( 2025-03-14T03:51:42.9660944Z  f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-03-14T03:51:42.9661782Z  ) 2025-03-14T03:51:42.9662232Z  continue 2025-03-14T03:51:42.9662709Z  2025-03-14T03:51:42.9663247Z  # Is any workflow_requestor opted out to this experiment? 2025-03-14T03:51:42.9663946Z  opted_out_users = [ 2025-03-14T03:51:42.9664487Z  requestor 2025-03-14T03:51:42.9665045Z  for requestor in workflow_requestors 2025-03-14T03:51:42.9665814Z  if is_user_opted_out(requestor, user_optins, experiment_name) 2025-03-14T03:51:42.9666507Z  ] 2025-03-14T03:51:42.9666930Z  2025-03-14T03:51:42.9667363Z  if opted_out_users: 2025-03-14T03:51:42.9667899Z  log.info( 2025-03-14T03:51:42.9668723Z  f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-03-14T03:51:42.9669494Z  ) 2025-03-14T03:51:42.9669947Z  continue 2025-03-14T03:51:42.9670423Z  2025-03-14T03:51:42.9670951Z  # Is any workflow_requestor opted in to this experiment? 2025-03-14T03:51:42.9671636Z  opted_in_users = [ 2025-03-14T03:51:42.9672166Z  requestor 2025-03-14T03:51:42.9672719Z  for requestor in workflow_requestors 2025-03-14T03:51:42.9673478Z  if is_user_opted_in(requestor, user_optins, experiment_name) 2025-03-14T03:51:42.9674303Z  ] 2025-03-14T03:51:42.9674719Z  2025-03-14T03:51:42.9675119Z  enabled = False 2025-03-14T03:51:42.9675648Z  if opted_in_users: 2025-03-14T03:51:42.9676172Z  log.info( 2025-03-14T03:51:42.9676914Z  f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-03-14T03:51:42.9677678Z  ) 2025-03-14T03:51:42.9678141Z  enabled = True 2025-03-14T03:51:42.9678747Z  2025-03-14T03:51:42.9679212Z  elif experiment_settings.rollout_perc: 2025-03-14T03:51:42.9680175Z  # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-03-14T03:51:42.9681205Z  if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-03-14T03:51:42.9681929Z  log.info( 2025-03-14T03:51:42.9682906Z  f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-03-14T03:51:42.9683898Z  ) 2025-03-14T03:51:42.9684398Z  enabled = True 2025-03-14T03:51:42.9684928Z  2025-03-14T03:51:42.9685349Z  if enabled: 2025-03-14T03:51:42.9685869Z  label = experiment_name 2025-03-14T03:51:42.9686501Z  if experiment_name == LF_FLEET_EXPERIMENT: 2025-03-14T03:51:42.9687417Z  # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-03-14T03:51:42.9688521Z  # - If it's enabled, then we always list it's prefix first 2025-03-14T03:51:42.9689491Z  # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-03-14T03:51:42.9690227Z  if is_canary: 2025-03-14T03:51:42.9690814Z  label += CANARY_FLEET_SUFFIX 2025-03-14T03:51:42.9691427Z  fleet_prefix = label 2025-03-14T03:51:42.9691993Z  else: 2025-03-14T03:51:42.9692515Z  prefixes.append(label) 2025-03-14T03:51:42.9693112Z  2025-03-14T03:51:42.9693535Z  if len(prefixes) > 1: 2025-03-14T03:51:42.9694065Z  log.error( 2025-03-14T03:51:42.9695208Z  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:42.9696393Z  ) 2025-03-14T03:51:42.9696854Z  prefixes = prefixes[:1] 2025-03-14T03:51:42.9697399Z  2025-03-14T03:51:42.9697819Z  # Fleet always comes first 2025-03-14T03:51:42.9698372Z  if fleet_prefix: 2025-03-14T03:51:42.9699008Z  prefixes.insert(0, fleet_prefix) 2025-03-14T03:51:42.9699594Z  2025-03-14T03:51:42.9700109Z  return ".".join(prefixes) + "." if prefixes else "" 2025-03-14T03:51:42.9700750Z  2025-03-14T03:51:42.9701133Z  2025-03-14T03:51:42.9701844Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-03-14T03:51:42.9702688Z  """ 2025-03-14T03:51:42.9703367Z  Gets the first comment of the issue, which contains the desired rollout state. 2025-03-14T03:51:42.9704143Z  2025-03-14T03:51:42.9704788Z  The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-03-14T03:51:42.9705567Z  """ 2025-03-14T03:51:42.9706047Z  gh = get_gh_client(github_token) 2025-03-14T03:51:42.9706689Z  issue = get_issue(gh, repo, issue_num) 2025-03-14T03:51:42.9707423Z  return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-03-14T03:51:42.9708227Z  2025-03-14T03:51:42.9708705Z  2025-03-14T03:51:42.9709388Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-03-14T03:51:42.9710230Z  for _ in range(num_retries): 2025-03-14T03:51:42.9710776Z  try: 2025-03-14T03:51:42.9711285Z  req = Request(url=url, headers=headers) 2025-03-14T03:51:42.9712038Z  content = urlopen(req, timeout=5).read().decode("utf-8") 2025-03-14T03:51:42.9712755Z  return json.loads(content) 2025-03-14T03:51:42.9713358Z  except Exception as e: 2025-03-14T03:51:42.9713993Z  log.warning(f"Could not download {url}: {e}") 2025-03-14T03:51:42.9714617Z  2025-03-14T03:51:42.9715265Z  log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-03-14T03:51:42.9716050Z  return {} 2025-03-14T03:51:42.9716501Z  2025-03-14T03:51:42.9716884Z  2025-03-14T03:51:42.9717269Z @cache 2025-03-14T03:51:42.9717993Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-03-14T03:51:42.9718919Z  """ 2025-03-14T03:51:42.9719381Z  Dynamically get PR information 2025-03-14T03:51:42.9787189Z  """ 2025-03-14T03:51:42.9787946Z  github_api = f"https://api.github.com/repos/{github_repo}" 2025-03-14T03:51:42.9788866Z  headers = { 2025-03-14T03:51:42.9789486Z  "Accept": "application/vnd.github.v3+json", 2025-03-14T03:51:42.9790188Z  "Authorization": f"token {github_token}", 2025-03-14T03:51:42.9790774Z  } 2025-03-14T03:51:42.9791482Z  json_response: dict[str, Any] = download_json( 2025-03-14T03:51:42.9792197Z  url=f"{github_api}/issues/{pr_number}", 2025-03-14T03:51:42.9792810Z  headers=headers, 2025-03-14T03:51:42.9793313Z  ) 2025-03-14T03:51:42.9793721Z  2025-03-14T03:51:42.9794132Z  if not json_response: 2025-03-14T03:51:42.9794801Z  log.warning(f"Failed to get the labels for #{pr_number}") 2025-03-14T03:51:42.9795497Z  return {} 2025-03-14T03:51:42.9795959Z  2025-03-14T03:51:42.9796378Z  return json_response 2025-03-14T03:51:42.9796879Z  2025-03-14T03:51:42.9797257Z  2025-03-14T03:51:42.9797903Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-03-14T03:51:42.9798797Z  """ 2025-03-14T03:51:42.9799413Z  Dynamically get the latest list of labels from the pull request 2025-03-14T03:51:42.9800111Z  """ 2025-03-14T03:51:42.9800673Z  pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-03-14T03:51:42.9801341Z  return { 2025-03-14T03:51:42.9802010Z  label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-03-14T03:51:42.9802762Z  } 2025-03-14T03:51:42.9803174Z  2025-03-14T03:51:42.9803561Z  2025-03-14T03:51:42.9803970Z def main() -> None: 2025-03-14T03:51:42.9804467Z  args = parse_args() 2025-03-14T03:51:42.9804952Z  2025-03-14T03:51:42.9805417Z  runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-03-14T03:51:42.9806006Z  2025-03-14T03:51:42.9806425Z  # Check if the PR is opt-out 2025-03-14T03:51:42.9806980Z  if args.pr_number: 2025-03-14T03:51:42.9807728Z  labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-03-14T03:51:42.9808540Z  if OPT_OUT_LABEL in labels: 2025-03-14T03:51:42.9809229Z  log.info( 2025-03-14T03:51:42.9810017Z  f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-03-14T03:51:42.9810991Z  ) 2025-03-14T03:51:42.9811635Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:42.9812394Z  sys.exit() 2025-03-14T03:51:42.9812890Z  2025-03-14T03:51:42.9813279Z  try: 2025-03-14T03:51:42.9813803Z  rollout_state = get_rollout_state_from_issue( 2025-03-14T03:51:42.9814587Z  args.github_token, args.github_issue_repo, args.github_issue 2025-03-14T03:51:42.9815271Z  ) 2025-03-14T03:51:42.9815694Z  2025-03-14T03:51:42.9816142Z  username = get_potential_pr_author( 2025-03-14T03:51:42.9816746Z  args.github_token, 2025-03-14T03:51:42.9817332Z  args.github_repo, 2025-03-14T03:51:42.9817900Z  args.github_actor, 2025-03-14T03:51:42.9818464Z  args.github_ref_type, 2025-03-14T03:51:42.9819316Z  args.github_branch, 2025-03-14T03:51:42.9819873Z  ) 2025-03-14T03:51:42.9820292Z  2025-03-14T03:51:42.9820829Z  is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-03-14T03:51:42.9821484Z  2025-03-14T03:51:42.9821961Z  runner_label_prefix = get_runner_prefix( 2025-03-14T03:51:42.9822578Z  rollout_state, 2025-03-14T03:51:42.9823163Z  (args.github_issue_owner, username), 2025-03-14T03:51:42.9823768Z  args.github_branch, 2025-03-14T03:51:42.9824345Z  args.eligible_experiments, 2025-03-14T03:51:42.9824921Z  is_canary, 2025-03-14T03:51:42.9825543Z  ) 2025-03-14T03:51:42.9825980Z  2025-03-14T03:51:42.9826383Z  except Exception as e: 2025-03-14T03:51:42.9826900Z  log.error( 2025-03-14T03:51:42.9827665Z  f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-03-14T03:51:42.9828463Z  ) 2025-03-14T03:51:42.9829382Z  2025-03-14T03:51:42.9829973Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:42.9830685Z  2025-03-14T03:51:42.9831061Z  2025-03-14T03:51:42.9831459Z if __name__ == "__main__": 2025-03-14T03:51:42.9831965Z  main() 2025-03-14T03:51:42.9832386Z  2025-03-14T03:51:42.9832757Z EOF 2025-03-14T03:51:42.9833149Z  2025-03-14T03:51:42.9833571Z cat runner_determinator.py 2025-03-14T03:51:43.0179892Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:43.0180714Z env: 2025-03-14T03:51:43.0181416Z GITHUB_TOKEN: *** 2025-03-14T03:51:43.0181866Z ISSUE_NUMBER: 5132 2025-03-14T03:51:43.0182342Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:43.0182897Z ISSUE_OWNER: 2025-03-14T03:51:43.0183319Z CHECK_EXPERIMENTS: 2025-03-14T03:51:43.0183751Z PR_NUMBER: 2025-03-14T03:51:43.0184151Z ##[endgroup] 2025-03-14T03:51:43.0397631Z # flake8: noqa: G004 2025-03-14T03:51:43.0397986Z 2025-03-14T03:51:43.0398443Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-03-14T03:51:43.0399769Z # must be kept in sync. You can do it easily by running the following command: 2025-03-14T03:51:43.0400597Z # python .github/scripts/update_runner_determinator.py 2025-03-14T03:51:43.0401062Z 2025-03-14T03:51:43.0401236Z """ 2025-03-14T03:51:43.0401829Z This runner determinator is used to determine which set of runners to run a 2025-03-14T03:51:43.0402748Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-03-14T03:51:43.0403705Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-03-14T03:51:43.0404560Z of which runners should be used to run which job. 2025-03-14T03:51:43.0404979Z 2025-03-14T03:51:43.0405595Z The configuration has two parts, the settings and a list of opted-in users, 2025-03-14T03:51:43.0406512Z separated by a line containing "---". If the line is not present, the 2025-03-14T03:51:43.0407399Z settings are considered to be empty with only the second part, the user 2025-03-14T03:51:43.0408116Z list, defined. 2025-03-14T03:51:43.0408367Z 2025-03-14T03:51:43.0408974Z The first part is a YAML block that defines the rollout settings. This can be 2025-03-14T03:51:43.0409945Z used to define any settings that are needed to determine which runners to use. 2025-03-14T03:51:43.0410797Z It's fields are defined by the RolloutSettings class below. 2025-03-14T03:51:43.0411256Z 2025-03-14T03:51:43.0411638Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-03-14T03:51:43.0412536Z The user list is also a comma separated list of additional features or 2025-03-14T03:51:43.0413285Z experiments which the user could be opted in to. 2025-03-14T03:51:43.0413735Z 2025-03-14T03:51:43.0413949Z The user list has the following rules: 2025-03-14T03:51:43.0414312Z 2025-03-14T03:51:43.0414631Z - Users are GitHub usernames, which must start with the @ prefix 2025-03-14T03:51:43.0415543Z - Each user is also a comma-separated list of features/experiments to enable 2025-03-14T03:51:43.0416334Z - A "#" prefix opts the user out of all experiments 2025-03-14T03:51:43.0416743Z 2025-03-14T03:51:43.0416932Z Example config: 2025-03-14T03:51:43.0417406Z # A list of experiments that can be opted into. 2025-03-14T03:51:43.0418093Z # This defines the behavior they'll induce when opted into. 2025-03-14T03:51:43.0418869Z # Expected syntax is: 2025-03-14T03:51:43.0419539Z # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-03-14T03:51:43.0420671Z # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-03-14T03:51:43.0421310Z 2025-03-14T03:51:43.0421494Z experiments: 2025-03-14T03:51:43.0421912Z lf: 2025-03-14T03:51:43.0422318Z rollout_percent: 25 2025-03-14T03:51:43.0422794Z all_branches: false 2025-03-14T03:51:43.0423249Z default: true 2025-03-14T03:51:43.0423676Z --- 2025-03-14T03:51:43.0423894Z 2025-03-14T03:51:43.0424066Z # Opt-ins: 2025-03-14T03:51:43.0424687Z # Users can opt into the LF fleet by adding their GitHub username to this list 2025-03-14T03:51:43.0425566Z # and specifying experiments to enable in a comma-separated list. 2025-03-14T03:51:43.0426362Z # To always opt out of an experiment, prefix it with a "-". 2025-03-14T03:51:43.0427038Z # Experiments should be from the above list. 2025-03-14T03:51:43.0427437Z 2025-03-14T03:51:43.0427626Z @User1,-lf,split_build 2025-03-14T03:51:43.0428080Z @User2,lf 2025-03-14T03:51:43.0428485Z @User3,split_build 2025-03-14T03:51:43.0429025Z """ 2025-03-14T03:51:43.0429226Z 2025-03-14T03:51:43.0429399Z import json 2025-03-14T03:51:43.0429792Z import logging 2025-03-14T03:51:43.0430203Z import os 2025-03-14T03:51:43.0430606Z import random 2025-03-14T03:51:43.0431019Z import re 2025-03-14T03:51:43.0431394Z import sys 2025-03-14T03:51:43.0431814Z from argparse import ArgumentParser 2025-03-14T03:51:43.0432380Z from collections.abc import Iterable 2025-03-14T03:51:43.0432923Z from functools import cache 2025-03-14T03:51:43.0433419Z from logging import LogRecord 2025-03-14T03:51:43.0433948Z from typing import Any, NamedTuple 2025-03-14T03:51:43.0434502Z from urllib.request import Request, urlopen 2025-03-14T03:51:43.0434894Z 2025-03-14T03:51:43.0435072Z import yaml 2025-03-14T03:51:43.0435502Z from github import Auth, Github 2025-03-14T03:51:43.0436018Z from github.Issue import Issue 2025-03-14T03:51:43.0436334Z 2025-03-14T03:51:43.0436341Z 2025-03-14T03:51:43.0436582Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-03-14T03:51:43.0437298Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-03-14T03:51:43.0438185Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-03-14T03:51:43.0439132Z 2025-03-14T03:51:43.0439381Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-03-14T03:51:43.0439988Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-03-14T03:51:43.0440523Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-03-14T03:51:43.0441111Z OPT_OUT_LABEL = "no-runner-experiments" 2025-03-14T03:51:43.0441482Z 2025-03-14T03:51:43.0441692Z SETTING_EXPERIMENTS = "experiments" 2025-03-14T03:51:43.0442036Z 2025-03-14T03:51:43.0442231Z LF_FLEET_EXPERIMENT = "lf" 2025-03-14T03:51:43.0442713Z CANARY_FLEET_SUFFIX = ".c" 2025-03-14T03:51:43.0443020Z 2025-03-14T03:51:43.0443031Z 2025-03-14T03:51:43.0443236Z class Experiment(NamedTuple): 2025-03-14T03:51:43.0443739Z rollout_perc: float = ( 2025-03-14T03:51:43.0444407Z 0 # Percentage of workflows to experiment on when user is not opted-in. 2025-03-14T03:51:43.0445099Z ) 2025-03-14T03:51:43.0445489Z all_branches: bool = ( 2025-03-14T03:51:43.0446136Z False # If True, the experiment is also enabled on the exception branches 2025-03-14T03:51:43.0446840Z ) 2025-03-14T03:51:43.0447221Z default: bool = ( 2025-03-14T03:51:43.0447814Z True # If True, the experiment is enabled by default for all queries 2025-03-14T03:51:43.0448488Z ) 2025-03-14T03:51:43.0448834Z 2025-03-14T03:51:43.0449030Z # Add more fields as needed 2025-03-14T03:51:43.0449348Z 2025-03-14T03:51:43.0449356Z 2025-03-14T03:51:43.0449558Z class Settings(NamedTuple): 2025-03-14T03:51:43.0450020Z """ 2025-03-14T03:51:43.0450487Z Settings for the experiments that can be opted into. 2025-03-14T03:51:43.0451084Z """ 2025-03-14T03:51:43.0451294Z 2025-03-14T03:51:43.0451514Z experiments: dict[str, Experiment] = {} 2025-03-14T03:51:43.0451898Z 2025-03-14T03:51:43.0451905Z 2025-03-14T03:51:43.0452263Z class ColorFormatter(logging.Formatter): 2025-03-14T03:51:43.0452922Z """Color codes the log messages based on the log level""" 2025-03-14T03:51:43.0453373Z 2025-03-14T03:51:43.0453550Z COLORS = { 2025-03-14T03:51:43.0453981Z "WARNING": "\033[33m", # Yellow 2025-03-14T03:51:43.0454521Z "ERROR": "\033[31m", # Red 2025-03-14T03:51:43.0455038Z "CRITICAL": "\033[31m", # Red 2025-03-14T03:51:43.0455558Z "INFO": "\033[0m", # Reset 2025-03-14T03:51:43.0456063Z "DEBUG": "\033[0m", # Reset 2025-03-14T03:51:43.0456550Z } 2025-03-14T03:51:43.0456763Z 2025-03-14T03:51:43.0456989Z def format(self, record: LogRecord) -> str: 2025-03-14T03:51:43.0457763Z log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-03-14T03:51:43.0458555Z record.msg = f"{log_color}{record.msg}\033[0m" 2025-03-14T03:51:43.0459270Z return super().format(record) 2025-03-14T03:51:43.0459631Z 2025-03-14T03:51:43.0459638Z 2025-03-14T03:51:43.0459853Z handler = logging.StreamHandler() 2025-03-14T03:51:43.0460582Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-03-14T03:51:43.0461165Z 2025-03-14T03:51:43.0461424Z log = logging.getLogger(os.path.basename(__file__)) 2025-03-14T03:51:43.0462038Z log.addHandler(handler) 2025-03-14T03:51:43.0462506Z log.setLevel(logging.INFO) 2025-03-14T03:51:43.0462805Z 2025-03-14T03:51:43.0462812Z 2025-03-14T03:51:43.0463072Z def set_github_output(key: str, value: str) -> None: 2025-03-14T03:51:43.0463648Z """ 2025-03-14T03:51:43.0464177Z Defines outputs of the github action that invokes this script 2025-03-14T03:51:43.0464821Z """ 2025-03-14T03:51:43.0465218Z if not GITHUB_OUTPUT: 2025-03-14T03:51:43.0466304Z # 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.0467443Z log.warning( 2025-03-14T03:51:43.0468306Z "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.0469378Z ) 2025-03-14T03:51:43.0479232Z print(f"::set-output name={key}::{value}") 2025-03-14T03:51:43.0480082Z return 2025-03-14T03:51:43.0480326Z 2025-03-14T03:51:43.0480546Z with open(GITHUB_OUTPUT, "a") as f: 2025-03-14T03:51:43.0481147Z log.info(f"Setting output: {key}='{value}'") 2025-03-14T03:51:43.0481745Z f.write(f"{key}={value}\n") 2025-03-14T03:51:43.0482087Z 2025-03-14T03:51:43.0482094Z 2025-03-14T03:51:43.0482403Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-03-14T03:51:43.0483056Z return frozenset( 2025-03-14T03:51:43.0483683Z filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-03-14T03:51:43.0484387Z ) 2025-03-14T03:51:43.0484606Z 2025-03-14T03:51:43.0484617Z 2025-03-14T03:51:43.0484827Z def parse_args() -> Any: 2025-03-14T03:51:43.0485401Z parser = ArgumentParser("Get dynamic rollout settings") 2025-03-14T03:51:43.0486346Z parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-03-14T03:51:43.0487142Z parser.add_argument( 2025-03-14T03:51:43.0487625Z "--github-issue-repo", 2025-03-14T03:51:43.0488107Z type=str, 2025-03-14T03:51:43.0488535Z required=False, 2025-03-14T03:51:43.0489146Z default="pytorch/test-infra", 2025-03-14T03:51:43.0489719Z help="GitHub repo to get the issue", 2025-03-14T03:51:43.0490258Z ) 2025-03-14T03:51:43.0490641Z parser.add_argument( 2025-03-14T03:51:43.0491108Z "--github-repo", 2025-03-14T03:51:43.0491553Z type=str, 2025-03-14T03:51:43.0491974Z required=True, 2025-03-14T03:51:43.0492462Z help="GitHub repo where CI is running", 2025-03-14T03:51:43.0493022Z ) 2025-03-14T03:51:43.0493411Z parser.add_argument( 2025-03-14T03:51:43.0494037Z "--github-issue", type=int, required=True, help="GitHub issue number" 2025-03-14T03:51:43.0494847Z ) 2025-03-14T03:51:43.0495259Z parser.add_argument( 2025-03-14T03:51:43.0495900Z "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-03-14T03:51:43.0496610Z ) 2025-03-14T03:51:43.0497000Z parser.add_argument( 2025-03-14T03:51:43.0497660Z "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-03-14T03:51:43.0498377Z ) 2025-03-14T03:51:43.0499053Z parser.add_argument( 2025-03-14T03:51:43.0499768Z "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-03-14T03:51:43.0500508Z ) 2025-03-14T03:51:43.0500892Z parser.add_argument( 2025-03-14T03:51:43.0501363Z "--github-ref-type", 2025-03-14T03:51:43.0501828Z type=str, 2025-03-14T03:51:43.0502242Z required=True, 2025-03-14T03:51:43.0502743Z help="Current GitHub ref type, branch or tag", 2025-03-14T03:51:43.0503313Z ) 2025-03-14T03:51:43.0503699Z parser.add_argument( 2025-03-14T03:51:43.0504194Z "--eligible-experiments", 2025-03-14T03:51:43.0504728Z type=_str_comma_separated_to_set, 2025-03-14T03:51:43.0505275Z required=False, 2025-03-14T03:51:43.0505720Z default="", 2025-03-14T03:51:43.0506578Z help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-03-14T03:51:43.0507546Z ) 2025-03-14T03:51:43.0507934Z parser.add_argument( 2025-03-14T03:51:43.0508389Z "--pr-number", 2025-03-14T03:51:43.0508945Z type=str, 2025-03-14T03:51:43.0509366Z required=False, 2025-03-14T03:51:43.0509806Z default="", 2025-03-14T03:51:43.0510292Z help="the optional PR number where this is run", 2025-03-14T03:51:43.0510872Z ) 2025-03-14T03:51:43.0511076Z 2025-03-14T03:51:43.0511283Z return parser.parse_args() 2025-03-14T03:51:43.0511603Z 2025-03-14T03:51:43.0511609Z 2025-03-14T03:51:43.0512037Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-03-14T03:51:43.0512813Z auth = Auth.Token(github_token) 2025-03-14T03:51:43.0513336Z return Github(auth=auth) 2025-03-14T03:51:43.0513650Z 2025-03-14T03:51:43.0513802Z 2025-03-14T03:51:43.0514300Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-03-14T03:51:43.0515163Z repo = gh.get_repo(repo) 2025-03-14T03:51:43.0515688Z return repo.get_issue(number=issue_num) 2025-03-14T03:51:43.0516065Z 2025-03-14T03:51:43.0516072Z 2025-03-14T03:51:43.0516275Z def get_potential_pr_author( 2025-03-14T03:51:43.0516926Z github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-03-14T03:51:43.0517628Z ) -> str: 2025-03-14T03:51:43.0518163Z # If the trigger was a new tag added by a bot, this is a ciflow case 2025-03-14T03:51:43.0519170Z # Fetch the actual username from the original PR. The PR number is 2025-03-14T03:51:43.0519940Z # embedded in the tag name: ciflow// 2025-03-14T03:51:43.0520363Z 2025-03-14T03:51:43.0520558Z gh = get_gh_client(github_token) 2025-03-14T03:51:43.0520903Z 2025-03-14T03:51:43.0521177Z if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-03-14T03:51:43.0521830Z split_tag = ref_name.split("/") 2025-03-14T03:51:43.0522353Z if ( 2025-03-14T03:51:43.0522762Z len(split_tag) == 3 2025-03-14T03:51:43.0523256Z and split_tag[0] == "ciflow" 2025-03-14T03:51:43.0523787Z and split_tag[2].isnumeric() 2025-03-14T03:51:43.0524300Z ): 2025-03-14T03:51:43.0524696Z pr_number = split_tag[2] 2025-03-14T03:51:43.0525197Z try: 2025-03-14T03:51:43.0525636Z repository = gh.get_repo(repo) 2025-03-14T03:51:43.0526259Z pull = repository.get_pull(number=int(pr_number)) 2025-03-14T03:51:43.0526879Z except Exception as e: 2025-03-14T03:51:43.0527419Z raise Exception( # noqa: TRY002 2025-03-14T03:51:43.0528246Z f"issue with pull request {pr_number} from repo {repository}" 2025-03-14T03:51:43.0529080Z ) from e 2025-03-14T03:51:43.0529637Z return pull.user.login # type: ignore[no-any-return] 2025-03-14T03:51:43.0530367Z # In all other cases, return the original input username 2025-03-14T03:51:43.0530978Z return username 2025-03-14T03:51:43.0531222Z 2025-03-14T03:51:43.0531230Z 2025-03-14T03:51:43.0531468Z def is_exception_branch(branch: str) -> bool: 2025-03-14T03:51:43.0532025Z """ 2025-03-14T03:51:43.0532672Z Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-03-14T03:51:43.0533458Z """ 2025-03-14T03:51:43.0534023Z return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-03-14T03:51:43.0534554Z 2025-03-14T03:51:43.0534567Z 2025-03-14T03:51:43.0534771Z def load_yaml(yaml_text: str) -> Any: 2025-03-14T03:51:43.0535288Z try: 2025-03-14T03:51:43.0535691Z data = yaml.safe_load(yaml_text) 2025-03-14T03:51:43.0536218Z return data 2025-03-14T03:51:43.0536663Z except yaml.YAMLError: 2025-03-14T03:51:43.0537165Z log.exception("Error loading YAML") 2025-03-14T03:51:43.0537702Z raise 2025-03-14T03:51:43.0537921Z 2025-03-14T03:51:43.0537928Z 2025-03-14T03:51:43.0538355Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-03-14T03:51:43.0539220Z """ 2025-03-14T03:51:43.0539853Z Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-03-14T03:51:43.0540470Z 2025-03-14T03:51:43.0540823Z If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:43.0541584Z and the text below is the list of opted in users. 2025-03-14T03:51:43.0541999Z 2025-03-14T03:51:43.0542385Z If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-03-14T03:51:43.0543102Z """ 2025-03-14T03:51:43.0543564Z rollout_state_parts = rollout_state.split("---") 2025-03-14T03:51:43.0544178Z if len(rollout_state_parts) >= 2: 2025-03-14T03:51:43.0544794Z return rollout_state_parts[0], rollout_state_parts[1] 2025-03-14T03:51:43.0545558Z else: 2025-03-14T03:51:43.0545952Z return "", rollout_state 2025-03-14T03:51:43.0546273Z 2025-03-14T03:51:43.0546280Z 2025-03-14T03:51:43.0546494Z class UserOptins(dict[str, list[str]]): 2025-03-14T03:51:43.0547024Z """ 2025-03-14T03:51:43.0547572Z Dictionary of users with a list of features they have opted into 2025-03-14T03:51:43.0548249Z """ 2025-03-14T03:51:43.0548457Z 2025-03-14T03:51:43.0548463Z 2025-03-14T03:51:43.0548938Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-03-14T03:51:43.0549617Z """ 2025-03-14T03:51:43.0550342Z 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.0551047Z 2025-03-14T03:51:43.0551689Z 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.0552708Z - Example line: "@User1,lf,split_build" 2025-03-14T03:51:43.0553415Z - A "#" prefix indicates the user is opted out of all experiments 2025-03-14T03:51:43.0553915Z 2025-03-14T03:51:43.0553921Z 2025-03-14T03:51:43.0554092Z """ 2025-03-14T03:51:43.0554491Z optins = UserOptins() 2025-03-14T03:51:43.0554994Z for user in user_optin_text.split("\n"): 2025-03-14T03:51:43.0555572Z user = user.strip("\r\n\t -") 2025-03-14T03:51:43.0556142Z if not user or not user.startswith("@"): 2025-03-14T03:51:43.0556719Z # Not a valid user. Skip 2025-03-14T03:51:43.0557219Z continue 2025-03-14T03:51:43.0557478Z 2025-03-14T03:51:43.0557648Z if user: 2025-03-14T03:51:43.0558098Z usr_name = user.split(",")[0].strip("@") 2025-03-14T03:51:43.0558941Z optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-03-14T03:51:43.0559587Z 2025-03-14T03:51:43.0559785Z return optins 2025-03-14T03:51:43.0560044Z 2025-03-14T03:51:43.0560051Z 2025-03-14T03:51:43.0560354Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-03-14T03:51:43.0560983Z """ 2025-03-14T03:51:43.0561392Z Check if the experiment name is valid. 2025-03-14T03:51:43.0561938Z A valid name: 2025-03-14T03:51:43.0562590Z - Contains only alphanumeric characters and the special characters "_" & "-" 2025-03-14T03:51:43.0563541Z - The special characters "_" & "-" shouldn't be the first or last characters 2025-03-14T03:51:43.0564285Z - Cannot contain spaces 2025-03-14T03:51:43.0564753Z """ 2025-03-14T03:51:43.0564959Z 2025-03-14T03:51:43.0565229Z valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-03-14T03:51:43.0565966Z valid = bool(re.match(valid_char_regex, experiment_name)) 2025-03-14T03:51:43.0566421Z 2025-03-14T03:51:43.0566596Z if valid: 2025-03-14T03:51:43.0567000Z return True 2025-03-14T03:51:43.0567247Z 2025-03-14T03:51:43.0567422Z log.error( 2025-03-14T03:51:43.0569029Z 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.0570646Z ) 2025-03-14T03:51:43.0571021Z return False 2025-03-14T03:51:43.0571261Z 2025-03-14T03:51:43.0571268Z 2025-03-14T03:51:43.0571589Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-03-14T03:51:43.0572232Z """ 2025-03-14T03:51:43.0572838Z Parse the experiments from the issue body into a list of ExperimentSettings 2025-03-14T03:51:43.0573587Z """ 2025-03-14T03:51:43.0573952Z try: 2025-03-14T03:51:43.0574341Z if settings_text: 2025-03-14T03:51:43.0575091Z # 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.0575910Z # for easy reading 2025-03-14T03:51:43.0576723Z # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-03-14T03:51:43.0577803Z # the backtick character in shell commands. 2025-03-14T03:51:43.0578431Z backtick = chr(96) # backtick character 2025-03-14T03:51:43.0579250Z settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-03-14T03:51:43.0579938Z settings = load_yaml(settings_text) 2025-03-14T03:51:43.0580320Z 2025-03-14T03:51:43.0580739Z # For now we just load experiments. We can expand this if/when we add more settings 2025-03-14T03:51:43.0581518Z experiments = {} 2025-03-14T03:51:43.0581827Z 2025-03-14T03:51:43.0582189Z for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-03-14T03:51:43.0582965Z if not is_valid_experiment_name(exp_name): 2025-03-14T03:51:43.0584103Z # 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.0585188Z continue 2025-03-14T03:51:43.0585485Z 2025-03-14T03:51:43.0585672Z valid_settings = {} 2025-03-14T03:51:43.0586210Z for setting in exp_settings: 2025-03-14T03:51:43.0586802Z if setting not in Experiment._fields: 2025-03-14T03:51:43.0587375Z log.warning( 2025-03-14T03:51:43.0588097Z f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-03-14T03:51:43.0588948Z ) 2025-03-14T03:51:43.0589394Z else: 2025-03-14T03:51:43.0589923Z valid_settings[setting] = exp_settings[setting] 2025-03-14T03:51:43.0590377Z 2025-03-14T03:51:43.0590666Z experiments[exp_name] = Experiment(**valid_settings) 2025-03-14T03:51:43.0591469Z return Settings(experiments) 2025-03-14T03:51:43.0591855Z 2025-03-14T03:51:43.0592048Z except Exception: 2025-03-14T03:51:43.0592542Z log.exception("Failed to parse settings") 2025-03-14T03:51:43.0592960Z 2025-03-14T03:51:43.0593143Z return Settings() 2025-03-14T03:51:43.0593419Z 2025-03-14T03:51:43.0593426Z 2025-03-14T03:51:43.0593680Z def parse_settings(rollout_state: str) -> Settings: 2025-03-14T03:51:43.0594288Z """ 2025-03-14T03:51:43.0594734Z Parse settings, if any, from the rollout state. 2025-03-14T03:51:43.0595153Z 2025-03-14T03:51:43.0595518Z If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:43.0596302Z and the text below is the list of opted in users. 2025-03-14T03:51:43.0596726Z 2025-03-14T03:51:43.0597169Z If it doesn't contain "---" then the settings are empty and the default values are used. 2025-03-14T03:51:43.0597929Z """ 2025-03-14T03:51:43.0598506Z settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:43.0599394Z return parse_settings_from_text(settings_text) 2025-03-14T03:51:43.0599812Z 2025-03-14T03:51:43.0599819Z 2025-03-14T03:51:43.0600084Z def parse_users(rollout_state: str) -> UserOptins: 2025-03-14T03:51:43.0600667Z """ 2025-03-14T03:51:43.0601070Z Parse users from the rollout state. 2025-03-14T03:51:43.0601441Z 2025-03-14T03:51:43.0601608Z """ 2025-03-14T03:51:43.0602159Z _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:43.0602913Z return parse_user_opt_in_from_text(users_text) 2025-03-14T03:51:43.0603325Z 2025-03-14T03:51:43.0603332Z 2025-03-14T03:51:43.0603764Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:43.0604532Z """ 2025-03-14T03:51:43.0604963Z Check if a user is opted into an experiment 2025-03-14T03:51:43.0605516Z """ 2025-03-14T03:51:43.0605973Z return experiment_name in user_optins.get(user, []) 2025-03-14T03:51:43.0606411Z 2025-03-14T03:51:43.0606419Z 2025-03-14T03:51:43.0606855Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:43.0607789Z """ 2025-03-14T03:51:43.0608265Z Check if a user explicitly opted out of an experiment 2025-03-14T03:51:43.0608966Z """ 2025-03-14T03:51:43.0609494Z # if the experiment is prefixed with a "-", then it's an opt-out 2025-03-14T03:51:43.0610224Z experiment_optout = "-" + experiment_name 2025-03-14T03:51:43.0610883Z if experiment_optout not in user_optins.get(user, []): 2025-03-14T03:51:43.0611506Z return False 2025-03-14T03:51:43.0611782Z 2025-03-14T03:51:43.0612074Z if is_user_opted_in(user, user_optins, experiment_name): 2025-03-14T03:51:43.0612694Z log.warning( 2025-03-14T03:51:43.0613524Z f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-03-14T03:51:43.0614431Z ) 2025-03-14T03:51:43.0614652Z 2025-03-14T03:51:43.0614823Z return True 2025-03-14T03:51:43.0615069Z 2025-03-14T03:51:43.0615075Z 2025-03-14T03:51:43.0615289Z def get_runner_prefix( 2025-03-14T03:51:43.0615750Z rollout_state: str, 2025-03-14T03:51:43.0616230Z workflow_requestors: Iterable[str], 2025-03-14T03:51:43.0616760Z branch: str, 2025-03-14T03:51:43.0617248Z eligible_experiments: frozenset[str] = frozenset(), 2025-03-14T03:51:43.0617866Z is_canary: bool = False, 2025-03-14T03:51:43.0618334Z ) -> str: 2025-03-14T03:51:43.0618857Z settings = parse_settings(rollout_state) 2025-03-14T03:51:43.0619464Z user_optins = parse_users(rollout_state) 2025-03-14T03:51:43.0619846Z 2025-03-14T03:51:43.0620026Z fleet_prefix = "" 2025-03-14T03:51:43.0620460Z prefixes = [] 2025-03-14T03:51:43.0621099Z for experiment_name, experiment_settings in settings.experiments.items(): 2025-03-14T03:51:43.0622062Z if not experiment_settings.all_branches and is_exception_branch(branch): 2025-03-14T03:51:43.0622919Z log.info( 2025-03-14T03:51:43.0623630Z f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-03-14T03:51:43.0624423Z ) 2025-03-14T03:51:43.0624817Z continue 2025-03-14T03:51:43.0625073Z 2025-03-14T03:51:43.0625270Z if eligible_experiments: 2025-03-14T03:51:43.0625844Z if experiment_name not in eligible_experiments: 2025-03-14T03:51:43.0626494Z exp_list = ", ".join(eligible_experiments) 2025-03-14T03:51:43.0627067Z log.info( 2025-03-14T03:51:43.0627879Z f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-03-14T03:51:43.0628863Z ) 2025-03-14T03:51:43.0629279Z continue 2025-03-14T03:51:43.0629757Z elif not experiment_settings.default: 2025-03-14T03:51:43.0630305Z log.info( 2025-03-14T03:51:43.0630980Z f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-03-14T03:51:43.0631746Z ) 2025-03-14T03:51:43.0632131Z continue 2025-03-14T03:51:43.0632381Z 2025-03-14T03:51:43.0632675Z # Is any workflow_requestor opted out to this experiment? 2025-03-14T03:51:43.0633308Z opted_out_users = [ 2025-03-14T03:51:43.0633768Z requestor 2025-03-14T03:51:43.0634235Z for requestor in workflow_requestors 2025-03-14T03:51:43.0634921Z if is_user_opted_out(requestor, user_optins, experiment_name) 2025-03-14T03:51:43.0635573Z ] 2025-03-14T03:51:43.0635786Z 2025-03-14T03:51:43.0635969Z if opted_out_users: 2025-03-14T03:51:43.0636433Z log.info( 2025-03-14T03:51:43.0637071Z f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-03-14T03:51:43.0637791Z ) 2025-03-14T03:51:43.0638183Z continue 2025-03-14T03:51:43.0638439Z 2025-03-14T03:51:43.0638820Z # Is any workflow_requestor opted in to this experiment? 2025-03-14T03:51:43.0639461Z opted_in_users = [ 2025-03-14T03:51:43.0639921Z requestor 2025-03-14T03:51:43.0640533Z for requestor in workflow_requestors 2025-03-14T03:51:43.0641220Z if is_user_opted_in(requestor, user_optins, experiment_name) 2025-03-14T03:51:43.0641872Z ] 2025-03-14T03:51:43.0642082Z 2025-03-14T03:51:43.0642259Z enabled = False 2025-03-14T03:51:43.0642712Z if opted_in_users: 2025-03-14T03:51:43.0643175Z log.info( 2025-03-14T03:51:43.0643797Z f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-03-14T03:51:43.0644503Z ) 2025-03-14T03:51:43.0644908Z enabled = True 2025-03-14T03:51:43.0645206Z 2025-03-14T03:51:43.0645427Z elif experiment_settings.rollout_perc: 2025-03-14T03:51:43.0646291Z # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-03-14T03:51:43.0647259Z if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-03-14T03:51:43.0647946Z log.info( 2025-03-14T03:51:43.0648945Z f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-03-14T03:51:43.0649933Z ) 2025-03-14T03:51:43.0650362Z enabled = True 2025-03-14T03:51:43.0650671Z 2025-03-14T03:51:43.0650841Z if enabled: 2025-03-14T03:51:43.0651276Z label = experiment_name 2025-03-14T03:51:43.0651842Z if experiment_name == LF_FLEET_EXPERIMENT: 2025-03-14T03:51:43.0652692Z # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-03-14T03:51:43.0653593Z # - If it's enabled, then we always list it's prefix first 2025-03-14T03:51:43.0654497Z # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-03-14T03:51:43.0655199Z if is_canary: 2025-03-14T03:51:43.0655710Z label += CANARY_FLEET_SUFFIX 2025-03-14T03:51:43.0656273Z fleet_prefix = label 2025-03-14T03:51:43.0656774Z else: 2025-03-14T03:51:43.0657216Z prefixes.append(label) 2025-03-14T03:51:43.0657581Z 2025-03-14T03:51:43.0657773Z if len(prefixes) > 1: 2025-03-14T03:51:43.0658237Z log.error( 2025-03-14T03:51:43.0659412Z 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.0660567Z ) 2025-03-14T03:51:43.0660975Z prefixes = prefixes[:1] 2025-03-14T03:51:43.0661305Z 2025-03-14T03:51:43.0661496Z # Fleet always comes first 2025-03-14T03:51:43.0662019Z if fleet_prefix: 2025-03-14T03:51:43.0662492Z prefixes.insert(0, fleet_prefix) 2025-03-14T03:51:43.0662866Z 2025-03-14T03:51:43.0663126Z return ".".join(prefixes) + "." if prefixes else "" 2025-03-14T03:51:43.0663551Z 2025-03-14T03:51:43.0663558Z 2025-03-14T03:51:43.0664009Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-03-14T03:51:43.0664813Z """ 2025-03-14T03:51:43.0665410Z Gets the first comment of the issue, which contains the desired rollout state. 2025-03-14T03:51:43.0665983Z 2025-03-14T03:51:43.0666381Z The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-03-14T03:51:43.0667113Z """ 2025-03-14T03:51:43.0667504Z gh = get_gh_client(github_token) 2025-03-14T03:51:43.0668060Z issue = get_issue(gh, repo, issue_num) 2025-03-14T03:51:43.0668803Z return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-03-14T03:51:43.0669264Z 2025-03-14T03:51:43.0669277Z 2025-03-14T03:51:43.0669686Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-03-14T03:51:43.0670470Z for _ in range(num_retries): 2025-03-14T03:51:43.0670976Z try: 2025-03-14T03:51:43.0671407Z req = Request(url=url, headers=headers) 2025-03-14T03:51:43.0672099Z content = urlopen(req, timeout=5).read().decode("utf-8") 2025-03-14T03:51:43.0672911Z return json.loads(content) 2025-03-14T03:51:43.0673467Z except Exception as e: 2025-03-14T03:51:43.0674020Z log.warning(f"Could not download {url}: {e}") 2025-03-14T03:51:43.0674439Z 2025-03-14T03:51:43.0674828Z log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-03-14T03:51:43.0675569Z return {} 2025-03-14T03:51:43.0675806Z 2025-03-14T03:51:43.0675814Z 2025-03-14T03:51:43.0675981Z @cache 2025-03-14T03:51:43.0676625Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-03-14T03:51:43.0677406Z """ 2025-03-14T03:51:43.0677804Z Dynamically get PR information 2025-03-14T03:51:43.0678302Z """ 2025-03-14T03:51:43.0678911Z github_api = f"https://api.github.com/repos/{github_repo}" 2025-03-14T03:51:43.0679563Z headers = { 2025-03-14T03:51:43.0680034Z "Accept": "application/vnd.github.v3+json", 2025-03-14T03:51:43.0680651Z "Authorization": f"token {github_token}", 2025-03-14T03:51:43.0681207Z } 2025-03-14T03:51:43.0681653Z json_response: dict[str, Any] = download_json( 2025-03-14T03:51:43.0682281Z url=f"{github_api}/issues/{pr_number}", 2025-03-14T03:51:43.0682842Z headers=headers, 2025-03-14T03:51:43.0683286Z ) 2025-03-14T03:51:43.0683492Z 2025-03-14T03:51:43.0683677Z if not json_response: 2025-03-14T03:51:43.0684257Z log.warning(f"Failed to get the labels for #{pr_number}") 2025-03-14T03:51:43.0684907Z return {} 2025-03-14T03:51:43.0685150Z 2025-03-14T03:51:43.0685336Z return json_response 2025-03-14T03:51:43.0685623Z 2025-03-14T03:51:43.0685629Z 2025-03-14T03:51:43.0686037Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-03-14T03:51:43.0686908Z """ 2025-03-14T03:51:43.0687472Z Dynamically get the latest list of labels from the pull request 2025-03-14T03:51:43.0688143Z """ 2025-03-14T03:51:43.0688733Z pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-03-14T03:51:43.0689384Z return { 2025-03-14T03:51:43.0689976Z label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-03-14T03:51:43.0690726Z } 2025-03-14T03:51:43.0690937Z 2025-03-14T03:51:43.0690944Z 2025-03-14T03:51:43.0691122Z def main() -> None: 2025-03-14T03:51:43.0691548Z args = parse_args() 2025-03-14T03:51:43.0691822Z 2025-03-14T03:51:43.0692057Z runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-03-14T03:51:43.0692460Z 2025-03-14T03:51:43.0692660Z # Check if the PR is opt-out 2025-03-14T03:51:43.0693157Z if args.pr_number: 2025-03-14T03:51:43.0693826Z labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-03-14T03:51:43.0694614Z if OPT_OUT_LABEL in labels: 2025-03-14T03:51:43.0695136Z log.info( 2025-03-14T03:51:43.0695842Z f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-03-14T03:51:43.0696625Z ) 2025-03-14T03:51:43.0697190Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:43.0697882Z sys.exit() 2025-03-14T03:51:43.0698144Z 2025-03-14T03:51:43.0698316Z try: 2025-03-14T03:51:43.0698862Z rollout_state = get_rollout_state_from_issue( 2025-03-14T03:51:43.0699583Z args.github_token, args.github_issue_repo, args.github_issue 2025-03-14T03:51:43.0700240Z ) 2025-03-14T03:51:43.0700457Z 2025-03-14T03:51:43.0700668Z username = get_potential_pr_author( 2025-03-14T03:51:43.0701227Z args.github_token, 2025-03-14T03:51:43.0701725Z args.github_repo, 2025-03-14T03:51:43.0702221Z args.github_actor, 2025-03-14T03:51:43.0702710Z args.github_ref_type, 2025-03-14T03:51:43.0703218Z args.github_branch, 2025-03-14T03:51:43.0703686Z ) 2025-03-14T03:51:43.0703898Z 2025-03-14T03:51:43.0704187Z is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-03-14T03:51:43.0704814Z 2025-03-14T03:51:43.0705042Z runner_label_prefix = get_runner_prefix( 2025-03-14T03:51:43.0705616Z rollout_state, 2025-03-14T03:51:43.0706118Z (args.github_issue_owner, username), 2025-03-14T03:51:43.0706681Z args.github_branch, 2025-03-14T03:51:43.0707200Z args.eligible_experiments, 2025-03-14T03:51:43.0707726Z is_canary, 2025-03-14T03:51:43.0708149Z ) 2025-03-14T03:51:43.0708364Z 2025-03-14T03:51:43.0708552Z except Exception as e: 2025-03-14T03:51:43.0709123Z log.error( 2025-03-14T03:51:43.0709808Z f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-03-14T03:51:43.0710588Z ) 2025-03-14T03:51:43.0710794Z 2025-03-14T03:51:43.0711140Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:43.0711660Z 2025-03-14T03:51:43.0711667Z 2025-03-14T03:51:43.0711863Z if __name__ == "__main__": 2025-03-14T03:51:43.0712322Z main() 2025-03-14T03:51:43.0712543Z 2025-03-14T03:51:43.0798253Z ##[group]Run python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-03-14T03:51:43.0799357Z python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-03-14T03:51:43.0843625Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:43.0844132Z env: 2025-03-14T03:51:43.0844755Z GITHUB_TOKEN: *** 2025-03-14T03:51:43.0845200Z ISSUE_NUMBER: 5132 2025-03-14T03:51:43.0845666Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:43.0846186Z ISSUE_OWNER: 2025-03-14T03:51:43.0846597Z CHECK_EXPERIMENTS: 2025-03-14T03:51:43.0847033Z PR_NUMBER: 2025-03-14T03:51:43.0847435Z ##[endgroup] 2025-03-14T03:51:43.4575852Z Defaulting to user installation because normal site-packages is not writeable 2025-03-14T03:51:43.7629355Z Collecting urllib3==1.26.18 2025-03-14T03:51:43.8023113Z Downloading urllib3-1.26.18-py2.py3-none-any.whl.metadata (48 kB) 2025-03-14T03:51:43.8230144Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 kB 3.8 MB/s eta 0:00:00 2025-03-14T03:51:43.8503004Z Collecting PyGithub==2.3.0 2025-03-14T03:51:43.8576495Z Downloading PyGithub-2.3.0-py3-none-any.whl.metadata (3.8 kB) 2025-03-14T03:51:43.9036163Z Collecting pynacl>=1.4.0 (from PyGithub==2.3.0) 2025-03-14T03:51:43.9109956Z 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:43.9155598Z 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:43.9172113Z 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:43.9186562Z 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:43.9463998Z Collecting Deprecated (from PyGithub==2.3.0) 2025-03-14T03:51:43.9534742Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl.metadata (5.7 kB) 2025-03-14T03:51:43.9760651Z 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:44.0930437Z Collecting cffi>=1.4.1 (from pynacl>=1.4.0->PyGithub==2.3.0) 2025-03-14T03:51:44.1002739Z Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.5 kB) 2025-03-14T03:51:44.2111466Z Collecting wrapt<2,>=1.10 (from Deprecated->PyGithub==2.3.0) 2025-03-14T03:51:44.2185431Z 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:44.2406781Z Collecting pycparser (from cffi>=1.4.1->pynacl>=1.4.0->PyGithub==2.3.0) 2025-03-14T03:51:44.2475909Z Downloading pycparser-2.22-py3-none-any.whl.metadata (943 bytes) 2025-03-14T03:51:44.2750307Z Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB) 2025-03-14T03:51:44.2856885Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.8/143.8 kB 15.4 MB/s eta 0:00:00 2025-03-14T03:51:44.2930392Z Downloading PyGithub-2.3.0-py3-none-any.whl (354 kB) 2025-03-14T03:51:44.3038763Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 354.4/354.4 kB 37.8 MB/s eta 0:00:00 2025-03-14T03:51:44.3116788Z 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:44.3228758Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 856.7/856.7 kB 90.0 MB/s eta 0:00:00 2025-03-14T03:51:44.3356197Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl (10.0 kB) 2025-03-14T03:51:44.3450988Z Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479 kB) 2025-03-14T03:51:44.3518802Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 479.4/479.4 kB 92.9 MB/s eta 0:00:00 2025-03-14T03:51:44.3597974Z 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:44.3638092Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 89.2/89.2 kB 32.1 MB/s eta 0:00:00 2025-03-14T03:51:44.3711431Z Downloading pycparser-2.22-py3-none-any.whl (117 kB) 2025-03-14T03:51:44.3764403Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.6/117.6 kB 29.8 MB/s eta 0:00:00 2025-03-14T03:51:44.6630263Z Installing collected packages: wrapt, urllib3, pycparser, Deprecated, cffi, pynacl, PyGithub 2025-03-14T03:51:45.1876709Z 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:45.2695137Z ##[group]Run curr_branch="main" 2025-03-14T03:51:45.2695536Z curr_branch="main" 2025-03-14T03:51:45.2695829Z curr_ref_type="branch" 2025-03-14T03:51:45.2696151Z echo "Current branch is '$curr_branch'" 2025-03-14T03:51:45.2696482Z  2025-03-14T03:51:45.2696736Z python3 runner_determinator.py \ 2025-03-14T03:51:45.2697082Z  --github-token "$GITHUB_TOKEN" \ 2025-03-14T03:51:45.2697429Z  --github-issue "$ISSUE_NUMBER" \ 2025-03-14T03:51:45.2697852Z  --github-branch "$curr_branch" \ 2025-03-14T03:51:45.2698179Z  --github-actor "$TRIGGERING_ACTOR" \ 2025-03-14T03:51:45.2698544Z  --github-issue-owner "$ISSUE_OWNER" \ 2025-03-14T03:51:45.2699077Z  --github-ref-type "$curr_ref_type" \ 2025-03-14T03:51:45.2699437Z  --github-repo "$GITHUB_REPOSITORY" \ 2025-03-14T03:51:45.2699840Z  --eligible-experiments "$CHECK_EXPERIMENTS" \ 2025-03-14T03:51:45.2700231Z  --pr-number "${PR_NUMBER}" 2025-03-14T03:51:45.2749419Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:45.2749710Z env: 2025-03-14T03:51:45.2750362Z GITHUB_TOKEN: *** 2025-03-14T03:51:45.2750612Z ISSUE_NUMBER: 5132 2025-03-14T03:51:45.2750880Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:45.2751169Z ISSUE_OWNER: 2025-03-14T03:51:45.2751409Z CHECK_EXPERIMENTS: 2025-03-14T03:51:45.2751663Z PR_NUMBER: 2025-03-14T03:51:45.2751880Z ##[endgroup] 2025-03-14T03:51:45.2819371Z Current branch is 'main' 2025-03-14T03:51:46.4929189Z INFO : Based on rollout percentage of 50%, enabling experiment lf. 2025-03-14T03:51:46.4930388Z INFO : Branch main is an exception branch. Not enabling experiment ephemeral. 2025-03-14T03:51:46.4931196Z INFO : Setting output: label-type='lf.' 2025-03-14T03:51:46.5236918Z Evaluate and set job outputs 2025-03-14T03:51:46.5244080Z Set output 'label-type' 2025-03-14T03:51:46.5245913Z Cleaning up orphan processes