2025-03-14T03:51:41.5273028Z Current runner version: '2.322.0' 2025-03-14T03:51:41.5299757Z ##[group]Operating System 2025-03-14T03:51:41.5300644Z Ubuntu 2025-03-14T03:51:41.5301165Z 24.04.2 2025-03-14T03:51:41.5301803Z LTS 2025-03-14T03:51:41.5302301Z ##[endgroup] 2025-03-14T03:51:41.5302796Z ##[group]Runner Image 2025-03-14T03:51:41.5303412Z Image: ubuntu-24.04 2025-03-14T03:51:41.5303965Z Version: 20250309.1.0 2025-03-14T03:51:41.5304995Z Included Software: https://github.com/actions/runner-images/blob/ubuntu24/20250309.1/images/ubuntu/Ubuntu2404-Readme.md 2025-03-14T03:51:41.5306611Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu24%2F20250309.1 2025-03-14T03:51:41.5307535Z ##[endgroup] 2025-03-14T03:51:41.5308037Z ##[group]Runner Image Provisioner 2025-03-14T03:51:41.5308696Z 2.0.422.1 2025-03-14T03:51:41.5309204Z ##[endgroup] 2025-03-14T03:51:41.5310315Z ##[group]GITHUB_TOKEN Permissions 2025-03-14T03:51:41.5312323Z Contents: read 2025-03-14T03:51:41.5312888Z Metadata: read 2025-03-14T03:51:41.5313695Z Packages: read 2025-03-14T03:51:41.5314259Z ##[endgroup] 2025-03-14T03:51:41.5317521Z Secret source: Actions 2025-03-14T03:51:41.5318575Z Prepare workflow directory 2025-03-14T03:51:41.5800922Z Prepare all required actions 2025-03-14T03:51:41.5855334Z Uses: pytorch/pytorch/.github/workflows/_runner-determinator.yml@refs/heads/main (aed0b7a742a2d7b7901790622829cbd2135049a4) 2025-03-14T03:51:41.5860629Z ##[group] Inputs 2025-03-14T03:51:41.5861277Z check_experiments: 2025-03-14T03:51:41.5862094Z triggering_actor: pytorchmergebot 2025-03-14T03:51:41.5862737Z issue_owner: 2025-03-14T03:51:41.5863322Z curr_branch: main 2025-03-14T03:51:41.5863855Z curr_ref_type: branch 2025-03-14T03:51:41.5864432Z issue_number: 5132 2025-03-14T03:51:41.5865007Z ##[endgroup] 2025-03-14T03:51:41.5865863Z Complete job name: get-label-type / runner-determinator 2025-03-14T03:51:41.6559809Z ##[group]Run cat < runner_determinator.py 2025-03-14T03:51:41.6561364Z cat < runner_determinator.py 2025-03-14T03:51:41.6561947Z # flake8: noqa: G004 2025-03-14T03:51:41.6562402Z  2025-03-14T03:51:41.6563071Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-03-14T03:51:41.6564053Z # must be kept in sync. You can do it easily by running the following command: 2025-03-14T03:51:41.6564880Z # python .github/scripts/update_runner_determinator.py 2025-03-14T03:51:41.6565487Z  2025-03-14T03:51:41.6566153Z """ 2025-03-14T03:51:41.6566782Z This runner determinator is used to determine which set of runners to run a 2025-03-14T03:51:41.6567702Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-03-14T03:51:41.6568681Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-03-14T03:51:41.6569534Z of which runners should be used to run which job. 2025-03-14T03:51:41.6570102Z  2025-03-14T03:51:41.6570713Z The configuration has two parts, the settings and a list of opted-in users, 2025-03-14T03:51:41.6571657Z separated by a line containing "---". If the line is not present, the 2025-03-14T03:51:41.6572568Z settings are considered to be empty with only the second part, the user 2025-03-14T03:51:41.6573282Z list, defined. 2025-03-14T03:51:41.6573693Z  2025-03-14T03:51:41.6574275Z The first part is a YAML block that defines the rollout settings. This can be 2025-03-14T03:51:41.6575233Z used to define any settings that are needed to determine which runners to use. 2025-03-14T03:51:41.6576241Z It's fields are defined by the RolloutSettings class below. 2025-03-14T03:51:41.6576860Z  2025-03-14T03:51:41.6577455Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-03-14T03:51:41.6578371Z The user list is also a comma separated list of additional features or 2025-03-14T03:51:41.6579483Z experiments which the user could be opted in to. 2025-03-14T03:51:41.6580061Z  2025-03-14T03:51:41.6580470Z The user list has the following rules: 2025-03-14T03:51:41.6580989Z  2025-03-14T03:51:41.6581531Z - Users are GitHub usernames, which must start with the @ prefix 2025-03-14T03:51:41.6582408Z - Each user is also a comma-separated list of features/experiments to enable 2025-03-14T03:51:41.6583212Z - A "#" prefix opts the user out of all experiments 2025-03-14T03:51:41.6583776Z  2025-03-14T03:51:41.6584151Z Example config: 2025-03-14T03:51:41.6584695Z  # A list of experiments that can be opted into. 2025-03-14T03:51:41.6585417Z  # This defines the behavior they'll induce when opted into. 2025-03-14T03:51:41.6586207Z  # Expected syntax is: 2025-03-14T03:51:41.6586932Z  # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-03-14T03:51:41.6587948Z  # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-03-14T03:51:41.6588717Z  2025-03-14T03:51:41.6589094Z  experiments: 2025-03-14T03:51:41.6589530Z  lf: 2025-03-14T03:51:41.6589951Z  rollout_percent: 25 2025-03-14T03:51:41.6590467Z  all_branches: false 2025-03-14T03:51:41.6590966Z  default: true 2025-03-14T03:51:41.6591417Z  --- 2025-03-14T03:51:41.6591789Z  2025-03-14T03:51:41.6592154Z  # Opt-ins: 2025-03-14T03:51:41.6592808Z  # Users can opt into the LF fleet by adding their GitHub username to this list 2025-03-14T03:51:41.6593887Z  # and specifying experiments to enable in a comma-separated list. 2025-03-14T03:51:41.6594703Z  # To always opt out of an experiment, prefix it with a "-". 2025-03-14T03:51:41.6595403Z  # Experiments should be from the above list. 2025-03-14T03:51:41.6596225Z  2025-03-14T03:51:41.6596612Z  @User1,-lf,split_build 2025-03-14T03:51:41.6597102Z  @User2,lf 2025-03-14T03:51:41.6597534Z  @User3,split_build 2025-03-14T03:51:41.6597985Z """ 2025-03-14T03:51:41.6598345Z  2025-03-14T03:51:41.6598707Z import json 2025-03-14T03:51:41.6599127Z import logging 2025-03-14T03:51:41.6599554Z import os 2025-03-14T03:51:41.6599957Z import random 2025-03-14T03:51:41.6600385Z import re 2025-03-14T03:51:41.6600782Z import sys 2025-03-14T03:51:41.6601285Z from argparse import ArgumentParser 2025-03-14T03:51:41.6601862Z from collections.abc import Iterable 2025-03-14T03:51:41.6602425Z from functools import cache 2025-03-14T03:51:41.6602949Z from logging import LogRecord 2025-03-14T03:51:41.6603489Z from typing import Any, NamedTuple 2025-03-14T03:51:41.6604089Z from urllib.request import Request, urlopen 2025-03-14T03:51:41.6604638Z  2025-03-14T03:51:41.6605004Z import yaml 2025-03-14T03:51:41.6605451Z from github import Auth, Github 2025-03-14T03:51:41.6606150Z from github.Issue import Issue 2025-03-14T03:51:41.6606649Z  2025-03-14T03:51:41.6606995Z  2025-03-14T03:51:41.6607435Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-03-14T03:51:41.6608170Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-03-14T03:51:41.6609068Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-03-14T03:51:41.6609774Z  2025-03-14T03:51:41.6610226Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-03-14T03:51:41.6610831Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-03-14T03:51:41.6611398Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-03-14T03:51:41.6612171Z OPT_OUT_LABEL = "no-runner-experiments" 2025-03-14T03:51:41.6612703Z  2025-03-14T03:51:41.6613111Z SETTING_EXPERIMENTS = "experiments" 2025-03-14T03:51:41.6613620Z  2025-03-14T03:51:41.6614006Z LF_FLEET_EXPERIMENT = "lf" 2025-03-14T03:51:41.6614514Z CANARY_FLEET_SUFFIX = ".c" 2025-03-14T03:51:41.6614980Z  2025-03-14T03:51:41.6615327Z  2025-03-14T03:51:41.6615824Z class Experiment(NamedTuple): 2025-03-14T03:51:41.6616358Z  rollout_perc: float = ( 2025-03-14T03:51:41.6617067Z  0 # Percentage of workflows to experiment on when user is not opted-in. 2025-03-14T03:51:41.6617760Z  ) 2025-03-14T03:51:41.6618162Z  all_branches: bool = ( 2025-03-14T03:51:41.6618859Z  False # If True, the experiment is also enabled on the exception branches 2025-03-14T03:51:41.6619544Z  ) 2025-03-14T03:51:41.6619948Z  default: bool = ( 2025-03-14T03:51:41.6620594Z  True # If True, the experiment is enabled by default for all queries 2025-03-14T03:51:41.6621250Z  ) 2025-03-14T03:51:41.6621616Z  2025-03-14T03:51:41.6622012Z  # Add more fields as needed 2025-03-14T03:51:41.6622504Z  2025-03-14T03:51:41.6622853Z  2025-03-14T03:51:41.6623239Z class Settings(NamedTuple): 2025-03-14T03:51:41.6623780Z  """ 2025-03-14T03:51:41.6624355Z  Settings for the experiments that can be opted into. 2025-03-14T03:51:41.6624951Z  """ 2025-03-14T03:51:41.6625330Z  2025-03-14T03:51:41.6625853Z  experiments: dict[str, Experiment] = {} 2025-03-14T03:51:41.6626381Z  2025-03-14T03:51:41.6626862Z  2025-03-14T03:51:41.6627297Z class ColorFormatter(logging.Formatter): 2025-03-14T03:51:41.6627980Z  """Color codes the log messages based on the log level""" 2025-03-14T03:51:41.6628589Z  2025-03-14T03:51:41.6628949Z  COLORS = { 2025-03-14T03:51:41.6629400Z  "WARNING": "\033[33m", # Yellow 2025-03-14T03:51:41.6629943Z  "ERROR": "\033[31m", # Red 2025-03-14T03:51:41.6630472Z  "CRITICAL": "\033[31m", # Red 2025-03-14T03:51:41.6631010Z  "INFO": "\033[0m", # Reset 2025-03-14T03:51:41.6631537Z  "DEBUG": "\033[0m", # Reset 2025-03-14T03:51:41.6632029Z  } 2025-03-14T03:51:41.6632402Z  2025-03-14T03:51:41.6632841Z  def format(self, record: LogRecord) -> str: 2025-03-14T03:51:41.6633632Z  log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-03-14T03:51:41.6634432Z  record.msg = f"{log_color}{record.msg}\033[0m" 2025-03-14T03:51:41.6635036Z  return super().format(record) 2025-03-14T03:51:41.6635540Z  2025-03-14T03:51:41.6636146Z  2025-03-14T03:51:41.6636548Z handler = logging.StreamHandler() 2025-03-14T03:51:41.6637309Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-03-14T03:51:41.6638029Z  2025-03-14T03:51:41.6638501Z log = logging.getLogger(os.path.basename(__file__)) 2025-03-14T03:51:41.6639122Z log.addHandler(handler) 2025-03-14T03:51:41.6639626Z log.setLevel(logging.INFO) 2025-03-14T03:51:41.6640101Z  2025-03-14T03:51:41.6640455Z  2025-03-14T03:51:41.6640934Z def set_github_output(key: str, value: str) -> None: 2025-03-14T03:51:41.6641537Z  """ 2025-03-14T03:51:41.6642094Z  Defines outputs of the github action that invokes this script 2025-03-14T03:51:41.6642751Z  """ 2025-03-14T03:51:41.6643154Z  if not GITHUB_OUTPUT: 2025-03-14T03:51:41.6644263Z  # See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ for deprecation notice 2025-03-14T03:51:41.6645537Z  log.warning( 2025-03-14T03:51:41.6646595Z  "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:41.6647522Z  ) 2025-03-14T03:51:41.6648001Z  print(f"::set-output name={key}::{value}") 2025-03-14T03:51:41.6648564Z  return 2025-03-14T03:51:41.6648978Z  2025-03-14T03:51:41.6649391Z  with open(GITHUB_OUTPUT, "a") as f: 2025-03-14T03:51:41.6650004Z  log.info(f"Setting output: {key}='{value}'") 2025-03-14T03:51:41.6650599Z  f.write(f"{key}={value}\n") 2025-03-14T03:51:41.6651101Z  2025-03-14T03:51:41.6651457Z  2025-03-14T03:51:41.6651988Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-03-14T03:51:41.6652660Z  return frozenset( 2025-03-14T03:51:41.6653330Z  filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-03-14T03:51:41.6654011Z  ) 2025-03-14T03:51:41.6654388Z  2025-03-14T03:51:41.6654732Z  2025-03-14T03:51:41.6655114Z def parse_args() -> Any: 2025-03-14T03:51:41.6655839Z  parser = ArgumentParser("Get dynamic rollout settings") 2025-03-14T03:51:41.6656743Z  parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-03-14T03:51:41.6657512Z  parser.add_argument( 2025-03-14T03:51:41.6658015Z  "--github-issue-repo", 2025-03-14T03:51:41.6658522Z  type=str, 2025-03-14T03:51:41.6658977Z  required=False, 2025-03-14T03:51:41.6659602Z  default="pytorch/test-infra", 2025-03-14T03:51:41.6660190Z  help="GitHub repo to get the issue", 2025-03-14T03:51:41.6660726Z  ) 2025-03-14T03:51:41.6661116Z  parser.add_argument( 2025-03-14T03:51:41.6661602Z  "--github-repo", 2025-03-14T03:51:41.6662074Z  type=str, 2025-03-14T03:51:41.6662545Z  required=True, 2025-03-14T03:51:41.6663066Z  help="GitHub repo where CI is running", 2025-03-14T03:51:41.6663635Z  ) 2025-03-14T03:51:41.6664037Z  parser.add_argument( 2025-03-14T03:51:41.6664701Z  "--github-issue", type=int, required=True, help="GitHub issue number" 2025-03-14T03:51:41.6665365Z  ) 2025-03-14T03:51:41.6665864Z  parser.add_argument( 2025-03-14T03:51:41.6666541Z  "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-03-14T03:51:41.6667223Z  ) 2025-03-14T03:51:41.6667615Z  parser.add_argument( 2025-03-14T03:51:41.6668308Z  "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-03-14T03:51:41.6669011Z  ) 2025-03-14T03:51:41.6669413Z  parser.add_argument( 2025-03-14T03:51:41.6670130Z  "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-03-14T03:51:41.6670857Z  ) 2025-03-14T03:51:41.6671253Z  parser.add_argument( 2025-03-14T03:51:41.6671742Z  "--github-ref-type", 2025-03-14T03:51:41.6672233Z  type=str, 2025-03-14T03:51:41.6672688Z  required=True, 2025-03-14T03:51:41.6673236Z  help="Current GitHub ref type, branch or tag", 2025-03-14T03:51:41.6673794Z  ) 2025-03-14T03:51:41.6674186Z  parser.add_argument( 2025-03-14T03:51:41.6674705Z  "--eligible-experiments", 2025-03-14T03:51:41.6675263Z  type=_str_comma_separated_to_set, 2025-03-14T03:51:41.6675903Z  required=False, 2025-03-14T03:51:41.6676538Z  default="", 2025-03-14T03:51:41.6677445Z  help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-03-14T03:51:41.6678452Z  ) 2025-03-14T03:51:41.6678853Z  parser.add_argument( 2025-03-14T03:51:41.6679343Z  "--pr-number", 2025-03-14T03:51:41.6679810Z  type=str, 2025-03-14T03:51:41.6680257Z  required=False, 2025-03-14T03:51:41.6680734Z  default="", 2025-03-14T03:51:41.6681276Z  help="the optional PR number where this is run", 2025-03-14T03:51:41.6681855Z  ) 2025-03-14T03:51:41.6682229Z  2025-03-14T03:51:41.6682629Z  return parser.parse_args() 2025-03-14T03:51:41.6683121Z  2025-03-14T03:51:41.6683476Z  2025-03-14T03:51:41.6684095Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-03-14T03:51:41.6684887Z  auth = Auth.Token(github_token) 2025-03-14T03:51:41.6685425Z  return Github(auth=auth) 2025-03-14T03:51:41.6686008Z  2025-03-14T03:51:41.6686355Z  2025-03-14T03:51:41.6687023Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-03-14T03:51:41.6687836Z  repo = gh.get_repo(repo) 2025-03-14T03:51:41.6688390Z  return repo.get_issue(number=issue_num) 2025-03-14T03:51:41.6688925Z  2025-03-14T03:51:41.6689274Z  2025-03-14T03:51:41.6689667Z def get_potential_pr_author( 2025-03-14T03:51:41.6690371Z  github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-03-14T03:51:41.6691067Z ) -> str: 2025-03-14T03:51:41.6691757Z  # If the trigger was a new tag added by a bot, this is a ciflow case 2025-03-14T03:51:41.6692590Z  # Fetch the actual username from the original PR. The PR number is 2025-03-14T03:51:41.6693375Z  # embedded in the tag name: ciflow// 2025-03-14T03:51:41.6693956Z  2025-03-14T03:51:41.6694354Z  gh = get_gh_client(github_token) 2025-03-14T03:51:41.6694866Z  2025-03-14T03:51:41.6695356Z  if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-03-14T03:51:41.6696115Z  split_tag = ref_name.split("/") 2025-03-14T03:51:41.6696641Z  if ( 2025-03-14T03:51:41.6697067Z  len(split_tag) == 3 2025-03-14T03:51:41.6697600Z  and split_tag[0] == "ciflow" 2025-03-14T03:51:41.6698157Z  and split_tag[2].isnumeric() 2025-03-14T03:51:41.6698668Z  ): 2025-03-14T03:51:41.6699105Z  pr_number = split_tag[2] 2025-03-14T03:51:41.6699616Z  try: 2025-03-14T03:51:41.6700159Z  repository = gh.get_repo(repo) 2025-03-14T03:51:41.6700825Z  pull = repository.get_pull(number=int(pr_number)) 2025-03-14T03:51:41.6701453Z  except Exception as e: 2025-03-14T03:51:41.6702005Z  raise Exception( # noqa: TRY002 2025-03-14T03:51:41.6702701Z  f"issue with pull request {pr_number} from repo {repository}" 2025-03-14T03:51:41.6703351Z  ) from e 2025-03-14T03:51:41.6703944Z  return pull.user.login # type: ignore[no-any-return] 2025-03-14T03:51:41.6704671Z  # In all other cases, return the original input username 2025-03-14T03:51:41.6705272Z  return username 2025-03-14T03:51:41.6705799Z  2025-03-14T03:51:41.6706147Z  2025-03-14T03:51:41.6706586Z def is_exception_branch(branch: str) -> bool: 2025-03-14T03:51:41.6707125Z  """ 2025-03-14T03:51:41.6707847Z  Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-03-14T03:51:41.6708744Z  """ 2025-03-14T03:51:41.6709322Z  return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-03-14T03:51:41.6709988Z  2025-03-14T03:51:41.6710326Z  2025-03-14T03:51:41.6710728Z def load_yaml(yaml_text: str) -> Any: 2025-03-14T03:51:41.6711240Z  try: 2025-03-14T03:51:41.6711661Z  data = yaml.safe_load(yaml_text) 2025-03-14T03:51:41.6712180Z  return data 2025-03-14T03:51:41.6712641Z  except yaml.YAMLError: 2025-03-14T03:51:41.6713168Z  log.exception("Error loading YAML") 2025-03-14T03:51:41.6713686Z  raise 2025-03-14T03:51:41.6714081Z  2025-03-14T03:51:41.6714418Z  2025-03-14T03:51:41.6715048Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-03-14T03:51:41.6715895Z  """ 2025-03-14T03:51:41.6716552Z  Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-03-14T03:51:41.6717289Z  2025-03-14T03:51:41.6717839Z  If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:41.6718630Z  and the text below is the list of opted in users. 2025-03-14T03:51:41.6719196Z  2025-03-14T03:51:41.6719775Z  If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-03-14T03:51:41.6720469Z  """ 2025-03-14T03:51:41.6720952Z  rollout_state_parts = rollout_state.split("---") 2025-03-14T03:51:41.6721564Z  if len(rollout_state_parts) >= 2: 2025-03-14T03:51:41.6722321Z  return rollout_state_parts[0], rollout_state_parts[1] 2025-03-14T03:51:41.6722927Z  else: 2025-03-14T03:51:41.6723350Z  return "", rollout_state 2025-03-14T03:51:41.6723830Z  2025-03-14T03:51:41.6724169Z  2025-03-14T03:51:41.6724578Z class UserOptins(dict[str, list[str]]): 2025-03-14T03:51:41.6725099Z  """ 2025-03-14T03:51:41.6725760Z  Dictionary of users with a list of features they have opted into 2025-03-14T03:51:41.6726417Z  """ 2025-03-14T03:51:41.6726794Z  2025-03-14T03:51:41.6727138Z  2025-03-14T03:51:41.6727691Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-03-14T03:51:41.6728358Z  """ 2025-03-14T03:51:41.6729102Z  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:41.6729927Z  2025-03-14T03:51:41.6730750Z  Users are GitHub usernames with the @ prefix. Each user is also a comma-separated list of features/experiments to enable. 2025-03-14T03:51:41.6731751Z  - Example line: "@User1,lf,split_build" 2025-03-14T03:51:41.6732462Z  - A "#" prefix indicates the user is opted out of all experiments 2025-03-14T03:51:41.6733099Z  2025-03-14T03:51:41.6733437Z  2025-03-14T03:51:41.6733783Z  """ 2025-03-14T03:51:41.6734186Z  optins = UserOptins() 2025-03-14T03:51:41.6734731Z  for user in user_optin_text.split("\n"): 2025-03-14T03:51:41.6735316Z  user = user.strip("\r\n\t -") 2025-03-14T03:51:41.6735984Z  if not user or not user.startswith("@"): 2025-03-14T03:51:41.6736556Z  # Not a valid user. Skip 2025-03-14T03:51:41.6737069Z  continue 2025-03-14T03:51:41.6737493Z  2025-03-14T03:51:41.6737849Z  if user: 2025-03-14T03:51:41.6738505Z  usr_name = user.split(",")[0].strip("@") 2025-03-14T03:51:41.6739604Z  optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-03-14T03:51:41.6740869Z  2025-03-14T03:51:41.6741452Z  return optins 2025-03-14T03:51:41.6742216Z  2025-03-14T03:51:41.6742827Z  2025-03-14T03:51:41.6743747Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-03-14T03:51:41.6744897Z  """ 2025-03-14T03:51:41.6746003Z  Check if the experiment name is valid. 2025-03-14T03:51:41.6747068Z  A valid name: 2025-03-14T03:51:41.6748352Z  - Contains only alphanumeric characters and the special characters "_" & "-" 2025-03-14T03:51:41.6750133Z  - The special characters "_" & "-" shouldn't be the first or last characters 2025-03-14T03:51:41.6751534Z  - Cannot contain spaces 2025-03-14T03:51:41.6752443Z  """ 2025-03-14T03:51:41.6753147Z  2025-03-14T03:51:41.6753994Z  valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-03-14T03:51:41.6755346Z  valid = bool(re.match(valid_char_regex, experiment_name)) 2025-03-14T03:51:41.6756758Z  2025-03-14T03:51:41.6757435Z  if valid: 2025-03-14T03:51:41.6758200Z  return True 2025-03-14T03:51:41.6759017Z  2025-03-14T03:51:41.6759682Z  log.error( 2025-03-14T03:51:41.6762380Z  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:41.6765239Z  ) 2025-03-14T03:51:41.6766184Z  return False 2025-03-14T03:51:41.6766938Z  2025-03-14T03:51:41.6767549Z  2025-03-14T03:51:41.6768761Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-03-14T03:51:41.6770002Z  """ 2025-03-14T03:51:41.6771145Z  Parse the experiments from the issue body into a list of ExperimentSettings 2025-03-14T03:51:41.6772466Z  """ 2025-03-14T03:51:41.6773129Z  try: 2025-03-14T03:51:41.6773811Z  if settings_text: 2025-03-14T03:51:41.6775170Z  # Escape the backtick as well so that we can have the settings in a code block on the GH issue 2025-03-14T03:51:41.6776834Z  # for easy reading 2025-03-14T03:51:41.6778333Z  # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-03-14T03:51:41.6780018Z  # the backtick character in shell commands. 2025-03-14T03:51:41.6781127Z  backtick = chr(96) # backtick character 2025-03-14T03:51:41.6782362Z  settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-03-14T03:51:41.6783600Z  settings = load_yaml(settings_text) 2025-03-14T03:51:41.6784556Z  2025-03-14T03:51:41.6785871Z  # For now we just load experiments. We can expand this if/when we add more settings 2025-03-14T03:51:41.6787297Z  experiments = {} 2025-03-14T03:51:41.6788197Z  2025-03-14T03:51:41.6789261Z  for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-03-14T03:51:41.6790729Z  if not is_valid_experiment_name(exp_name): 2025-03-14T03:51:41.6792783Z  # 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:41.6794777Z  continue 2025-03-14T03:51:41.6795812Z  2025-03-14T03:51:41.6796511Z  valid_settings = {} 2025-03-14T03:51:41.6797530Z  for setting in exp_settings: 2025-03-14T03:51:41.6798589Z  if setting not in Experiment._fields: 2025-03-14T03:51:41.6799915Z  log.warning( 2025-03-14T03:51:41.6801232Z  f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-03-14T03:51:41.6802587Z  ) 2025-03-14T03:51:41.6803464Z  else: 2025-03-14T03:51:41.6804501Z  valid_settings[setting] = exp_settings[setting] 2025-03-14T03:51:41.6805773Z  2025-03-14T03:51:41.6806709Z  experiments[exp_name] = Experiment(**valid_settings) 2025-03-14T03:51:41.6807894Z  return Settings(experiments) 2025-03-14T03:51:41.6808812Z  2025-03-14T03:51:41.6809462Z  except Exception: 2025-03-14T03:51:41.6810415Z  log.exception("Failed to parse settings") 2025-03-14T03:51:41.6811432Z  2025-03-14T03:51:41.6812117Z  return Settings() 2025-03-14T03:51:41.6812944Z  2025-03-14T03:51:41.6813601Z  2025-03-14T03:51:41.6814483Z def parse_settings(rollout_state: str) -> Settings: 2025-03-14T03:51:41.6815783Z  """ 2025-03-14T03:51:41.6816751Z  Parse settings, if any, from the rollout state. 2025-03-14T03:51:41.6817807Z  2025-03-14T03:51:41.6818803Z  If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:41.6820261Z  and the text below is the list of opted in users. 2025-03-14T03:51:41.6821309Z  2025-03-14T03:51:41.6822415Z  If it doesn't contain "---" then the settings are empty and the default values are used. 2025-03-14T03:51:41.6823757Z  """ 2025-03-14T03:51:41.6824856Z  settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:41.6826800Z  return parse_settings_from_text(settings_text) 2025-03-14T03:51:41.6827911Z  2025-03-14T03:51:41.6828521Z  2025-03-14T03:51:41.6829386Z def parse_users(rollout_state: str) -> UserOptins: 2025-03-14T03:51:41.6830475Z  """ 2025-03-14T03:51:41.6831252Z  Parse users from the rollout state. 2025-03-14T03:51:41.6832186Z  2025-03-14T03:51:41.6832785Z  """ 2025-03-14T03:51:41.6833796Z  _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:41.6835231Z  return parse_user_opt_in_from_text(users_text) 2025-03-14T03:51:41.6836475Z  2025-03-14T03:51:41.6837105Z  2025-03-14T03:51:41.6838229Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:41.6839625Z  """ 2025-03-14T03:51:41.6840472Z  Check if a user is opted into an experiment 2025-03-14T03:51:41.6841491Z  """ 2025-03-14T03:51:41.6842393Z  return experiment_name in user_optins.get(user, []) 2025-03-14T03:51:41.6843488Z  2025-03-14T03:51:41.6844094Z  2025-03-14T03:51:41.6845216Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:41.6846853Z  """ 2025-03-14T03:51:41.6847774Z  Check if a user explicitly opted out of an experiment 2025-03-14T03:51:41.6848865Z  """ 2025-03-14T03:51:41.6849866Z  # if the experiment is prefixed with a "-", then it's an opt-out 2025-03-14T03:51:41.6851187Z  experiment_optout = "-" + experiment_name 2025-03-14T03:51:41.6852417Z  if experiment_optout not in user_optins.get(user, []): 2025-03-14T03:51:41.6853575Z  return False 2025-03-14T03:51:41.6854366Z  2025-03-14T03:51:41.6855273Z  if is_user_opted_in(user, user_optins, experiment_name): 2025-03-14T03:51:41.6856621Z  log.warning( 2025-03-14T03:51:41.6858134Z  f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-03-14T03:51:41.6859991Z  ) 2025-03-14T03:51:41.6860659Z  2025-03-14T03:51:41.6861290Z  return True 2025-03-14T03:51:41.6862022Z  2025-03-14T03:51:41.6862623Z  2025-03-14T03:51:41.6863280Z def get_runner_prefix( 2025-03-14T03:51:41.6864133Z  rollout_state: str, 2025-03-14T03:51:41.6865104Z  workflow_requestors: Iterable[str], 2025-03-14T03:51:41.6866324Z  branch: str, 2025-03-14T03:51:41.6867350Z  eligible_experiments: frozenset[str] = frozenset(), 2025-03-14T03:51:41.6868510Z  is_canary: bool = False, 2025-03-14T03:51:41.6869389Z ) -> str: 2025-03-14T03:51:41.6870247Z  settings = parse_settings(rollout_state) 2025-03-14T03:51:41.6871345Z  user_optins = parse_users(rollout_state) 2025-03-14T03:51:41.6872291Z  2025-03-14T03:51:41.6872960Z  fleet_prefix = "" 2025-03-14T03:51:41.6873839Z  prefixes = [] 2025-03-14T03:51:41.6875123Z  for experiment_name, experiment_settings in settings.experiments.items(): 2025-03-14T03:51:41.6877153Z  if not experiment_settings.all_branches and is_exception_branch(branch): 2025-03-14T03:51:41.6878507Z  log.info( 2025-03-14T03:51:41.6879804Z  f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-03-14T03:51:41.6881168Z  ) 2025-03-14T03:51:41.6881907Z  continue 2025-03-14T03:51:41.6882686Z  2025-03-14T03:51:41.6883406Z  if eligible_experiments: 2025-03-14T03:51:41.6884786Z  if experiment_name not in eligible_experiments: 2025-03-14T03:51:41.6886237Z  exp_list = ", ".join(eligible_experiments) 2025-03-14T03:51:41.6886843Z  log.info( 2025-03-14T03:51:41.6887692Z  f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-03-14T03:51:41.6888519Z  ) 2025-03-14T03:51:41.6888954Z  continue 2025-03-14T03:51:41.6889479Z  elif not experiment_settings.default: 2025-03-14T03:51:41.6890043Z  log.info( 2025-03-14T03:51:41.6890748Z  f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-03-14T03:51:41.6891490Z  ) 2025-03-14T03:51:41.6891912Z  continue 2025-03-14T03:51:41.6892340Z  2025-03-14T03:51:41.6892842Z  # Is any workflow_requestor opted out to this experiment? 2025-03-14T03:51:41.6893481Z  opted_out_users = [ 2025-03-14T03:51:41.6893971Z  requestor 2025-03-14T03:51:41.6894479Z  for requestor in workflow_requestors 2025-03-14T03:51:41.6895186Z  if is_user_opted_out(requestor, user_optins, experiment_name) 2025-03-14T03:51:41.6896074Z  ] 2025-03-14T03:51:41.6896462Z  2025-03-14T03:51:41.6896829Z  if opted_out_users: 2025-03-14T03:51:41.6897316Z  log.info( 2025-03-14T03:51:41.6897990Z  f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-03-14T03:51:41.6898681Z  ) 2025-03-14T03:51:41.6899094Z  continue 2025-03-14T03:51:41.6899518Z  2025-03-14T03:51:41.6900005Z  # Is any workflow_requestor opted in to this experiment? 2025-03-14T03:51:41.6900628Z  opted_in_users = [ 2025-03-14T03:51:41.6901114Z  requestor 2025-03-14T03:51:41.6901621Z  for requestor in workflow_requestors 2025-03-14T03:51:41.6902320Z  if is_user_opted_in(requestor, user_optins, experiment_name) 2025-03-14T03:51:41.6903133Z  ] 2025-03-14T03:51:41.6903505Z  2025-03-14T03:51:41.6903866Z  enabled = False 2025-03-14T03:51:41.6904333Z  if opted_in_users: 2025-03-14T03:51:41.6904805Z  log.info( 2025-03-14T03:51:41.6905461Z  f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-03-14T03:51:41.6906326Z  ) 2025-03-14T03:51:41.6906746Z  enabled = True 2025-03-14T03:51:41.6907202Z  2025-03-14T03:51:41.6907616Z  elif experiment_settings.rollout_perc: 2025-03-14T03:51:41.6908476Z  # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-03-14T03:51:41.6909422Z  if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-03-14T03:51:41.6910074Z  log.info( 2025-03-14T03:51:41.6910984Z  f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-03-14T03:51:41.6911873Z  ) 2025-03-14T03:51:41.6912311Z  enabled = True 2025-03-14T03:51:41.6912788Z  2025-03-14T03:51:41.6913145Z  if enabled: 2025-03-14T03:51:41.6913615Z  label = experiment_name 2025-03-14T03:51:41.6914200Z  if experiment_name == LF_FLEET_EXPERIMENT: 2025-03-14T03:51:41.6915046Z  # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-03-14T03:51:41.6916347Z  # - If it's enabled, then we always list it's prefix first 2025-03-14T03:51:41.6917157Z  # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-03-14T03:51:41.6917839Z  if is_canary: 2025-03-14T03:51:41.6918380Z  label += CANARY_FLEET_SUFFIX 2025-03-14T03:51:41.6918938Z  fleet_prefix = label 2025-03-14T03:51:41.6919440Z  else: 2025-03-14T03:51:41.6919915Z  prefixes.append(label) 2025-03-14T03:51:41.6920421Z  2025-03-14T03:51:41.6920799Z  if len(prefixes) > 1: 2025-03-14T03:51:41.6921285Z  log.error( 2025-03-14T03:51:41.6922345Z  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:41.6923440Z  ) 2025-03-14T03:51:41.6923857Z  prefixes = prefixes[:1] 2025-03-14T03:51:41.6924346Z  2025-03-14T03:51:41.6924723Z  # Fleet always comes first 2025-03-14T03:51:41.6925227Z  if fleet_prefix: 2025-03-14T03:51:41.6926000Z  prefixes.insert(0, fleet_prefix) 2025-03-14T03:51:41.6926535Z  2025-03-14T03:51:41.6927001Z  return ".".join(prefixes) + "." if prefixes else "" 2025-03-14T03:51:41.6927567Z  2025-03-14T03:51:41.6927906Z  2025-03-14T03:51:41.6928547Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-03-14T03:51:41.6929301Z  """ 2025-03-14T03:51:41.6929916Z  Gets the first comment of the issue, which contains the desired rollout state. 2025-03-14T03:51:41.6930608Z  2025-03-14T03:51:41.6931197Z  The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-03-14T03:51:41.6931903Z  """ 2025-03-14T03:51:41.6932323Z  gh = get_gh_client(github_token) 2025-03-14T03:51:41.6932893Z  issue = get_issue(gh, repo, issue_num) 2025-03-14T03:51:41.6933554Z  return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-03-14T03:51:41.6934298Z  2025-03-14T03:51:41.6934640Z  2025-03-14T03:51:41.6935238Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-03-14T03:51:41.6936195Z  for _ in range(num_retries): 2025-03-14T03:51:41.6936687Z  try: 2025-03-14T03:51:41.6937156Z  req = Request(url=url, headers=headers) 2025-03-14T03:51:41.6937843Z  content = urlopen(req, timeout=5).read().decode("utf-8") 2025-03-14T03:51:41.6938500Z  return json.loads(content) 2025-03-14T03:51:41.6939031Z  except Exception as e: 2025-03-14T03:51:41.6939608Z  log.warning(f"Could not download {url}: {e}") 2025-03-14T03:51:41.6940163Z  2025-03-14T03:51:41.6940763Z  log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-03-14T03:51:41.6941473Z  return {} 2025-03-14T03:51:41.6941876Z  2025-03-14T03:51:41.6942212Z  2025-03-14T03:51:41.6942558Z @cache 2025-03-14T03:51:41.6943220Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-03-14T03:51:41.6943968Z  """ 2025-03-14T03:51:41.6944377Z  Dynamically get PR information 2025-03-14T03:51:41.6944885Z  """ 2025-03-14T03:51:41.6945416Z  github_api = f"https://api.github.com/repos/{github_repo}" 2025-03-14T03:51:41.6946286Z  headers = { 2025-03-14T03:51:41.6946802Z  "Accept": "application/vnd.github.v3+json", 2025-03-14T03:51:41.6947431Z  "Authorization": f"token {github_token}", 2025-03-14T03:51:41.6947965Z  } 2025-03-14T03:51:41.6948553Z  json_response: dict[str, Any] = download_json( 2025-03-14T03:51:41.6949192Z  url=f"{github_api}/issues/{pr_number}", 2025-03-14T03:51:41.6949752Z  headers=headers, 2025-03-14T03:51:41.6950207Z  ) 2025-03-14T03:51:41.6950564Z  2025-03-14T03:51:41.6950933Z  if not json_response: 2025-03-14T03:51:41.6951556Z  log.warning(f"Failed to get the labels for #{pr_number}") 2025-03-14T03:51:41.6952182Z  return {} 2025-03-14T03:51:41.6952596Z  2025-03-14T03:51:41.6952958Z  return json_response 2025-03-14T03:51:41.6953425Z  2025-03-14T03:51:41.6953762Z  2025-03-14T03:51:41.6954354Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-03-14T03:51:41.6955073Z  """ 2025-03-14T03:51:41.6955754Z  Dynamically get the latest list of labels from the pull request 2025-03-14T03:51:41.6956414Z  """ 2025-03-14T03:51:41.6956932Z  pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-03-14T03:51:41.6957542Z  return { 2025-03-14T03:51:41.6958162Z  label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-03-14T03:51:41.6958870Z  } 2025-03-14T03:51:41.6959226Z  2025-03-14T03:51:41.6959570Z  2025-03-14T03:51:41.6959927Z def main() -> None: 2025-03-14T03:51:41.6960381Z  args = parse_args() 2025-03-14T03:51:41.6960830Z  2025-03-14T03:51:41.6961252Z  runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-03-14T03:51:41.6961793Z  2025-03-14T03:51:41.6962165Z  # Check if the PR is opt-out 2025-03-14T03:51:41.6962676Z  if args.pr_number: 2025-03-14T03:51:41.6963372Z  labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-03-14T03:51:41.6964166Z  if OPT_OUT_LABEL in labels: 2025-03-14T03:51:41.6964672Z  log.info( 2025-03-14T03:51:41.6965397Z  f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-03-14T03:51:41.6966593Z  ) 2025-03-14T03:51:41.6967198Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:41.6967867Z  sys.exit() 2025-03-14T03:51:41.6968308Z  2025-03-14T03:51:41.6968658Z  try: 2025-03-14T03:51:41.6969195Z  rollout_state = get_rollout_state_from_issue( 2025-03-14T03:51:41.6969922Z  args.github_token, args.github_issue_repo, args.github_issue 2025-03-14T03:51:41.6970560Z  ) 2025-03-14T03:51:41.6970930Z  2025-03-14T03:51:41.6971345Z  username = get_potential_pr_author( 2025-03-14T03:51:41.6971898Z  args.github_token, 2025-03-14T03:51:41.6972413Z  args.github_repo, 2025-03-14T03:51:41.6972902Z  args.github_actor, 2025-03-14T03:51:41.6973418Z  args.github_ref_type, 2025-03-14T03:51:41.6973934Z  args.github_branch, 2025-03-14T03:51:41.6974413Z  ) 2025-03-14T03:51:41.6974797Z  2025-03-14T03:51:41.6975290Z  is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-03-14T03:51:41.6976111Z  2025-03-14T03:51:41.6976530Z  runner_label_prefix = get_runner_prefix( 2025-03-14T03:51:41.6977088Z  rollout_state, 2025-03-14T03:51:41.6977620Z  (args.github_issue_owner, username), 2025-03-14T03:51:41.6978177Z  args.github_branch, 2025-03-14T03:51:41.6978707Z  args.eligible_experiments, 2025-03-14T03:51:41.6979223Z  is_canary, 2025-03-14T03:51:41.6979803Z  ) 2025-03-14T03:51:41.6980188Z  2025-03-14T03:51:41.6980570Z  except Exception as e: 2025-03-14T03:51:41.6981052Z  log.error( 2025-03-14T03:51:41.6981765Z  f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-03-14T03:51:41.6982511Z  ) 2025-03-14T03:51:41.6982886Z  2025-03-14T03:51:41.6983424Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:41.6984069Z  2025-03-14T03:51:41.6984408Z  2025-03-14T03:51:41.6984768Z if __name__ == "__main__": 2025-03-14T03:51:41.6985241Z  main() 2025-03-14T03:51:41.6985821Z  2025-03-14T03:51:41.6986182Z EOF 2025-03-14T03:51:41.6986542Z  2025-03-14T03:51:41.6986928Z cat runner_determinator.py 2025-03-14T03:51:41.7334676Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:41.7335418Z env: 2025-03-14T03:51:41.7336436Z GITHUB_TOKEN: *** 2025-03-14T03:51:41.7336857Z ISSUE_NUMBER: 5132 2025-03-14T03:51:41.7337294Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:41.7337783Z ISSUE_OWNER: 2025-03-14T03:51:41.7338178Z CHECK_EXPERIMENTS: 2025-03-14T03:51:41.7338578Z PR_NUMBER: 2025-03-14T03:51:41.7338945Z ##[endgroup] 2025-03-14T03:51:41.7620612Z # flake8: noqa: G004 2025-03-14T03:51:41.7620931Z 2025-03-14T03:51:41.7621348Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-03-14T03:51:41.7622256Z # must be kept in sync. You can do it easily by running the following command: 2025-03-14T03:51:41.7623021Z # python .github/scripts/update_runner_determinator.py 2025-03-14T03:51:41.7623434Z 2025-03-14T03:51:41.7623588Z """ 2025-03-14T03:51:41.7624127Z This runner determinator is used to determine which set of runners to run a 2025-03-14T03:51:41.7624954Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-03-14T03:51:41.7626159Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-03-14T03:51:41.7626952Z of which runners should be used to run which job. 2025-03-14T03:51:41.7627543Z 2025-03-14T03:51:41.7627908Z The configuration has two parts, the settings and a list of opted-in users, 2025-03-14T03:51:41.7628748Z separated by a line containing "---". If the line is not present, the 2025-03-14T03:51:41.7629575Z settings are considered to be empty with only the second part, the user 2025-03-14T03:51:41.7630214Z list, defined. 2025-03-14T03:51:41.7630431Z 2025-03-14T03:51:41.7630779Z The first part is a YAML block that defines the rollout settings. This can be 2025-03-14T03:51:41.7631632Z used to define any settings that are needed to determine which runners to use. 2025-03-14T03:51:41.7632409Z It's fields are defined by the RolloutSettings class below. 2025-03-14T03:51:41.7632822Z 2025-03-14T03:51:41.7633172Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-03-14T03:51:41.7633991Z The user list is also a comma separated list of additional features or 2025-03-14T03:51:41.7634675Z experiments which the user could be opted in to. 2025-03-14T03:51:41.7635060Z 2025-03-14T03:51:41.7635248Z The user list has the following rules: 2025-03-14T03:51:41.7635778Z 2025-03-14T03:51:41.7636095Z - Users are GitHub usernames, which must start with the @ prefix 2025-03-14T03:51:41.7636897Z - Each user is also a comma-separated list of features/experiments to enable 2025-03-14T03:51:41.7637623Z - A "#" prefix opts the user out of all experiments 2025-03-14T03:51:41.7637996Z 2025-03-14T03:51:41.7638157Z Example config: 2025-03-14T03:51:41.7638580Z # A list of experiments that can be opted into. 2025-03-14T03:51:41.7639216Z # This defines the behavior they'll induce when opted into. 2025-03-14T03:51:41.7639801Z # Expected syntax is: 2025-03-14T03:51:41.7640402Z # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-03-14T03:51:41.7641455Z # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-03-14T03:51:41.7642032Z 2025-03-14T03:51:41.7642190Z experiments: 2025-03-14T03:51:41.7642558Z lf: 2025-03-14T03:51:41.7642916Z rollout_percent: 25 2025-03-14T03:51:41.7643342Z all_branches: false 2025-03-14T03:51:41.7643760Z default: true 2025-03-14T03:51:41.7644140Z --- 2025-03-14T03:51:41.7644332Z 2025-03-14T03:51:41.7644483Z # Opt-ins: 2025-03-14T03:51:41.7645025Z # Users can opt into the LF fleet by adding their GitHub username to this list 2025-03-14T03:51:41.7646091Z # and specifying experiments to enable in a comma-separated list. 2025-03-14T03:51:41.7646827Z # To always opt out of an experiment, prefix it with a "-". 2025-03-14T03:51:41.7647440Z # Experiments should be from the above list. 2025-03-14T03:51:41.7647804Z 2025-03-14T03:51:41.7647980Z @User1,-lf,split_build 2025-03-14T03:51:41.7648389Z @User2,lf 2025-03-14T03:51:41.7648747Z @User3,split_build 2025-03-14T03:51:41.7649126Z """ 2025-03-14T03:51:41.7649304Z 2025-03-14T03:51:41.7649457Z import json 2025-03-14T03:51:41.7649803Z import logging 2025-03-14T03:51:41.7650164Z import os 2025-03-14T03:51:41.7650508Z import random 2025-03-14T03:51:41.7650855Z import re 2025-03-14T03:51:41.7651190Z import sys 2025-03-14T03:51:41.7651570Z from argparse import ArgumentParser 2025-03-14T03:51:41.7652068Z from collections.abc import Iterable 2025-03-14T03:51:41.7652557Z from functools import cache 2025-03-14T03:51:41.7653001Z from logging import LogRecord 2025-03-14T03:51:41.7653459Z from typing import Any, NamedTuple 2025-03-14T03:51:41.7653958Z from urllib.request import Request, urlopen 2025-03-14T03:51:41.7654314Z 2025-03-14T03:51:41.7654462Z import yaml 2025-03-14T03:51:41.7654832Z from github import Auth, Github 2025-03-14T03:51:41.7655293Z from github.Issue import Issue 2025-03-14T03:51:41.7655752Z 2025-03-14T03:51:41.7655761Z 2025-03-14T03:51:41.7656014Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-03-14T03:51:41.7656661Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-03-14T03:51:41.7657461Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-03-14T03:51:41.7658134Z 2025-03-14T03:51:41.7658351Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-03-14T03:51:41.7658892Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-03-14T03:51:41.7659378Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-03-14T03:51:41.7659893Z OPT_OUT_LABEL = "no-runner-experiments" 2025-03-14T03:51:41.7660228Z 2025-03-14T03:51:41.7660413Z SETTING_EXPERIMENTS = "experiments" 2025-03-14T03:51:41.7660725Z 2025-03-14T03:51:41.7660897Z LF_FLEET_EXPERIMENT = "lf" 2025-03-14T03:51:41.7661328Z CANARY_FLEET_SUFFIX = ".c" 2025-03-14T03:51:41.7661628Z 2025-03-14T03:51:41.7661634Z 2025-03-14T03:51:41.7661817Z class Experiment(NamedTuple): 2025-03-14T03:51:41.7662275Z rollout_perc: float = ( 2025-03-14T03:51:41.7663305Z 0 # Percentage of workflows to experiment on when user is not opted-in. 2025-03-14T03:51:41.7664495Z ) 2025-03-14T03:51:41.7665082Z all_branches: bool = ( 2025-03-14T03:51:41.7666291Z False # If True, the experiment is also enabled on the exception branches 2025-03-14T03:51:41.7666994Z ) 2025-03-14T03:51:41.7667332Z default: bool = ( 2025-03-14T03:51:41.7667865Z True # If True, the experiment is enabled by default for all queries 2025-03-14T03:51:41.7668457Z ) 2025-03-14T03:51:41.7668643Z 2025-03-14T03:51:41.7668815Z # Add more fields as needed 2025-03-14T03:51:41.7669098Z 2025-03-14T03:51:41.7669104Z 2025-03-14T03:51:41.7669284Z class Settings(NamedTuple): 2025-03-14T03:51:41.7669693Z """ 2025-03-14T03:51:41.7670117Z Settings for the experiments that can be opted into. 2025-03-14T03:51:41.7670648Z """ 2025-03-14T03:51:41.7670833Z 2025-03-14T03:51:41.7671030Z experiments: dict[str, Experiment] = {} 2025-03-14T03:51:41.7671371Z 2025-03-14T03:51:41.7671377Z 2025-03-14T03:51:41.7671746Z class ColorFormatter(logging.Formatter): 2025-03-14T03:51:41.7672348Z """Color codes the log messages based on the log level""" 2025-03-14T03:51:41.7672752Z 2025-03-14T03:51:41.7672934Z COLORS = { 2025-03-14T03:51:41.7673311Z "WARNING": "\033[33m", # Yellow 2025-03-14T03:51:41.7673783Z "ERROR": "\033[31m", # Red 2025-03-14T03:51:41.7674244Z "CRITICAL": "\033[31m", # Red 2025-03-14T03:51:41.7674712Z "INFO": "\033[0m", # Reset 2025-03-14T03:51:41.7675160Z "DEBUG": "\033[0m", # Reset 2025-03-14T03:51:41.7675811Z } 2025-03-14T03:51:41.7676013Z 2025-03-14T03:51:41.7676221Z def format(self, record: LogRecord) -> str: 2025-03-14T03:51:41.7676929Z log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-03-14T03:51:41.7677652Z record.msg = f"{log_color}{record.msg}\033[0m" 2025-03-14T03:51:41.7678183Z return super().format(record) 2025-03-14T03:51:41.7678501Z 2025-03-14T03:51:41.7678507Z 2025-03-14T03:51:41.7678696Z handler = logging.StreamHandler() 2025-03-14T03:51:41.7679359Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-03-14T03:51:41.7679883Z 2025-03-14T03:51:41.7680108Z log = logging.getLogger(os.path.basename(__file__)) 2025-03-14T03:51:41.7680657Z log.addHandler(handler) 2025-03-14T03:51:41.7681072Z log.setLevel(logging.INFO) 2025-03-14T03:51:41.7681340Z 2025-03-14T03:51:41.7681346Z 2025-03-14T03:51:41.7681575Z def set_github_output(key: str, value: str) -> None: 2025-03-14T03:51:41.7682096Z """ 2025-03-14T03:51:41.7682568Z Defines outputs of the github action that invokes this script 2025-03-14T03:51:41.7683150Z """ 2025-03-14T03:51:41.7683491Z if not GITHUB_OUTPUT: 2025-03-14T03:51:41.7684479Z # See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ for deprecation notice 2025-03-14T03:51:41.7685518Z log.warning( 2025-03-14T03:51:41.7686527Z "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:41.7687384Z ) 2025-03-14T03:51:41.7696978Z print(f"::set-output name={key}::{value}") 2025-03-14T03:51:41.7697744Z return 2025-03-14T03:51:41.7697963Z 2025-03-14T03:51:41.7698152Z with open(GITHUB_OUTPUT, "a") as f: 2025-03-14T03:51:41.7698702Z log.info(f"Setting output: {key}='{value}'") 2025-03-14T03:51:41.7699242Z f.write(f"{key}={value}\n") 2025-03-14T03:51:41.7699548Z 2025-03-14T03:51:41.7699556Z 2025-03-14T03:51:41.7699851Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-03-14T03:51:41.7700457Z return frozenset( 2025-03-14T03:51:41.7701028Z filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-03-14T03:51:41.7701677Z ) 2025-03-14T03:51:41.7701869Z 2025-03-14T03:51:41.7701876Z 2025-03-14T03:51:41.7702049Z def parse_args() -> Any: 2025-03-14T03:51:41.7702584Z parser = ArgumentParser("Get dynamic rollout settings") 2025-03-14T03:51:41.7703394Z parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-03-14T03:51:41.7704110Z parser.add_argument( 2025-03-14T03:51:41.7704532Z "--github-issue-repo", 2025-03-14T03:51:41.7704970Z type=str, 2025-03-14T03:51:41.7705344Z required=False, 2025-03-14T03:51:41.7705998Z default="pytorch/test-infra", 2025-03-14T03:51:41.7706510Z help="GitHub repo to get the issue", 2025-03-14T03:51:41.7706977Z ) 2025-03-14T03:51:41.7707322Z parser.add_argument( 2025-03-14T03:51:41.7707740Z "--github-repo", 2025-03-14T03:51:41.7708135Z type=str, 2025-03-14T03:51:41.7708781Z required=True, 2025-03-14T03:51:41.7709532Z help="GitHub repo where CI is running", 2025-03-14T03:51:41.7710356Z ) 2025-03-14T03:51:41.7710935Z parser.add_argument( 2025-03-14T03:51:41.7711907Z "--github-issue", type=int, required=True, help="GitHub issue number" 2025-03-14T03:51:41.7713184Z ) 2025-03-14T03:51:41.7713836Z parser.add_argument( 2025-03-14T03:51:41.7714847Z "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-03-14T03:51:41.7716213Z ) 2025-03-14T03:51:41.7716826Z parser.add_argument( 2025-03-14T03:51:41.7717852Z "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-03-14T03:51:41.7718985Z ) 2025-03-14T03:51:41.7719593Z parser.add_argument( 2025-03-14T03:51:41.7720649Z "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-03-14T03:51:41.7721838Z ) 2025-03-14T03:51:41.7722406Z parser.add_argument( 2025-03-14T03:51:41.7723119Z "--github-ref-type", 2025-03-14T03:51:41.7723921Z type=str, 2025-03-14T03:51:41.7724562Z required=True, 2025-03-14T03:51:41.7725334Z help="Current GitHub ref type, branch or tag", 2025-03-14T03:51:41.7726407Z ) 2025-03-14T03:51:41.7727003Z parser.add_argument( 2025-03-14T03:51:41.7727751Z "--eligible-experiments", 2025-03-14T03:51:41.7728577Z type=_str_comma_separated_to_set, 2025-03-14T03:51:41.7729410Z required=False, 2025-03-14T03:51:41.7730108Z default="", 2025-03-14T03:51:41.7731499Z help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-03-14T03:51:41.7733033Z ) 2025-03-14T03:51:41.7733612Z parser.add_argument( 2025-03-14T03:51:41.7734301Z "--pr-number", 2025-03-14T03:51:41.7734965Z type=str, 2025-03-14T03:51:41.7735835Z required=False, 2025-03-14T03:51:41.7736573Z default="", 2025-03-14T03:51:41.7737349Z help="the optional PR number where this is run", 2025-03-14T03:51:41.7738155Z ) 2025-03-14T03:51:41.7738429Z 2025-03-14T03:51:41.7738608Z return parser.parse_args() 2025-03-14T03:51:41.7738910Z 2025-03-14T03:51:41.7738917Z 2025-03-14T03:51:41.7739314Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-03-14T03:51:41.7740026Z auth = Auth.Token(github_token) 2025-03-14T03:51:41.7740508Z return Github(auth=auth) 2025-03-14T03:51:41.7740984Z 2025-03-14T03:51:41.7740991Z 2025-03-14T03:51:41.7741426Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-03-14T03:51:41.7742170Z repo = gh.get_repo(repo) 2025-03-14T03:51:41.7742628Z return repo.get_issue(number=issue_num) 2025-03-14T03:51:41.7742974Z 2025-03-14T03:51:41.7742980Z 2025-03-14T03:51:41.7743155Z def get_potential_pr_author( 2025-03-14T03:51:41.7743763Z github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-03-14T03:51:41.7744390Z ) -> str: 2025-03-14T03:51:41.7744875Z # If the trigger was a new tag added by a bot, this is a ciflow case 2025-03-14T03:51:41.7745848Z # Fetch the actual username from the original PR. The PR number is 2025-03-14T03:51:41.7746606Z # embedded in the tag name: ciflow// 2025-03-14T03:51:41.7746999Z 2025-03-14T03:51:41.7747173Z gh = get_gh_client(github_token) 2025-03-14T03:51:41.7747496Z 2025-03-14T03:51:41.7747753Z if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-03-14T03:51:41.7748333Z split_tag = ref_name.split("/") 2025-03-14T03:51:41.7748803Z if ( 2025-03-14T03:51:41.7749162Z len(split_tag) == 3 2025-03-14T03:51:41.7749621Z and split_tag[0] == "ciflow" 2025-03-14T03:51:41.7750115Z and split_tag[2].isnumeric() 2025-03-14T03:51:41.7750581Z ): 2025-03-14T03:51:41.7750942Z pr_number = split_tag[2] 2025-03-14T03:51:41.7751384Z try: 2025-03-14T03:51:41.7751782Z repository = gh.get_repo(repo) 2025-03-14T03:51:41.7752352Z pull = repository.get_pull(number=int(pr_number)) 2025-03-14T03:51:41.7752925Z except Exception as e: 2025-03-14T03:51:41.7753412Z raise Exception( # noqa: TRY002 2025-03-14T03:51:41.7754174Z f"issue with pull request {pr_number} from repo {repository}" 2025-03-14T03:51:41.7754793Z ) from e 2025-03-14T03:51:41.7755304Z return pull.user.login # type: ignore[no-any-return] 2025-03-14T03:51:41.7756181Z # In all other cases, return the original input username 2025-03-14T03:51:41.7756735Z return username 2025-03-14T03:51:41.7756960Z 2025-03-14T03:51:41.7756966Z 2025-03-14T03:51:41.7757182Z def is_exception_branch(branch: str) -> bool: 2025-03-14T03:51:41.7757683Z """ 2025-03-14T03:51:41.7758284Z Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-03-14T03:51:41.7758997Z """ 2025-03-14T03:51:41.7759511Z return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-03-14T03:51:41.7759994Z 2025-03-14T03:51:41.7760000Z 2025-03-14T03:51:41.7760187Z def load_yaml(yaml_text: str) -> Any: 2025-03-14T03:51:41.7760637Z try: 2025-03-14T03:51:41.7761008Z data = yaml.safe_load(yaml_text) 2025-03-14T03:51:41.7761490Z return data 2025-03-14T03:51:41.7761910Z except yaml.YAMLError: 2025-03-14T03:51:41.7762359Z log.exception("Error loading YAML") 2025-03-14T03:51:41.7762844Z raise 2025-03-14T03:51:41.7763048Z 2025-03-14T03:51:41.7763054Z 2025-03-14T03:51:41.7763437Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-03-14T03:51:41.7764118Z """ 2025-03-14T03:51:41.7764696Z Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-03-14T03:51:41.7765251Z 2025-03-14T03:51:41.7765745Z If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:41.7766477Z and the text below is the list of opted in users. 2025-03-14T03:51:41.7766850Z 2025-03-14T03:51:41.7767201Z If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-03-14T03:51:41.7767851Z """ 2025-03-14T03:51:41.7768266Z rollout_state_parts = rollout_state.split("---") 2025-03-14T03:51:41.7768817Z if len(rollout_state_parts) >= 2: 2025-03-14T03:51:41.7769377Z return rollout_state_parts[0], rollout_state_parts[1] 2025-03-14T03:51:41.7770062Z else: 2025-03-14T03:51:41.7770420Z return "", rollout_state 2025-03-14T03:51:41.7770713Z 2025-03-14T03:51:41.7770719Z 2025-03-14T03:51:41.7770901Z class UserOptins(dict[str, list[str]]): 2025-03-14T03:51:41.7771372Z """ 2025-03-14T03:51:41.7771851Z Dictionary of users with a list of features they have opted into 2025-03-14T03:51:41.7772462Z """ 2025-03-14T03:51:41.7772648Z 2025-03-14T03:51:41.7772654Z 2025-03-14T03:51:41.7772965Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-03-14T03:51:41.7773573Z """ 2025-03-14T03:51:41.7774231Z 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:41.7774867Z 2025-03-14T03:51:41.7775452Z Users are GitHub usernames with the @ prefix. Each user is also a comma-separated list of features/experiments to enable. 2025-03-14T03:51:41.7776590Z - Example line: "@User1,lf,split_build" 2025-03-14T03:51:41.7777244Z - A "#" prefix indicates the user is opted out of all experiments 2025-03-14T03:51:41.7777699Z 2025-03-14T03:51:41.7777706Z 2025-03-14T03:51:41.7777851Z """ 2025-03-14T03:51:41.7778199Z optins = UserOptins() 2025-03-14T03:51:41.7778658Z for user in user_optin_text.split("\n"): 2025-03-14T03:51:41.7779181Z user = user.strip("\r\n\t -") 2025-03-14T03:51:41.7779688Z if not user or not user.startswith("@"): 2025-03-14T03:51:41.7780199Z # Not a valid user. Skip 2025-03-14T03:51:41.7780655Z continue 2025-03-14T03:51:41.7780885Z 2025-03-14T03:51:41.7781038Z if user: 2025-03-14T03:51:41.7781447Z usr_name = user.split(",")[0].strip("@") 2025-03-14T03:51:41.7782094Z optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-03-14T03:51:41.7782690Z 2025-03-14T03:51:41.7782858Z return optins 2025-03-14T03:51:41.7783077Z 2025-03-14T03:51:41.7783083Z 2025-03-14T03:51:41.7783357Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-03-14T03:51:41.7783923Z """ 2025-03-14T03:51:41.7784296Z Check if the experiment name is valid. 2025-03-14T03:51:41.7784782Z A valid name: 2025-03-14T03:51:41.7785374Z - Contains only alphanumeric characters and the special characters "_" & "-" 2025-03-14T03:51:41.7786552Z - The special characters "_" & "-" shouldn't be the first or last characters 2025-03-14T03:51:41.7787222Z - Cannot contain spaces 2025-03-14T03:51:41.7787644Z """ 2025-03-14T03:51:41.7787829Z 2025-03-14T03:51:41.7788081Z valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-03-14T03:51:41.7788729Z valid = bool(re.match(valid_char_regex, experiment_name)) 2025-03-14T03:51:41.7789138Z 2025-03-14T03:51:41.7789293Z if valid: 2025-03-14T03:51:41.7789647Z return True 2025-03-14T03:51:41.7789876Z 2025-03-14T03:51:41.7790028Z log.error( 2025-03-14T03:51:41.7791368Z 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:41.7792798Z ) 2025-03-14T03:51:41.7793133Z return False 2025-03-14T03:51:41.7793349Z 2025-03-14T03:51:41.7793356Z 2025-03-14T03:51:41.7793647Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-03-14T03:51:41.7794225Z """ 2025-03-14T03:51:41.7794774Z Parse the experiments from the issue body into a list of ExperimentSettings 2025-03-14T03:51:41.7795434Z """ 2025-03-14T03:51:41.7795990Z try: 2025-03-14T03:51:41.7796337Z if settings_text: 2025-03-14T03:51:41.7797015Z # Escape the backtick as well so that we can have the settings in a code block on the GH issue 2025-03-14T03:51:41.7797751Z # for easy reading 2025-03-14T03:51:41.7798485Z # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-03-14T03:51:41.7799480Z # the backtick character in shell commands. 2025-03-14T03:51:41.7800052Z backtick = chr(96) # backtick character 2025-03-14T03:51:41.7800671Z settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-03-14T03:51:41.7801284Z settings = load_yaml(settings_text) 2025-03-14T03:51:41.7801633Z 2025-03-14T03:51:41.7802009Z # For now we just load experiments. We can expand this if/when we add more settings 2025-03-14T03:51:41.7802718Z experiments = {} 2025-03-14T03:51:41.7802990Z 2025-03-14T03:51:41.7803323Z for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-03-14T03:51:41.7804024Z if not is_valid_experiment_name(exp_name): 2025-03-14T03:51:41.7805046Z # 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:41.7806162Z continue 2025-03-14T03:51:41.7806432Z 2025-03-14T03:51:41.7806598Z valid_settings = {} 2025-03-14T03:51:41.7807082Z for setting in exp_settings: 2025-03-14T03:51:41.7807634Z if setting not in Experiment._fields: 2025-03-14T03:51:41.7808154Z log.warning( 2025-03-14T03:51:41.7808802Z f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-03-14T03:51:41.7809467Z ) 2025-03-14T03:51:41.7809871Z else: 2025-03-14T03:51:41.7810351Z valid_settings[setting] = exp_settings[setting] 2025-03-14T03:51:41.7810744Z 2025-03-14T03:51:41.7811001Z experiments[exp_name] = Experiment(**valid_settings) 2025-03-14T03:51:41.7811724Z return Settings(experiments) 2025-03-14T03:51:41.7812066Z 2025-03-14T03:51:41.7812228Z except Exception: 2025-03-14T03:51:41.7812666Z log.exception("Failed to parse settings") 2025-03-14T03:51:41.7813030Z 2025-03-14T03:51:41.7813190Z return Settings() 2025-03-14T03:51:41.7813426Z 2025-03-14T03:51:41.7813431Z 2025-03-14T03:51:41.7813665Z def parse_settings(rollout_state: str) -> Settings: 2025-03-14T03:51:41.7814191Z """ 2025-03-14T03:51:41.7814580Z Parse settings, if any, from the rollout state. 2025-03-14T03:51:41.7814954Z 2025-03-14T03:51:41.7815275Z If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:41.7816220Z and the text below is the list of opted in users. 2025-03-14T03:51:41.7816607Z 2025-03-14T03:51:41.7817011Z If it doesn't contain "---" then the settings are empty and the default values are used. 2025-03-14T03:51:41.7817688Z """ 2025-03-14T03:51:41.7818207Z settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:41.7818895Z return parse_settings_from_text(settings_text) 2025-03-14T03:51:41.7819272Z 2025-03-14T03:51:41.7819282Z 2025-03-14T03:51:41.7819511Z def parse_users(rollout_state: str) -> UserOptins: 2025-03-14T03:51:41.7820034Z """ 2025-03-14T03:51:41.7820390Z Parse users from the rollout state. 2025-03-14T03:51:41.7820712Z 2025-03-14T03:51:41.7820857Z """ 2025-03-14T03:51:41.7821334Z _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:41.7822012Z return parse_user_opt_in_from_text(users_text) 2025-03-14T03:51:41.7822383Z 2025-03-14T03:51:41.7822389Z 2025-03-14T03:51:41.7822777Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:41.7823459Z """ 2025-03-14T03:51:41.7823840Z Check if a user is opted into an experiment 2025-03-14T03:51:41.7824333Z """ 2025-03-14T03:51:41.7824742Z return experiment_name in user_optins.get(user, []) 2025-03-14T03:51:41.7825143Z 2025-03-14T03:51:41.7825150Z 2025-03-14T03:51:41.7825535Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:41.7826616Z """ 2025-03-14T03:51:41.7827046Z Check if a user explicitly opted out of an experiment 2025-03-14T03:51:41.7827588Z """ 2025-03-14T03:51:41.7828058Z # if the experiment is prefixed with a "-", then it's an opt-out 2025-03-14T03:51:41.7828698Z experiment_optout = "-" + experiment_name 2025-03-14T03:51:41.7829684Z if experiment_optout not in user_optins.get(user, []): 2025-03-14T03:51:41.7830380Z return False 2025-03-14T03:51:41.7830609Z 2025-03-14T03:51:41.7830862Z if is_user_opted_in(user, user_optins, experiment_name): 2025-03-14T03:51:41.7831424Z log.warning( 2025-03-14T03:51:41.7832157Z f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-03-14T03:51:41.7832962Z ) 2025-03-14T03:51:41.7833166Z 2025-03-14T03:51:41.7833318Z return True 2025-03-14T03:51:41.7833538Z 2025-03-14T03:51:41.7833551Z 2025-03-14T03:51:41.7833713Z def get_runner_prefix( 2025-03-14T03:51:41.7834123Z rollout_state: str, 2025-03-14T03:51:41.7834557Z workflow_requestors: Iterable[str], 2025-03-14T03:51:41.7835035Z branch: str, 2025-03-14T03:51:41.7835490Z eligible_experiments: frozenset[str] = frozenset(), 2025-03-14T03:51:41.7836176Z is_canary: bool = False, 2025-03-14T03:51:41.7836594Z ) -> str: 2025-03-14T03:51:41.7836971Z settings = parse_settings(rollout_state) 2025-03-14T03:51:41.7837501Z user_optins = parse_users(rollout_state) 2025-03-14T03:51:41.7837848Z 2025-03-14T03:51:41.7838012Z fleet_prefix = "" 2025-03-14T03:51:41.7838408Z prefixes = [] 2025-03-14T03:51:41.7838991Z for experiment_name, experiment_settings in settings.experiments.items(): 2025-03-14T03:51:41.7839850Z if not experiment_settings.all_branches and is_exception_branch(branch): 2025-03-14T03:51:41.7840631Z log.info( 2025-03-14T03:51:41.7841267Z f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-03-14T03:51:41.7841965Z ) 2025-03-14T03:51:41.7842316Z continue 2025-03-14T03:51:41.7842543Z 2025-03-14T03:51:41.7842722Z if eligible_experiments: 2025-03-14T03:51:41.7843229Z if experiment_name not in eligible_experiments: 2025-03-14T03:51:41.7843814Z exp_list = ", ".join(eligible_experiments) 2025-03-14T03:51:41.7844338Z log.info( 2025-03-14T03:51:41.7845062Z f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-03-14T03:51:41.7846038Z ) 2025-03-14T03:51:41.7846411Z continue 2025-03-14T03:51:41.7846873Z elif not experiment_settings.default: 2025-03-14T03:51:41.7847371Z log.info( 2025-03-14T03:51:41.7847976Z f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-03-14T03:51:41.7848655Z ) 2025-03-14T03:51:41.7849002Z continue 2025-03-14T03:51:41.7849232Z 2025-03-14T03:51:41.7849489Z # Is any workflow_requestor opted out to this experiment? 2025-03-14T03:51:41.7850071Z opted_out_users = [ 2025-03-14T03:51:41.7850488Z requestor 2025-03-14T03:51:41.7850909Z for requestor in workflow_requestors 2025-03-14T03:51:41.7851536Z if is_user_opted_out(requestor, user_optins, experiment_name) 2025-03-14T03:51:41.7852117Z ] 2025-03-14T03:51:41.7852313Z 2025-03-14T03:51:41.7852474Z if opted_out_users: 2025-03-14T03:51:41.7852894Z log.info( 2025-03-14T03:51:41.7853467Z f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-03-14T03:51:41.7854110Z ) 2025-03-14T03:51:41.7854457Z continue 2025-03-14T03:51:41.7854687Z 2025-03-14T03:51:41.7854942Z # Is any workflow_requestor opted in to this experiment? 2025-03-14T03:51:41.7855507Z opted_in_users = [ 2025-03-14T03:51:41.7856193Z requestor 2025-03-14T03:51:41.7856767Z for requestor in workflow_requestors 2025-03-14T03:51:41.7857378Z if is_user_opted_in(requestor, user_optins, experiment_name) 2025-03-14T03:51:41.7857943Z ] 2025-03-14T03:51:41.7858136Z 2025-03-14T03:51:41.7858295Z enabled = False 2025-03-14T03:51:41.7858699Z if opted_in_users: 2025-03-14T03:51:41.7859104Z log.info( 2025-03-14T03:51:41.7859650Z f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-03-14T03:51:41.7860272Z ) 2025-03-14T03:51:41.7860626Z enabled = True 2025-03-14T03:51:41.7860879Z 2025-03-14T03:51:41.7861085Z elif experiment_settings.rollout_perc: 2025-03-14T03:51:41.7861888Z # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-03-14T03:51:41.7862759Z if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-03-14T03:51:41.7863351Z log.info( 2025-03-14T03:51:41.7864140Z f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-03-14T03:51:41.7864984Z ) 2025-03-14T03:51:41.7865365Z enabled = True 2025-03-14T03:51:41.7865855Z 2025-03-14T03:51:41.7866027Z if enabled: 2025-03-14T03:51:41.7866411Z label = experiment_name 2025-03-14T03:51:41.7866915Z if experiment_name == LF_FLEET_EXPERIMENT: 2025-03-14T03:51:41.7867685Z # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-03-14T03:51:41.7868481Z # - If it's enabled, then we always list it's prefix first 2025-03-14T03:51:41.7869305Z # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-03-14T03:51:41.7869917Z if is_canary: 2025-03-14T03:51:41.7870363Z label += CANARY_FLEET_SUFFIX 2025-03-14T03:51:41.7870870Z fleet_prefix = label 2025-03-14T03:51:41.7871321Z else: 2025-03-14T03:51:41.7871706Z prefixes.append(label) 2025-03-14T03:51:41.7872024Z 2025-03-14T03:51:41.7872194Z if len(prefixes) > 1: 2025-03-14T03:51:41.7872595Z log.error( 2025-03-14T03:51:41.7873560Z 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:41.7874579Z ) 2025-03-14T03:51:41.7874938Z prefixes = prefixes[:1] 2025-03-14T03:51:41.7875220Z 2025-03-14T03:51:41.7875394Z # Fleet always comes first 2025-03-14T03:51:41.7875942Z if fleet_prefix: 2025-03-14T03:51:41.7876360Z prefixes.insert(0, fleet_prefix) 2025-03-14T03:51:41.7876701Z 2025-03-14T03:51:41.7876934Z return ".".join(prefixes) + "." if prefixes else "" 2025-03-14T03:51:41.7877320Z 2025-03-14T03:51:41.7877327Z 2025-03-14T03:51:41.7877734Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-03-14T03:51:41.7878445Z """ 2025-03-14T03:51:41.7878981Z Gets the first comment of the issue, which contains the desired rollout state. 2025-03-14T03:51:41.7879494Z 2025-03-14T03:51:41.7879857Z The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-03-14T03:51:41.7880497Z """ 2025-03-14T03:51:41.7880856Z gh = get_gh_client(github_token) 2025-03-14T03:51:41.7881354Z issue = get_issue(gh, repo, issue_num) 2025-03-14T03:51:41.7881944Z return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-03-14T03:51:41.7882349Z 2025-03-14T03:51:41.7882356Z 2025-03-14T03:51:41.7882726Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-03-14T03:51:41.7883415Z for _ in range(num_retries): 2025-03-14T03:51:41.7883854Z try: 2025-03-14T03:51:41.7884248Z req = Request(url=url, headers=headers) 2025-03-14T03:51:41.7884859Z content = urlopen(req, timeout=5).read().decode("utf-8") 2025-03-14T03:51:41.7885677Z return json.loads(content) 2025-03-14T03:51:41.7886164Z except Exception as e: 2025-03-14T03:51:41.7886657Z log.warning(f"Could not download {url}: {e}") 2025-03-14T03:51:41.7887024Z 2025-03-14T03:51:41.7887368Z log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-03-14T03:51:41.7888017Z return {} 2025-03-14T03:51:41.7888218Z 2025-03-14T03:51:41.7888225Z 2025-03-14T03:51:41.7888373Z @cache 2025-03-14T03:51:41.7888941Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-03-14T03:51:41.7889620Z """ 2025-03-14T03:51:41.7889981Z Dynamically get PR information 2025-03-14T03:51:41.7890429Z """ 2025-03-14T03:51:41.7890886Z github_api = f"https://api.github.com/repos/{github_repo}" 2025-03-14T03:51:41.7891458Z headers = { 2025-03-14T03:51:41.7891873Z "Accept": "application/vnd.github.v3+json", 2025-03-14T03:51:41.7892437Z "Authorization": f"token {github_token}", 2025-03-14T03:51:41.7892933Z } 2025-03-14T03:51:41.7893320Z json_response: dict[str, Any] = download_json( 2025-03-14T03:51:41.7893881Z url=f"{github_api}/issues/{pr_number}", 2025-03-14T03:51:41.7894377Z headers=headers, 2025-03-14T03:51:41.7894770Z ) 2025-03-14T03:51:41.7894956Z 2025-03-14T03:51:41.7895122Z if not json_response: 2025-03-14T03:51:41.7895834Z log.warning(f"Failed to get the labels for #{pr_number}") 2025-03-14T03:51:41.7896437Z return {} 2025-03-14T03:51:41.7896653Z 2025-03-14T03:51:41.7896816Z return json_response 2025-03-14T03:51:41.7897077Z 2025-03-14T03:51:41.7897084Z 2025-03-14T03:51:41.7897447Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-03-14T03:51:41.7898240Z """ 2025-03-14T03:51:41.7898732Z Dynamically get the latest list of labels from the pull request 2025-03-14T03:51:41.7899331Z """ 2025-03-14T03:51:41.7899782Z pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-03-14T03:51:41.7900333Z return { 2025-03-14T03:51:41.7900867Z label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-03-14T03:51:41.7901508Z } 2025-03-14T03:51:41.7901692Z 2025-03-14T03:51:41.7901698Z 2025-03-14T03:51:41.7901863Z def main() -> None: 2025-03-14T03:51:41.7902251Z args = parse_args() 2025-03-14T03:51:41.7902493Z 2025-03-14T03:51:41.7902693Z runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-03-14T03:51:41.7903046Z 2025-03-14T03:51:41.7903223Z # Check if the PR is opt-out 2025-03-14T03:51:41.7903675Z if args.pr_number: 2025-03-14T03:51:41.7904274Z labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-03-14T03:51:41.7904965Z if OPT_OUT_LABEL in labels: 2025-03-14T03:51:41.7905414Z log.info( 2025-03-14T03:51:41.7906270Z f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-03-14T03:51:41.7906983Z ) 2025-03-14T03:51:41.7907494Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:41.7908113Z sys.exit() 2025-03-14T03:51:41.7908346Z 2025-03-14T03:51:41.7908497Z try: 2025-03-14T03:51:41.7908891Z rollout_state = get_rollout_state_from_issue( 2025-03-14T03:51:41.7909542Z args.github_token, args.github_issue_repo, args.github_issue 2025-03-14T03:51:41.7910122Z ) 2025-03-14T03:51:41.7910310Z 2025-03-14T03:51:41.7910505Z username = get_potential_pr_author( 2025-03-14T03:51:41.7911010Z args.github_token, 2025-03-14T03:51:41.7911450Z args.github_repo, 2025-03-14T03:51:41.7911892Z args.github_actor, 2025-03-14T03:51:41.7912328Z args.github_ref_type, 2025-03-14T03:51:41.7912795Z args.github_branch, 2025-03-14T03:51:41.7913209Z ) 2025-03-14T03:51:41.7913397Z 2025-03-14T03:51:41.7913657Z is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-03-14T03:51:41.7914234Z 2025-03-14T03:51:41.7914433Z runner_label_prefix = get_runner_prefix( 2025-03-14T03:51:41.7914940Z rollout_state, 2025-03-14T03:51:41.7915383Z (args.github_issue_owner, username), 2025-03-14T03:51:41.7916088Z args.github_branch, 2025-03-14T03:51:41.7916538Z args.eligible_experiments, 2025-03-14T03:51:41.7917005Z is_canary, 2025-03-14T03:51:41.7917379Z ) 2025-03-14T03:51:41.7917568Z 2025-03-14T03:51:41.7917744Z except Exception as e: 2025-03-14T03:51:41.7918153Z log.error( 2025-03-14T03:51:41.7918767Z f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-03-14T03:51:41.7919466Z ) 2025-03-14T03:51:41.7919658Z 2025-03-14T03:51:41.7919967Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:41.7920423Z 2025-03-14T03:51:41.7920430Z 2025-03-14T03:51:41.7920595Z if __name__ == "__main__": 2025-03-14T03:51:41.7920997Z main() 2025-03-14T03:51:41.7921186Z 2025-03-14T03:51:41.8005200Z ##[group]Run python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-03-14T03:51:41.8006352Z python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-03-14T03:51:41.8051645Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:41.8052094Z env: 2025-03-14T03:51:41.8052646Z GITHUB_TOKEN: *** 2025-03-14T03:51:41.8053043Z ISSUE_NUMBER: 5132 2025-03-14T03:51:41.8053460Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:41.8053937Z ISSUE_OWNER: 2025-03-14T03:51:41.8054318Z CHECK_EXPERIMENTS: 2025-03-14T03:51:41.8054712Z PR_NUMBER: 2025-03-14T03:51:41.8055078Z ##[endgroup] 2025-03-14T03:51:42.2173633Z Defaulting to user installation because normal site-packages is not writeable 2025-03-14T03:51:42.9600126Z Collecting urllib3==1.26.18 2025-03-14T03:51:43.0119989Z Downloading urllib3-1.26.18-py2.py3-none-any.whl.metadata (48 kB) 2025-03-14T03:51:43.0311789Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 kB 4.4 MB/s eta 0:00:00 2025-03-14T03:51:43.0548525Z Collecting PyGithub==2.3.0 2025-03-14T03:51:43.0593052Z Downloading PyGithub-2.3.0-py3-none-any.whl.metadata (3.8 kB) 2025-03-14T03:51:43.1053817Z Collecting pynacl>=1.4.0 (from PyGithub==2.3.0) 2025-03-14T03:51:43.2431878Z 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.2490819Z 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.2506597Z 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.2520957Z 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.2760377Z Collecting Deprecated (from PyGithub==2.3.0) 2025-03-14T03:51:43.2816408Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl.metadata (5.7 kB) 2025-03-14T03:51:43.3046105Z 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:43.4274699Z Collecting cffi>=1.4.1 (from pynacl>=1.4.0->PyGithub==2.3.0) 2025-03-14T03:51:43.4332189Z Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.5 kB) 2025-03-14T03:51:43.5373191Z Collecting wrapt<2,>=1.10 (from Deprecated->PyGithub==2.3.0) 2025-03-14T03:51:43.5438017Z 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:43.5646335Z Collecting pycparser (from cffi>=1.4.1->pynacl>=1.4.0->PyGithub==2.3.0) 2025-03-14T03:51:43.5690728Z Downloading pycparser-2.22-py3-none-any.whl.metadata (943 bytes) 2025-03-14T03:51:43.5923178Z Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB) 2025-03-14T03:51:43.5990024Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.8/143.8 kB 27.5 MB/s eta 0:00:00 2025-03-14T03:51:43.6036813Z Downloading PyGithub-2.3.0-py3-none-any.whl (354 kB) 2025-03-14T03:51:43.6097182Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 354.4/354.4 kB 76.9 MB/s eta 0:00:00 2025-03-14T03:51:43.6130651Z 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:43.6222938Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 856.7/856.7 kB 111.1 MB/s eta 0:00:00 2025-03-14T03:51:43.6270347Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl (10.0 kB) 2025-03-14T03:51:43.6326010Z Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479 kB) 2025-03-14T03:51:43.6390962Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 479.4/479.4 kB 92.6 MB/s eta 0:00:00 2025-03-14T03:51:43.6422376Z 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:43.6465927Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 89.2/89.2 kB 26.6 MB/s eta 0:00:00 2025-03-14T03:51:43.6495256Z Downloading pycparser-2.22-py3-none-any.whl (117 kB) 2025-03-14T03:51:43.6552924Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.6/117.6 kB 26.2 MB/s eta 0:00:00 2025-03-14T03:51:43.9437975Z Installing collected packages: wrapt, urllib3, pycparser, Deprecated, cffi, pynacl, PyGithub 2025-03-14T03:51:44.4837089Z 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:44.5576011Z ##[group]Run curr_branch="main" 2025-03-14T03:51:44.5577252Z curr_branch="main" 2025-03-14T03:51:44.5578345Z curr_ref_type="branch" 2025-03-14T03:51:44.5579571Z echo "Current branch is '$curr_branch'" 2025-03-14T03:51:44.5580853Z  2025-03-14T03:51:44.5581760Z python3 runner_determinator.py \ 2025-03-14T03:51:44.5583068Z  --github-token "$GITHUB_TOKEN" \ 2025-03-14T03:51:44.5584403Z  --github-issue "$ISSUE_NUMBER" \ 2025-03-14T03:51:44.5585822Z  --github-branch "$curr_branch" \ 2025-03-14T03:51:44.5587171Z  --github-actor "$TRIGGERING_ACTOR" \ 2025-03-14T03:51:44.5588541Z  --github-issue-owner "$ISSUE_OWNER" \ 2025-03-14T03:51:44.5589921Z  --github-ref-type "$curr_ref_type" \ 2025-03-14T03:51:44.5591279Z  --github-repo "$GITHUB_REPOSITORY" \ 2025-03-14T03:51:44.5592760Z  --eligible-experiments "$CHECK_EXPERIMENTS" \ 2025-03-14T03:51:44.5594225Z  --pr-number "${PR_NUMBER}" 2025-03-14T03:51:44.5643359Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:44.5644404Z env: 2025-03-14T03:51:44.5645879Z GITHUB_TOKEN: *** 2025-03-14T03:51:44.5646795Z ISSUE_NUMBER: 5132 2025-03-14T03:51:44.5647783Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:44.5648926Z ISSUE_OWNER: 2025-03-14T03:51:44.5649803Z CHECK_EXPERIMENTS: 2025-03-14T03:51:44.5650744Z PR_NUMBER: 2025-03-14T03:51:44.5651583Z ##[endgroup] 2025-03-14T03:51:44.5726800Z Current branch is 'main' 2025-03-14T03:51:46.3391663Z INFO : Based on rollout percentage of 50%, enabling experiment lf. 2025-03-14T03:51:46.3392798Z INFO : Branch main is an exception branch. Not enabling experiment ephemeral. 2025-03-14T03:51:46.3393539Z INFO : Setting output: label-type='lf.' 2025-03-14T03:51:46.3695060Z Evaluate and set job outputs 2025-03-14T03:51:46.3702023Z Set output 'label-type' 2025-03-14T03:51:46.3703883Z Cleaning up orphan processes