2025-03-14T03:51:43.6723962Z Current runner version: '2.322.0' 2025-03-14T03:51:43.6750885Z ##[group]Operating System 2025-03-14T03:51:43.6751696Z Ubuntu 2025-03-14T03:51:43.6752283Z 24.04.2 2025-03-14T03:51:43.6752783Z LTS 2025-03-14T03:51:43.6753266Z ##[endgroup] 2025-03-14T03:51:43.6753830Z ##[group]Runner Image 2025-03-14T03:51:43.6754486Z Image: ubuntu-24.04 2025-03-14T03:51:43.6755028Z Version: 20250309.1.0 2025-03-14T03:51:43.6756119Z Included Software: https://github.com/actions/runner-images/blob/ubuntu24/20250309.1/images/ubuntu/Ubuntu2404-Readme.md 2025-03-14T03:51:43.6757718Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu24%2F20250309.1 2025-03-14T03:51:43.6758671Z ##[endgroup] 2025-03-14T03:51:43.6759301Z ##[group]Runner Image Provisioner 2025-03-14T03:51:43.6759911Z 2.0.422.1 2025-03-14T03:51:43.6760400Z ##[endgroup] 2025-03-14T03:51:43.6761543Z ##[group]GITHUB_TOKEN Permissions 2025-03-14T03:51:43.6763629Z Contents: read 2025-03-14T03:51:43.6764285Z Metadata: read 2025-03-14T03:51:43.6765011Z Packages: read 2025-03-14T03:51:43.6765695Z ##[endgroup] 2025-03-14T03:51:43.6769099Z Secret source: Actions 2025-03-14T03:51:43.6770133Z Prepare workflow directory 2025-03-14T03:51:43.7270756Z Prepare all required actions 2025-03-14T03:51:43.7326580Z Uses: pytorch/pytorch/.github/workflows/_runner-determinator.yml@refs/heads/main (aed0b7a742a2d7b7901790622829cbd2135049a4) 2025-03-14T03:51:43.7331623Z ##[group] Inputs 2025-03-14T03:51:43.7332412Z check_experiments: 2025-03-14T03:51:43.7333037Z triggering_actor: pytorchmergebot 2025-03-14T03:51:43.7333628Z issue_owner: 2025-03-14T03:51:43.7334296Z curr_branch: main 2025-03-14T03:51:43.7334846Z curr_ref_type: branch 2025-03-14T03:51:43.7335433Z issue_number: 5132 2025-03-14T03:51:43.7336018Z ##[endgroup] 2025-03-14T03:51:43.7336606Z Complete job name: get-label-type / runner-determinator 2025-03-14T03:51:43.8156994Z ##[group]Run cat < runner_determinator.py 2025-03-14T03:51:43.8159779Z cat < runner_determinator.py 2025-03-14T03:51:43.8160846Z # flake8: noqa: G004 2025-03-14T03:51:43.8161695Z  2025-03-14T03:51:43.8162893Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-03-14T03:51:43.8164718Z # must be kept in sync. You can do it easily by running the following command: 2025-03-14T03:51:43.8166247Z # python .github/scripts/update_runner_determinator.py 2025-03-14T03:51:43.8167372Z  2025-03-14T03:51:43.8168340Z """ 2025-03-14T03:51:43.8169531Z This runner determinator is used to determine which set of runners to run a 2025-03-14T03:51:43.8171295Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-03-14T03:51:43.8173165Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-03-14T03:51:43.8174807Z of which runners should be used to run which job. 2025-03-14T03:51:43.8175832Z  2025-03-14T03:51:43.8176954Z The configuration has two parts, the settings and a list of opted-in users, 2025-03-14T03:51:43.8178942Z separated by a line containing "---". If the line is not present, the 2025-03-14T03:51:43.8180594Z settings are considered to be empty with only the second part, the user 2025-03-14T03:51:43.8181856Z list, defined. 2025-03-14T03:51:43.8182582Z  2025-03-14T03:51:43.8183639Z The first part is a YAML block that defines the rollout settings. This can be 2025-03-14T03:51:43.8185335Z used to define any settings that are needed to determine which runners to use. 2025-03-14T03:51:43.8186910Z It's fields are defined by the RolloutSettings class below. 2025-03-14T03:51:43.8188213Z  2025-03-14T03:51:43.8189261Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-03-14T03:51:43.8190940Z The user list is also a comma separated list of additional features or 2025-03-14T03:51:43.8193004Z experiments which the user could be opted in to. 2025-03-14T03:51:43.8194055Z  2025-03-14T03:51:43.8194780Z The user list has the following rules: 2025-03-14T03:51:43.8195738Z  2025-03-14T03:51:43.8196749Z - Users are GitHub usernames, which must start with the @ prefix 2025-03-14T03:51:43.8198653Z - Each user is also a comma-separated list of features/experiments to enable 2025-03-14T03:51:43.8200201Z - A "#" prefix opts the user out of all experiments 2025-03-14T03:51:43.8201278Z  2025-03-14T03:51:43.8201997Z Example config: 2025-03-14T03:51:43.8202996Z  # A list of experiments that can be opted into. 2025-03-14T03:51:43.8204339Z  # This defines the behavior they'll induce when opted into. 2025-03-14T03:51:43.8205590Z  # Expected syntax is: 2025-03-14T03:51:43.8206922Z  # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-03-14T03:51:43.8209106Z  # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-03-14T03:51:43.8210598Z  2025-03-14T03:51:43.8211310Z  experiments: 2025-03-14T03:51:43.8212124Z  lf: 2025-03-14T03:51:43.8212913Z  rollout_percent: 25 2025-03-14T03:51:43.8213839Z  all_branches: false 2025-03-14T03:51:43.8214751Z  default: true 2025-03-14T03:51:43.8215593Z  --- 2025-03-14T03:51:43.8216304Z  2025-03-14T03:51:43.8216974Z  # Opt-ins: 2025-03-14T03:51:43.8218358Z  # Users can opt into the LF fleet by adding their GitHub username to this list 2025-03-14T03:51:43.8220301Z  # and specifying experiments to enable in a comma-separated list. 2025-03-14T03:51:43.8221866Z  # To always opt out of an experiment, prefix it with a "-". 2025-03-14T03:51:43.8223209Z  # Experiments should be from the above list. 2025-03-14T03:51:43.8224229Z  2025-03-14T03:51:43.8224931Z  @User1,-lf,split_build 2025-03-14T03:51:43.8225877Z  @User2,lf 2025-03-14T03:51:43.8226718Z  @User3,split_build 2025-03-14T03:51:43.8227786Z """ 2025-03-14T03:51:43.8228491Z  2025-03-14T03:51:43.8229191Z import json 2025-03-14T03:51:43.8229980Z import logging 2025-03-14T03:51:43.8230789Z import os 2025-03-14T03:51:43.8231530Z import random 2025-03-14T03:51:43.8232301Z import re 2025-03-14T03:51:43.8233058Z import sys 2025-03-14T03:51:43.8234005Z from argparse import ArgumentParser 2025-03-14T03:51:43.8235127Z from collections.abc import Iterable 2025-03-14T03:51:43.8236190Z from functools import cache 2025-03-14T03:51:43.8237143Z from logging import LogRecord 2025-03-14T03:51:43.8238379Z from typing import Any, NamedTuple 2025-03-14T03:51:43.8239588Z from urllib.request import Request, urlopen 2025-03-14T03:51:43.8240614Z  2025-03-14T03:51:43.8241271Z import yaml 2025-03-14T03:51:43.8242090Z from github import Auth, Github 2025-03-14T03:51:43.8243102Z from github.Issue import Issue 2025-03-14T03:51:43.8244070Z  2025-03-14T03:51:43.8244739Z  2025-03-14T03:51:43.8245560Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-03-14T03:51:43.8246916Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-03-14T03:51:43.8248848Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-03-14T03:51:43.8250177Z  2025-03-14T03:51:43.8251021Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-03-14T03:51:43.8252136Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-03-14T03:51:43.8253191Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-03-14T03:51:43.8254673Z OPT_OUT_LABEL = "no-runner-experiments" 2025-03-14T03:51:43.8255701Z  2025-03-14T03:51:43.8256483Z SETTING_EXPERIMENTS = "experiments" 2025-03-14T03:51:43.8257451Z  2025-03-14T03:51:43.8258421Z LF_FLEET_EXPERIMENT = "lf" 2025-03-14T03:51:43.8259348Z CANARY_FLEET_SUFFIX = ".c" 2025-03-14T03:51:43.8260173Z  2025-03-14T03:51:43.8260783Z  2025-03-14T03:51:43.8261478Z class Experiment(NamedTuple): 2025-03-14T03:51:43.8262431Z  rollout_perc: float = ( 2025-03-14T03:51:43.8263673Z  0 # Percentage of workflows to experiment on when user is not opted-in. 2025-03-14T03:51:43.8264931Z  ) 2025-03-14T03:51:43.8265649Z  all_branches: bool = ( 2025-03-14T03:51:43.8266904Z  False # If True, the experiment is also enabled on the exception branches 2025-03-14T03:51:43.8268383Z  ) 2025-03-14T03:51:43.8269103Z  default: bool = ( 2025-03-14T03:51:43.8271090Z  True # If True, the experiment is enabled by default for all queries 2025-03-14T03:51:43.8272386Z  ) 2025-03-14T03:51:43.8273110Z  2025-03-14T03:51:43.8273825Z  # Add more fields as needed 2025-03-14T03:51:43.8274751Z  2025-03-14T03:51:43.8275403Z  2025-03-14T03:51:43.8276119Z class Settings(NamedTuple): 2025-03-14T03:51:43.8277054Z  """ 2025-03-14T03:51:43.8278236Z  Settings for the experiments that can be opted into. 2025-03-14T03:51:43.8279370Z  """ 2025-03-14T03:51:43.8280066Z  2025-03-14T03:51:43.8280814Z  experiments: dict[str, Experiment] = {} 2025-03-14T03:51:43.8281765Z  2025-03-14T03:51:43.8282652Z  2025-03-14T03:51:43.8283445Z class ColorFormatter(logging.Formatter): 2025-03-14T03:51:43.8284645Z  """Color codes the log messages based on the log level""" 2025-03-14T03:51:43.8285731Z  2025-03-14T03:51:43.8286375Z  COLORS = { 2025-03-14T03:51:43.8287193Z  "WARNING": "\033[33m", # Yellow 2025-03-14T03:51:43.8288455Z  "ERROR": "\033[31m", # Red 2025-03-14T03:51:43.8289454Z  "CRITICAL": "\033[31m", # Red 2025-03-14T03:51:43.8290495Z  "INFO": "\033[0m", # Reset 2025-03-14T03:51:43.8291510Z  "DEBUG": "\033[0m", # Reset 2025-03-14T03:51:43.8292483Z  } 2025-03-14T03:51:43.8293181Z  2025-03-14T03:51:43.8293999Z  def format(self, record: LogRecord) -> str: 2025-03-14T03:51:43.8294941Z  log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-03-14T03:51:43.8295773Z  record.msg = f"{log_color}{record.msg}\033[0m" 2025-03-14T03:51:43.8296412Z  return super().format(record) 2025-03-14T03:51:43.8296962Z  2025-03-14T03:51:43.8297335Z  2025-03-14T03:51:43.8298010Z handler = logging.StreamHandler() 2025-03-14T03:51:43.8298803Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-03-14T03:51:43.8299553Z  2025-03-14T03:51:43.8300056Z log = logging.getLogger(os.path.basename(__file__)) 2025-03-14T03:51:43.8300691Z log.addHandler(handler) 2025-03-14T03:51:43.8301203Z log.setLevel(logging.INFO) 2025-03-14T03:51:43.8301686Z  2025-03-14T03:51:43.8302058Z  2025-03-14T03:51:43.8302552Z def set_github_output(key: str, value: str) -> None: 2025-03-14T03:51:43.8303161Z  """ 2025-03-14T03:51:43.8303735Z  Defines outputs of the github action that invokes this script 2025-03-14T03:51:43.8304405Z  """ 2025-03-14T03:51:43.8304828Z  if not GITHUB_OUTPUT: 2025-03-14T03:51:43.8305960Z  # 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.8307310Z  log.warning( 2025-03-14T03:51:43.8308405Z  "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.8309341Z  ) 2025-03-14T03:51:43.8309834Z  print(f"::set-output name={key}::{value}") 2025-03-14T03:51:43.8310404Z  return 2025-03-14T03:51:43.8310836Z  2025-03-14T03:51:43.8311246Z  with open(GITHUB_OUTPUT, "a") as f: 2025-03-14T03:51:43.8311878Z  log.info(f"Setting output: {key}='{value}'") 2025-03-14T03:51:43.8312501Z  f.write(f"{key}={value}\n") 2025-03-14T03:51:43.8313028Z  2025-03-14T03:51:43.8313399Z  2025-03-14T03:51:43.8313945Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-03-14T03:51:43.8314637Z  return frozenset( 2025-03-14T03:51:43.8315323Z  filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-03-14T03:51:43.8316092Z  ) 2025-03-14T03:51:43.8316484Z  2025-03-14T03:51:43.8316854Z  2025-03-14T03:51:43.8317243Z def parse_args() -> Any: 2025-03-14T03:51:43.8318057Z  parser = ArgumentParser("Get dynamic rollout settings") 2025-03-14T03:51:43.8318977Z  parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-03-14T03:51:43.8319770Z  parser.add_argument( 2025-03-14T03:51:43.8320290Z  "--github-issue-repo", 2025-03-14T03:51:43.8320811Z  type=str, 2025-03-14T03:51:43.8321277Z  required=False, 2025-03-14T03:51:43.8321942Z  default="pytorch/test-infra", 2025-03-14T03:51:43.8322547Z  help="GitHub repo to get the issue", 2025-03-14T03:51:43.8323099Z  ) 2025-03-14T03:51:43.8323508Z  parser.add_argument( 2025-03-14T03:51:43.8324004Z  "--github-repo", 2025-03-14T03:51:43.8324487Z  type=str, 2025-03-14T03:51:43.8324950Z  required=True, 2025-03-14T03:51:43.8325501Z  help="GitHub repo where CI is running", 2025-03-14T03:51:43.8326058Z  ) 2025-03-14T03:51:43.8326472Z  parser.add_argument( 2025-03-14T03:51:43.8327160Z  "--github-issue", type=int, required=True, help="GitHub issue number" 2025-03-14T03:51:43.8328076Z  ) 2025-03-14T03:51:43.8328486Z  parser.add_argument( 2025-03-14T03:51:43.8329190Z  "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-03-14T03:51:43.8329895Z  ) 2025-03-14T03:51:43.8330304Z  parser.add_argument( 2025-03-14T03:51:43.8331015Z  "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-03-14T03:51:43.8331739Z  ) 2025-03-14T03:51:43.8332150Z  parser.add_argument( 2025-03-14T03:51:43.8332879Z  "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-03-14T03:51:43.8333611Z  ) 2025-03-14T03:51:43.8334019Z  parser.add_argument( 2025-03-14T03:51:43.8334532Z  "--github-ref-type", 2025-03-14T03:51:43.8335041Z  type=str, 2025-03-14T03:51:43.8335515Z  required=True, 2025-03-14T03:51:43.8336082Z  help="Current GitHub ref type, branch or tag", 2025-03-14T03:51:43.8336663Z  ) 2025-03-14T03:51:43.8337069Z  parser.add_argument( 2025-03-14T03:51:43.8337763Z  "--eligible-experiments", 2025-03-14T03:51:43.8338384Z  type=_str_comma_separated_to_set, 2025-03-14T03:51:43.8339004Z  required=False, 2025-03-14T03:51:43.8339681Z  default="", 2025-03-14T03:51:43.8340610Z  help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-03-14T03:51:43.8341553Z  ) 2025-03-14T03:51:43.8341964Z  parser.add_argument( 2025-03-14T03:51:43.8342466Z  "--pr-number", 2025-03-14T03:51:43.8342965Z  type=str, 2025-03-14T03:51:43.8343429Z  required=False, 2025-03-14T03:51:43.8343918Z  default="", 2025-03-14T03:51:43.8344476Z  help="the optional PR number where this is run", 2025-03-14T03:51:43.8345069Z  ) 2025-03-14T03:51:43.8345462Z  2025-03-14T03:51:43.8345872Z  return parser.parse_args() 2025-03-14T03:51:43.8346390Z  2025-03-14T03:51:43.8346752Z  2025-03-14T03:51:43.8347390Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-03-14T03:51:43.8348409Z  auth = Auth.Token(github_token) 2025-03-14T03:51:43.8348977Z  return Github(auth=auth) 2025-03-14T03:51:43.8349473Z  2025-03-14T03:51:43.8349836Z  2025-03-14T03:51:43.8350525Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-03-14T03:51:43.8351386Z  repo = gh.get_repo(repo) 2025-03-14T03:51:43.8351969Z  return repo.get_issue(number=issue_num) 2025-03-14T03:51:43.8352529Z  2025-03-14T03:51:43.8352890Z  2025-03-14T03:51:43.8353298Z def get_potential_pr_author( 2025-03-14T03:51:43.8354021Z  github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-03-14T03:51:43.8354730Z ) -> str: 2025-03-14T03:51:43.8355463Z  # If the trigger was a new tag added by a bot, this is a ciflow case 2025-03-14T03:51:43.8356332Z  # Fetch the actual username from the original PR. The PR number is 2025-03-14T03:51:43.8357140Z  # embedded in the tag name: ciflow// 2025-03-14T03:51:43.8357940Z  2025-03-14T03:51:43.8358395Z  gh = get_gh_client(github_token) 2025-03-14T03:51:43.8358923Z  2025-03-14T03:51:43.8359436Z  if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-03-14T03:51:43.8360122Z  split_tag = ref_name.split("/") 2025-03-14T03:51:43.8360661Z  if ( 2025-03-14T03:51:43.8361110Z  len(split_tag) == 3 2025-03-14T03:51:43.8361665Z  and split_tag[0] == "ciflow" 2025-03-14T03:51:43.8362251Z  and split_tag[2].isnumeric() 2025-03-14T03:51:43.8362785Z  ): 2025-03-14T03:51:43.8363232Z  pr_number = split_tag[2] 2025-03-14T03:51:43.8363768Z  try: 2025-03-14T03:51:43.8364269Z  repository = gh.get_repo(repo) 2025-03-14T03:51:43.8364944Z  pull = repository.get_pull(number=int(pr_number)) 2025-03-14T03:51:43.8365604Z  except Exception as e: 2025-03-14T03:51:43.8366176Z  raise Exception( # noqa: TRY002 2025-03-14T03:51:43.8366898Z  f"issue with pull request {pr_number} from repo {repository}" 2025-03-14T03:51:43.8367808Z  ) from e 2025-03-14T03:51:43.8368456Z  return pull.user.login # type: ignore[no-any-return] 2025-03-14T03:51:43.8369224Z  # In all other cases, return the original input username 2025-03-14T03:51:43.8369847Z  return username 2025-03-14T03:51:43.8370294Z  2025-03-14T03:51:43.8370659Z  2025-03-14T03:51:43.8371128Z def is_exception_branch(branch: str) -> bool: 2025-03-14T03:51:43.8371700Z  """ 2025-03-14T03:51:43.8372411Z  Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-03-14T03:51:43.8373352Z  """ 2025-03-14T03:51:43.8373961Z  return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-03-14T03:51:43.8374665Z  2025-03-14T03:51:43.8375026Z  2025-03-14T03:51:43.8375448Z def load_yaml(yaml_text: str) -> Any: 2025-03-14T03:51:43.8375992Z  try: 2025-03-14T03:51:43.8376429Z  data = yaml.safe_load(yaml_text) 2025-03-14T03:51:43.8376969Z  return data 2025-03-14T03:51:43.8377450Z  except yaml.YAMLError: 2025-03-14T03:51:43.8378221Z  log.exception("Error loading YAML") 2025-03-14T03:51:43.8378777Z  raise 2025-03-14T03:51:43.8379187Z  2025-03-14T03:51:43.8379543Z  2025-03-14T03:51:43.8380203Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-03-14T03:51:43.8380970Z  """ 2025-03-14T03:51:43.8381668Z  Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-03-14T03:51:43.8382440Z  2025-03-14T03:51:43.8383015Z  If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:43.8383829Z  and the text below is the list of opted in users. 2025-03-14T03:51:43.8384410Z  2025-03-14T03:51:43.8385014Z  If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-03-14T03:51:43.8385733Z  """ 2025-03-14T03:51:43.8386235Z  rollout_state_parts = rollout_state.split("---") 2025-03-14T03:51:43.8386874Z  if len(rollout_state_parts) >= 2: 2025-03-14T03:51:43.8387769Z  return rollout_state_parts[0], rollout_state_parts[1] 2025-03-14T03:51:43.8388404Z  else: 2025-03-14T03:51:43.8388848Z  return "", rollout_state 2025-03-14T03:51:43.8389360Z  2025-03-14T03:51:43.8389719Z  2025-03-14T03:51:43.8390142Z class UserOptins(dict[str, list[str]]): 2025-03-14T03:51:43.8390681Z  """ 2025-03-14T03:51:43.8391268Z  Dictionary of users with a list of features they have opted into 2025-03-14T03:51:43.8391935Z  """ 2025-03-14T03:51:43.8392320Z  2025-03-14T03:51:43.8392677Z  2025-03-14T03:51:43.8393351Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-03-14T03:51:43.8394045Z  """ 2025-03-14T03:51:43.8394817Z  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.8395670Z  2025-03-14T03:51:43.8396509Z  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.8397644Z  - Example line: "@User1,lf,split_build" 2025-03-14T03:51:43.8398381Z  - A "#" prefix indicates the user is opted out of all experiments 2025-03-14T03:51:43.8399040Z  2025-03-14T03:51:43.8399400Z  2025-03-14T03:51:43.8399757Z  """ 2025-03-14T03:51:43.8400167Z  optins = UserOptins() 2025-03-14T03:51:43.8400722Z  for user in user_optin_text.split("\n"): 2025-03-14T03:51:43.8401321Z  user = user.strip("\r\n\t -") 2025-03-14T03:51:43.8401919Z  if not user or not user.startswith("@"): 2025-03-14T03:51:43.8402510Z  # Not a valid user. Skip 2025-03-14T03:51:43.8403036Z  continue 2025-03-14T03:51:43.8403475Z  2025-03-14T03:51:43.8403840Z  if user: 2025-03-14T03:51:43.8404360Z  usr_name = user.split(",")[0].strip("@") 2025-03-14T03:51:43.8405110Z  optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-03-14T03:51:43.8405904Z  2025-03-14T03:51:43.8406285Z  return optins 2025-03-14T03:51:43.8406729Z  2025-03-14T03:51:43.8407093Z  2025-03-14T03:51:43.8407839Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-03-14T03:51:43.8408537Z  """ 2025-03-14T03:51:43.8409001Z  Check if the experiment name is valid. 2025-03-14T03:51:43.8409560Z  A valid name: 2025-03-14T03:51:43.8410261Z  - Contains only alphanumeric characters and the special characters "_" & "-" 2025-03-14T03:51:43.8411245Z  - The special characters "_" & "-" shouldn't be the first or last characters 2025-03-14T03:51:43.8411989Z  - Cannot contain spaces 2025-03-14T03:51:43.8412501Z  """ 2025-03-14T03:51:43.8412940Z  2025-03-14T03:51:43.8413429Z  valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-03-14T03:51:43.8414180Z  valid = bool(re.match(valid_char_regex, experiment_name)) 2025-03-14T03:51:43.8414810Z  2025-03-14T03:51:43.8415181Z  if valid: 2025-03-14T03:51:43.8415616Z  return True 2025-03-14T03:51:43.8416051Z  2025-03-14T03:51:43.8416421Z  log.error( 2025-03-14T03:51:43.8417988Z  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.8419512Z  ) 2025-03-14T03:51:43.8419911Z  return False 2025-03-14T03:51:43.8420340Z  2025-03-14T03:51:43.8420688Z  2025-03-14T03:51:43.8421367Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-03-14T03:51:43.8422028Z  """ 2025-03-14T03:51:43.8422665Z  Parse the experiments from the issue body into a list of ExperimentSettings 2025-03-14T03:51:43.8423407Z  """ 2025-03-14T03:51:43.8423790Z  try: 2025-03-14T03:51:43.8424199Z  if settings_text: 2025-03-14T03:51:43.8424979Z  # 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.8425786Z  # for easy reading 2025-03-14T03:51:43.8426636Z  # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-03-14T03:51:43.8427665Z  # the backtick character in shell commands. 2025-03-14T03:51:43.8428314Z  backtick = chr(96) # backtick character 2025-03-14T03:51:43.8429021Z  settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-03-14T03:51:43.8429732Z  settings = load_yaml(settings_text) 2025-03-14T03:51:43.8430277Z  2025-03-14T03:51:43.8430902Z  # For now we just load experiments. We can expand this if/when we add more settings 2025-03-14T03:51:43.8431714Z  experiments = {} 2025-03-14T03:51:43.8432201Z  2025-03-14T03:51:43.8432788Z  for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-03-14T03:51:43.8433573Z  if not is_valid_experiment_name(exp_name): 2025-03-14T03:51:43.8434692Z  # 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.8435775Z  continue 2025-03-14T03:51:43.8436253Z  2025-03-14T03:51:43.8436648Z  valid_settings = {} 2025-03-14T03:51:43.8437216Z  for setting in exp_settings: 2025-03-14T03:51:43.8437930Z  if setting not in Experiment._fields: 2025-03-14T03:51:43.8438694Z  log.warning( 2025-03-14T03:51:43.8439446Z  f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-03-14T03:51:43.8440177Z  ) 2025-03-14T03:51:43.8440651Z  else: 2025-03-14T03:51:43.8441232Z  valid_settings[setting] = exp_settings[setting] 2025-03-14T03:51:43.8441830Z  2025-03-14T03:51:43.8442333Z  experiments[exp_name] = Experiment(**valid_settings) 2025-03-14T03:51:43.8443010Z  return Settings(experiments) 2025-03-14T03:51:43.8443536Z  2025-03-14T03:51:43.8443907Z  except Exception: 2025-03-14T03:51:43.8444454Z  log.exception("Failed to parse settings") 2025-03-14T03:51:43.8445018Z  2025-03-14T03:51:43.8445397Z  return Settings() 2025-03-14T03:51:43.8445848Z  2025-03-14T03:51:43.8446206Z  2025-03-14T03:51:43.8446689Z def parse_settings(rollout_state: str) -> Settings: 2025-03-14T03:51:43.8447288Z  """ 2025-03-14T03:51:43.8447882Z  Parse settings, if any, from the rollout state. 2025-03-14T03:51:43.8448458Z  2025-03-14T03:51:43.8449021Z  If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:43.8449824Z  and the text below is the list of opted in users. 2025-03-14T03:51:43.8450398Z  2025-03-14T03:51:43.8451019Z  If it doesn't contain "---" then the settings are empty and the default values are used. 2025-03-14T03:51:43.8451760Z  """ 2025-03-14T03:51:43.8452371Z  settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:43.8453298Z  return parse_settings_from_text(settings_text) 2025-03-14T03:51:43.8453879Z  2025-03-14T03:51:43.8454229Z  2025-03-14T03:51:43.8454714Z def parse_users(rollout_state: str) -> UserOptins: 2025-03-14T03:51:43.8455309Z  """ 2025-03-14T03:51:43.8455740Z  Parse users from the rollout state. 2025-03-14T03:51:43.8456271Z  2025-03-14T03:51:43.8456633Z  """ 2025-03-14T03:51:43.8457219Z  _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:43.8458103Z  return parse_user_opt_in_from_text(users_text) 2025-03-14T03:51:43.8458673Z  2025-03-14T03:51:43.8459030Z  2025-03-14T03:51:43.8459671Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:43.8460447Z  """ 2025-03-14T03:51:43.8460917Z  Check if a user is opted into an experiment 2025-03-14T03:51:43.8461495Z  """ 2025-03-14T03:51:43.8462002Z  return experiment_name in user_optins.get(user, []) 2025-03-14T03:51:43.8462610Z  2025-03-14T03:51:43.8462971Z  2025-03-14T03:51:43.8463612Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:43.8464388Z  """ 2025-03-14T03:51:43.8464899Z  Check if a user explicitly opted out of an experiment 2025-03-14T03:51:43.8465509Z  """ 2025-03-14T03:51:43.8466077Z  # if the experiment is prefixed with a "-", then it's an opt-out 2025-03-14T03:51:43.8466813Z  experiment_optout = "-" + experiment_name 2025-03-14T03:51:43.8467601Z  if experiment_optout not in user_optins.get(user, []): 2025-03-14T03:51:43.8468234Z  return False 2025-03-14T03:51:43.8468679Z  2025-03-14T03:51:43.8469173Z  if is_user_opted_in(user, user_optins, experiment_name): 2025-03-14T03:51:43.8469805Z  log.warning( 2025-03-14T03:51:43.8470664Z  f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-03-14T03:51:43.8471684Z  ) 2025-03-14T03:51:43.8472070Z  2025-03-14T03:51:43.8472439Z  return True 2025-03-14T03:51:43.8472870Z  2025-03-14T03:51:43.8473222Z  2025-03-14T03:51:43.8473601Z def get_runner_prefix( 2025-03-14T03:51:43.8474079Z  rollout_state: str, 2025-03-14T03:51:43.8474600Z  workflow_requestors: Iterable[str], 2025-03-14T03:51:43.8475145Z  branch: str, 2025-03-14T03:51:43.8475708Z  eligible_experiments: frozenset[str] = frozenset(), 2025-03-14T03:51:43.8476339Z  is_canary: bool = False, 2025-03-14T03:51:43.8476828Z ) -> str: 2025-03-14T03:51:43.8477295Z  settings = parse_settings(rollout_state) 2025-03-14T03:51:43.8478013Z  user_optins = parse_users(rollout_state) 2025-03-14T03:51:43.8478556Z  2025-03-14T03:51:43.8478939Z  fleet_prefix = "" 2025-03-14T03:51:43.8479415Z  prefixes = [] 2025-03-14T03:51:43.8480098Z  for experiment_name, experiment_settings in settings.experiments.items(): 2025-03-14T03:51:43.8481070Z  if not experiment_settings.all_branches and is_exception_branch(branch): 2025-03-14T03:51:43.8481802Z  log.info( 2025-03-14T03:51:43.8482536Z  f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-03-14T03:51:43.8483302Z  ) 2025-03-14T03:51:43.8483727Z  continue 2025-03-14T03:51:43.8484160Z  2025-03-14T03:51:43.8484558Z  if eligible_experiments: 2025-03-14T03:51:43.8485303Z  if experiment_name not in eligible_experiments: 2025-03-14T03:51:43.8485981Z  exp_list = ", ".join(eligible_experiments) 2025-03-14T03:51:43.8486554Z  log.info( 2025-03-14T03:51:43.8487380Z  f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-03-14T03:51:43.8488330Z  ) 2025-03-14T03:51:43.8488779Z  continue 2025-03-14T03:51:43.8489312Z  elif not experiment_settings.default: 2025-03-14T03:51:43.8489886Z  log.info( 2025-03-14T03:51:43.8490603Z  f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-03-14T03:51:43.8491352Z  ) 2025-03-14T03:51:43.8491779Z  continue 2025-03-14T03:51:43.8492219Z  2025-03-14T03:51:43.8492718Z  # Is any workflow_requestor opted out to this experiment? 2025-03-14T03:51:43.8493371Z  opted_out_users = [ 2025-03-14T03:51:43.8493875Z  requestor 2025-03-14T03:51:43.8494382Z  for requestor in workflow_requestors 2025-03-14T03:51:43.8495105Z  if is_user_opted_out(requestor, user_optins, experiment_name) 2025-03-14T03:51:43.8495748Z  ] 2025-03-14T03:51:43.8496147Z  2025-03-14T03:51:43.8496529Z  if opted_out_users: 2025-03-14T03:51:43.8497021Z  log.info( 2025-03-14T03:51:43.8497798Z  f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-03-14T03:51:43.8498514Z  ) 2025-03-14T03:51:43.8498937Z  continue 2025-03-14T03:51:43.8499373Z  2025-03-14T03:51:43.8499877Z  # Is any workflow_requestor opted in to this experiment? 2025-03-14T03:51:43.8500508Z  opted_in_users = [ 2025-03-14T03:51:43.8501011Z  requestor 2025-03-14T03:51:43.8501530Z  for requestor in workflow_requestors 2025-03-14T03:51:43.8502237Z  if is_user_opted_in(requestor, user_optins, experiment_name) 2025-03-14T03:51:43.8503007Z  ] 2025-03-14T03:51:43.8503397Z  2025-03-14T03:51:43.8503782Z  enabled = False 2025-03-14T03:51:43.8504277Z  if opted_in_users: 2025-03-14T03:51:43.8504774Z  log.info( 2025-03-14T03:51:43.8505429Z  f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-03-14T03:51:43.8506118Z  ) 2025-03-14T03:51:43.8506555Z  enabled = True 2025-03-14T03:51:43.8507024Z  2025-03-14T03:51:43.8507461Z  elif experiment_settings.rollout_perc: 2025-03-14T03:51:43.8508426Z  # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-03-14T03:51:43.8509403Z  if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-03-14T03:51:43.8510070Z  log.info( 2025-03-14T03:51:43.8510979Z  f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-03-14T03:51:43.8511898Z  ) 2025-03-14T03:51:43.8512352Z  enabled = True 2025-03-14T03:51:43.8512841Z  2025-03-14T03:51:43.8513222Z  if enabled: 2025-03-14T03:51:43.8513695Z  label = experiment_name 2025-03-14T03:51:43.8514290Z  if experiment_name == LF_FLEET_EXPERIMENT: 2025-03-14T03:51:43.8515141Z  # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-03-14T03:51:43.8516155Z  # - If it's enabled, then we always list it's prefix first 2025-03-14T03:51:43.8516952Z  # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-03-14T03:51:43.8517735Z  if is_canary: 2025-03-14T03:51:43.8518283Z  label += CANARY_FLEET_SUFFIX 2025-03-14T03:51:43.8518880Z  fleet_prefix = label 2025-03-14T03:51:43.8519403Z  else: 2025-03-14T03:51:43.8519895Z  prefixes.append(label) 2025-03-14T03:51:43.8520420Z  2025-03-14T03:51:43.8520798Z  if len(prefixes) > 1: 2025-03-14T03:51:43.8521300Z  log.error( 2025-03-14T03:51:43.8522363Z  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.8523455Z  ) 2025-03-14T03:51:43.8523895Z  prefixes = prefixes[:1] 2025-03-14T03:51:43.8524404Z  2025-03-14T03:51:43.8524792Z  # Fleet always comes first 2025-03-14T03:51:43.8525315Z  if fleet_prefix: 2025-03-14T03:51:43.8525822Z  prefixes.insert(0, fleet_prefix) 2025-03-14T03:51:43.8526354Z  2025-03-14T03:51:43.8526833Z  return ".".join(prefixes) + "." if prefixes else "" 2025-03-14T03:51:43.8527412Z  2025-03-14T03:51:43.8527862Z  2025-03-14T03:51:43.8528529Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-03-14T03:51:43.8529313Z  """ 2025-03-14T03:51:43.8529938Z  Gets the first comment of the issue, which contains the desired rollout state. 2025-03-14T03:51:43.8530655Z  2025-03-14T03:51:43.8531248Z  The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-03-14T03:51:43.8531966Z  """ 2025-03-14T03:51:43.8532403Z  gh = get_gh_client(github_token) 2025-03-14T03:51:43.8532986Z  issue = get_issue(gh, repo, issue_num) 2025-03-14T03:51:43.8533667Z  return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-03-14T03:51:43.8534406Z  2025-03-14T03:51:43.8534766Z  2025-03-14T03:51:43.8535378Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-03-14T03:51:43.8536147Z  for _ in range(num_retries): 2025-03-14T03:51:43.8536659Z  try: 2025-03-14T03:51:43.8537138Z  req = Request(url=url, headers=headers) 2025-03-14T03:51:43.8537918Z  content = urlopen(req, timeout=5).read().decode("utf-8") 2025-03-14T03:51:43.8538594Z  return json.loads(content) 2025-03-14T03:51:43.8539179Z  except Exception as e: 2025-03-14T03:51:43.8539775Z  log.warning(f"Could not download {url}: {e}") 2025-03-14T03:51:43.8540387Z  2025-03-14T03:51:43.8540985Z  log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-03-14T03:51:43.8541710Z  return {} 2025-03-14T03:51:43.8542137Z  2025-03-14T03:51:43.8542494Z  2025-03-14T03:51:43.8542850Z @cache 2025-03-14T03:51:43.8543518Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-03-14T03:51:43.8544268Z  """ 2025-03-14T03:51:43.8544705Z  Dynamically get PR information 2025-03-14T03:51:43.8545224Z  """ 2025-03-14T03:51:43.8545767Z  github_api = f"https://api.github.com/repos/{github_repo}" 2025-03-14T03:51:43.8546413Z  headers = { 2025-03-14T03:51:43.8546925Z  "Accept": "application/vnd.github.v3+json", 2025-03-14T03:51:43.8547663Z  "Authorization": f"token {github_token}", 2025-03-14T03:51:43.8548215Z  } 2025-03-14T03:51:43.8548836Z  json_response: dict[str, Any] = download_json( 2025-03-14T03:51:43.8549480Z  url=f"{github_api}/issues/{pr_number}", 2025-03-14T03:51:43.8550043Z  headers=headers, 2025-03-14T03:51:43.8550515Z  ) 2025-03-14T03:51:43.8550895Z  2025-03-14T03:51:43.8551279Z  if not json_response: 2025-03-14T03:51:43.8551903Z  log.warning(f"Failed to get the labels for #{pr_number}") 2025-03-14T03:51:43.8552543Z  return {} 2025-03-14T03:51:43.8552993Z  2025-03-14T03:51:43.8553379Z  return json_response 2025-03-14T03:51:43.8553847Z  2025-03-14T03:51:43.8554200Z  2025-03-14T03:51:43.8554803Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-03-14T03:51:43.8555542Z  """ 2025-03-14T03:51:43.8556114Z  Dynamically get the latest list of labels from the pull request 2025-03-14T03:51:43.8556787Z  """ 2025-03-14T03:51:43.8557310Z  pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-03-14T03:51:43.8558039Z  return { 2025-03-14T03:51:43.8558667Z  label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-03-14T03:51:43.8559374Z  } 2025-03-14T03:51:43.8559753Z  2025-03-14T03:51:43.8560110Z  2025-03-14T03:51:43.8560482Z def main() -> None: 2025-03-14T03:51:43.8560943Z  args = parse_args() 2025-03-14T03:51:43.8561412Z  2025-03-14T03:51:43.8561853Z  runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-03-14T03:51:43.8562414Z  2025-03-14T03:51:43.8562807Z  # Check if the PR is opt-out 2025-03-14T03:51:43.8563330Z  if args.pr_number: 2025-03-14T03:51:43.8564045Z  labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-03-14T03:51:43.8564818Z  if OPT_OUT_LABEL in labels: 2025-03-14T03:51:43.8565349Z  log.info( 2025-03-14T03:51:43.8566087Z  f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-03-14T03:51:43.8567026Z  ) 2025-03-14T03:51:43.8567726Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:43.8568456Z  sys.exit() 2025-03-14T03:51:43.8568924Z  2025-03-14T03:51:43.8569290Z  try: 2025-03-14T03:51:43.8569784Z  rollout_state = get_rollout_state_from_issue( 2025-03-14T03:51:43.8570533Z  args.github_token, args.github_issue_repo, args.github_issue 2025-03-14T03:51:43.8571185Z  ) 2025-03-14T03:51:43.8571579Z  2025-03-14T03:51:43.8571997Z  username = get_potential_pr_author( 2025-03-14T03:51:43.8572562Z  args.github_token, 2025-03-14T03:51:43.8573091Z  args.github_repo, 2025-03-14T03:51:43.8573609Z  args.github_actor, 2025-03-14T03:51:43.8574137Z  args.github_ref_type, 2025-03-14T03:51:43.8574674Z  args.github_branch, 2025-03-14T03:51:43.8575174Z  ) 2025-03-14T03:51:43.8575568Z  2025-03-14T03:51:43.8576068Z  is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-03-14T03:51:43.8576693Z  2025-03-14T03:51:43.8577126Z  runner_label_prefix = get_runner_prefix( 2025-03-14T03:51:43.8577795Z  rollout_state, 2025-03-14T03:51:43.8578337Z  (args.github_issue_owner, username), 2025-03-14T03:51:43.8578919Z  args.github_branch, 2025-03-14T03:51:43.8579463Z  args.eligible_experiments, 2025-03-14T03:51:43.8580000Z  is_canary, 2025-03-14T03:51:43.8580581Z  ) 2025-03-14T03:51:43.8580985Z  2025-03-14T03:51:43.8581380Z  except Exception as e: 2025-03-14T03:51:43.8581877Z  log.error( 2025-03-14T03:51:43.8582604Z  f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-03-14T03:51:43.8583365Z  ) 2025-03-14T03:51:43.8583750Z  2025-03-14T03:51:43.8584297Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:43.8584948Z  2025-03-14T03:51:43.8585302Z  2025-03-14T03:51:43.8585677Z if __name__ == "__main__": 2025-03-14T03:51:43.8586159Z  main() 2025-03-14T03:51:43.8586557Z  2025-03-14T03:51:43.8586902Z EOF 2025-03-14T03:51:43.8587269Z  2025-03-14T03:51:43.8587753Z cat runner_determinator.py 2025-03-14T03:51:43.9060482Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:43.9061317Z env: 2025-03-14T03:51:43.9062013Z GITHUB_TOKEN: *** 2025-03-14T03:51:43.9062483Z ISSUE_NUMBER: 5132 2025-03-14T03:51:43.9062967Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:43.9063492Z ISSUE_OWNER: 2025-03-14T03:51:43.9063914Z CHECK_EXPERIMENTS: 2025-03-14T03:51:43.9064365Z PR_NUMBER: 2025-03-14T03:51:43.9064764Z ##[endgroup] 2025-03-14T03:51:43.9286729Z # flake8: noqa: G004 2025-03-14T03:51:43.9287090Z 2025-03-14T03:51:43.9287781Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-03-14T03:51:43.9288778Z # must be kept in sync. You can do it easily by running the following command: 2025-03-14T03:51:43.9289573Z # python .github/scripts/update_runner_determinator.py 2025-03-14T03:51:43.9290012Z 2025-03-14T03:51:43.9290172Z """ 2025-03-14T03:51:43.9290730Z This runner determinator is used to determine which set of runners to run a 2025-03-14T03:51:43.9291562Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-03-14T03:51:43.9292451Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-03-14T03:51:43.9293230Z of which runners should be used to run which job. 2025-03-14T03:51:43.9293838Z 2025-03-14T03:51:43.9294215Z The configuration has two parts, the settings and a list of opted-in users, 2025-03-14T03:51:43.9295084Z separated by a line containing "---". If the line is not present, the 2025-03-14T03:51:43.9295915Z settings are considered to be empty with only the second part, the user 2025-03-14T03:51:43.9296571Z list, defined. 2025-03-14T03:51:43.9296799Z 2025-03-14T03:51:43.9297148Z The first part is a YAML block that defines the rollout settings. This can be 2025-03-14T03:51:43.9298289Z used to define any settings that are needed to determine which runners to use. 2025-03-14T03:51:43.9299095Z It's fields are defined by the RolloutSettings class below. 2025-03-14T03:51:43.9299519Z 2025-03-14T03:51:43.9299887Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-03-14T03:51:43.9300736Z The user list is also a comma separated list of additional features or 2025-03-14T03:51:43.9301452Z experiments which the user could be opted in to. 2025-03-14T03:51:43.9301853Z 2025-03-14T03:51:43.9302047Z The user list has the following rules: 2025-03-14T03:51:43.9302390Z 2025-03-14T03:51:43.9302700Z - Users are GitHub usernames, which must start with the @ prefix 2025-03-14T03:51:43.9303526Z - Each user is also a comma-separated list of features/experiments to enable 2025-03-14T03:51:43.9304260Z - A "#" prefix opts the user out of all experiments 2025-03-14T03:51:43.9304641Z 2025-03-14T03:51:43.9304809Z Example config: 2025-03-14T03:51:43.9305252Z # A list of experiments that can be opted into. 2025-03-14T03:51:43.9305904Z # This defines the behavior they'll induce when opted into. 2025-03-14T03:51:43.9306512Z # Expected syntax is: 2025-03-14T03:51:43.9307144Z # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-03-14T03:51:43.9308457Z # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-03-14T03:51:43.9309059Z 2025-03-14T03:51:43.9309225Z experiments: 2025-03-14T03:51:43.9309619Z lf: 2025-03-14T03:51:43.9309991Z rollout_percent: 25 2025-03-14T03:51:43.9310457Z all_branches: false 2025-03-14T03:51:43.9310906Z default: true 2025-03-14T03:51:43.9311310Z --- 2025-03-14T03:51:43.9311513Z 2025-03-14T03:51:43.9311671Z # Opt-ins: 2025-03-14T03:51:43.9312239Z # Users can opt into the LF fleet by adding their GitHub username to this list 2025-03-14T03:51:43.9313082Z # and specifying experiments to enable in a comma-separated list. 2025-03-14T03:51:43.9313840Z # To always opt out of an experiment, prefix it with a "-". 2025-03-14T03:51:43.9314475Z # Experiments should be from the above list. 2025-03-14T03:51:43.9314854Z 2025-03-14T03:51:43.9315034Z @User1,-lf,split_build 2025-03-14T03:51:43.9315467Z @User2,lf 2025-03-14T03:51:43.9315861Z @User3,split_build 2025-03-14T03:51:43.9316269Z """ 2025-03-14T03:51:43.9316459Z 2025-03-14T03:51:43.9316621Z import json 2025-03-14T03:51:43.9316987Z import logging 2025-03-14T03:51:43.9317366Z import os 2025-03-14T03:51:43.9317938Z import random 2025-03-14T03:51:43.9318355Z import re 2025-03-14T03:51:43.9318704Z import sys 2025-03-14T03:51:43.9319093Z from argparse import ArgumentParser 2025-03-14T03:51:43.9319618Z from collections.abc import Iterable 2025-03-14T03:51:43.9320141Z from functools import cache 2025-03-14T03:51:43.9320605Z from logging import LogRecord 2025-03-14T03:51:43.9321081Z from typing import Any, NamedTuple 2025-03-14T03:51:43.9321609Z from urllib.request import Request, urlopen 2025-03-14T03:51:43.9321967Z 2025-03-14T03:51:43.9322129Z import yaml 2025-03-14T03:51:43.9322515Z from github import Auth, Github 2025-03-14T03:51:43.9322988Z from github.Issue import Issue 2025-03-14T03:51:43.9323287Z 2025-03-14T03:51:43.9323294Z 2025-03-14T03:51:43.9323512Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-03-14T03:51:43.9324180Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-03-14T03:51:43.9325025Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-03-14T03:51:43.9325707Z 2025-03-14T03:51:43.9325935Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-03-14T03:51:43.9326514Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-03-14T03:51:43.9327016Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-03-14T03:51:43.9327665Z OPT_OUT_LABEL = "no-runner-experiments" 2025-03-14T03:51:43.9328019Z 2025-03-14T03:51:43.9328209Z SETTING_EXPERIMENTS = "experiments" 2025-03-14T03:51:43.9328540Z 2025-03-14T03:51:43.9328723Z LF_FLEET_EXPERIMENT = "lf" 2025-03-14T03:51:43.9329174Z CANARY_FLEET_SUFFIX = ".c" 2025-03-14T03:51:43.9329450Z 2025-03-14T03:51:43.9329457Z 2025-03-14T03:51:43.9329647Z class Experiment(NamedTuple): 2025-03-14T03:51:43.9330122Z rollout_perc: float = ( 2025-03-14T03:51:43.9330736Z 0 # Percentage of workflows to experiment on when user is not opted-in. 2025-03-14T03:51:43.9331391Z ) 2025-03-14T03:51:43.9331757Z all_branches: bool = ( 2025-03-14T03:51:43.9332367Z False # If True, the experiment is also enabled on the exception branches 2025-03-14T03:51:43.9333031Z ) 2025-03-14T03:51:43.9333376Z default: bool = ( 2025-03-14T03:51:43.9333930Z True # If True, the experiment is enabled by default for all queries 2025-03-14T03:51:43.9334553Z ) 2025-03-14T03:51:43.9334741Z 2025-03-14T03:51:43.9334922Z # Add more fields as needed 2025-03-14T03:51:43.9335215Z 2025-03-14T03:51:43.9335221Z 2025-03-14T03:51:43.9335407Z class Settings(NamedTuple): 2025-03-14T03:51:43.9335835Z """ 2025-03-14T03:51:43.9336277Z Settings for the experiments that can be opted into. 2025-03-14T03:51:43.9336837Z """ 2025-03-14T03:51:43.9337028Z 2025-03-14T03:51:43.9337233Z experiments: dict[str, Experiment] = {} 2025-03-14T03:51:43.9337731Z 2025-03-14T03:51:43.9337737Z 2025-03-14T03:51:43.9338068Z class ColorFormatter(logging.Formatter): 2025-03-14T03:51:43.9338690Z """Color codes the log messages based on the log level""" 2025-03-14T03:51:43.9339112Z 2025-03-14T03:51:43.9339273Z COLORS = { 2025-03-14T03:51:43.9339671Z "WARNING": "\033[33m", # Yellow 2025-03-14T03:51:43.9340172Z "ERROR": "\033[31m", # Red 2025-03-14T03:51:43.9340656Z "CRITICAL": "\033[31m", # Red 2025-03-14T03:51:43.9341140Z "INFO": "\033[0m", # Reset 2025-03-14T03:51:43.9341613Z "DEBUG": "\033[0m", # Reset 2025-03-14T03:51:43.9342082Z } 2025-03-14T03:51:43.9342284Z 2025-03-14T03:51:43.9342497Z def format(self, record: LogRecord) -> str: 2025-03-14T03:51:43.9343228Z log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-03-14T03:51:43.9343984Z record.msg = f"{log_color}{record.msg}\033[0m" 2025-03-14T03:51:43.9344545Z return super().format(record) 2025-03-14T03:51:43.9344880Z 2025-03-14T03:51:43.9344887Z 2025-03-14T03:51:43.9345079Z handler = logging.StreamHandler() 2025-03-14T03:51:43.9345767Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-03-14T03:51:43.9346328Z 2025-03-14T03:51:43.9346570Z log = logging.getLogger(os.path.basename(__file__)) 2025-03-14T03:51:43.9347144Z log.addHandler(handler) 2025-03-14T03:51:43.9347778Z log.setLevel(logging.INFO) 2025-03-14T03:51:43.9348071Z 2025-03-14T03:51:43.9348078Z 2025-03-14T03:51:43.9348325Z def set_github_output(key: str, value: str) -> None: 2025-03-14T03:51:43.9348863Z """ 2025-03-14T03:51:43.9349352Z Defines outputs of the github action that invokes this script 2025-03-14T03:51:43.9349969Z """ 2025-03-14T03:51:43.9350324Z if not GITHUB_OUTPUT: 2025-03-14T03:51:43.9351341Z # 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.9352411Z log.warning( 2025-03-14T03:51:43.9353230Z "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.9354107Z ) 2025-03-14T03:51:43.9364072Z print(f"::set-output name={key}::{value}") 2025-03-14T03:51:43.9364865Z return 2025-03-14T03:51:43.9365098Z 2025-03-14T03:51:43.9365299Z with open(GITHUB_OUTPUT, "a") as f: 2025-03-14T03:51:43.9365864Z log.info(f"Setting output: {key}='{value}'") 2025-03-14T03:51:43.9366426Z f.write(f"{key}={value}\n") 2025-03-14T03:51:43.9366751Z 2025-03-14T03:51:43.9366757Z 2025-03-14T03:51:43.9367072Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-03-14T03:51:43.9367959Z return frozenset( 2025-03-14T03:51:43.9368572Z filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-03-14T03:51:43.9369250Z ) 2025-03-14T03:51:43.9369444Z 2025-03-14T03:51:43.9369449Z 2025-03-14T03:51:43.9369631Z def parse_args() -> Any: 2025-03-14T03:51:43.9370205Z parser = ArgumentParser("Get dynamic rollout settings") 2025-03-14T03:51:43.9371059Z parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-03-14T03:51:43.9371828Z parser.add_argument( 2025-03-14T03:51:43.9372276Z "--github-issue-repo", 2025-03-14T03:51:43.9372721Z type=str, 2025-03-14T03:51:43.9373110Z required=False, 2025-03-14T03:51:43.9373553Z default="pytorch/test-infra", 2025-03-14T03:51:43.9374073Z help="GitHub repo to get the issue", 2025-03-14T03:51:43.9374573Z ) 2025-03-14T03:51:43.9374937Z parser.add_argument( 2025-03-14T03:51:43.9375372Z "--github-repo", 2025-03-14T03:51:43.9375780Z type=str, 2025-03-14T03:51:43.9376172Z required=True, 2025-03-14T03:51:43.9376608Z help="GitHub repo where CI is running", 2025-03-14T03:51:43.9377115Z ) 2025-03-14T03:51:43.9377469Z parser.add_argument( 2025-03-14T03:51:43.9378200Z "--github-issue", type=int, required=True, help="GitHub issue number" 2025-03-14T03:51:43.9378982Z ) 2025-03-14T03:51:43.9379354Z parser.add_argument( 2025-03-14T03:51:43.9379960Z "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-03-14T03:51:43.9380633Z ) 2025-03-14T03:51:43.9380992Z parser.add_argument( 2025-03-14T03:51:43.9381615Z "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-03-14T03:51:43.9382294Z ) 2025-03-14T03:51:43.9382643Z parser.add_argument( 2025-03-14T03:51:43.9383312Z "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-03-14T03:51:43.9383999Z ) 2025-03-14T03:51:43.9384350Z parser.add_argument( 2025-03-14T03:51:43.9384785Z "--github-ref-type", 2025-03-14T03:51:43.9385221Z type=str, 2025-03-14T03:51:43.9385607Z required=True, 2025-03-14T03:51:43.9386077Z help="Current GitHub ref type, branch or tag", 2025-03-14T03:51:43.9386611Z ) 2025-03-14T03:51:43.9386963Z parser.add_argument( 2025-03-14T03:51:43.9387412Z "--eligible-experiments", 2025-03-14T03:51:43.9388013Z type=_str_comma_separated_to_set, 2025-03-14T03:51:43.9388520Z required=False, 2025-03-14T03:51:43.9388931Z default="", 2025-03-14T03:51:43.9389740Z help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-03-14T03:51:43.9390635Z ) 2025-03-14T03:51:43.9390984Z parser.add_argument( 2025-03-14T03:51:43.9391411Z "--pr-number", 2025-03-14T03:51:43.9391819Z type=str, 2025-03-14T03:51:43.9392203Z required=False, 2025-03-14T03:51:43.9392609Z default="", 2025-03-14T03:51:43.9393067Z help="the optional PR number where this is run", 2025-03-14T03:51:43.9393601Z ) 2025-03-14T03:51:43.9393790Z 2025-03-14T03:51:43.9393975Z return parser.parse_args() 2025-03-14T03:51:43.9394271Z 2025-03-14T03:51:43.9394277Z 2025-03-14T03:51:43.9394675Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-03-14T03:51:43.9395394Z auth = Auth.Token(github_token) 2025-03-14T03:51:43.9395885Z return Github(auth=auth) 2025-03-14T03:51:43.9396315Z 2025-03-14T03:51:43.9396321Z 2025-03-14T03:51:43.9396781Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-03-14T03:51:43.9397786Z repo = gh.get_repo(repo) 2025-03-14T03:51:43.9398289Z return repo.get_issue(number=issue_num) 2025-03-14T03:51:43.9398643Z 2025-03-14T03:51:43.9398649Z 2025-03-14T03:51:43.9398837Z def get_potential_pr_author( 2025-03-14T03:51:43.9399462Z github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-03-14T03:51:43.9400110Z ) -> str: 2025-03-14T03:51:43.9400617Z # If the trigger was a new tag added by a bot, this is a ciflow case 2025-03-14T03:51:43.9401397Z # Fetch the actual username from the original PR. The PR number is 2025-03-14T03:51:43.9402112Z # embedded in the tag name: ciflow// 2025-03-14T03:51:43.9402507Z 2025-03-14T03:51:43.9402689Z gh = get_gh_client(github_token) 2025-03-14T03:51:43.9403024Z 2025-03-14T03:51:43.9403280Z if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-03-14T03:51:43.9403894Z split_tag = ref_name.split("/") 2025-03-14T03:51:43.9404489Z if ( 2025-03-14T03:51:43.9405003Z len(split_tag) == 3 2025-03-14T03:51:43.9405652Z and split_tag[0] == "ciflow" 2025-03-14T03:51:43.9406489Z and split_tag[2].isnumeric() 2025-03-14T03:51:43.9407063Z ): 2025-03-14T03:51:43.9407443Z pr_number = split_tag[2] 2025-03-14T03:51:43.9408219Z try: 2025-03-14T03:51:43.9408641Z repository = gh.get_repo(repo) 2025-03-14T03:51:43.9409248Z pull = repository.get_pull(number=int(pr_number)) 2025-03-14T03:51:43.9409833Z except Exception as e: 2025-03-14T03:51:43.9410343Z raise Exception( # noqa: TRY002 2025-03-14T03:51:43.9411161Z f"issue with pull request {pr_number} from repo {repository}" 2025-03-14T03:51:43.9411798Z ) from e 2025-03-14T03:51:43.9412328Z return pull.user.login # type: ignore[no-any-return] 2025-03-14T03:51:43.9413006Z # In all other cases, return the original input username 2025-03-14T03:51:43.9413571Z return username 2025-03-14T03:51:43.9413800Z 2025-03-14T03:51:43.9413806Z 2025-03-14T03:51:43.9414060Z def is_exception_branch(branch: str) -> bool: 2025-03-14T03:51:43.9414677Z """ 2025-03-14T03:51:43.9415295Z Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-03-14T03:51:43.9416039Z """ 2025-03-14T03:51:43.9416565Z return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-03-14T03:51:43.9417063Z 2025-03-14T03:51:43.9417075Z 2025-03-14T03:51:43.9417262Z def load_yaml(yaml_text: str) -> Any: 2025-03-14T03:51:43.9417999Z try: 2025-03-14T03:51:43.9418405Z data = yaml.safe_load(yaml_text) 2025-03-14T03:51:43.9418901Z return data 2025-03-14T03:51:43.9419314Z except yaml.YAMLError: 2025-03-14T03:51:43.9419790Z log.exception("Error loading YAML") 2025-03-14T03:51:43.9420290Z raise 2025-03-14T03:51:43.9420498Z 2025-03-14T03:51:43.9420504Z 2025-03-14T03:51:43.9420902Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-03-14T03:51:43.9421612Z """ 2025-03-14T03:51:43.9422208Z Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-03-14T03:51:43.9422794Z 2025-03-14T03:51:43.9423129Z If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:43.9423852Z and the text below is the list of opted in users. 2025-03-14T03:51:43.9424240Z 2025-03-14T03:51:43.9424605Z If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-03-14T03:51:43.9425281Z """ 2025-03-14T03:51:43.9425704Z rollout_state_parts = rollout_state.split("---") 2025-03-14T03:51:43.9426286Z if len(rollout_state_parts) >= 2: 2025-03-14T03:51:43.9426879Z return rollout_state_parts[0], rollout_state_parts[1] 2025-03-14T03:51:43.9427854Z else: 2025-03-14T03:51:43.9428235Z return "", rollout_state 2025-03-14T03:51:43.9428540Z 2025-03-14T03:51:43.9428549Z 2025-03-14T03:51:43.9428742Z class UserOptins(dict[str, list[str]]): 2025-03-14T03:51:43.9429235Z """ 2025-03-14T03:51:43.9429743Z Dictionary of users with a list of features they have opted into 2025-03-14T03:51:43.9430378Z """ 2025-03-14T03:51:43.9430569Z 2025-03-14T03:51:43.9430575Z 2025-03-14T03:51:43.9430907Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-03-14T03:51:43.9431543Z """ 2025-03-14T03:51:43.9432227Z 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.9432888Z 2025-03-14T03:51:43.9433490Z 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.9434450Z - Example line: "@User1,lf,split_build" 2025-03-14T03:51:43.9435124Z - A "#" prefix indicates the user is opted out of all experiments 2025-03-14T03:51:43.9435593Z 2025-03-14T03:51:43.9435599Z 2025-03-14T03:51:43.9435755Z """ 2025-03-14T03:51:43.9436123Z optins = UserOptins() 2025-03-14T03:51:43.9436589Z for user in user_optin_text.split("\n"): 2025-03-14T03:51:43.9437129Z user = user.strip("\r\n\t -") 2025-03-14T03:51:43.9437847Z if not user or not user.startswith("@"): 2025-03-14T03:51:43.9438393Z # Not a valid user. Skip 2025-03-14T03:51:43.9438869Z continue 2025-03-14T03:51:43.9439105Z 2025-03-14T03:51:43.9439256Z if user: 2025-03-14T03:51:43.9439674Z usr_name = user.split(",")[0].strip("@") 2025-03-14T03:51:43.9440352Z optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-03-14T03:51:43.9440956Z 2025-03-14T03:51:43.9441196Z return optins 2025-03-14T03:51:43.9441454Z 2025-03-14T03:51:43.9441460Z 2025-03-14T03:51:43.9441746Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-03-14T03:51:43.9442332Z """ 2025-03-14T03:51:43.9442711Z Check if the experiment name is valid. 2025-03-14T03:51:43.9443212Z A valid name: 2025-03-14T03:51:43.9443824Z - Contains only alphanumeric characters and the special characters "_" & "-" 2025-03-14T03:51:43.9444730Z - The special characters "_" & "-" shouldn't be the first or last characters 2025-03-14T03:51:43.9445422Z - Cannot contain spaces 2025-03-14T03:51:43.9445860Z """ 2025-03-14T03:51:43.9446050Z 2025-03-14T03:51:43.9446300Z valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-03-14T03:51:43.9446983Z valid = bool(re.match(valid_char_regex, experiment_name)) 2025-03-14T03:51:43.9447409Z 2025-03-14T03:51:43.9447785Z if valid: 2025-03-14T03:51:43.9448207Z return True 2025-03-14T03:51:43.9448443Z 2025-03-14T03:51:43.9448601Z log.error( 2025-03-14T03:51:43.9449991Z 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.9451479Z ) 2025-03-14T03:51:43.9451823Z return False 2025-03-14T03:51:43.9452049Z 2025-03-14T03:51:43.9452055Z 2025-03-14T03:51:43.9452357Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-03-14T03:51:43.9452962Z """ 2025-03-14T03:51:43.9453523Z Parse the experiments from the issue body into a list of ExperimentSettings 2025-03-14T03:51:43.9454218Z """ 2025-03-14T03:51:43.9454567Z try: 2025-03-14T03:51:43.9454929Z if settings_text: 2025-03-14T03:51:43.9455628Z # 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.9456385Z # for easy reading 2025-03-14T03:51:43.9457212Z # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-03-14T03:51:43.9459000Z # the backtick character in shell commands. 2025-03-14T03:51:43.9459614Z backtick = chr(96) # backtick character 2025-03-14T03:51:43.9460283Z settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-03-14T03:51:43.9460939Z settings = load_yaml(settings_text) 2025-03-14T03:51:43.9461305Z 2025-03-14T03:51:43.9461702Z # For now we just load experiments. We can expand this if/when we add more settings 2025-03-14T03:51:43.9462458Z experiments = {} 2025-03-14T03:51:43.9462755Z 2025-03-14T03:51:43.9463097Z for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-03-14T03:51:43.9463827Z if not is_valid_experiment_name(exp_name): 2025-03-14T03:51:43.9464918Z # 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.9465930Z continue 2025-03-14T03:51:43.9466207Z 2025-03-14T03:51:43.9466382Z valid_settings = {} 2025-03-14T03:51:43.9466893Z for setting in exp_settings: 2025-03-14T03:51:43.9467451Z if setting not in Experiment._fields: 2025-03-14T03:51:43.9468211Z log.warning( 2025-03-14T03:51:43.9468898Z f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-03-14T03:51:43.9469591Z ) 2025-03-14T03:51:43.9470008Z else: 2025-03-14T03:51:43.9470505Z valid_settings[setting] = exp_settings[setting] 2025-03-14T03:51:43.9470921Z 2025-03-14T03:51:43.9471185Z experiments[exp_name] = Experiment(**valid_settings) 2025-03-14T03:51:43.9471949Z return Settings(experiments) 2025-03-14T03:51:43.9472299Z 2025-03-14T03:51:43.9472477Z except Exception: 2025-03-14T03:51:43.9472937Z log.exception("Failed to parse settings") 2025-03-14T03:51:43.9473330Z 2025-03-14T03:51:43.9473498Z return Settings() 2025-03-14T03:51:43.9473749Z 2025-03-14T03:51:43.9473755Z 2025-03-14T03:51:43.9473996Z def parse_settings(rollout_state: str) -> Settings: 2025-03-14T03:51:43.9474547Z """ 2025-03-14T03:51:43.9474962Z Parse settings, if any, from the rollout state. 2025-03-14T03:51:43.9475679Z 2025-03-14T03:51:43.9476053Z If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:43.9476781Z and the text below is the list of opted in users. 2025-03-14T03:51:43.9477176Z 2025-03-14T03:51:43.9477819Z If it doesn't contain "---" then the settings are empty and the default values are used. 2025-03-14T03:51:43.9478612Z """ 2025-03-14T03:51:43.9479154Z settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:43.9479904Z return parse_settings_from_text(settings_text) 2025-03-14T03:51:43.9480297Z 2025-03-14T03:51:43.9480310Z 2025-03-14T03:51:43.9480549Z def parse_users(rollout_state: str) -> UserOptins: 2025-03-14T03:51:43.9481093Z """ 2025-03-14T03:51:43.9481634Z Parse users from the rollout state. 2025-03-14T03:51:43.9482372Z 2025-03-14T03:51:43.9482580Z """ 2025-03-14T03:51:43.9483145Z _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:43.9483859Z return parse_user_opt_in_from_text(users_text) 2025-03-14T03:51:43.9484263Z 2025-03-14T03:51:43.9484270Z 2025-03-14T03:51:43.9484668Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:43.9485374Z """ 2025-03-14T03:51:43.9485775Z Check if a user is opted into an experiment 2025-03-14T03:51:43.9486296Z """ 2025-03-14T03:51:43.9486726Z return experiment_name in user_optins.get(user, []) 2025-03-14T03:51:43.9487128Z 2025-03-14T03:51:43.9487134Z 2025-03-14T03:51:43.9487729Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:43.9488696Z """ 2025-03-14T03:51:43.9489148Z Check if a user explicitly opted out of an experiment 2025-03-14T03:51:43.9489725Z """ 2025-03-14T03:51:43.9490215Z # if the experiment is prefixed with a "-", then it's an opt-out 2025-03-14T03:51:43.9490899Z experiment_optout = "-" + experiment_name 2025-03-14T03:51:43.9491519Z if experiment_optout not in user_optins.get(user, []): 2025-03-14T03:51:43.9492101Z return False 2025-03-14T03:51:43.9492351Z 2025-03-14T03:51:43.9492612Z if is_user_opted_in(user, user_optins, experiment_name): 2025-03-14T03:51:43.9493202Z log.warning( 2025-03-14T03:51:43.9494006Z f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-03-14T03:51:43.9494842Z ) 2025-03-14T03:51:43.9495050Z 2025-03-14T03:51:43.9495211Z return True 2025-03-14T03:51:43.9495463Z 2025-03-14T03:51:43.9495469Z 2025-03-14T03:51:43.9495643Z def get_runner_prefix( 2025-03-14T03:51:43.9496079Z rollout_state: str, 2025-03-14T03:51:43.9496527Z workflow_requestors: Iterable[str], 2025-03-14T03:51:43.9497051Z branch: str, 2025-03-14T03:51:43.9497774Z eligible_experiments: frozenset[str] = frozenset(), 2025-03-14T03:51:43.9498425Z is_canary: bool = False, 2025-03-14T03:51:43.9498869Z ) -> str: 2025-03-14T03:51:43.9499268Z settings = parse_settings(rollout_state) 2025-03-14T03:51:43.9499829Z user_optins = parse_users(rollout_state) 2025-03-14T03:51:43.9500183Z 2025-03-14T03:51:43.9500358Z fleet_prefix = "" 2025-03-14T03:51:43.9500768Z prefixes = [] 2025-03-14T03:51:43.9501372Z for experiment_name, experiment_settings in settings.experiments.items(): 2025-03-14T03:51:43.9502275Z if not experiment_settings.all_branches and is_exception_branch(branch): 2025-03-14T03:51:43.9503099Z log.info( 2025-03-14T03:51:43.9503770Z f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-03-14T03:51:43.9504495Z ) 2025-03-14T03:51:43.9504858Z continue 2025-03-14T03:51:43.9505102Z 2025-03-14T03:51:43.9505285Z if eligible_experiments: 2025-03-14T03:51:43.9505823Z if experiment_name not in eligible_experiments: 2025-03-14T03:51:43.9506430Z exp_list = ", ".join(eligible_experiments) 2025-03-14T03:51:43.9506964Z log.info( 2025-03-14T03:51:43.9507989Z f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-03-14T03:51:43.9508803Z ) 2025-03-14T03:51:43.9509192Z continue 2025-03-14T03:51:43.9509674Z elif not experiment_settings.default: 2025-03-14T03:51:43.9510182Z log.info( 2025-03-14T03:51:43.9510849Z f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-03-14T03:51:43.9511576Z ) 2025-03-14T03:51:43.9511943Z continue 2025-03-14T03:51:43.9512185Z 2025-03-14T03:51:43.9512456Z # Is any workflow_requestor opted out to this experiment? 2025-03-14T03:51:43.9513052Z opted_out_users = [ 2025-03-14T03:51:43.9513487Z requestor 2025-03-14T03:51:43.9513919Z for requestor in workflow_requestors 2025-03-14T03:51:43.9514566Z if is_user_opted_out(requestor, user_optins, experiment_name) 2025-03-14T03:51:43.9515165Z ] 2025-03-14T03:51:43.9515364Z 2025-03-14T03:51:43.9515542Z if opted_out_users: 2025-03-14T03:51:43.9515965Z log.info( 2025-03-14T03:51:43.9516560Z f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-03-14T03:51:43.9517230Z ) 2025-03-14T03:51:43.9517843Z continue 2025-03-14T03:51:43.9518090Z 2025-03-14T03:51:43.9518364Z # Is any workflow_requestor opted in to this experiment? 2025-03-14T03:51:43.9518965Z opted_in_users = [ 2025-03-14T03:51:43.9519395Z requestor 2025-03-14T03:51:43.9519977Z for requestor in workflow_requestors 2025-03-14T03:51:43.9520615Z if is_user_opted_in(requestor, user_optins, experiment_name) 2025-03-14T03:51:43.9521232Z ] 2025-03-14T03:51:43.9521439Z 2025-03-14T03:51:43.9521622Z enabled = False 2025-03-14T03:51:43.9522046Z if opted_in_users: 2025-03-14T03:51:43.9522475Z log.info( 2025-03-14T03:51:43.9523052Z f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-03-14T03:51:43.9523988Z ) 2025-03-14T03:51:43.9524622Z enabled = True 2025-03-14T03:51:43.9525082Z 2025-03-14T03:51:43.9525436Z elif experiment_settings.rollout_perc: 2025-03-14T03:51:43.9526285Z # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-03-14T03:51:43.9527193Z if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-03-14T03:51:43.9528153Z log.info( 2025-03-14T03:51:43.9529034Z f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-03-14T03:51:43.9529973Z ) 2025-03-14T03:51:43.9530365Z enabled = True 2025-03-14T03:51:43.9530658Z 2025-03-14T03:51:43.9530821Z if enabled: 2025-03-14T03:51:43.9531225Z label = experiment_name 2025-03-14T03:51:43.9531757Z if experiment_name == LF_FLEET_EXPERIMENT: 2025-03-14T03:51:43.9532553Z # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-03-14T03:51:43.9533385Z # - If it's enabled, then we always list it's prefix first 2025-03-14T03:51:43.9534283Z # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-03-14T03:51:43.9534943Z if is_canary: 2025-03-14T03:51:43.9535422Z label += CANARY_FLEET_SUFFIX 2025-03-14T03:51:43.9535961Z fleet_prefix = label 2025-03-14T03:51:43.9536434Z else: 2025-03-14T03:51:43.9536842Z prefixes.append(label) 2025-03-14T03:51:43.9537182Z 2025-03-14T03:51:43.9537356Z if len(prefixes) > 1: 2025-03-14T03:51:43.9538012Z log.error( 2025-03-14T03:51:43.9538997Z 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.9540270Z ) 2025-03-14T03:51:43.9540647Z prefixes = prefixes[:1] 2025-03-14T03:51:43.9540950Z 2025-03-14T03:51:43.9541133Z # Fleet always comes first 2025-03-14T03:51:43.9541596Z if fleet_prefix: 2025-03-14T03:51:43.9542034Z prefixes.insert(0, fleet_prefix) 2025-03-14T03:51:43.9542374Z 2025-03-14T03:51:43.9542626Z return ".".join(prefixes) + "." if prefixes else "" 2025-03-14T03:51:43.9543027Z 2025-03-14T03:51:43.9543033Z 2025-03-14T03:51:43.9543785Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-03-14T03:51:43.9544543Z """ 2025-03-14T03:51:43.9545109Z Gets the first comment of the issue, which contains the desired rollout state. 2025-03-14T03:51:43.9545648Z 2025-03-14T03:51:43.9546018Z The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-03-14T03:51:43.9546882Z """ 2025-03-14T03:51:43.9547258Z gh = get_gh_client(github_token) 2025-03-14T03:51:43.9547931Z issue = get_issue(gh, repo, issue_num) 2025-03-14T03:51:43.9548586Z return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-03-14T03:51:43.9549012Z 2025-03-14T03:51:43.9549018Z 2025-03-14T03:51:43.9549401Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-03-14T03:51:43.9550130Z for _ in range(num_retries): 2025-03-14T03:51:43.9550600Z try: 2025-03-14T03:51:43.9551010Z req = Request(url=url, headers=headers) 2025-03-14T03:51:43.9551648Z content = urlopen(req, timeout=5).read().decode("utf-8") 2025-03-14T03:51:43.9552434Z return json.loads(content) 2025-03-14T03:51:43.9552950Z except Exception as e: 2025-03-14T03:51:43.9553471Z log.warning(f"Could not download {url}: {e}") 2025-03-14T03:51:43.9554014Z 2025-03-14T03:51:43.9554387Z log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-03-14T03:51:43.9555070Z return {} 2025-03-14T03:51:43.9555286Z 2025-03-14T03:51:43.9555292Z 2025-03-14T03:51:43.9555442Z @cache 2025-03-14T03:51:43.9556046Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-03-14T03:51:43.9556821Z """ 2025-03-14T03:51:43.9557203Z Dynamically get PR information 2025-03-14T03:51:43.9557902Z """ 2025-03-14T03:51:43.9558392Z github_api = f"https://api.github.com/repos/{github_repo}" 2025-03-14T03:51:43.9558999Z headers = { 2025-03-14T03:51:43.9559442Z "Accept": "application/vnd.github.v3+json", 2025-03-14T03:51:43.9560024Z "Authorization": f"token {github_token}", 2025-03-14T03:51:43.9560543Z } 2025-03-14T03:51:43.9560953Z json_response: dict[str, Any] = download_json( 2025-03-14T03:51:43.9561537Z url=f"{github_api}/issues/{pr_number}", 2025-03-14T03:51:43.9562068Z headers=headers, 2025-03-14T03:51:43.9562672Z ) 2025-03-14T03:51:43.9562870Z 2025-03-14T03:51:43.9563050Z if not json_response: 2025-03-14T03:51:43.9563587Z log.warning(f"Failed to get the labels for #{pr_number}") 2025-03-14T03:51:43.9564175Z return {} 2025-03-14T03:51:43.9564411Z 2025-03-14T03:51:43.9564587Z return json_response 2025-03-14T03:51:43.9564852Z 2025-03-14T03:51:43.9564857Z 2025-03-14T03:51:43.9565245Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-03-14T03:51:43.9566104Z """ 2025-03-14T03:51:43.9566624Z Dynamically get the latest list of labels from the pull request 2025-03-14T03:51:43.9567242Z """ 2025-03-14T03:51:43.9567954Z pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-03-14T03:51:43.9568559Z return { 2025-03-14T03:51:43.9569124Z label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-03-14T03:51:43.9569784Z } 2025-03-14T03:51:43.9569975Z 2025-03-14T03:51:43.9569981Z 2025-03-14T03:51:43.9570171Z def main() -> None: 2025-03-14T03:51:43.9570580Z args = parse_args() 2025-03-14T03:51:43.9570843Z 2025-03-14T03:51:43.9571058Z runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-03-14T03:51:43.9571426Z 2025-03-14T03:51:43.9571619Z # Check if the PR is opt-out 2025-03-14T03:51:43.9572090Z if args.pr_number: 2025-03-14T03:51:43.9572718Z labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-03-14T03:51:43.9573456Z if OPT_OUT_LABEL in labels: 2025-03-14T03:51:43.9573938Z log.info( 2025-03-14T03:51:43.9574597Z f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-03-14T03:51:43.9575342Z ) 2025-03-14T03:51:43.9575870Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:43.9576503Z sys.exit() 2025-03-14T03:51:43.9576755Z 2025-03-14T03:51:43.9576912Z try: 2025-03-14T03:51:43.9577326Z rollout_state = get_rollout_state_from_issue( 2025-03-14T03:51:43.9578214Z args.github_token, args.github_issue_repo, args.github_issue 2025-03-14T03:51:43.9578831Z ) 2025-03-14T03:51:43.9579029Z 2025-03-14T03:51:43.9579227Z username = get_potential_pr_author( 2025-03-14T03:51:43.9579752Z args.github_token, 2025-03-14T03:51:43.9580218Z args.github_repo, 2025-03-14T03:51:43.9580676Z args.github_actor, 2025-03-14T03:51:43.9581141Z args.github_ref_type, 2025-03-14T03:51:43.9581610Z args.github_branch, 2025-03-14T03:51:43.9582048Z ) 2025-03-14T03:51:43.9582255Z 2025-03-14T03:51:43.9582528Z is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-03-14T03:51:43.9583174Z 2025-03-14T03:51:43.9583387Z runner_label_prefix = get_runner_prefix( 2025-03-14T03:51:43.9583919Z rollout_state, 2025-03-14T03:51:43.9584374Z (args.github_issue_owner, username), 2025-03-14T03:51:43.9584908Z args.github_branch, 2025-03-14T03:51:43.9585381Z args.eligible_experiments, 2025-03-14T03:51:43.9585872Z is_canary, 2025-03-14T03:51:43.9586276Z ) 2025-03-14T03:51:43.9586471Z 2025-03-14T03:51:43.9586648Z except Exception as e: 2025-03-14T03:51:43.9587078Z log.error( 2025-03-14T03:51:43.9587834Z f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-03-14T03:51:43.9588563Z ) 2025-03-14T03:51:43.9588760Z 2025-03-14T03:51:43.9589087Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:43.9589560Z 2025-03-14T03:51:43.9589567Z 2025-03-14T03:51:43.9589745Z if __name__ == "__main__": 2025-03-14T03:51:43.9590160Z main() 2025-03-14T03:51:43.9590366Z 2025-03-14T03:51:43.9679158Z ##[group]Run python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-03-14T03:51:43.9680015Z python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-03-14T03:51:43.9726630Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:43.9727111Z env: 2025-03-14T03:51:43.9727971Z GITHUB_TOKEN: *** 2025-03-14T03:51:43.9728443Z ISSUE_NUMBER: 5132 2025-03-14T03:51:43.9728885Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:43.9729371Z ISSUE_OWNER: 2025-03-14T03:51:43.9729757Z CHECK_EXPERIMENTS: 2025-03-14T03:51:43.9730179Z PR_NUMBER: 2025-03-14T03:51:43.9730553Z ##[endgroup] 2025-03-14T03:51:45.0936399Z Defaulting to user installation because normal site-packages is not writeable 2025-03-14T03:51:45.9219113Z Collecting urllib3==1.26.18 2025-03-14T03:51:45.9898387Z Downloading urllib3-1.26.18-py2.py3-none-any.whl.metadata (48 kB) 2025-03-14T03:51:46.0129797Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 kB 3.9 MB/s eta 0:00:00 2025-03-14T03:51:46.0487967Z Collecting PyGithub==2.3.0 2025-03-14T03:51:46.0602127Z Downloading PyGithub-2.3.0-py3-none-any.whl.metadata (3.8 kB) 2025-03-14T03:51:46.1137922Z Collecting pynacl>=1.4.0 (from PyGithub==2.3.0) 2025-03-14T03:51:46.1241490Z 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:46.1292051Z 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:46.1309443Z 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:46.1324170Z 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:46.1770807Z Collecting Deprecated (from PyGithub==2.3.0) 2025-03-14T03:51:46.1881926Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl.metadata (5.7 kB) 2025-03-14T03:51:46.2188419Z 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:46.3441444Z Collecting cffi>=1.4.1 (from pynacl>=1.4.0->PyGithub==2.3.0) 2025-03-14T03:51:46.3544923Z Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.5 kB) 2025-03-14T03:51:46.4788138Z Collecting wrapt<2,>=1.10 (from Deprecated->PyGithub==2.3.0) 2025-03-14T03:51:46.4895658Z 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:46.5164017Z Collecting pycparser (from cffi>=1.4.1->pynacl>=1.4.0->PyGithub==2.3.0) 2025-03-14T03:51:46.5264272Z Downloading pycparser-2.22-py3-none-any.whl.metadata (943 bytes) 2025-03-14T03:51:46.5602204Z Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB) 2025-03-14T03:51:46.5731485Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.8/143.8 kB 11.9 MB/s eta 0:00:00 2025-03-14T03:51:46.5860251Z Downloading PyGithub-2.3.0-py3-none-any.whl (354 kB) 2025-03-14T03:51:46.5996797Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 354.4/354.4 kB 28.5 MB/s eta 0:00:00 2025-03-14T03:51:46.6097073Z 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:46.6277232Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 856.7/856.7 kB 55.2 MB/s eta 0:00:00 2025-03-14T03:51:46.6379481Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl (10.0 kB) 2025-03-14T03:51:46.6513176Z Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479 kB) 2025-03-14T03:51:46.6581125Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 479.4/479.4 kB 89.9 MB/s eta 0:00:00 2025-03-14T03:51:46.6700709Z 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:46.6759344Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 89.2/89.2 kB 18.4 MB/s eta 0:00:00 2025-03-14T03:51:46.6877859Z Downloading pycparser-2.22-py3-none-any.whl (117 kB) 2025-03-14T03:51:46.6934867Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.6/117.6 kB 27.6 MB/s eta 0:00:00 2025-03-14T03:51:46.9896926Z Installing collected packages: wrapt, urllib3, pycparser, Deprecated, cffi, pynacl, PyGithub 2025-03-14T03:51:47.5208513Z 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:47.5964891Z ##[group]Run curr_branch="main" 2025-03-14T03:51:47.5965219Z curr_branch="main" 2025-03-14T03:51:47.5965462Z curr_ref_type="branch" 2025-03-14T03:51:47.5965722Z echo "Current branch is '$curr_branch'" 2025-03-14T03:51:47.5965996Z  2025-03-14T03:51:47.5966201Z python3 runner_determinator.py \ 2025-03-14T03:51:47.5966499Z  --github-token "$GITHUB_TOKEN" \ 2025-03-14T03:51:47.5966806Z  --github-issue "$ISSUE_NUMBER" \ 2025-03-14T03:51:47.5967082Z  --github-branch "$curr_branch" \ 2025-03-14T03:51:47.5967360Z  --github-actor "$TRIGGERING_ACTOR" \ 2025-03-14T03:51:47.5967982Z  --github-issue-owner "$ISSUE_OWNER" \ 2025-03-14T03:51:47.5968287Z  --github-ref-type "$curr_ref_type" \ 2025-03-14T03:51:47.5968587Z  --github-repo "$GITHUB_REPOSITORY" \ 2025-03-14T03:51:47.5968939Z  --eligible-experiments "$CHECK_EXPERIMENTS" \ 2025-03-14T03:51:47.5969285Z  --pr-number "${PR_NUMBER}" 2025-03-14T03:51:47.6016024Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:47.6016275Z env: 2025-03-14T03:51:47.6016846Z GITHUB_TOKEN: *** 2025-03-14T03:51:47.6017061Z ISSUE_NUMBER: 5132 2025-03-14T03:51:47.6017277Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:47.6017746Z ISSUE_OWNER: 2025-03-14T03:51:47.6017966Z CHECK_EXPERIMENTS: 2025-03-14T03:51:47.6018176Z PR_NUMBER: 2025-03-14T03:51:47.6018367Z ##[endgroup] 2025-03-14T03:51:47.6081271Z Current branch is 'main' 2025-03-14T03:51:49.2942568Z INFO : Based on rollout percentage of 50%, enabling experiment lf. 2025-03-14T03:51:49.2943559Z INFO : Branch main is an exception branch. Not enabling experiment ephemeral. 2025-03-14T03:51:49.2944240Z INFO : Setting output: label-type='lf.' 2025-03-14T03:51:49.3275858Z Evaluate and set job outputs 2025-03-14T03:51:49.3283225Z Set output 'label-type' 2025-03-14T03:51:49.3285066Z Cleaning up orphan processes