2025-03-14T03:51:41.7923629Z Current runner version: '2.322.0' 2025-03-14T03:51:41.7953125Z ##[group]Operating System 2025-03-14T03:51:41.7954029Z Ubuntu 2025-03-14T03:51:41.7954563Z 24.04.2 2025-03-14T03:51:41.7955071Z LTS 2025-03-14T03:51:41.7955683Z ##[endgroup] 2025-03-14T03:51:41.7956192Z ##[group]Runner Image 2025-03-14T03:51:41.7956781Z Image: ubuntu-24.04 2025-03-14T03:51:41.7957370Z Version: 20250309.1.0 2025-03-14T03:51:41.7958444Z Included Software: https://github.com/actions/runner-images/blob/ubuntu24/20250309.1/images/ubuntu/Ubuntu2404-Readme.md 2025-03-14T03:51:41.7959850Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu24%2F20250309.1 2025-03-14T03:51:41.7961158Z ##[endgroup] 2025-03-14T03:51:41.7961671Z ##[group]Runner Image Provisioner 2025-03-14T03:51:41.7962273Z 2.0.422.1 2025-03-14T03:51:41.7962850Z ##[endgroup] 2025-03-14T03:51:41.7963957Z ##[group]GITHUB_TOKEN Permissions 2025-03-14T03:51:41.7965844Z Contents: read 2025-03-14T03:51:41.7966427Z Metadata: read 2025-03-14T03:51:41.7967247Z Packages: read 2025-03-14T03:51:41.7967838Z ##[endgroup] 2025-03-14T03:51:41.7971413Z Secret source: Actions 2025-03-14T03:51:41.7972391Z Prepare workflow directory 2025-03-14T03:51:41.8462065Z Prepare all required actions 2025-03-14T03:51:41.8517557Z Uses: pytorch/pytorch/.github/workflows/_runner-determinator.yml@refs/heads/main (aed0b7a742a2d7b7901790622829cbd2135049a4) 2025-03-14T03:51:41.8522898Z ##[group] Inputs 2025-03-14T03:51:41.8523553Z check_experiments: 2025-03-14T03:51:41.8524184Z triggering_actor: pytorchmergebot 2025-03-14T03:51:41.8524904Z issue_owner: 2025-03-14T03:51:41.8525443Z curr_branch: main 2025-03-14T03:51:41.8525966Z curr_ref_type: branch 2025-03-14T03:51:41.8526582Z issue_number: 5132 2025-03-14T03:51:41.8527174Z ##[endgroup] 2025-03-14T03:51:41.8527803Z Complete job name: get-label-type / runner-determinator 2025-03-14T03:51:41.9260192Z ##[group]Run cat < runner_determinator.py 2025-03-14T03:51:41.9262160Z cat < runner_determinator.py 2025-03-14T03:51:41.9262788Z # flake8: noqa: G004 2025-03-14T03:51:41.9263288Z  2025-03-14T03:51:41.9263962Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-03-14T03:51:41.9264957Z # must be kept in sync. You can do it easily by running the following command: 2025-03-14T03:51:41.9265822Z # python .github/scripts/update_runner_determinator.py 2025-03-14T03:51:41.9266459Z  2025-03-14T03:51:41.9266835Z """ 2025-03-14T03:51:41.9267474Z This runner determinator is used to determine which set of runners to run a 2025-03-14T03:51:41.9268428Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-03-14T03:51:41.9269456Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-03-14T03:51:41.9270576Z of which runners should be used to run which job. 2025-03-14T03:51:41.9271201Z  2025-03-14T03:51:41.9271841Z The configuration has two parts, the settings and a list of opted-in users, 2025-03-14T03:51:41.9272802Z separated by a line containing "---". If the line is not present, the 2025-03-14T03:51:41.9273726Z settings are considered to be empty with only the second part, the user 2025-03-14T03:51:41.9274489Z list, defined. 2025-03-14T03:51:41.9274924Z  2025-03-14T03:51:41.9275519Z The first part is a YAML block that defines the rollout settings. This can be 2025-03-14T03:51:41.9276510Z used to define any settings that are needed to determine which runners to use. 2025-03-14T03:51:41.9277456Z It's fields are defined by the RolloutSettings class below. 2025-03-14T03:51:41.9278095Z  2025-03-14T03:51:41.9278711Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-03-14T03:51:41.9279645Z The user list is also a comma separated list of additional features or 2025-03-14T03:51:41.9280958Z experiments which the user could be opted in to. 2025-03-14T03:51:41.9281561Z  2025-03-14T03:51:41.9281987Z The user list has the following rules: 2025-03-14T03:51:41.9282532Z  2025-03-14T03:51:41.9283085Z - Users are GitHub usernames, which must start with the @ prefix 2025-03-14T03:51:41.9283969Z - Each user is also a comma-separated list of features/experiments to enable 2025-03-14T03:51:41.9284790Z - A "#" prefix opts the user out of all experiments 2025-03-14T03:51:41.9285468Z  2025-03-14T03:51:41.9286097Z Example config: 2025-03-14T03:51:41.9286924Z  # A list of experiments that can be opted into. 2025-03-14T03:51:41.9288151Z  # This defines the behavior they'll induce when opted into. 2025-03-14T03:51:41.9289293Z  # Expected syntax is: 2025-03-14T03:51:41.9290784Z  # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-03-14T03:51:41.9292762Z  # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-03-14T03:51:41.9294246Z  2025-03-14T03:51:41.9294938Z  experiments: 2025-03-14T03:51:41.9295739Z  lf: 2025-03-14T03:51:41.9296468Z  rollout_percent: 25 2025-03-14T03:51:41.9297374Z  all_branches: false 2025-03-14T03:51:41.9298246Z  default: true 2025-03-14T03:51:41.9299042Z  --- 2025-03-14T03:51:41.9299706Z  2025-03-14T03:51:41.9300311Z  # Opt-ins: 2025-03-14T03:51:41.9301661Z  # Users can opt into the LF fleet by adding their GitHub username to this list 2025-03-14T03:51:41.9303599Z  # and specifying experiments to enable in a comma-separated list. 2025-03-14T03:51:41.9305162Z  # To always opt out of an experiment, prefix it with a "-". 2025-03-14T03:51:41.9306498Z  # Experiments should be from the above list. 2025-03-14T03:51:41.9307513Z  2025-03-14T03:51:41.9308180Z  @User1,-lf,split_build 2025-03-14T03:51:41.9309058Z  @User2,lf 2025-03-14T03:51:41.9309835Z  @User3,split_build 2025-03-14T03:51:41.9310906Z """ 2025-03-14T03:51:41.9311574Z  2025-03-14T03:51:41.9312246Z import json 2025-03-14T03:51:41.9313036Z import logging 2025-03-14T03:51:41.9313856Z import os 2025-03-14T03:51:41.9314634Z import random 2025-03-14T03:51:41.9315344Z import re 2025-03-14T03:51:41.9316013Z import sys 2025-03-14T03:51:41.9316834Z from argparse import ArgumentParser 2025-03-14T03:51:41.9317885Z from collections.abc import Iterable 2025-03-14T03:51:41.9318914Z from functools import cache 2025-03-14T03:51:41.9319768Z from logging import LogRecord 2025-03-14T03:51:41.9320915Z from typing import Any, NamedTuple 2025-03-14T03:51:41.9322051Z from urllib.request import Request, urlopen 2025-03-14T03:51:41.9323133Z  2025-03-14T03:51:41.9323786Z import yaml 2025-03-14T03:51:41.9324588Z from github import Auth, Github 2025-03-14T03:51:41.9325564Z from github.Issue import Issue 2025-03-14T03:51:41.9326449Z  2025-03-14T03:51:41.9327061Z  2025-03-14T03:51:41.9327849Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-03-14T03:51:41.9329171Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-03-14T03:51:41.9331032Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-03-14T03:51:41.9332354Z  2025-03-14T03:51:41.9333164Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-03-14T03:51:41.9334298Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-03-14T03:51:41.9335371Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-03-14T03:51:41.9336812Z OPT_OUT_LABEL = "no-runner-experiments" 2025-03-14T03:51:41.9337863Z  2025-03-14T03:51:41.9338576Z SETTING_EXPERIMENTS = "experiments" 2025-03-14T03:51:41.9339501Z  2025-03-14T03:51:41.9340168Z LF_FLEET_EXPERIMENT = "lf" 2025-03-14T03:51:41.9341281Z CANARY_FLEET_SUFFIX = ".c" 2025-03-14T03:51:41.9342172Z  2025-03-14T03:51:41.9342810Z  2025-03-14T03:51:41.9343571Z class Experiment(NamedTuple): 2025-03-14T03:51:41.9344599Z  rollout_perc: float = ( 2025-03-14T03:51:41.9345924Z  0 # Percentage of workflows to experiment on when user is not opted-in. 2025-03-14T03:51:41.9347250Z  ) 2025-03-14T03:51:41.9347987Z  all_branches: bool = ( 2025-03-14T03:51:41.9349251Z  False # If True, the experiment is also enabled on the exception branches 2025-03-14T03:51:41.9351065Z  ) 2025-03-14T03:51:41.9352044Z  default: bool = ( 2025-03-14T03:51:41.9353221Z  True # If True, the experiment is enabled by default for all queries 2025-03-14T03:51:41.9354508Z  ) 2025-03-14T03:51:41.9355186Z  2025-03-14T03:51:41.9355872Z  # Add more fields as needed 2025-03-14T03:51:41.9356754Z  2025-03-14T03:51:41.9357372Z  2025-03-14T03:51:41.9358101Z class Settings(NamedTuple): 2025-03-14T03:51:41.9359010Z  """ 2025-03-14T03:51:41.9360021Z  Settings for the experiments that can be opted into. 2025-03-14T03:51:41.9361360Z  """ 2025-03-14T03:51:41.9362066Z  2025-03-14T03:51:41.9362877Z  experiments: dict[str, Experiment] = {} 2025-03-14T03:51:41.9363877Z  2025-03-14T03:51:41.9364780Z  2025-03-14T03:51:41.9365635Z class ColorFormatter(logging.Formatter): 2025-03-14T03:51:41.9366914Z  """Color codes the log messages based on the log level""" 2025-03-14T03:51:41.9368055Z  2025-03-14T03:51:41.9368687Z  COLORS = { 2025-03-14T03:51:41.9369464Z  "WARNING": "\033[33m", # Yellow 2025-03-14T03:51:41.9370591Z  "ERROR": "\033[31m", # Red 2025-03-14T03:51:41.9371564Z  "CRITICAL": "\033[31m", # Red 2025-03-14T03:51:41.9372522Z  "INFO": "\033[0m", # Reset 2025-03-14T03:51:41.9373437Z  "DEBUG": "\033[0m", # Reset 2025-03-14T03:51:41.9374296Z  } 2025-03-14T03:51:41.9374931Z  2025-03-14T03:51:41.9375668Z  def format(self, record: LogRecord) -> str: 2025-03-14T03:51:41.9377152Z  log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-03-14T03:51:41.9378598Z  record.msg = f"{log_color}{record.msg}\033[0m" 2025-03-14T03:51:41.9379678Z  return super().format(record) 2025-03-14T03:51:41.9380663Z  2025-03-14T03:51:41.9381306Z  2025-03-14T03:51:41.9382043Z handler = logging.StreamHandler() 2025-03-14T03:51:41.9383395Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-03-14T03:51:41.9384273Z  2025-03-14T03:51:41.9384782Z log = logging.getLogger(os.path.basename(__file__)) 2025-03-14T03:51:41.9385443Z log.addHandler(handler) 2025-03-14T03:51:41.9386318Z log.setLevel(logging.INFO) 2025-03-14T03:51:41.9387090Z  2025-03-14T03:51:41.9387462Z  2025-03-14T03:51:41.9387967Z def set_github_output(key: str, value: str) -> None: 2025-03-14T03:51:41.9388596Z  """ 2025-03-14T03:51:41.9389170Z  Defines outputs of the github action that invokes this script 2025-03-14T03:51:41.9389853Z  """ 2025-03-14T03:51:41.9390270Z  if not GITHUB_OUTPUT: 2025-03-14T03:51:41.9391676Z  # 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.9393026Z  log.warning( 2025-03-14T03:51:41.9393957Z  "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.9394909Z  ) 2025-03-14T03:51:41.9395410Z  print(f"::set-output name={key}::{value}") 2025-03-14T03:51:41.9395990Z  return 2025-03-14T03:51:41.9396417Z  2025-03-14T03:51:41.9396829Z  with open(GITHUB_OUTPUT, "a") as f: 2025-03-14T03:51:41.9397466Z  log.info(f"Setting output: {key}='{value}'") 2025-03-14T03:51:41.9398097Z  f.write(f"{key}={value}\n") 2025-03-14T03:51:41.9398622Z  2025-03-14T03:51:41.9398989Z  2025-03-14T03:51:41.9399539Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-03-14T03:51:41.9400243Z  return frozenset( 2025-03-14T03:51:41.9401154Z  filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-03-14T03:51:41.9401864Z  ) 2025-03-14T03:51:41.9402252Z  2025-03-14T03:51:41.9402602Z  2025-03-14T03:51:41.9402992Z def parse_args() -> Any: 2025-03-14T03:51:41.9403631Z  parser = ArgumentParser("Get dynamic rollout settings") 2025-03-14T03:51:41.9404561Z  parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-03-14T03:51:41.9405373Z  parser.add_argument( 2025-03-14T03:51:41.9405897Z  "--github-issue-repo", 2025-03-14T03:51:41.9406413Z  type=str, 2025-03-14T03:51:41.9406879Z  required=False, 2025-03-14T03:51:41.9407543Z  default="pytorch/test-infra", 2025-03-14T03:51:41.9408155Z  help="GitHub repo to get the issue", 2025-03-14T03:51:41.9408722Z  ) 2025-03-14T03:51:41.9409130Z  parser.add_argument( 2025-03-14T03:51:41.9409633Z  "--github-repo", 2025-03-14T03:51:41.9410118Z  type=str, 2025-03-14T03:51:41.9410819Z  required=True, 2025-03-14T03:51:41.9411378Z  help="GitHub repo where CI is running", 2025-03-14T03:51:41.9411924Z  ) 2025-03-14T03:51:41.9412337Z  parser.add_argument( 2025-03-14T03:51:41.9413023Z  "--github-issue", type=int, required=True, help="GitHub issue number" 2025-03-14T03:51:41.9413717Z  ) 2025-03-14T03:51:41.9414132Z  parser.add_argument( 2025-03-14T03:51:41.9414837Z  "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-03-14T03:51:41.9415540Z  ) 2025-03-14T03:51:41.9415947Z  parser.add_argument( 2025-03-14T03:51:41.9416662Z  "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-03-14T03:51:41.9417392Z  ) 2025-03-14T03:51:41.9417805Z  parser.add_argument( 2025-03-14T03:51:41.9418526Z  "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-03-14T03:51:41.9419271Z  ) 2025-03-14T03:51:41.9419681Z  parser.add_argument( 2025-03-14T03:51:41.9420186Z  "--github-ref-type", 2025-03-14T03:51:41.9421370Z  type=str, 2025-03-14T03:51:41.9422181Z  required=True, 2025-03-14T03:51:41.9423147Z  help="Current GitHub ref type, branch or tag", 2025-03-14T03:51:41.9423983Z  ) 2025-03-14T03:51:41.9424401Z  parser.add_argument( 2025-03-14T03:51:41.9424931Z  "--eligible-experiments", 2025-03-14T03:51:41.9425521Z  type=_str_comma_separated_to_set, 2025-03-14T03:51:41.9426083Z  required=False, 2025-03-14T03:51:41.9426760Z  default="", 2025-03-14T03:51:41.9427690Z  help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-03-14T03:51:41.9428644Z  ) 2025-03-14T03:51:41.9429055Z  parser.add_argument( 2025-03-14T03:51:41.9429556Z  "--pr-number", 2025-03-14T03:51:41.9430037Z  type=str, 2025-03-14T03:51:41.9430742Z  required=False, 2025-03-14T03:51:41.9431226Z  default="", 2025-03-14T03:51:41.9431785Z  help="the optional PR number where this is run", 2025-03-14T03:51:41.9432381Z  ) 2025-03-14T03:51:41.9432764Z  2025-03-14T03:51:41.9433169Z  return parser.parse_args() 2025-03-14T03:51:41.9433674Z  2025-03-14T03:51:41.9434038Z  2025-03-14T03:51:41.9434682Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-03-14T03:51:41.9435500Z  auth = Auth.Token(github_token) 2025-03-14T03:51:41.9436047Z  return Github(auth=auth) 2025-03-14T03:51:41.9436879Z  2025-03-14T03:51:41.9437443Z  2025-03-14T03:51:41.9438153Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-03-14T03:51:41.9438997Z  repo = gh.get_repo(repo) 2025-03-14T03:51:41.9439561Z  return repo.get_issue(number=issue_num) 2025-03-14T03:51:41.9440113Z  2025-03-14T03:51:41.9440682Z  2025-03-14T03:51:41.9441170Z def get_potential_pr_author( 2025-03-14T03:51:41.9441889Z  github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-03-14T03:51:41.9442592Z ) -> str: 2025-03-14T03:51:41.9443350Z  # If the trigger was a new tag added by a bot, this is a ciflow case 2025-03-14T03:51:41.9444210Z  # Fetch the actual username from the original PR. The PR number is 2025-03-14T03:51:41.9445010Z  # embedded in the tag name: ciflow// 2025-03-14T03:51:41.9445666Z  2025-03-14T03:51:41.9446107Z  gh = get_gh_client(github_token) 2025-03-14T03:51:41.9446632Z  2025-03-14T03:51:41.9447134Z  if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-03-14T03:51:41.9447802Z  split_tag = ref_name.split("/") 2025-03-14T03:51:41.9448395Z  if ( 2025-03-14T03:51:41.9448859Z  len(split_tag) == 3 2025-03-14T03:51:41.9449407Z  and split_tag[0] == "ciflow" 2025-03-14T03:51:41.9450009Z  and split_tag[2].isnumeric() 2025-03-14T03:51:41.9450880Z  ): 2025-03-14T03:51:41.9451343Z  pr_number = split_tag[2] 2025-03-14T03:51:41.9451874Z  try: 2025-03-14T03:51:41.9452364Z  repository = gh.get_repo(repo) 2025-03-14T03:51:41.9453037Z  pull = repository.get_pull(number=int(pr_number)) 2025-03-14T03:51:41.9453693Z  except Exception as e: 2025-03-14T03:51:41.9454265Z  raise Exception( # noqa: TRY002 2025-03-14T03:51:41.9454986Z  f"issue with pull request {pr_number} from repo {repository}" 2025-03-14T03:51:41.9455669Z  ) from e 2025-03-14T03:51:41.9456287Z  return pull.user.login # type: ignore[no-any-return] 2025-03-14T03:51:41.9457026Z  # In all other cases, return the original input username 2025-03-14T03:51:41.9457655Z  return username 2025-03-14T03:51:41.9458100Z  2025-03-14T03:51:41.9458470Z  2025-03-14T03:51:41.9458926Z def is_exception_branch(branch: str) -> bool: 2025-03-14T03:51:41.9459487Z  """ 2025-03-14T03:51:41.9460197Z  Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-03-14T03:51:41.9461320Z  """ 2025-03-14T03:51:41.9461920Z  return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-03-14T03:51:41.9462616Z  2025-03-14T03:51:41.9462971Z  2025-03-14T03:51:41.9463381Z def load_yaml(yaml_text: str) -> Any: 2025-03-14T03:51:41.9463900Z  try: 2025-03-14T03:51:41.9464337Z  data = yaml.safe_load(yaml_text) 2025-03-14T03:51:41.9464879Z  return data 2025-03-14T03:51:41.9465353Z  except yaml.YAMLError: 2025-03-14T03:51:41.9465899Z  log.exception("Error loading YAML") 2025-03-14T03:51:41.9466433Z  raise 2025-03-14T03:51:41.9466857Z  2025-03-14T03:51:41.9467205Z  2025-03-14T03:51:41.9467864Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-03-14T03:51:41.9468640Z  """ 2025-03-14T03:51:41.9469332Z  Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-03-14T03:51:41.9470125Z  2025-03-14T03:51:41.9470914Z  If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:41.9471723Z  and the text below is the list of opted in users. 2025-03-14T03:51:41.9472309Z  2025-03-14T03:51:41.9472932Z  If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-03-14T03:51:41.9473653Z  """ 2025-03-14T03:51:41.9474141Z  rollout_state_parts = rollout_state.split("---") 2025-03-14T03:51:41.9474781Z  if len(rollout_state_parts) >= 2: 2025-03-14T03:51:41.9475648Z  return rollout_state_parts[0], rollout_state_parts[1] 2025-03-14T03:51:41.9476316Z  else: 2025-03-14T03:51:41.9476776Z  return "", rollout_state 2025-03-14T03:51:41.9477272Z  2025-03-14T03:51:41.9477617Z  2025-03-14T03:51:41.9478043Z class UserOptins(dict[str, list[str]]): 2025-03-14T03:51:41.9478580Z  """ 2025-03-14T03:51:41.9479149Z  Dictionary of users with a list of features they have opted into 2025-03-14T03:51:41.9479820Z  """ 2025-03-14T03:51:41.9480195Z  2025-03-14T03:51:41.9480783Z  2025-03-14T03:51:41.9481357Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-03-14T03:51:41.9482040Z  """ 2025-03-14T03:51:41.9482804Z  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.9483649Z  2025-03-14T03:51:41.9484484Z  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.9485518Z  - Example line: "@User1,lf,split_build" 2025-03-14T03:51:41.9486251Z  - A "#" prefix indicates the user is opted out of all experiments 2025-03-14T03:51:41.9486911Z  2025-03-14T03:51:41.9487269Z  2025-03-14T03:51:41.9487627Z  """ 2025-03-14T03:51:41.9488039Z  optins = UserOptins() 2025-03-14T03:51:41.9488604Z  for user in user_optin_text.split("\n"): 2025-03-14T03:51:41.9489205Z  user = user.strip("\r\n\t -") 2025-03-14T03:51:41.9489800Z  if not user or not user.startswith("@"): 2025-03-14T03:51:41.9490569Z  # Not a valid user. Skip 2025-03-14T03:51:41.9491098Z  continue 2025-03-14T03:51:41.9491536Z  2025-03-14T03:51:41.9491899Z  if user: 2025-03-14T03:51:41.9492406Z  usr_name = user.split(",")[0].strip("@") 2025-03-14T03:51:41.9493142Z  optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-03-14T03:51:41.9493955Z  2025-03-14T03:51:41.9494331Z  return optins 2025-03-14T03:51:41.9494776Z  2025-03-14T03:51:41.9495131Z  2025-03-14T03:51:41.9495651Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-03-14T03:51:41.9496297Z  """ 2025-03-14T03:51:41.9497152Z  Check if the experiment name is valid. 2025-03-14T03:51:41.9498059Z  A valid name: 2025-03-14T03:51:41.9499244Z  - Contains only alphanumeric characters and the special characters "_" & "-" 2025-03-14T03:51:41.9501040Z  - The special characters "_" & "-" shouldn't be the first or last characters 2025-03-14T03:51:41.9501798Z  - Cannot contain spaces 2025-03-14T03:51:41.9502311Z  """ 2025-03-14T03:51:41.9502764Z  2025-03-14T03:51:41.9503268Z  valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-03-14T03:51:41.9504026Z  valid = bool(re.match(valid_char_regex, experiment_name)) 2025-03-14T03:51:41.9504652Z  2025-03-14T03:51:41.9505017Z  if valid: 2025-03-14T03:51:41.9505450Z  return True 2025-03-14T03:51:41.9505894Z  2025-03-14T03:51:41.9506263Z  log.error( 2025-03-14T03:51:41.9507774Z  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.9509341Z  ) 2025-03-14T03:51:41.9509745Z  return False 2025-03-14T03:51:41.9510175Z  2025-03-14T03:51:41.9510782Z  2025-03-14T03:51:41.9511497Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-03-14T03:51:41.9512170Z  """ 2025-03-14T03:51:41.9512815Z  Parse the experiments from the issue body into a list of ExperimentSettings 2025-03-14T03:51:41.9513565Z  """ 2025-03-14T03:51:41.9513950Z  try: 2025-03-14T03:51:41.9514349Z  if settings_text: 2025-03-14T03:51:41.9515133Z  # 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.9515940Z  # for easy reading 2025-03-14T03:51:41.9516792Z  # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-03-14T03:51:41.9517724Z  # the backtick character in shell commands. 2025-03-14T03:51:41.9518375Z  backtick = chr(96) # backtick character 2025-03-14T03:51:41.9519093Z  settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-03-14T03:51:41.9519795Z  settings = load_yaml(settings_text) 2025-03-14T03:51:41.9520328Z  2025-03-14T03:51:41.9521107Z  # For now we just load experiments. We can expand this if/when we add more settings 2025-03-14T03:51:41.9521873Z  experiments = {} 2025-03-14T03:51:41.9522352Z  2025-03-14T03:51:41.9522944Z  for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-03-14T03:51:41.9523749Z  if not is_valid_experiment_name(exp_name): 2025-03-14T03:51:41.9524890Z  # 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.9525955Z  continue 2025-03-14T03:51:41.9526435Z  2025-03-14T03:51:41.9526839Z  valid_settings = {} 2025-03-14T03:51:41.9527408Z  for setting in exp_settings: 2025-03-14T03:51:41.9528010Z  if setting not in Experiment._fields: 2025-03-14T03:51:41.9528722Z  log.warning( 2025-03-14T03:51:41.9529483Z  f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-03-14T03:51:41.9530219Z  ) 2025-03-14T03:51:41.9530804Z  else: 2025-03-14T03:51:41.9531384Z  valid_settings[setting] = exp_settings[setting] 2025-03-14T03:51:41.9531977Z  2025-03-14T03:51:41.9532469Z  experiments[exp_name] = Experiment(**valid_settings) 2025-03-14T03:51:41.9533180Z  return Settings(experiments) 2025-03-14T03:51:41.9533713Z  2025-03-14T03:51:41.9534092Z  except Exception: 2025-03-14T03:51:41.9534640Z  log.exception("Failed to parse settings") 2025-03-14T03:51:41.9535211Z  2025-03-14T03:51:41.9535597Z  return Settings() 2025-03-14T03:51:41.9536043Z  2025-03-14T03:51:41.9536401Z  2025-03-14T03:51:41.9536882Z def parse_settings(rollout_state: str) -> Settings: 2025-03-14T03:51:41.9537477Z  """ 2025-03-14T03:51:41.9537975Z  Parse settings, if any, from the rollout state. 2025-03-14T03:51:41.9538549Z  2025-03-14T03:51:41.9539109Z  If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:41.9539912Z  and the text below is the list of opted in users. 2025-03-14T03:51:41.9540598Z  2025-03-14T03:51:41.9541222Z  If it doesn't contain "---" then the settings are empty and the default values are used. 2025-03-14T03:51:41.9541974Z  """ 2025-03-14T03:51:41.9542590Z  settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:41.9543520Z  return parse_settings_from_text(settings_text) 2025-03-14T03:51:41.9544096Z  2025-03-14T03:51:41.9544442Z  2025-03-14T03:51:41.9544922Z def parse_users(rollout_state: str) -> UserOptins: 2025-03-14T03:51:41.9545550Z  """ 2025-03-14T03:51:41.9545992Z  Parse users from the rollout state. 2025-03-14T03:51:41.9546520Z  2025-03-14T03:51:41.9546868Z  """ 2025-03-14T03:51:41.9547464Z  _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:41.9548253Z  return parse_user_opt_in_from_text(users_text) 2025-03-14T03:51:41.9548821Z  2025-03-14T03:51:41.9549179Z  2025-03-14T03:51:41.9549834Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:41.9550730Z  """ 2025-03-14T03:51:41.9551328Z  Check if a user is opted into an experiment 2025-03-14T03:51:41.9551890Z  """ 2025-03-14T03:51:41.9552399Z  return experiment_name in user_optins.get(user, []) 2025-03-14T03:51:41.9553000Z  2025-03-14T03:51:41.9553352Z  2025-03-14T03:51:41.9554024Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:41.9554803Z  """ 2025-03-14T03:51:41.9555323Z  Check if a user explicitly opted out of an experiment 2025-03-14T03:51:41.9555934Z  """ 2025-03-14T03:51:41.9556488Z  # if the experiment is prefixed with a "-", then it's an opt-out 2025-03-14T03:51:41.9557233Z  experiment_optout = "-" + experiment_name 2025-03-14T03:51:41.9557932Z  if experiment_optout not in user_optins.get(user, []): 2025-03-14T03:51:41.9558556Z  return False 2025-03-14T03:51:41.9559012Z  2025-03-14T03:51:41.9559512Z  if is_user_opted_in(user, user_optins, experiment_name): 2025-03-14T03:51:41.9560139Z  log.warning( 2025-03-14T03:51:41.9561104Z  f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-03-14T03:51:41.9562936Z  ) 2025-03-14T03:51:41.9563597Z  2025-03-14T03:51:41.9564183Z  return True 2025-03-14T03:51:41.9564859Z  2025-03-14T03:51:41.9565414Z  2025-03-14T03:51:41.9566023Z def get_runner_prefix( 2025-03-14T03:51:41.9566760Z  rollout_state: str, 2025-03-14T03:51:41.9567295Z  workflow_requestors: Iterable[str], 2025-03-14T03:51:41.9567844Z  branch: str, 2025-03-14T03:51:41.9568417Z  eligible_experiments: frozenset[str] = frozenset(), 2025-03-14T03:51:41.9569064Z  is_canary: bool = False, 2025-03-14T03:51:41.9569571Z ) -> str: 2025-03-14T03:51:41.9570052Z  settings = parse_settings(rollout_state) 2025-03-14T03:51:41.9570840Z  user_optins = parse_users(rollout_state) 2025-03-14T03:51:41.9571375Z  2025-03-14T03:51:41.9571764Z  fleet_prefix = "" 2025-03-14T03:51:41.9572240Z  prefixes = [] 2025-03-14T03:51:41.9572935Z  for experiment_name, experiment_settings in settings.experiments.items(): 2025-03-14T03:51:41.9573929Z  if not experiment_settings.all_branches and is_exception_branch(branch): 2025-03-14T03:51:41.9574670Z  log.info( 2025-03-14T03:51:41.9575415Z  f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-03-14T03:51:41.9576180Z  ) 2025-03-14T03:51:41.9576604Z  continue 2025-03-14T03:51:41.9577075Z  2025-03-14T03:51:41.9577476Z  if eligible_experiments: 2025-03-14T03:51:41.9578264Z  if experiment_name not in eligible_experiments: 2025-03-14T03:51:41.9578961Z  exp_list = ", ".join(eligible_experiments) 2025-03-14T03:51:41.9579601Z  log.info( 2025-03-14T03:51:41.9580597Z  f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-03-14T03:51:41.9581451Z  ) 2025-03-14T03:51:41.9581914Z  continue 2025-03-14T03:51:41.9582478Z  elif not experiment_settings.default: 2025-03-14T03:51:41.9583047Z  log.info( 2025-03-14T03:51:41.9583768Z  f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-03-14T03:51:41.9584546Z  ) 2025-03-14T03:51:41.9584967Z  continue 2025-03-14T03:51:41.9585410Z  2025-03-14T03:51:41.9585910Z  # Is any workflow_requestor opted out to this experiment? 2025-03-14T03:51:41.9586569Z  opted_out_users = [ 2025-03-14T03:51:41.9587080Z  requestor 2025-03-14T03:51:41.9587600Z  for requestor in workflow_requestors 2025-03-14T03:51:41.9588324Z  if is_user_opted_out(requestor, user_optins, experiment_name) 2025-03-14T03:51:41.9588978Z  ] 2025-03-14T03:51:41.9589372Z  2025-03-14T03:51:41.9589755Z  if opted_out_users: 2025-03-14T03:51:41.9590256Z  log.info( 2025-03-14T03:51:41.9591241Z  f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-03-14T03:51:41.9591965Z  ) 2025-03-14T03:51:41.9592386Z  continue 2025-03-14T03:51:41.9592820Z  2025-03-14T03:51:41.9593308Z  # Is any workflow_requestor opted in to this experiment? 2025-03-14T03:51:41.9593961Z  opted_in_users = [ 2025-03-14T03:51:41.9594456Z  requestor 2025-03-14T03:51:41.9594974Z  for requestor in workflow_requestors 2025-03-14T03:51:41.9595680Z  if is_user_opted_in(requestor, user_optins, experiment_name) 2025-03-14T03:51:41.9596499Z  ] 2025-03-14T03:51:41.9596890Z  2025-03-14T03:51:41.9597265Z  enabled = False 2025-03-14T03:51:41.9597750Z  if opted_in_users: 2025-03-14T03:51:41.9598252Z  log.info( 2025-03-14T03:51:41.9598916Z  f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-03-14T03:51:41.9599615Z  ) 2025-03-14T03:51:41.9600047Z  enabled = True 2025-03-14T03:51:41.9600716Z  2025-03-14T03:51:41.9601176Z  elif experiment_settings.rollout_perc: 2025-03-14T03:51:41.9602045Z  # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-03-14T03:51:41.9603016Z  if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-03-14T03:51:41.9603694Z  log.info( 2025-03-14T03:51:41.9604608Z  f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-03-14T03:51:41.9605534Z  ) 2025-03-14T03:51:41.9605989Z  enabled = True 2025-03-14T03:51:41.9606476Z  2025-03-14T03:51:41.9606848Z  if enabled: 2025-03-14T03:51:41.9607333Z  label = experiment_name 2025-03-14T03:51:41.9607965Z  if experiment_name == LF_FLEET_EXPERIMENT: 2025-03-14T03:51:41.9608851Z  # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-03-14T03:51:41.9610730Z  # - If it's enabled, then we always list it's prefix first 2025-03-14T03:51:41.9612039Z  # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-03-14T03:51:41.9613206Z  if is_canary: 2025-03-14T03:51:41.9614092Z  label += CANARY_FLEET_SUFFIX 2025-03-14T03:51:41.9615031Z  fleet_prefix = label 2025-03-14T03:51:41.9615909Z  else: 2025-03-14T03:51:41.9616706Z  prefixes.append(label) 2025-03-14T03:51:41.9617591Z  2025-03-14T03:51:41.9618227Z  if len(prefixes) > 1: 2025-03-14T03:51:41.9619039Z  log.error( 2025-03-14T03:51:41.9621076Z  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.9623096Z  ) 2025-03-14T03:51:41.9623771Z  prefixes = prefixes[:1] 2025-03-14T03:51:41.9624543Z  2025-03-14T03:51:41.9625178Z  # Fleet always comes first 2025-03-14T03:51:41.9626043Z  if fleet_prefix: 2025-03-14T03:51:41.9626873Z  prefixes.insert(0, fleet_prefix) 2025-03-14T03:51:41.9627758Z  2025-03-14T03:51:41.9628548Z  return ".".join(prefixes) + "." if prefixes else "" 2025-03-14T03:51:41.9629543Z  2025-03-14T03:51:41.9630136Z  2025-03-14T03:51:41.9631413Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-03-14T03:51:41.9632759Z  """ 2025-03-14T03:51:41.9633818Z  Gets the first comment of the issue, which contains the desired rollout state. 2025-03-14T03:51:41.9635061Z  2025-03-14T03:51:41.9635978Z  The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-03-14T03:51:41.9637111Z  """ 2025-03-14T03:51:41.9637825Z  gh = get_gh_client(github_token) 2025-03-14T03:51:41.9638780Z  issue = get_issue(gh, repo, issue_num) 2025-03-14T03:51:41.9639483Z  return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-03-14T03:51:41.9640306Z  2025-03-14T03:51:41.9641017Z  2025-03-14T03:51:41.9641659Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-03-14T03:51:41.9642473Z  for _ in range(num_retries): 2025-03-14T03:51:41.9642982Z  try: 2025-03-14T03:51:41.9643513Z  req = Request(url=url, headers=headers) 2025-03-14T03:51:41.9644220Z  content = urlopen(req, timeout=5).read().decode("utf-8") 2025-03-14T03:51:41.9644906Z  return json.loads(content) 2025-03-14T03:51:41.9645497Z  except Exception as e: 2025-03-14T03:51:41.9646101Z  log.warning(f"Could not download {url}: {e}") 2025-03-14T03:51:41.9646681Z  2025-03-14T03:51:41.9647286Z  log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-03-14T03:51:41.9648035Z  return {} 2025-03-14T03:51:41.9648458Z  2025-03-14T03:51:41.9648806Z  2025-03-14T03:51:41.9649169Z @cache 2025-03-14T03:51:41.9649852Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-03-14T03:51:41.9650783Z  """ 2025-03-14T03:51:41.9651222Z  Dynamically get PR information 2025-03-14T03:51:41.9651730Z  """ 2025-03-14T03:51:41.9652282Z  github_api = f"https://api.github.com/repos/{github_repo}" 2025-03-14T03:51:41.9652936Z  headers = { 2025-03-14T03:51:41.9653461Z  "Accept": "application/vnd.github.v3+json", 2025-03-14T03:51:41.9654106Z  "Authorization": f"token {github_token}", 2025-03-14T03:51:41.9654650Z  } 2025-03-14T03:51:41.9655270Z  json_response: dict[str, Any] = download_json( 2025-03-14T03:51:41.9655930Z  url=f"{github_api}/issues/{pr_number}", 2025-03-14T03:51:41.9656502Z  headers=headers, 2025-03-14T03:51:41.9656968Z  ) 2025-03-14T03:51:41.9657343Z  2025-03-14T03:51:41.9657750Z  if not json_response: 2025-03-14T03:51:41.9658388Z  log.warning(f"Failed to get the labels for #{pr_number}") 2025-03-14T03:51:41.9659042Z  return {} 2025-03-14T03:51:41.9659477Z  2025-03-14T03:51:41.9659851Z  return json_response 2025-03-14T03:51:41.9660313Z  2025-03-14T03:51:41.9660780Z  2025-03-14T03:51:41.9661395Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-03-14T03:51:41.9662139Z  """ 2025-03-14T03:51:41.9662714Z  Dynamically get the latest list of labels from the pull request 2025-03-14T03:51:41.9663390Z  """ 2025-03-14T03:51:41.9663914Z  pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-03-14T03:51:41.9664550Z  return { 2025-03-14T03:51:41.9665190Z  label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-03-14T03:51:41.9665902Z  } 2025-03-14T03:51:41.9666272Z  2025-03-14T03:51:41.9666619Z  2025-03-14T03:51:41.9667020Z def main() -> None: 2025-03-14T03:51:41.9667548Z  args = parse_args() 2025-03-14T03:51:41.9668069Z  2025-03-14T03:51:41.9668500Z  runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-03-14T03:51:41.9669057Z  2025-03-14T03:51:41.9669440Z  # Check if the PR is opt-out 2025-03-14T03:51:41.9669971Z  if args.pr_number: 2025-03-14T03:51:41.9670852Z  labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-03-14T03:51:41.9671640Z  if OPT_OUT_LABEL in labels: 2025-03-14T03:51:41.9672162Z  log.info( 2025-03-14T03:51:41.9672913Z  f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-03-14T03:51:41.9673820Z  ) 2025-03-14T03:51:41.9674441Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:41.9675145Z  sys.exit() 2025-03-14T03:51:41.9675603Z  2025-03-14T03:51:41.9675949Z  try: 2025-03-14T03:51:41.9676435Z  rollout_state = get_rollout_state_from_issue( 2025-03-14T03:51:41.9677225Z  args.github_token, args.github_issue_repo, args.github_issue 2025-03-14T03:51:41.9677884Z  ) 2025-03-14T03:51:41.9678276Z  2025-03-14T03:51:41.9678692Z  username = get_potential_pr_author( 2025-03-14T03:51:41.9679258Z  args.github_token, 2025-03-14T03:51:41.9679786Z  args.github_repo, 2025-03-14T03:51:41.9680304Z  args.github_actor, 2025-03-14T03:51:41.9680975Z  args.github_ref_type, 2025-03-14T03:51:41.9681501Z  args.github_branch, 2025-03-14T03:51:41.9681999Z  ) 2025-03-14T03:51:41.9682916Z  2025-03-14T03:51:41.9683783Z  is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-03-14T03:51:41.9684857Z  2025-03-14T03:51:41.9685535Z  runner_label_prefix = get_runner_prefix( 2025-03-14T03:51:41.9686162Z  rollout_state, 2025-03-14T03:51:41.9686754Z  (args.github_issue_owner, username), 2025-03-14T03:51:41.9687357Z  args.github_branch, 2025-03-14T03:51:41.9687906Z  args.eligible_experiments, 2025-03-14T03:51:41.9688449Z  is_canary, 2025-03-14T03:51:41.9689088Z  ) 2025-03-14T03:51:41.9689489Z  2025-03-14T03:51:41.9689876Z  except Exception as e: 2025-03-14T03:51:41.9690516Z  log.error( 2025-03-14T03:51:41.9691261Z  f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-03-14T03:51:41.9692022Z  ) 2025-03-14T03:51:41.9692410Z  2025-03-14T03:51:41.9692962Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:41.9693637Z  2025-03-14T03:51:41.9694270Z  2025-03-14T03:51:41.9694814Z if __name__ == "__main__": 2025-03-14T03:51:41.9695605Z  main() 2025-03-14T03:51:41.9696164Z  2025-03-14T03:51:41.9696626Z EOF 2025-03-14T03:51:41.9697153Z  2025-03-14T03:51:41.9697748Z cat runner_determinator.py 2025-03-14T03:51:42.0210273Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:42.0211412Z env: 2025-03-14T03:51:42.0212082Z GITHUB_TOKEN: *** 2025-03-14T03:51:42.0212507Z ISSUE_NUMBER: 5132 2025-03-14T03:51:42.0212950Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:42.0213438Z ISSUE_OWNER: 2025-03-14T03:51:42.0213831Z CHECK_EXPERIMENTS: 2025-03-14T03:51:42.0214238Z PR_NUMBER: 2025-03-14T03:51:42.0214611Z ##[endgroup] 2025-03-14T03:51:42.0437586Z # flake8: noqa: G004 2025-03-14T03:51:42.0437941Z 2025-03-14T03:51:42.0438380Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-03-14T03:51:42.0439341Z # must be kept in sync. You can do it easily by running the following command: 2025-03-14T03:51:42.0440141Z # python .github/scripts/update_runner_determinator.py 2025-03-14T03:51:42.0440874Z 2025-03-14T03:51:42.0441039Z """ 2025-03-14T03:51:42.0441607Z This runner determinator is used to determine which set of runners to run a 2025-03-14T03:51:42.0442476Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-03-14T03:51:42.0443400Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-03-14T03:51:42.0444200Z of which runners should be used to run which job. 2025-03-14T03:51:42.0444819Z 2025-03-14T03:51:42.0445211Z The configuration has two parts, the settings and a list of opted-in users, 2025-03-14T03:51:42.0446093Z separated by a line containing "---". If the line is not present, the 2025-03-14T03:51:42.0446944Z settings are considered to be empty with only the second part, the user 2025-03-14T03:51:42.0447622Z list, defined. 2025-03-14T03:51:42.0447845Z 2025-03-14T03:51:42.0448199Z The first part is a YAML block that defines the rollout settings. This can be 2025-03-14T03:51:42.0449095Z used to define any settings that are needed to determine which runners to use. 2025-03-14T03:51:42.0449911Z It's fields are defined by the RolloutSettings class below. 2025-03-14T03:51:42.0450510Z 2025-03-14T03:51:42.0450915Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-03-14T03:51:42.0451780Z The user list is also a comma separated list of additional features or 2025-03-14T03:51:42.0452507Z experiments which the user could be opted in to. 2025-03-14T03:51:42.0452917Z 2025-03-14T03:51:42.0453106Z The user list has the following rules: 2025-03-14T03:51:42.0453451Z 2025-03-14T03:51:42.0453756Z - Users are GitHub usernames, which must start with the @ prefix 2025-03-14T03:51:42.0454594Z - Each user is also a comma-separated list of features/experiments to enable 2025-03-14T03:51:42.0455341Z - A "#" prefix opts the user out of all experiments 2025-03-14T03:51:42.0455735Z 2025-03-14T03:51:42.0455904Z Example config: 2025-03-14T03:51:42.0456342Z # A list of experiments that can be opted into. 2025-03-14T03:51:42.0457004Z # This defines the behavior they'll induce when opted into. 2025-03-14T03:51:42.0457613Z # Expected syntax is: 2025-03-14T03:51:42.0458249Z # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-03-14T03:51:42.0459354Z # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-03-14T03:51:42.0459967Z 2025-03-14T03:51:42.0460130Z experiments: 2025-03-14T03:51:42.0460981Z lf: 2025-03-14T03:51:42.0461357Z rollout_percent: 25 2025-03-14T03:51:42.0461805Z all_branches: false 2025-03-14T03:51:42.0462239Z default: true 2025-03-14T03:51:42.0462626Z --- 2025-03-14T03:51:42.0462828Z 2025-03-14T03:51:42.0463015Z # Opt-ins: 2025-03-14T03:51:42.0463582Z # Users can opt into the LF fleet by adding their GitHub username to this list 2025-03-14T03:51:42.0464477Z # and specifying experiments to enable in a comma-separated list. 2025-03-14T03:51:42.0465257Z # To always opt out of an experiment, prefix it with a "-". 2025-03-14T03:51:42.0465898Z # Experiments should be from the above list. 2025-03-14T03:51:42.0466276Z 2025-03-14T03:51:42.0466454Z @User1,-lf,split_build 2025-03-14T03:51:42.0466879Z @User2,lf 2025-03-14T03:51:42.0467265Z @User3,split_build 2025-03-14T03:51:42.0467661Z """ 2025-03-14T03:51:42.0467849Z 2025-03-14T03:51:42.0468007Z import json 2025-03-14T03:51:42.0468367Z import logging 2025-03-14T03:51:42.0468744Z import os 2025-03-14T03:51:42.0469097Z import random 2025-03-14T03:51:42.0469464Z import re 2025-03-14T03:51:42.0469804Z import sys 2025-03-14T03:51:42.0470187Z from argparse import ArgumentParser 2025-03-14T03:51:42.0470929Z from collections.abc import Iterable 2025-03-14T03:51:42.0471441Z from functools import cache 2025-03-14T03:51:42.0471903Z from logging import LogRecord 2025-03-14T03:51:42.0472372Z from typing import Any, NamedTuple 2025-03-14T03:51:42.0472888Z from urllib.request import Request, urlopen 2025-03-14T03:51:42.0473257Z 2025-03-14T03:51:42.0473413Z import yaml 2025-03-14T03:51:42.0473786Z from github import Auth, Github 2025-03-14T03:51:42.0474260Z from github.Issue import Issue 2025-03-14T03:51:42.0474556Z 2025-03-14T03:51:42.0474561Z 2025-03-14T03:51:42.0474778Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-03-14T03:51:42.0475457Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-03-14T03:51:42.0476309Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-03-14T03:51:42.0477012Z 2025-03-14T03:51:42.0477240Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-03-14T03:51:42.0477806Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-03-14T03:51:42.0478302Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-03-14T03:51:42.0478832Z OPT_OUT_LABEL = "no-runner-experiments" 2025-03-14T03:51:42.0479185Z 2025-03-14T03:51:42.0479375Z SETTING_EXPERIMENTS = "experiments" 2025-03-14T03:51:42.0479700Z 2025-03-14T03:51:42.0479873Z LF_FLEET_EXPERIMENT = "lf" 2025-03-14T03:51:42.0480553Z CANARY_FLEET_SUFFIX = ".c" 2025-03-14T03:51:42.0480847Z 2025-03-14T03:51:42.0480853Z 2025-03-14T03:51:42.0481042Z class Experiment(NamedTuple): 2025-03-14T03:51:42.0481508Z rollout_perc: float = ( 2025-03-14T03:51:42.0482136Z 0 # Percentage of workflows to experiment on when user is not opted-in. 2025-03-14T03:51:42.0482804Z ) 2025-03-14T03:51:42.0483163Z all_branches: bool = ( 2025-03-14T03:51:42.0483776Z False # If True, the experiment is also enabled on the exception branches 2025-03-14T03:51:42.0484446Z ) 2025-03-14T03:51:42.0484788Z default: bool = ( 2025-03-14T03:51:42.0485339Z True # If True, the experiment is enabled by default for all queries 2025-03-14T03:51:42.0485985Z ) 2025-03-14T03:51:42.0486199Z 2025-03-14T03:51:42.0486405Z # Add more fields as needed 2025-03-14T03:51:42.0486700Z 2025-03-14T03:51:42.0486706Z 2025-03-14T03:51:42.0486891Z class Settings(NamedTuple): 2025-03-14T03:51:42.0487313Z """ 2025-03-14T03:51:42.0487751Z Settings for the experiments that can be opted into. 2025-03-14T03:51:42.0488323Z """ 2025-03-14T03:51:42.0488512Z 2025-03-14T03:51:42.0488721Z experiments: dict[str, Experiment] = {} 2025-03-14T03:51:42.0489076Z 2025-03-14T03:51:42.0489081Z 2025-03-14T03:51:42.0489425Z class ColorFormatter(logging.Formatter): 2025-03-14T03:51:42.0490050Z """Color codes the log messages based on the log level""" 2025-03-14T03:51:42.0490659Z 2025-03-14T03:51:42.0490826Z COLORS = { 2025-03-14T03:51:42.0491226Z "WARNING": "\033[33m", # Yellow 2025-03-14T03:51:42.0491729Z "ERROR": "\033[31m", # Red 2025-03-14T03:51:42.0492209Z "CRITICAL": "\033[31m", # Red 2025-03-14T03:51:42.0492701Z "INFO": "\033[0m", # Reset 2025-03-14T03:51:42.0493169Z "DEBUG": "\033[0m", # Reset 2025-03-14T03:51:42.0493627Z } 2025-03-14T03:51:42.0493816Z 2025-03-14T03:51:42.0494027Z def format(self, record: LogRecord) -> str: 2025-03-14T03:51:42.0494764Z log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-03-14T03:51:42.0495541Z record.msg = f"{log_color}{record.msg}\033[0m" 2025-03-14T03:51:42.0496105Z return super().format(record) 2025-03-14T03:51:42.0496435Z 2025-03-14T03:51:42.0496442Z 2025-03-14T03:51:42.0496639Z handler = logging.StreamHandler() 2025-03-14T03:51:42.0497361Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-03-14T03:51:42.0497927Z 2025-03-14T03:51:42.0498160Z log = logging.getLogger(os.path.basename(__file__)) 2025-03-14T03:51:42.0498728Z log.addHandler(handler) 2025-03-14T03:51:42.0499157Z log.setLevel(logging.INFO) 2025-03-14T03:51:42.0499432Z 2025-03-14T03:51:42.0499438Z 2025-03-14T03:51:42.0499678Z def set_github_output(key: str, value: str) -> None: 2025-03-14T03:51:42.0500218Z """ 2025-03-14T03:51:42.0500879Z Defines outputs of the github action that invokes this script 2025-03-14T03:51:42.0501495Z """ 2025-03-14T03:51:42.0501849Z if not GITHUB_OUTPUT: 2025-03-14T03:51:42.0502899Z # See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ for deprecation notice 2025-03-14T03:51:42.0503995Z log.warning( 2025-03-14T03:51:42.0504837Z "No env var found for GITHUB_OUTPUT, you must be running this code locally. Falling back to the deprecated print method." 2025-03-14T03:51:42.0505746Z ) 2025-03-14T03:51:42.0516066Z print(f"::set-output name={key}::{value}") 2025-03-14T03:51:42.0516930Z return 2025-03-14T03:51:42.0517167Z 2025-03-14T03:51:42.0517365Z with open(GITHUB_OUTPUT, "a") as f: 2025-03-14T03:51:42.0517943Z log.info(f"Setting output: {key}='{value}'") 2025-03-14T03:51:42.0518514Z f.write(f"{key}={value}\n") 2025-03-14T03:51:42.0518832Z 2025-03-14T03:51:42.0518838Z 2025-03-14T03:51:42.0519141Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-03-14T03:51:42.0519774Z return frozenset( 2025-03-14T03:51:42.0520597Z filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-03-14T03:51:42.0521311Z ) 2025-03-14T03:51:42.0521508Z 2025-03-14T03:51:42.0521516Z 2025-03-14T03:51:42.0521694Z def parse_args() -> Any: 2025-03-14T03:51:42.0522255Z parser = ArgumentParser("Get dynamic rollout settings") 2025-03-14T03:51:42.0523119Z parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-03-14T03:51:42.0523883Z parser.add_argument( 2025-03-14T03:51:42.0524323Z "--github-issue-repo", 2025-03-14T03:51:42.0524781Z type=str, 2025-03-14T03:51:42.0525171Z required=False, 2025-03-14T03:51:42.0525604Z default="pytorch/test-infra", 2025-03-14T03:51:42.0526145Z help="GitHub repo to get the issue", 2025-03-14T03:51:42.0526645Z ) 2025-03-14T03:51:42.0526996Z parser.add_argument( 2025-03-14T03:51:42.0527416Z "--github-repo", 2025-03-14T03:51:42.0527832Z type=str, 2025-03-14T03:51:42.0528214Z required=True, 2025-03-14T03:51:42.0528659Z help="GitHub repo where CI is running", 2025-03-14T03:51:42.0529170Z ) 2025-03-14T03:51:42.0529521Z parser.add_argument( 2025-03-14T03:51:42.0530114Z "--github-issue", type=int, required=True, help="GitHub issue number" 2025-03-14T03:51:42.0531130Z ) 2025-03-14T03:51:42.0531512Z parser.add_argument( 2025-03-14T03:51:42.0532151Z "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-03-14T03:51:42.0532814Z ) 2025-03-14T03:51:42.0533161Z parser.add_argument( 2025-03-14T03:51:42.0533779Z "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-03-14T03:51:42.0534457Z ) 2025-03-14T03:51:42.0534805Z parser.add_argument( 2025-03-14T03:51:42.0535460Z "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-03-14T03:51:42.0536155Z ) 2025-03-14T03:51:42.0536497Z parser.add_argument( 2025-03-14T03:51:42.0536920Z "--github-ref-type", 2025-03-14T03:51:42.0537356Z type=str, 2025-03-14T03:51:42.0537737Z required=True, 2025-03-14T03:51:42.0538201Z help="Current GitHub ref type, branch or tag", 2025-03-14T03:51:42.0538736Z ) 2025-03-14T03:51:42.0539085Z parser.add_argument( 2025-03-14T03:51:42.0539527Z "--eligible-experiments", 2025-03-14T03:51:42.0540021Z type=_str_comma_separated_to_set, 2025-03-14T03:51:42.0540726Z required=False, 2025-03-14T03:51:42.0541141Z default="", 2025-03-14T03:51:42.0541973Z help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-03-14T03:51:42.0542888Z ) 2025-03-14T03:51:42.0543239Z parser.add_argument( 2025-03-14T03:51:42.0543688Z "--pr-number", 2025-03-14T03:51:42.0544088Z type=str, 2025-03-14T03:51:42.0544468Z required=False, 2025-03-14T03:51:42.0544874Z default="", 2025-03-14T03:51:42.0545319Z help="the optional PR number where this is run", 2025-03-14T03:51:42.0545856Z ) 2025-03-14T03:51:42.0546048Z 2025-03-14T03:51:42.0546226Z return parser.parse_args() 2025-03-14T03:51:42.0546529Z 2025-03-14T03:51:42.0546536Z 2025-03-14T03:51:42.0546948Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-03-14T03:51:42.0547763Z auth = Auth.Token(github_token) 2025-03-14T03:51:42.0548258Z return Github(auth=auth) 2025-03-14T03:51:42.0548690Z 2025-03-14T03:51:42.0548697Z 2025-03-14T03:51:42.0549149Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-03-14T03:51:42.0549942Z repo = gh.get_repo(repo) 2025-03-14T03:51:42.0550568Z return repo.get_issue(number=issue_num) 2025-03-14T03:51:42.0550932Z 2025-03-14T03:51:42.0550939Z 2025-03-14T03:51:42.0551131Z def get_potential_pr_author( 2025-03-14T03:51:42.0551756Z github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-03-14T03:51:42.0552411Z ) -> str: 2025-03-14T03:51:42.0552908Z # If the trigger was a new tag added by a bot, this is a ciflow case 2025-03-14T03:51:42.0553747Z # Fetch the actual username from the original PR. The PR number is 2025-03-14T03:51:42.0554533Z # embedded in the tag name: ciflow// 2025-03-14T03:51:42.0554945Z 2025-03-14T03:51:42.0555136Z gh = get_gh_client(github_token) 2025-03-14T03:51:42.0555459Z 2025-03-14T03:51:42.0555720Z if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-03-14T03:51:42.0556332Z split_tag = ref_name.split("/") 2025-03-14T03:51:42.0556868Z if ( 2025-03-14T03:51:42.0557262Z len(split_tag) == 3 2025-03-14T03:51:42.0557730Z and split_tag[0] == "ciflow" 2025-03-14T03:51:42.0558242Z and split_tag[2].isnumeric() 2025-03-14T03:51:42.0558713Z ): 2025-03-14T03:51:42.0559086Z pr_number = split_tag[2] 2025-03-14T03:51:42.0559567Z try: 2025-03-14T03:51:42.0559986Z repository = gh.get_repo(repo) 2025-03-14T03:51:42.0560682Z pull = repository.get_pull(number=int(pr_number)) 2025-03-14T03:51:42.0561262Z except Exception as e: 2025-03-14T03:51:42.0561766Z raise Exception( # noqa: TRY002 2025-03-14T03:51:42.0562553Z f"issue with pull request {pr_number} from repo {repository}" 2025-03-14T03:51:42.0563184Z ) from e 2025-03-14T03:51:42.0563723Z return pull.user.login # type: ignore[no-any-return] 2025-03-14T03:51:42.0564398Z # In all other cases, return the original input username 2025-03-14T03:51:42.0565013Z return username 2025-03-14T03:51:42.0565244Z 2025-03-14T03:51:42.0565250Z 2025-03-14T03:51:42.0565470Z def is_exception_branch(branch: str) -> bool: 2025-03-14T03:51:42.0565984Z """ 2025-03-14T03:51:42.0566610Z Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-03-14T03:51:42.0567364Z """ 2025-03-14T03:51:42.0567887Z return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-03-14T03:51:42.0568406Z 2025-03-14T03:51:42.0568412Z 2025-03-14T03:51:42.0568597Z def load_yaml(yaml_text: str) -> Any: 2025-03-14T03:51:42.0569084Z try: 2025-03-14T03:51:42.0569464Z data = yaml.safe_load(yaml_text) 2025-03-14T03:51:42.0569957Z return data 2025-03-14T03:51:42.0570475Z except yaml.YAMLError: 2025-03-14T03:51:42.0570949Z log.exception("Error loading YAML") 2025-03-14T03:51:42.0571451Z raise 2025-03-14T03:51:42.0571656Z 2025-03-14T03:51:42.0571663Z 2025-03-14T03:51:42.0572077Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-03-14T03:51:42.0572803Z """ 2025-03-14T03:51:42.0573393Z Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-03-14T03:51:42.0573988Z 2025-03-14T03:51:42.0574320Z If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:42.0575055Z and the text below is the list of opted in users. 2025-03-14T03:51:42.0575450Z 2025-03-14T03:51:42.0575816Z If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-03-14T03:51:42.0576500Z """ 2025-03-14T03:51:42.0576935Z rollout_state_parts = rollout_state.split("---") 2025-03-14T03:51:42.0577503Z if len(rollout_state_parts) >= 2: 2025-03-14T03:51:42.0578093Z return rollout_state_parts[0], rollout_state_parts[1] 2025-03-14T03:51:42.0578791Z else: 2025-03-14T03:51:42.0579160Z return "", rollout_state 2025-03-14T03:51:42.0579460Z 2025-03-14T03:51:42.0579466Z 2025-03-14T03:51:42.0579664Z class UserOptins(dict[str, list[str]]): 2025-03-14T03:51:42.0580156Z """ 2025-03-14T03:51:42.0580768Z Dictionary of users with a list of features they have opted into 2025-03-14T03:51:42.0581411Z """ 2025-03-14T03:51:42.0581603Z 2025-03-14T03:51:42.0581609Z 2025-03-14T03:51:42.0581931Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-03-14T03:51:42.0582559Z """ 2025-03-14T03:51:42.0583257Z Parse the user opt-in text into a key value pair of username and the list of features they have opted into 2025-03-14T03:51:42.0583925Z 2025-03-14T03:51:42.0584535Z Users are GitHub usernames with the @ prefix. Each user is also a comma-separated list of features/experiments to enable. 2025-03-14T03:51:42.0585507Z - Example line: "@User1,lf,split_build" 2025-03-14T03:51:42.0586166Z - A "#" prefix indicates the user is opted out of all experiments 2025-03-14T03:51:42.0586637Z 2025-03-14T03:51:42.0586643Z 2025-03-14T03:51:42.0586791Z """ 2025-03-14T03:51:42.0587152Z optins = UserOptins() 2025-03-14T03:51:42.0587622Z for user in user_optin_text.split("\n"): 2025-03-14T03:51:42.0588157Z user = user.strip("\r\n\t -") 2025-03-14T03:51:42.0588686Z if not user or not user.startswith("@"): 2025-03-14T03:51:42.0589226Z # Not a valid user. Skip 2025-03-14T03:51:42.0589689Z continue 2025-03-14T03:51:42.0589925Z 2025-03-14T03:51:42.0590081Z if user: 2025-03-14T03:51:42.0590626Z usr_name = user.split(",")[0].strip("@") 2025-03-14T03:51:42.0591310Z optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-03-14T03:51:42.0591920Z 2025-03-14T03:51:42.0592085Z return optins 2025-03-14T03:51:42.0592321Z 2025-03-14T03:51:42.0592327Z 2025-03-14T03:51:42.0592603Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-03-14T03:51:42.0593184Z """ 2025-03-14T03:51:42.0593560Z Check if the experiment name is valid. 2025-03-14T03:51:42.0594083Z A valid name: 2025-03-14T03:51:42.0594700Z - Contains only alphanumeric characters and the special characters "_" & "-" 2025-03-14T03:51:42.0595633Z - The special characters "_" & "-" shouldn't be the first or last characters 2025-03-14T03:51:42.0596334Z - Cannot contain spaces 2025-03-14T03:51:42.0596777Z """ 2025-03-14T03:51:42.0596970Z 2025-03-14T03:51:42.0597221Z valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-03-14T03:51:42.0597896Z valid = bool(re.match(valid_char_regex, experiment_name)) 2025-03-14T03:51:42.0598329Z 2025-03-14T03:51:42.0598488Z if valid: 2025-03-14T03:51:42.0598859Z return True 2025-03-14T03:51:42.0599086Z 2025-03-14T03:51:42.0599246Z log.error( 2025-03-14T03:51:42.0600783Z f"Invalid experiment name: {experiment_name}. Experiment names should only contain alphanumeric characters, '_', and '-'. They cannot contain spaces, and the special characters '_' and '-' cannot be the first or last characters." 2025-03-14T03:51:42.0602329Z ) 2025-03-14T03:51:42.0602677Z return False 2025-03-14T03:51:42.0602908Z 2025-03-14T03:51:42.0602914Z 2025-03-14T03:51:42.0603203Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-03-14T03:51:42.0603805Z """ 2025-03-14T03:51:42.0604422Z Parse the experiments from the issue body into a list of ExperimentSettings 2025-03-14T03:51:42.0605121Z """ 2025-03-14T03:51:42.0605450Z try: 2025-03-14T03:51:42.0605805Z if settings_text: 2025-03-14T03:51:42.0606504Z # Escape the backtick as well so that we can have the settings in a code block on the GH issue 2025-03-14T03:51:42.0607288Z # for easy reading 2025-03-14T03:51:42.0608054Z # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-03-14T03:51:42.0609067Z # the backtick character in shell commands. 2025-03-14T03:51:42.0609654Z backtick = chr(96) # backtick character 2025-03-14T03:51:42.0610300Z settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-03-14T03:51:42.0611053Z settings = load_yaml(settings_text) 2025-03-14T03:51:42.0611406Z 2025-03-14T03:51:42.0611803Z # For now we just load experiments. We can expand this if/when we add more settings 2025-03-14T03:51:42.0612533Z experiments = {} 2025-03-14T03:51:42.0612814Z 2025-03-14T03:51:42.0613156Z for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-03-14T03:51:42.0613896Z if not is_valid_experiment_name(exp_name): 2025-03-14T03:51:42.0614980Z # Exclude invalid experiments from the list. We log an error, but don't raise an exception so that other experiments can still be processed. 2025-03-14T03:51:42.0616008Z continue 2025-03-14T03:51:42.0616278Z 2025-03-14T03:51:42.0616454Z valid_settings = {} 2025-03-14T03:51:42.0616951Z for setting in exp_settings: 2025-03-14T03:51:42.0617491Z if setting not in Experiment._fields: 2025-03-14T03:51:42.0618021Z log.warning( 2025-03-14T03:51:42.0618701Z f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-03-14T03:51:42.0619408Z ) 2025-03-14T03:51:42.0619817Z else: 2025-03-14T03:51:42.0620301Z valid_settings[setting] = exp_settings[setting] 2025-03-14T03:51:42.0620807Z 2025-03-14T03:51:42.0621073Z experiments[exp_name] = Experiment(**valid_settings) 2025-03-14T03:51:42.0621800Z return Settings(experiments) 2025-03-14T03:51:42.0622155Z 2025-03-14T03:51:42.0622321Z except Exception: 2025-03-14T03:51:42.0622787Z log.exception("Failed to parse settings") 2025-03-14T03:51:42.0623162Z 2025-03-14T03:51:42.0623328Z return Settings() 2025-03-14T03:51:42.0623596Z 2025-03-14T03:51:42.0623602Z 2025-03-14T03:51:42.0623860Z def parse_settings(rollout_state: str) -> Settings: 2025-03-14T03:51:42.0624404Z """ 2025-03-14T03:51:42.0624809Z Parse settings, if any, from the rollout state. 2025-03-14T03:51:42.0625195Z 2025-03-14T03:51:42.0625532Z If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:42.0626259Z and the text below is the list of opted in users. 2025-03-14T03:51:42.0626639Z 2025-03-14T03:51:42.0627071Z If it doesn't contain "---" then the settings are empty and the default values are used. 2025-03-14T03:51:42.0627773Z """ 2025-03-14T03:51:42.0628312Z settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:42.0629041Z return parse_settings_from_text(settings_text) 2025-03-14T03:51:42.0629427Z 2025-03-14T03:51:42.0629440Z 2025-03-14T03:51:42.0629681Z def parse_users(rollout_state: str) -> UserOptins: 2025-03-14T03:51:42.0630223Z """ 2025-03-14T03:51:42.0630695Z Parse users from the rollout state. 2025-03-14T03:51:42.0631035Z 2025-03-14T03:51:42.0631181Z """ 2025-03-14T03:51:42.0631686Z _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:42.0632385Z return parse_user_opt_in_from_text(users_text) 2025-03-14T03:51:42.0632763Z 2025-03-14T03:51:42.0632770Z 2025-03-14T03:51:42.0633173Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:42.0633899Z """ 2025-03-14T03:51:42.0634285Z Check if a user is opted into an experiment 2025-03-14T03:51:42.0634797Z """ 2025-03-14T03:51:42.0635219Z return experiment_name in user_optins.get(user, []) 2025-03-14T03:51:42.0635633Z 2025-03-14T03:51:42.0635645Z 2025-03-14T03:51:42.0636058Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:42.0636917Z """ 2025-03-14T03:51:42.0637351Z Check if a user explicitly opted out of an experiment 2025-03-14T03:51:42.0637928Z """ 2025-03-14T03:51:42.0638429Z # if the experiment is prefixed with a "-", then it's an opt-out 2025-03-14T03:51:42.0639091Z experiment_optout = "-" + experiment_name 2025-03-14T03:51:42.0639708Z if experiment_optout not in user_optins.get(user, []): 2025-03-14T03:51:42.0640292Z return False 2025-03-14T03:51:42.0640633Z 2025-03-14T03:51:42.0640893Z if is_user_opted_in(user, user_optins, experiment_name): 2025-03-14T03:51:42.0641467Z log.warning( 2025-03-14T03:51:42.0642237Z f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-03-14T03:51:42.0643079Z ) 2025-03-14T03:51:42.0643276Z 2025-03-14T03:51:42.0643435Z return True 2025-03-14T03:51:42.0643651Z 2025-03-14T03:51:42.0643657Z 2025-03-14T03:51:42.0643831Z def get_runner_prefix( 2025-03-14T03:51:42.0644254Z rollout_state: str, 2025-03-14T03:51:42.0644690Z workflow_requestors: Iterable[str], 2025-03-14T03:51:42.0645172Z branch: str, 2025-03-14T03:51:42.0645635Z eligible_experiments: frozenset[str] = frozenset(), 2025-03-14T03:51:42.0646197Z is_canary: bool = False, 2025-03-14T03:51:42.0646622Z ) -> str: 2025-03-14T03:51:42.0647014Z settings = parse_settings(rollout_state) 2025-03-14T03:51:42.0647559Z user_optins = parse_users(rollout_state) 2025-03-14T03:51:42.0647912Z 2025-03-14T03:51:42.0648081Z fleet_prefix = "" 2025-03-14T03:51:42.0648503Z prefixes = [] 2025-03-14T03:51:42.0649093Z for experiment_name, experiment_settings in settings.experiments.items(): 2025-03-14T03:51:42.0649991Z if not experiment_settings.all_branches and is_exception_branch(branch): 2025-03-14T03:51:42.0650892Z log.info( 2025-03-14T03:51:42.0651547Z f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-03-14T03:51:42.0652270Z ) 2025-03-14T03:51:42.0652627Z continue 2025-03-14T03:51:42.0652865Z 2025-03-14T03:51:42.0653042Z if eligible_experiments: 2025-03-14T03:51:42.0653578Z if experiment_name not in eligible_experiments: 2025-03-14T03:51:42.0654184Z exp_list = ", ".join(eligible_experiments) 2025-03-14T03:51:42.0654715Z log.info( 2025-03-14T03:51:42.0655459Z f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-03-14T03:51:42.0656279Z ) 2025-03-14T03:51:42.0656659Z continue 2025-03-14T03:51:42.0657136Z elif not experiment_settings.default: 2025-03-14T03:51:42.0657651Z log.info( 2025-03-14T03:51:42.0658276Z f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-03-14T03:51:42.0658983Z ) 2025-03-14T03:51:42.0659343Z continue 2025-03-14T03:51:42.0659584Z 2025-03-14T03:51:42.0659850Z # Is any workflow_requestor opted out to this experiment? 2025-03-14T03:51:42.0660551Z opted_out_users = [ 2025-03-14T03:51:42.0660977Z requestor 2025-03-14T03:51:42.0661406Z for requestor in workflow_requestors 2025-03-14T03:51:42.0662048Z if is_user_opted_out(requestor, user_optins, experiment_name) 2025-03-14T03:51:42.0662654Z ] 2025-03-14T03:51:42.0662847Z 2025-03-14T03:51:42.0663016Z if opted_out_users: 2025-03-14T03:51:42.0663449Z log.info( 2025-03-14T03:51:42.0664042Z f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-03-14T03:51:42.0664752Z ) 2025-03-14T03:51:42.0665101Z continue 2025-03-14T03:51:42.0665330Z 2025-03-14T03:51:42.0665595Z # Is any workflow_requestor opted in to this experiment? 2025-03-14T03:51:42.0666194Z opted_in_users = [ 2025-03-14T03:51:42.0666606Z requestor 2025-03-14T03:51:42.0667168Z for requestor in workflow_requestors 2025-03-14T03:51:42.0667805Z if is_user_opted_in(requestor, user_optins, experiment_name) 2025-03-14T03:51:42.0668403Z ] 2025-03-14T03:51:42.0668594Z 2025-03-14T03:51:42.0668763Z enabled = False 2025-03-14T03:51:42.0669170Z if opted_in_users: 2025-03-14T03:51:42.0669590Z log.info( 2025-03-14T03:51:42.0670163Z f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-03-14T03:51:42.0670914Z ) 2025-03-14T03:51:42.0671279Z enabled = True 2025-03-14T03:51:42.0671546Z 2025-03-14T03:51:42.0671752Z elif experiment_settings.rollout_perc: 2025-03-14T03:51:42.0672554Z # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-03-14T03:51:42.0673459Z if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-03-14T03:51:42.0674087Z log.info( 2025-03-14T03:51:42.0674932Z f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-03-14T03:51:42.0675821Z ) 2025-03-14T03:51:42.0676201Z enabled = True 2025-03-14T03:51:42.0676487Z 2025-03-14T03:51:42.0676641Z if enabled: 2025-03-14T03:51:42.0677035Z label = experiment_name 2025-03-14T03:51:42.0677564Z if experiment_name == LF_FLEET_EXPERIMENT: 2025-03-14T03:51:42.0678352Z # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-03-14T03:51:42.0679192Z # - If it's enabled, then we always list it's prefix first 2025-03-14T03:51:42.0680031Z # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-03-14T03:51:42.0680791Z if is_canary: 2025-03-14T03:51:42.0681300Z label += CANARY_FLEET_SUFFIX 2025-03-14T03:51:42.0681829Z fleet_prefix = label 2025-03-14T03:51:42.0682290Z else: 2025-03-14T03:51:42.0682690Z prefixes.append(label) 2025-03-14T03:51:42.0683036Z 2025-03-14T03:51:42.0683211Z if len(prefixes) > 1: 2025-03-14T03:51:42.0683625Z log.error( 2025-03-14T03:51:42.0684628Z f"Only a fleet and one other experiment can be enabled for a job at any time. Enabling {prefixes[0]} and ignoring the rest, which are {', '.join(prefixes[1:])}" 2025-03-14T03:51:42.0685717Z ) 2025-03-14T03:51:42.0686072Z prefixes = prefixes[:1] 2025-03-14T03:51:42.0686374Z 2025-03-14T03:51:42.0686546Z # Fleet always comes first 2025-03-14T03:51:42.0686993Z if fleet_prefix: 2025-03-14T03:51:42.0687422Z prefixes.insert(0, fleet_prefix) 2025-03-14T03:51:42.0687767Z 2025-03-14T03:51:42.0688012Z return ".".join(prefixes) + "." if prefixes else "" 2025-03-14T03:51:42.0688410Z 2025-03-14T03:51:42.0688416Z 2025-03-14T03:51:42.0688853Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-03-14T03:51:42.0689594Z """ 2025-03-14T03:51:42.0690152Z Gets the first comment of the issue, which contains the desired rollout state. 2025-03-14T03:51:42.0690793Z 2025-03-14T03:51:42.0691164Z The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-03-14T03:51:42.0691838Z """ 2025-03-14T03:51:42.0692203Z gh = get_gh_client(github_token) 2025-03-14T03:51:42.0692715Z issue = get_issue(gh, repo, issue_num) 2025-03-14T03:51:42.0693320Z return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-03-14T03:51:42.0693750Z 2025-03-14T03:51:42.0693756Z 2025-03-14T03:51:42.0694137Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-03-14T03:51:42.0694867Z for _ in range(num_retries): 2025-03-14T03:51:42.0695320Z try: 2025-03-14T03:51:42.0695721Z req = Request(url=url, headers=headers) 2025-03-14T03:51:42.0696362Z content = urlopen(req, timeout=5).read().decode("utf-8") 2025-03-14T03:51:42.0697161Z return json.loads(content) 2025-03-14T03:51:42.0697664Z except Exception as e: 2025-03-14T03:51:42.0698179Z log.warning(f"Could not download {url}: {e}") 2025-03-14T03:51:42.0698564Z 2025-03-14T03:51:42.0698936Z log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-03-14T03:51:42.0699624Z return {} 2025-03-14T03:51:42.0699832Z 2025-03-14T03:51:42.0699839Z 2025-03-14T03:51:42.0699986Z @cache 2025-03-14T03:51:42.0700673Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-03-14T03:51:42.0701400Z """ 2025-03-14T03:51:42.0701768Z Dynamically get PR information 2025-03-14T03:51:42.0702231Z """ 2025-03-14T03:51:42.0702698Z github_api = f"https://api.github.com/repos/{github_repo}" 2025-03-14T03:51:42.0703297Z headers = { 2025-03-14T03:51:42.0704061Z "Accept": "application/vnd.github.v3+json", 2025-03-14T03:51:42.0704671Z "Authorization": f"token {github_token}", 2025-03-14T03:51:42.0705190Z } 2025-03-14T03:51:42.0705591Z json_response: dict[str, Any] = download_json( 2025-03-14T03:51:42.0706167Z url=f"{github_api}/issues/{pr_number}", 2025-03-14T03:51:42.0706695Z headers=headers, 2025-03-14T03:51:42.0707102Z ) 2025-03-14T03:51:42.0707291Z 2025-03-14T03:51:42.0707469Z if not json_response: 2025-03-14T03:51:42.0708004Z log.warning(f"Failed to get the labels for #{pr_number}") 2025-03-14T03:51:42.0708598Z return {} 2025-03-14T03:51:42.0708825Z 2025-03-14T03:51:42.0708992Z return json_response 2025-03-14T03:51:42.0709255Z 2025-03-14T03:51:42.0709268Z 2025-03-14T03:51:42.0709648Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-03-14T03:51:42.0710582Z """ 2025-03-14T03:51:42.0711122Z Dynamically get the latest list of labels from the pull request 2025-03-14T03:51:42.0711753Z """ 2025-03-14T03:51:42.0712216Z pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-03-14T03:51:42.0712797Z return { 2025-03-14T03:51:42.0713359Z label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-03-14T03:51:42.0714031Z } 2025-03-14T03:51:42.0714214Z 2025-03-14T03:51:42.0714221Z 2025-03-14T03:51:42.0714389Z def main() -> None: 2025-03-14T03:51:42.0714788Z args = parse_args() 2025-03-14T03:51:42.0715051Z 2025-03-14T03:51:42.0715260Z runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-03-14T03:51:42.0715624Z 2025-03-14T03:51:42.0715814Z # Check if the PR is opt-out 2025-03-14T03:51:42.0716280Z if args.pr_number: 2025-03-14T03:51:42.0716900Z labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-03-14T03:51:42.0717634Z if OPT_OUT_LABEL in labels: 2025-03-14T03:51:42.0718110Z log.info( 2025-03-14T03:51:42.0718763Z f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-03-14T03:51:42.0719503Z ) 2025-03-14T03:51:42.0720023Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:42.0720776Z sys.exit() 2025-03-14T03:51:42.0721027Z 2025-03-14T03:51:42.0721175Z try: 2025-03-14T03:51:42.0721592Z rollout_state = get_rollout_state_from_issue( 2025-03-14T03:51:42.0722262Z args.github_token, args.github_issue_repo, args.github_issue 2025-03-14T03:51:42.0722880Z ) 2025-03-14T03:51:42.0723075Z 2025-03-14T03:51:42.0723268Z username = get_potential_pr_author( 2025-03-14T03:51:42.0723793Z args.github_token, 2025-03-14T03:51:42.0724253Z args.github_repo, 2025-03-14T03:51:42.0724704Z args.github_actor, 2025-03-14T03:51:42.0725165Z args.github_ref_type, 2025-03-14T03:51:42.0725632Z args.github_branch, 2025-03-14T03:51:42.0726069Z ) 2025-03-14T03:51:42.0726272Z 2025-03-14T03:51:42.0726537Z is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-03-14T03:51:42.0727122Z 2025-03-14T03:51:42.0727331Z runner_label_prefix = get_runner_prefix( 2025-03-14T03:51:42.0727858Z rollout_state, 2025-03-14T03:51:42.0728311Z (args.github_issue_owner, username), 2025-03-14T03:51:42.0728833Z args.github_branch, 2025-03-14T03:51:42.0729311Z args.eligible_experiments, 2025-03-14T03:51:42.0729803Z is_canary, 2025-03-14T03:51:42.0730190Z ) 2025-03-14T03:51:42.0730484Z 2025-03-14T03:51:42.0730654Z except Exception as e: 2025-03-14T03:51:42.0731085Z log.error( 2025-03-14T03:51:42.0731725Z f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-03-14T03:51:42.0732465Z ) 2025-03-14T03:51:42.0732660Z 2025-03-14T03:51:42.0732987Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:42.0733465Z 2025-03-14T03:51:42.0733472Z 2025-03-14T03:51:42.0733645Z if __name__ == "__main__": 2025-03-14T03:51:42.0734057Z main() 2025-03-14T03:51:42.0734259Z 2025-03-14T03:51:42.0824646Z ##[group]Run python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-03-14T03:51:42.0825522Z python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-03-14T03:51:42.0871988Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:42.0872455Z env: 2025-03-14T03:51:42.0873047Z GITHUB_TOKEN: *** 2025-03-14T03:51:42.0873452Z ISSUE_NUMBER: 5132 2025-03-14T03:51:42.0873886Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:42.0874384Z ISSUE_OWNER: 2025-03-14T03:51:42.0874768Z CHECK_EXPERIMENTS: 2025-03-14T03:51:42.0875169Z PR_NUMBER: 2025-03-14T03:51:42.0875543Z ##[endgroup] 2025-03-14T03:51:42.4808262Z Defaulting to user installation because normal site-packages is not writeable 2025-03-14T03:51:42.8703811Z Collecting urllib3==1.26.18 2025-03-14T03:51:42.9167534Z Downloading urllib3-1.26.18-py2.py3-none-any.whl.metadata (48 kB) 2025-03-14T03:51:42.9382677Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 kB 3.8 MB/s eta 0:00:00 2025-03-14T03:51:42.9677638Z Collecting PyGithub==2.3.0 2025-03-14T03:51:42.9759328Z Downloading PyGithub-2.3.0-py3-none-any.whl.metadata (3.8 kB) 2025-03-14T03:51:43.0241390Z Collecting pynacl>=1.4.0 (from PyGithub==2.3.0) 2025-03-14T03:51:43.0321092Z 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.0371853Z 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.0391446Z 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.0408038Z 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.0695370Z Collecting Deprecated (from PyGithub==2.3.0) 2025-03-14T03:51:43.0770839Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl.metadata (5.7 kB) 2025-03-14T03:51:43.1007650Z 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.2187512Z Collecting cffi>=1.4.1 (from pynacl>=1.4.0->PyGithub==2.3.0) 2025-03-14T03:51:43.2271822Z 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.3364670Z Collecting wrapt<2,>=1.10 (from Deprecated->PyGithub==2.3.0) 2025-03-14T03:51:43.3446770Z 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.3688976Z Collecting pycparser (from cffi>=1.4.1->pynacl>=1.4.0->PyGithub==2.3.0) 2025-03-14T03:51:43.3761754Z Downloading pycparser-2.22-py3-none-any.whl.metadata (943 bytes) 2025-03-14T03:51:43.4039375Z Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB) 2025-03-14T03:51:43.4177201Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.8/143.8 kB 11.4 MB/s eta 0:00:00 2025-03-14T03:51:43.4304141Z Downloading PyGithub-2.3.0-py3-none-any.whl (354 kB) 2025-03-14T03:51:43.4572416Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 354.4/354.4 kB 14.1 MB/s eta 0:00:00 2025-03-14T03:51:43.4659553Z 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.5205780Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 856.7/856.7 kB 16.2 MB/s eta 0:00:00 2025-03-14T03:51:43.5285066Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl (10.0 kB) 2025-03-14T03:51:43.5392644Z Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479 kB) 2025-03-14T03:51:43.5649703Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 479.4/479.4 kB 20.2 MB/s eta 0:00:00 2025-03-14T03:51:43.5732295Z 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.5789628Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 89.2/89.2 kB 24.5 MB/s eta 0:00:00 2025-03-14T03:51:43.5867517Z Downloading pycparser-2.22-py3-none-any.whl (117 kB) 2025-03-14T03:51:43.5944398Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.6/117.6 kB 21.8 MB/s eta 0:00:00 2025-03-14T03:51:43.8834442Z Installing collected packages: wrapt, urllib3, pycparser, Deprecated, cffi, pynacl, PyGithub 2025-03-14T03:51:44.4145463Z 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.4958152Z ##[group]Run curr_branch="main" 2025-03-14T03:51:44.4958527Z curr_branch="main" 2025-03-14T03:51:44.4958802Z curr_ref_type="branch" 2025-03-14T03:51:44.4959103Z echo "Current branch is '$curr_branch'" 2025-03-14T03:51:44.4959414Z  2025-03-14T03:51:44.4959662Z python3 runner_determinator.py \ 2025-03-14T03:51:44.4959999Z  --github-token "$GITHUB_TOKEN" \ 2025-03-14T03:51:44.4960569Z  --github-issue "$ISSUE_NUMBER" \ 2025-03-14T03:51:44.4961050Z  --github-branch "$curr_branch" \ 2025-03-14T03:51:44.4961376Z  --github-actor "$TRIGGERING_ACTOR" \ 2025-03-14T03:51:44.4961714Z  --github-issue-owner "$ISSUE_OWNER" \ 2025-03-14T03:51:44.4962052Z  --github-ref-type "$curr_ref_type" \ 2025-03-14T03:51:44.4962392Z  --github-repo "$GITHUB_REPOSITORY" \ 2025-03-14T03:51:44.4962782Z  --eligible-experiments "$CHECK_EXPERIMENTS" \ 2025-03-14T03:51:44.4963174Z  --pr-number "${PR_NUMBER}" 2025-03-14T03:51:44.5011221Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:44.5011511Z env: 2025-03-14T03:51:44.5012172Z GITHUB_TOKEN: *** 2025-03-14T03:51:44.5012420Z ISSUE_NUMBER: 5132 2025-03-14T03:51:44.5012676Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:44.5012959Z ISSUE_OWNER: 2025-03-14T03:51:44.5013199Z CHECK_EXPERIMENTS: 2025-03-14T03:51:44.5013454Z PR_NUMBER: 2025-03-14T03:51:44.5013685Z ##[endgroup] 2025-03-14T03:51:44.5083783Z Current branch is 'main' 2025-03-14T03:51:45.8348735Z INFO : Based on rollout percentage of 50%, enabling experiment lf. 2025-03-14T03:51:45.8350140Z INFO : Branch main is an exception branch. Not enabling experiment ephemeral. 2025-03-14T03:51:45.8351385Z INFO : Setting output: label-type='lf.' 2025-03-14T03:51:45.8671088Z Evaluate and set job outputs 2025-03-14T03:51:45.8677892Z Set output 'label-type' 2025-03-14T03:51:45.8679728Z Cleaning up orphan processes