2025-03-14T03:51:41.4302692Z Current runner version: '2.322.0' 2025-03-14T03:51:41.4325859Z ##[group]Operating System 2025-03-14T03:51:41.4326703Z Ubuntu 2025-03-14T03:51:41.4327230Z 24.04.2 2025-03-14T03:51:41.4327728Z LTS 2025-03-14T03:51:41.4328206Z ##[endgroup] 2025-03-14T03:51:41.4328756Z ##[group]Runner Image 2025-03-14T03:51:41.4329327Z Image: ubuntu-24.04 2025-03-14T03:51:41.4329908Z Version: 20250309.1.0 2025-03-14T03:51:41.4330941Z Included Software: https://github.com/actions/runner-images/blob/ubuntu24/20250309.1/images/ubuntu/Ubuntu2404-Readme.md 2025-03-14T03:51:41.4332567Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu24%2F20250309.1 2025-03-14T03:51:41.4333518Z ##[endgroup] 2025-03-14T03:51:41.4334072Z ##[group]Runner Image Provisioner 2025-03-14T03:51:41.4334654Z 2.0.422.1 2025-03-14T03:51:41.4335216Z ##[endgroup] 2025-03-14T03:51:41.4336302Z ##[group]GITHUB_TOKEN Permissions 2025-03-14T03:51:41.4338123Z Contents: read 2025-03-14T03:51:41.4338687Z Metadata: read 2025-03-14T03:51:41.4339483Z Packages: read 2025-03-14T03:51:41.4340074Z ##[endgroup] 2025-03-14T03:51:41.4343469Z Secret source: Actions 2025-03-14T03:51:41.4344392Z Prepare workflow directory 2025-03-14T03:51:41.4823120Z Prepare all required actions 2025-03-14T03:51:41.4876883Z Uses: pytorch/pytorch/.github/workflows/_runner-determinator.yml@refs/heads/main (aed0b7a742a2d7b7901790622829cbd2135049a4) 2025-03-14T03:51:41.4882368Z ##[group] Inputs 2025-03-14T03:51:41.4883014Z check_experiments: 2025-03-14T03:51:41.4883634Z triggering_actor: pytorchmergebot 2025-03-14T03:51:41.4884317Z issue_owner: 2025-03-14T03:51:41.4884817Z curr_branch: main 2025-03-14T03:51:41.4885381Z curr_ref_type: branch 2025-03-14T03:51:41.4885990Z issue_number: 5132 2025-03-14T03:51:41.4886529Z ##[endgroup] 2025-03-14T03:51:41.4887134Z Complete job name: get-label-type / runner-determinator 2025-03-14T03:51:41.5686930Z ##[group]Run cat < runner_determinator.py 2025-03-14T03:51:41.5689115Z cat < runner_determinator.py 2025-03-14T03:51:41.5690061Z # flake8: noqa: G004 2025-03-14T03:51:41.5690567Z  2025-03-14T03:51:41.5691809Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-03-14T03:51:41.5693467Z # must be kept in sync. You can do it easily by running the following command: 2025-03-14T03:51:41.5694879Z # python .github/scripts/update_runner_determinator.py 2025-03-14T03:51:41.5695627Z  2025-03-14T03:51:41.5696233Z """ 2025-03-14T03:51:41.5697284Z This runner determinator is used to determine which set of runners to run a 2025-03-14T03:51:41.5698853Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-03-14T03:51:41.5700390Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-03-14T03:51:41.5701862Z of which runners should be used to run which job. 2025-03-14T03:51:41.5702860Z  2025-03-14T03:51:41.5703902Z The configuration has two parts, the settings and a list of opted-in users, 2025-03-14T03:51:41.5705420Z separated by a line containing "---". If the line is not present, the 2025-03-14T03:51:41.5706726Z settings are considered to be empty with only the second part, the user 2025-03-14T03:51:41.5707982Z list, defined. 2025-03-14T03:51:41.5708697Z  2025-03-14T03:51:41.5709690Z The first part is a YAML block that defines the rollout settings. This can be 2025-03-14T03:51:41.5710961Z used to define any settings that are needed to determine which runners to use. 2025-03-14T03:51:41.5712670Z It's fields are defined by the RolloutSettings class below. 2025-03-14T03:51:41.5713746Z  2025-03-14T03:51:41.5714766Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-03-14T03:51:41.5715968Z The user list is also a comma separated list of additional features or 2025-03-14T03:51:41.5717795Z experiments which the user could be opted in to. 2025-03-14T03:51:41.5718805Z  2025-03-14T03:51:41.5719510Z The user list has the following rules: 2025-03-14T03:51:41.5720411Z  2025-03-14T03:51:41.5720986Z - Users are GitHub usernames, which must start with the @ prefix 2025-03-14T03:51:41.5722623Z - Each user is also a comma-separated list of features/experiments to enable 2025-03-14T03:51:41.5724011Z - A "#" prefix opts the user out of all experiments 2025-03-14T03:51:41.5724995Z  2025-03-14T03:51:41.5725635Z Example config: 2025-03-14T03:51:41.5726191Z  # A list of experiments that can be opted into. 2025-03-14T03:51:41.5727397Z  # This defines the behavior they'll induce when opted into. 2025-03-14T03:51:41.5728537Z  # Expected syntax is: 2025-03-14T03:51:41.5729744Z  # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-03-14T03:51:41.5731162Z  # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-03-14T03:51:41.5732606Z  2025-03-14T03:51:41.5733258Z  experiments: 2025-03-14T03:51:41.5734015Z  lf: 2025-03-14T03:51:41.5734712Z  rollout_percent: 25 2025-03-14T03:51:41.5735580Z  all_branches: false 2025-03-14T03:51:41.5736243Z  default: true 2025-03-14T03:51:41.5736925Z  --- 2025-03-14T03:51:41.5737587Z  2025-03-14T03:51:41.5738208Z  # Opt-ins: 2025-03-14T03:51:41.5739305Z  # Users can opt into the LF fleet by adding their GitHub username to this list 2025-03-14T03:51:41.5741037Z  # and specifying experiments to enable in a comma-separated list. 2025-03-14T03:51:41.5742404Z  # To always opt out of an experiment, prefix it with a "-". 2025-03-14T03:51:41.5743624Z  # Experiments should be from the above list. 2025-03-14T03:51:41.5744584Z  2025-03-14T03:51:41.5745232Z  @User1,-lf,split_build 2025-03-14T03:51:41.5746039Z  @User2,lf 2025-03-14T03:51:41.5746492Z  @User3,split_build 2025-03-14T03:51:41.5747225Z """ 2025-03-14T03:51:41.5747858Z  2025-03-14T03:51:41.5748482Z import json 2025-03-14T03:51:41.5749201Z import logging 2025-03-14T03:51:41.5749934Z import os 2025-03-14T03:51:41.5750630Z import random 2025-03-14T03:51:41.5751219Z import re 2025-03-14T03:51:41.5751863Z import sys 2025-03-14T03:51:41.5752735Z from argparse import ArgumentParser 2025-03-14T03:51:41.5753727Z from collections.abc import Iterable 2025-03-14T03:51:41.5754698Z from functools import cache 2025-03-14T03:51:41.5755588Z from logging import LogRecord 2025-03-14T03:51:41.5756386Z from typing import Any, NamedTuple 2025-03-14T03:51:41.5757024Z from urllib.request import Request, urlopen 2025-03-14T03:51:41.5757986Z  2025-03-14T03:51:41.5758617Z import yaml 2025-03-14T03:51:41.5759373Z from github import Auth, Github 2025-03-14T03:51:41.5760296Z from github.Issue import Issue 2025-03-14T03:51:41.5761143Z  2025-03-14T03:51:41.5761745Z  2025-03-14T03:51:41.5762365Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-03-14T03:51:41.5763634Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-03-14T03:51:41.5765186Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-03-14T03:51:41.5766439Z  2025-03-14T03:51:41.5766918Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-03-14T03:51:41.5767880Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-03-14T03:51:41.5768848Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-03-14T03:51:41.5770118Z OPT_OUT_LABEL = "no-runner-experiments" 2025-03-14T03:51:41.5771047Z  2025-03-14T03:51:41.5771755Z SETTING_EXPERIMENTS = "experiments" 2025-03-14T03:51:41.5772484Z  2025-03-14T03:51:41.5773139Z LF_FLEET_EXPERIMENT = "lf" 2025-03-14T03:51:41.5774014Z CANARY_FLEET_SUFFIX = ".c" 2025-03-14T03:51:41.5774821Z  2025-03-14T03:51:41.5775422Z  2025-03-14T03:51:41.5776098Z class Experiment(NamedTuple): 2025-03-14T03:51:41.5776798Z  rollout_perc: float = ( 2025-03-14T03:51:41.5777864Z  0 # Percentage of workflows to experiment on when user is not opted-in. 2025-03-14T03:51:41.5779074Z  ) 2025-03-14T03:51:41.5779753Z  all_branches: bool = ( 2025-03-14T03:51:41.5780940Z  False # If True, the experiment is also enabled on the exception branches 2025-03-14T03:51:41.5782015Z  ) 2025-03-14T03:51:41.5782727Z  default: bool = ( 2025-03-14T03:51:41.5783806Z  True # If True, the experiment is enabled by default for all queries 2025-03-14T03:51:41.5784957Z  ) 2025-03-14T03:51:41.5785602Z  2025-03-14T03:51:41.5786267Z  # Add more fields as needed 2025-03-14T03:51:41.5786816Z  2025-03-14T03:51:41.5787344Z  2025-03-14T03:51:41.5788006Z class Settings(NamedTuple): 2025-03-14T03:51:41.5788844Z  """ 2025-03-14T03:51:41.5789711Z  Settings for the experiments that can be opted into. 2025-03-14T03:51:41.5790748Z  """ 2025-03-14T03:51:41.5791390Z  2025-03-14T03:51:41.5791964Z  experiments: dict[str, Experiment] = {} 2025-03-14T03:51:41.5792884Z  2025-03-14T03:51:41.5793718Z  2025-03-14T03:51:41.5794468Z class ColorFormatter(logging.Formatter): 2025-03-14T03:51:41.5795625Z  """Color codes the log messages based on the log level""" 2025-03-14T03:51:41.5796579Z  2025-03-14T03:51:41.5796946Z  COLORS = { 2025-03-14T03:51:41.5797725Z  "WARNING": "\033[33m", # Yellow 2025-03-14T03:51:41.5798661Z  "ERROR": "\033[31m", # Red 2025-03-14T03:51:41.5799575Z  "CRITICAL": "\033[31m", # Red 2025-03-14T03:51:41.5800495Z  "INFO": "\033[0m", # Reset 2025-03-14T03:51:41.5801394Z  "DEBUG": "\033[0m", # Reset 2025-03-14T03:51:41.5802145Z  } 2025-03-14T03:51:41.5802811Z  2025-03-14T03:51:41.5803562Z  def format(self, record: LogRecord) -> str: 2025-03-14T03:51:41.5804908Z  log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-03-14T03:51:41.5806301Z  record.msg = f"{log_color}{record.msg}\033[0m" 2025-03-14T03:51:41.5806967Z  return super().format(record) 2025-03-14T03:51:41.5807533Z  2025-03-14T03:51:41.5808161Z  2025-03-14T03:51:41.5808845Z handler = logging.StreamHandler() 2025-03-14T03:51:41.5810160Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-03-14T03:51:41.5811433Z  2025-03-14T03:51:41.5812271Z log = logging.getLogger(os.path.basename(__file__)) 2025-03-14T03:51:41.5812909Z log.addHandler(handler) 2025-03-14T03:51:41.5813730Z log.setLevel(logging.INFO) 2025-03-14T03:51:41.5814561Z  2025-03-14T03:51:41.5815173Z  2025-03-14T03:51:41.5815988Z def set_github_output(key: str, value: str) -> None: 2025-03-14T03:51:41.5817012Z  """ 2025-03-14T03:51:41.5817748Z  Defines outputs of the github action that invokes this script 2025-03-14T03:51:41.5818700Z  """ 2025-03-14T03:51:41.5819395Z  if not GITHUB_OUTPUT: 2025-03-14T03:51:41.5821308Z  # 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.5823226Z  log.warning( 2025-03-14T03:51:41.5824798Z  "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.5826430Z  ) 2025-03-14T03:51:41.5827223Z  print(f"::set-output name={key}::{value}") 2025-03-14T03:51:41.5827977Z  return 2025-03-14T03:51:41.5828431Z  2025-03-14T03:51:41.5829140Z  with open(GITHUB_OUTPUT, "a") as f: 2025-03-14T03:51:41.5830178Z  log.info(f"Setting output: {key}='{value}'") 2025-03-14T03:51:41.5831186Z  f.write(f"{key}={value}\n") 2025-03-14T03:51:41.5832224Z  2025-03-14T03:51:41.5832835Z  2025-03-14T03:51:41.5833423Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-03-14T03:51:41.5834551Z  return frozenset( 2025-03-14T03:51:41.5835724Z  filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-03-14T03:51:41.5836928Z  ) 2025-03-14T03:51:41.5837576Z  2025-03-14T03:51:41.5838104Z  2025-03-14T03:51:41.5838494Z def parse_args() -> Any: 2025-03-14T03:51:41.5839485Z  parser = ArgumentParser("Get dynamic rollout settings") 2025-03-14T03:51:41.5841024Z  parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-03-14T03:51:41.5842536Z  parser.add_argument( 2025-03-14T03:51:41.5843319Z  "--github-issue-repo", 2025-03-14T03:51:41.5843876Z  type=str, 2025-03-14T03:51:41.5844657Z  required=False, 2025-03-14T03:51:41.5845712Z  default="pytorch/test-infra", 2025-03-14T03:51:41.5846715Z  help="GitHub repo to get the issue", 2025-03-14T03:51:41.5847639Z  ) 2025-03-14T03:51:41.5848283Z  parser.add_argument( 2025-03-14T03:51:41.5848801Z  "--github-repo", 2025-03-14T03:51:41.5849613Z  type=str, 2025-03-14T03:51:41.5850387Z  required=True, 2025-03-14T03:51:41.5851285Z  help="GitHub repo where CI is running", 2025-03-14T03:51:41.5852366Z  ) 2025-03-14T03:51:41.5853055Z  parser.add_argument( 2025-03-14T03:51:41.5853864Z  "--github-issue", type=int, required=True, help="GitHub issue number" 2025-03-14T03:51:41.5854551Z  ) 2025-03-14T03:51:41.5854962Z  parser.add_argument( 2025-03-14T03:51:41.5855703Z  "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-03-14T03:51:41.5856424Z  ) 2025-03-14T03:51:41.5856829Z  parser.add_argument( 2025-03-14T03:51:41.5857511Z  "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-03-14T03:51:41.5858217Z  ) 2025-03-14T03:51:41.5858651Z  parser.add_argument( 2025-03-14T03:51:41.5859394Z  "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-03-14T03:51:41.5860118Z  ) 2025-03-14T03:51:41.5860516Z  parser.add_argument( 2025-03-14T03:51:41.5861037Z  "--github-ref-type", 2025-03-14T03:51:41.5861536Z  type=str, 2025-03-14T03:51:41.5862204Z  required=True, 2025-03-14T03:51:41.5862759Z  help="Current GitHub ref type, branch or tag", 2025-03-14T03:51:41.5863324Z  ) 2025-03-14T03:51:41.5863729Z  parser.add_argument( 2025-03-14T03:51:41.5864236Z  "--eligible-experiments", 2025-03-14T03:51:41.5864823Z  type=_str_comma_separated_to_set, 2025-03-14T03:51:41.5865380Z  required=False, 2025-03-14T03:51:41.5866068Z  default="", 2025-03-14T03:51:41.5866964Z  help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-03-14T03:51:41.5867893Z  ) 2025-03-14T03:51:41.5868300Z  parser.add_argument( 2025-03-14T03:51:41.5868832Z  "--pr-number", 2025-03-14T03:51:41.5869301Z  type=str, 2025-03-14T03:51:41.5869752Z  required=False, 2025-03-14T03:51:41.5870228Z  default="", 2025-03-14T03:51:41.5870779Z  help="the optional PR number where this is run", 2025-03-14T03:51:41.5871349Z  ) 2025-03-14T03:51:41.5871998Z  2025-03-14T03:51:41.5872692Z  return parser.parse_args() 2025-03-14T03:51:41.5873564Z  2025-03-14T03:51:41.5874187Z  2025-03-14T03:51:41.5875240Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-03-14T03:51:41.5876507Z  auth = Auth.Token(github_token) 2025-03-14T03:51:41.5877097Z  return Github(auth=auth) 2025-03-14T03:51:41.5877938Z  2025-03-14T03:51:41.5878549Z  2025-03-14T03:51:41.5879750Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-03-14T03:51:41.5881171Z  repo = gh.get_repo(repo) 2025-03-14T03:51:41.5881975Z  return repo.get_issue(number=issue_num) 2025-03-14T03:51:41.5882839Z  2025-03-14T03:51:41.5883479Z  2025-03-14T03:51:41.5884165Z def get_potential_pr_author( 2025-03-14T03:51:41.5885347Z  github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-03-14T03:51:41.5886546Z ) -> str: 2025-03-14T03:51:41.5887535Z  # If the trigger was a new tag added by a bot, this is a ciflow case 2025-03-14T03:51:41.5889004Z  # Fetch the actual username from the original PR. The PR number is 2025-03-14T03:51:41.5890386Z  # embedded in the tag name: ciflow// 2025-03-14T03:51:41.5891410Z  2025-03-14T03:51:41.5892061Z  gh = get_gh_client(github_token) 2025-03-14T03:51:41.5892874Z  2025-03-14T03:51:41.5893703Z  if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-03-14T03:51:41.5894824Z  split_tag = ref_name.split("/") 2025-03-14T03:51:41.5895729Z  if ( 2025-03-14T03:51:41.5896451Z  len(split_tag) == 3 2025-03-14T03:51:41.5897092Z  and split_tag[0] == "ciflow" 2025-03-14T03:51:41.5898005Z  and split_tag[2].isnumeric() 2025-03-14T03:51:41.5898901Z  ): 2025-03-14T03:51:41.5899656Z  pr_number = split_tag[2] 2025-03-14T03:51:41.5900539Z  try: 2025-03-14T03:51:41.5901352Z  repository = gh.get_repo(repo) 2025-03-14T03:51:41.5902320Z  pull = repository.get_pull(number=int(pr_number)) 2025-03-14T03:51:41.5903431Z  except Exception as e: 2025-03-14T03:51:41.5904390Z  raise Exception( # noqa: TRY002 2025-03-14T03:51:41.5905584Z  f"issue with pull request {pr_number} from repo {repository}" 2025-03-14T03:51:41.5906662Z  ) from e 2025-03-14T03:51:41.5907402Z  return pull.user.login # type: ignore[no-any-return] 2025-03-14T03:51:41.5908667Z  # In all other cases, return the original input username 2025-03-14T03:51:41.5909755Z  return username 2025-03-14T03:51:41.5910509Z  2025-03-14T03:51:41.5911121Z  2025-03-14T03:51:41.5911923Z def is_exception_branch(branch: str) -> bool: 2025-03-14T03:51:41.5912866Z  """ 2025-03-14T03:51:41.5914078Z  Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-03-14T03:51:41.5915687Z  """ 2025-03-14T03:51:41.5916598Z  return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-03-14T03:51:41.5917576Z  2025-03-14T03:51:41.5918187Z  2025-03-14T03:51:41.5918876Z def load_yaml(yaml_text: str) -> Any: 2025-03-14T03:51:41.5919771Z  try: 2025-03-14T03:51:41.5920500Z  data = yaml.safe_load(yaml_text) 2025-03-14T03:51:41.5921362Z  return data 2025-03-14T03:51:41.5922000Z  except yaml.YAMLError: 2025-03-14T03:51:41.5922922Z  log.exception("Error loading YAML") 2025-03-14T03:51:41.5923842Z  raise 2025-03-14T03:51:41.5924548Z  2025-03-14T03:51:41.5925147Z  2025-03-14T03:51:41.5926238Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-03-14T03:51:41.5927200Z  """ 2025-03-14T03:51:41.5928331Z  Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-03-14T03:51:41.5929643Z  2025-03-14T03:51:41.5930593Z  If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:41.5931786Z  and the text below is the list of opted in users. 2025-03-14T03:51:41.5932685Z  2025-03-14T03:51:41.5933686Z  If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-03-14T03:51:41.5934948Z  """ 2025-03-14T03:51:41.5935804Z  rollout_state_parts = rollout_state.split("---") 2025-03-14T03:51:41.5936718Z  if len(rollout_state_parts) >= 2: 2025-03-14T03:51:41.5937895Z  return rollout_state_parts[0], rollout_state_parts[1] 2025-03-14T03:51:41.5938966Z  else: 2025-03-14T03:51:41.5939676Z  return "", rollout_state 2025-03-14T03:51:41.5940526Z  2025-03-14T03:51:41.5941122Z  2025-03-14T03:51:41.5941746Z class UserOptins(dict[str, list[str]]): 2025-03-14T03:51:41.5942582Z  """ 2025-03-14T03:51:41.5943528Z  Dictionary of users with a list of features they have opted into 2025-03-14T03:51:41.5944664Z  """ 2025-03-14T03:51:41.5945306Z  2025-03-14T03:51:41.5945905Z  2025-03-14T03:51:41.5946666Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-03-14T03:51:41.5947706Z  """ 2025-03-14T03:51:41.5948984Z  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.5950462Z  2025-03-14T03:51:41.5952252Z  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.5954210Z  - Example line: "@User1,lf,split_build" 2025-03-14T03:51:41.5955488Z  - A "#" prefix indicates the user is opted out of all experiments 2025-03-14T03:51:41.5956566Z  2025-03-14T03:51:41.5957051Z  2025-03-14T03:51:41.5957653Z  """ 2025-03-14T03:51:41.5958345Z  optins = UserOptins() 2025-03-14T03:51:41.5959268Z  for user in user_optin_text.split("\n"): 2025-03-14T03:51:41.5960267Z  user = user.strip("\r\n\t -") 2025-03-14T03:51:41.5961247Z  if not user or not user.startswith("@"): 2025-03-14T03:51:41.5962372Z  # Not a valid user. Skip 2025-03-14T03:51:41.5963260Z  continue 2025-03-14T03:51:41.5964010Z  2025-03-14T03:51:41.5964628Z  if user: 2025-03-14T03:51:41.5965470Z  usr_name = user.split(",")[0].strip("@") 2025-03-14T03:51:41.5966761Z  optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-03-14T03:51:41.5967866Z  2025-03-14T03:51:41.5968495Z  return optins 2025-03-14T03:51:41.5969235Z  2025-03-14T03:51:41.5969835Z  2025-03-14T03:51:41.5970711Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-03-14T03:51:41.5971937Z  """ 2025-03-14T03:51:41.5972497Z  Check if the experiment name is valid. 2025-03-14T03:51:41.5973057Z  A valid name: 2025-03-14T03:51:41.5974185Z  - Contains only alphanumeric characters and the special characters "_" & "-" 2025-03-14T03:51:41.5975836Z  - The special characters "_" & "-" shouldn't be the first or last characters 2025-03-14T03:51:41.5977094Z  - Cannot contain spaces 2025-03-14T03:51:41.5977807Z  """ 2025-03-14T03:51:41.5978198Z  2025-03-14T03:51:41.5978896Z  valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-03-14T03:51:41.5980149Z  valid = bool(re.match(valid_char_regex, experiment_name)) 2025-03-14T03:51:41.5981213Z  2025-03-14T03:51:41.5981977Z  if valid: 2025-03-14T03:51:41.5982704Z  return True 2025-03-14T03:51:41.5983258Z  2025-03-14T03:51:41.5983626Z  log.error( 2025-03-14T03:51:41.5986330Z  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.5988627Z  ) 2025-03-14T03:51:41.5989008Z  return False 2025-03-14T03:51:41.5989719Z  2025-03-14T03:51:41.5990322Z  2025-03-14T03:51:41.5991432Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-03-14T03:51:41.5992726Z  """ 2025-03-14T03:51:41.5993722Z  Parse the experiments from the issue body into a list of ExperimentSettings 2025-03-14T03:51:41.5994616Z  """ 2025-03-14T03:51:41.5995277Z  try: 2025-03-14T03:51:41.5995960Z  if settings_text: 2025-03-14T03:51:41.5997279Z  # 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.5998644Z  # for easy reading 2025-03-14T03:51:41.5999647Z  # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-03-14T03:51:41.6001214Z  # the backtick character in shell commands. 2025-03-14T03:51:41.6002443Z  backtick = chr(96) # backtick character 2025-03-14T03:51:41.6003625Z  settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-03-14T03:51:41.6004472Z  settings = load_yaml(settings_text) 2025-03-14T03:51:41.6005345Z  2025-03-14T03:51:41.6006375Z  # For now we just load experiments. We can expand this if/when we add more settings 2025-03-14T03:51:41.6007684Z  experiments = {} 2025-03-14T03:51:41.6008497Z  2025-03-14T03:51:41.6009293Z  for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-03-14T03:51:41.6010434Z  if not is_valid_experiment_name(exp_name): 2025-03-14T03:51:41.6012543Z  # 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.6014283Z  continue 2025-03-14T03:51:41.6014765Z  2025-03-14T03:51:41.6015434Z  valid_settings = {} 2025-03-14T03:51:41.6016389Z  for setting in exp_settings: 2025-03-14T03:51:41.6017393Z  if setting not in Experiment._fields: 2025-03-14T03:51:41.6018572Z  log.warning( 2025-03-14T03:51:41.6019598Z  f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-03-14T03:51:41.6020742Z  ) 2025-03-14T03:51:41.6021548Z  else: 2025-03-14T03:51:41.6022648Z  valid_settings[setting] = exp_settings[setting] 2025-03-14T03:51:41.6023657Z  2025-03-14T03:51:41.6024438Z  experiments[exp_name] = Experiment(**valid_settings) 2025-03-14T03:51:41.6025110Z  return Settings(experiments) 2025-03-14T03:51:41.6025831Z  2025-03-14T03:51:41.6026469Z  except Exception: 2025-03-14T03:51:41.6027369Z  log.exception("Failed to parse settings") 2025-03-14T03:51:41.6028325Z  2025-03-14T03:51:41.6028954Z  return Settings() 2025-03-14T03:51:41.6029709Z  2025-03-14T03:51:41.6030108Z  2025-03-14T03:51:41.6030743Z def parse_settings(rollout_state: str) -> Settings: 2025-03-14T03:51:41.6031904Z  """ 2025-03-14T03:51:41.6032707Z  Parse settings, if any, from the rollout state. 2025-03-14T03:51:41.6033679Z  2025-03-14T03:51:41.6034626Z  If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:41.6035603Z  and the text below is the list of opted in users. 2025-03-14T03:51:41.6036640Z  2025-03-14T03:51:41.6037678Z  If it doesn't contain "---" then the settings are empty and the default values are used. 2025-03-14T03:51:41.6038952Z  """ 2025-03-14T03:51:41.6039960Z  settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:41.6041135Z  return parse_settings_from_text(settings_text) 2025-03-14T03:51:41.6042315Z  2025-03-14T03:51:41.6042918Z  2025-03-14T03:51:41.6043706Z def parse_users(rollout_state: str) -> UserOptins: 2025-03-14T03:51:41.6044704Z  """ 2025-03-14T03:51:41.6045799Z  Parse users from the rollout state. 2025-03-14T03:51:41.6046697Z  2025-03-14T03:51:41.6047113Z  """ 2025-03-14T03:51:41.6047688Z  _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:41.6048692Z  return parse_user_opt_in_from_text(users_text) 2025-03-14T03:51:41.6049664Z  2025-03-14T03:51:41.6050275Z  2025-03-14T03:51:41.6051367Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:41.6052830Z  """ 2025-03-14T03:51:41.6053344Z  Check if a user is opted into an experiment 2025-03-14T03:51:41.6054240Z  """ 2025-03-14T03:51:41.6055098Z  return experiment_name in user_optins.get(user, []) 2025-03-14T03:51:41.6056126Z  2025-03-14T03:51:41.6056718Z  2025-03-14T03:51:41.6057799Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:41.6058720Z  """ 2025-03-14T03:51:41.6059580Z  Check if a user explicitly opted out of an experiment 2025-03-14T03:51:41.6060608Z  """ 2025-03-14T03:51:41.6061535Z  # if the experiment is prefixed with a "-", then it's an opt-out 2025-03-14T03:51:41.6062907Z  experiment_optout = "-" + experiment_name 2025-03-14T03:51:41.6063739Z  if experiment_optout not in user_optins.get(user, []): 2025-03-14T03:51:41.6064809Z  return False 2025-03-14T03:51:41.6065563Z  2025-03-14T03:51:41.6066392Z  if is_user_opted_in(user, user_optins, experiment_name): 2025-03-14T03:51:41.6067450Z  log.warning( 2025-03-14T03:51:41.6068523Z  f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-03-14T03:51:41.6070333Z  ) 2025-03-14T03:51:41.6070999Z  2025-03-14T03:51:41.6071777Z  return True 2025-03-14T03:51:41.6072503Z  2025-03-14T03:51:41.6073091Z  2025-03-14T03:51:41.6073528Z def get_runner_prefix( 2025-03-14T03:51:41.6074243Z  rollout_state: str, 2025-03-14T03:51:41.6075123Z  workflow_requestors: Iterable[str], 2025-03-14T03:51:41.6076044Z  branch: str, 2025-03-14T03:51:41.6076963Z  eligible_experiments: frozenset[str] = frozenset(), 2025-03-14T03:51:41.6078022Z  is_canary: bool = False, 2025-03-14T03:51:41.6078558Z ) -> str: 2025-03-14T03:51:41.6079302Z  settings = parse_settings(rollout_state) 2025-03-14T03:51:41.6080345Z  user_optins = parse_users(rollout_state) 2025-03-14T03:51:41.6081252Z  2025-03-14T03:51:41.6082036Z  fleet_prefix = "" 2025-03-14T03:51:41.6082839Z  prefixes = [] 2025-03-14T03:51:41.6083711Z  for experiment_name, experiment_settings in settings.experiments.items(): 2025-03-14T03:51:41.6085374Z  if not experiment_settings.all_branches and is_exception_branch(branch): 2025-03-14T03:51:41.6086637Z  log.info( 2025-03-14T03:51:41.6087859Z  f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-03-14T03:51:41.6088819Z  ) 2025-03-14T03:51:41.6089545Z  continue 2025-03-14T03:51:41.6090285Z  2025-03-14T03:51:41.6090949Z  if eligible_experiments: 2025-03-14T03:51:41.6092307Z  if experiment_name not in eligible_experiments: 2025-03-14T03:51:41.6093394Z  exp_list = ", ".join(eligible_experiments) 2025-03-14T03:51:41.6094129Z  log.info( 2025-03-14T03:51:41.6095545Z  f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-03-14T03:51:41.6097002Z  ) 2025-03-14T03:51:41.6097747Z  continue 2025-03-14T03:51:41.6098476Z  elif not experiment_settings.default: 2025-03-14T03:51:41.6099292Z  log.info( 2025-03-14T03:51:41.6100494Z  f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-03-14T03:51:41.6101932Z  ) 2025-03-14T03:51:41.6102651Z  continue 2025-03-14T03:51:41.6103361Z  2025-03-14T03:51:41.6103908Z  # Is any workflow_requestor opted out to this experiment? 2025-03-14T03:51:41.6105020Z  opted_out_users = [ 2025-03-14T03:51:41.6105861Z  requestor 2025-03-14T03:51:41.6106719Z  for requestor in workflow_requestors 2025-03-14T03:51:41.6107912Z  if is_user_opted_out(requestor, user_optins, experiment_name) 2025-03-14T03:51:41.6108693Z  ] 2025-03-14T03:51:41.6109367Z  2025-03-14T03:51:41.6110010Z  if opted_out_users: 2025-03-14T03:51:41.6110851Z  log.info( 2025-03-14T03:51:41.6112132Z  f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-03-14T03:51:41.6113329Z  ) 2025-03-14T03:51:41.6113749Z  continue 2025-03-14T03:51:41.6114496Z  2025-03-14T03:51:41.6115316Z  # Is any workflow_requestor opted in to this experiment? 2025-03-14T03:51:41.6116391Z  opted_in_users = [ 2025-03-14T03:51:41.6117231Z  requestor 2025-03-14T03:51:41.6118082Z  for requestor in workflow_requestors 2025-03-14T03:51:41.6118973Z  if is_user_opted_in(requestor, user_optins, experiment_name) 2025-03-14T03:51:41.6120274Z  ] 2025-03-14T03:51:41.6120936Z  2025-03-14T03:51:41.6121740Z  enabled = False 2025-03-14T03:51:41.6122566Z  if opted_in_users: 2025-03-14T03:51:41.6123304Z  log.info( 2025-03-14T03:51:41.6124210Z  f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-03-14T03:51:41.6125398Z  ) 2025-03-14T03:51:41.6126116Z  enabled = True 2025-03-14T03:51:41.6126903Z  2025-03-14T03:51:41.6127616Z  elif experiment_settings.rollout_perc: 2025-03-14T03:51:41.6128666Z  # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-03-14T03:51:41.6129894Z  if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-03-14T03:51:41.6131040Z  log.info( 2025-03-14T03:51:41.6132735Z  f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-03-14T03:51:41.6134125Z  ) 2025-03-14T03:51:41.6134572Z  enabled = True 2025-03-14T03:51:41.6135235Z  2025-03-14T03:51:41.6135909Z  if enabled: 2025-03-14T03:51:41.6136720Z  label = experiment_name 2025-03-14T03:51:41.6137707Z  if experiment_name == LF_FLEET_EXPERIMENT: 2025-03-14T03:51:41.6139140Z  # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-03-14T03:51:41.6140329Z  # - If it's enabled, then we always list it's prefix first 2025-03-14T03:51:41.6141850Z  # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-03-14T03:51:41.6143028Z  if is_canary: 2025-03-14T03:51:41.6143935Z  label += CANARY_FLEET_SUFFIX 2025-03-14T03:51:41.6144848Z  fleet_prefix = label 2025-03-14T03:51:41.6145368Z  else: 2025-03-14T03:51:41.6146070Z  prefixes.append(label) 2025-03-14T03:51:41.6147311Z  2025-03-14T03:51:41.6147975Z  if len(prefixes) > 1: 2025-03-14T03:51:41.6148797Z  log.error( 2025-03-14T03:51:41.6150349Z  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.6152270Z  ) 2025-03-14T03:51:41.6152995Z  prefixes = prefixes[:1] 2025-03-14T03:51:41.6153855Z  2025-03-14T03:51:41.6154510Z  # Fleet always comes first 2025-03-14T03:51:41.6155300Z  if fleet_prefix: 2025-03-14T03:51:41.6155911Z  prefixes.insert(0, fleet_prefix) 2025-03-14T03:51:41.6156806Z  2025-03-14T03:51:41.6157591Z  return ".".join(prefixes) + "." if prefixes else "" 2025-03-14T03:51:41.6158576Z  2025-03-14T03:51:41.6159176Z  2025-03-14T03:51:41.6160211Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-03-14T03:51:41.6161276Z  """ 2025-03-14T03:51:41.6162472Z  Gets the first comment of the issue, which contains the desired rollout state. 2025-03-14T03:51:41.6163700Z  2025-03-14T03:51:41.6164698Z  The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-03-14T03:51:41.6165661Z  """ 2025-03-14T03:51:41.6166305Z  gh = get_gh_client(github_token) 2025-03-14T03:51:41.6167269Z  issue = get_issue(gh, repo, issue_num) 2025-03-14T03:51:41.6168405Z  return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-03-14T03:51:41.6169654Z  2025-03-14T03:51:41.6170238Z  2025-03-14T03:51:41.6170859Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-03-14T03:51:41.6172327Z  for _ in range(num_retries): 2025-03-14T03:51:41.6173196Z  try: 2025-03-14T03:51:41.6173987Z  req = Request(url=url, headers=headers) 2025-03-14T03:51:41.6175141Z  content = urlopen(req, timeout=5).read().decode("utf-8") 2025-03-14T03:51:41.6175961Z  return json.loads(content) 2025-03-14T03:51:41.6176907Z  except Exception as e: 2025-03-14T03:51:41.6177902Z  log.warning(f"Could not download {url}: {e}") 2025-03-14T03:51:41.6178877Z  2025-03-14T03:51:41.6179882Z  log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-03-14T03:51:41.6180836Z  return {} 2025-03-14T03:51:41.6181499Z  2025-03-14T03:51:41.6182243Z  2025-03-14T03:51:41.6182673Z @cache 2025-03-14T03:51:41.6183324Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-03-14T03:51:41.6184072Z  """ 2025-03-14T03:51:41.6184505Z  Dynamically get PR information 2025-03-14T03:51:41.6185005Z  """ 2025-03-14T03:51:41.6185534Z  github_api = f"https://api.github.com/repos/{github_repo}" 2025-03-14T03:51:41.6186166Z  headers = { 2025-03-14T03:51:41.6186671Z  "Accept": "application/vnd.github.v3+json", 2025-03-14T03:51:41.6187298Z  "Authorization": f"token {github_token}", 2025-03-14T03:51:41.6187828Z  } 2025-03-14T03:51:41.6188431Z  json_response: dict[str, Any] = download_json( 2025-03-14T03:51:41.6189067Z  url=f"{github_api}/issues/{pr_number}", 2025-03-14T03:51:41.6189629Z  headers=headers, 2025-03-14T03:51:41.6190089Z  ) 2025-03-14T03:51:41.6190801Z  2025-03-14T03:51:41.6191345Z  if not json_response: 2025-03-14T03:51:41.6192211Z  log.warning(f"Failed to get the labels for #{pr_number}") 2025-03-14T03:51:41.6192852Z  return {} 2025-03-14T03:51:41.6193276Z  2025-03-14T03:51:41.6193653Z  return json_response 2025-03-14T03:51:41.6194107Z  2025-03-14T03:51:41.6194456Z  2025-03-14T03:51:41.6195051Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-03-14T03:51:41.6195770Z  """ 2025-03-14T03:51:41.6196328Z  Dynamically get the latest list of labels from the pull request 2025-03-14T03:51:41.6196990Z  """ 2025-03-14T03:51:41.6197498Z  pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-03-14T03:51:41.6198117Z  return { 2025-03-14T03:51:41.6198757Z  label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-03-14T03:51:41.6199447Z  } 2025-03-14T03:51:41.6199817Z  2025-03-14T03:51:41.6200154Z  2025-03-14T03:51:41.6200516Z def main() -> None: 2025-03-14T03:51:41.6200975Z  args = parse_args() 2025-03-14T03:51:41.6201429Z  2025-03-14T03:51:41.6201995Z  runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-03-14T03:51:41.6202530Z  2025-03-14T03:51:41.6202911Z  # Check if the PR is opt-out 2025-03-14T03:51:41.6203475Z  if args.pr_number: 2025-03-14T03:51:41.6204166Z  labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-03-14T03:51:41.6204916Z  if OPT_OUT_LABEL in labels: 2025-03-14T03:51:41.6205426Z  log.info( 2025-03-14T03:51:41.6206179Z  f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-03-14T03:51:41.6207117Z  ) 2025-03-14T03:51:41.6207712Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:41.6208392Z  sys.exit() 2025-03-14T03:51:41.6209082Z  2025-03-14T03:51:41.6209692Z  try: 2025-03-14T03:51:41.6210495Z  rollout_state = get_rollout_state_from_issue( 2025-03-14T03:51:41.6211906Z  args.github_token, args.github_issue_repo, args.github_issue 2025-03-14T03:51:41.6213024Z  ) 2025-03-14T03:51:41.6213484Z  2025-03-14T03:51:41.6213885Z  username = get_potential_pr_author( 2025-03-14T03:51:41.6214834Z  args.github_token, 2025-03-14T03:51:41.6215723Z  args.github_repo, 2025-03-14T03:51:41.6216592Z  args.github_actor, 2025-03-14T03:51:41.6217481Z  args.github_ref_type, 2025-03-14T03:51:41.6218365Z  args.github_branch, 2025-03-14T03:51:41.6218855Z  ) 2025-03-14T03:51:41.6219487Z  2025-03-14T03:51:41.6220322Z  is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-03-14T03:51:41.6221373Z  2025-03-14T03:51:41.6222252Z  runner_label_prefix = get_runner_prefix( 2025-03-14T03:51:41.6223211Z  rollout_state, 2025-03-14T03:51:41.6223876Z  (args.github_issue_owner, username), 2025-03-14T03:51:41.6224774Z  args.github_branch, 2025-03-14T03:51:41.6225691Z  args.eligible_experiments, 2025-03-14T03:51:41.6226591Z  is_canary, 2025-03-14T03:51:41.6227545Z  ) 2025-03-14T03:51:41.6228214Z  2025-03-14T03:51:41.6228675Z  except Exception as e: 2025-03-14T03:51:41.6229397Z  log.error( 2025-03-14T03:51:41.6230620Z  f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-03-14T03:51:41.6232070Z  ) 2025-03-14T03:51:41.6232724Z  2025-03-14T03:51:41.6233563Z  set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:41.6234224Z  2025-03-14T03:51:41.6234820Z  2025-03-14T03:51:41.6235453Z if __name__ == "__main__": 2025-03-14T03:51:41.6236306Z  main() 2025-03-14T03:51:41.6236973Z  2025-03-14T03:51:41.6237571Z EOF 2025-03-14T03:51:41.6238190Z  2025-03-14T03:51:41.6238783Z cat runner_determinator.py 2025-03-14T03:51:41.6610783Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:41.6611830Z env: 2025-03-14T03:51:41.6612506Z GITHUB_TOKEN: *** 2025-03-14T03:51:41.6612930Z ISSUE_NUMBER: 5132 2025-03-14T03:51:41.6613372Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:41.6613870Z ISSUE_OWNER: 2025-03-14T03:51:41.6614279Z CHECK_EXPERIMENTS: 2025-03-14T03:51:41.6614734Z PR_NUMBER: 2025-03-14T03:51:41.6615112Z ##[endgroup] 2025-03-14T03:51:41.6833256Z # flake8: noqa: G004 2025-03-14T03:51:41.6833580Z 2025-03-14T03:51:41.6834011Z # Note: Copies of this script in runner_determinator.py and _runner-determinator.yml 2025-03-14T03:51:41.6834919Z # must be kept in sync. You can do it easily by running the following command: 2025-03-14T03:51:41.6835697Z # python .github/scripts/update_runner_determinator.py 2025-03-14T03:51:41.6836124Z 2025-03-14T03:51:41.6836282Z """ 2025-03-14T03:51:41.6836840Z This runner determinator is used to determine which set of runners to run a 2025-03-14T03:51:41.6837675Z GitHub job on. It uses the first comment of a GitHub issue (by default 2025-03-14T03:51:41.6838553Z https://github.com/pytorch/test-infra/issues/5132) to define the configuration 2025-03-14T03:51:41.6839327Z of which runners should be used to run which job. 2025-03-14T03:51:41.6839924Z 2025-03-14T03:51:41.6840298Z The configuration has two parts, the settings and a list of opted-in users, 2025-03-14T03:51:41.6841143Z separated by a line containing "---". If the line is not present, the 2025-03-14T03:51:41.6842227Z settings are considered to be empty with only the second part, the user 2025-03-14T03:51:41.6842886Z list, defined. 2025-03-14T03:51:41.6843114Z 2025-03-14T03:51:41.6843464Z The first part is a YAML block that defines the rollout settings. This can be 2025-03-14T03:51:41.6844331Z used to define any settings that are needed to determine which runners to use. 2025-03-14T03:51:41.6845118Z It's fields are defined by the RolloutSettings class below. 2025-03-14T03:51:41.6845539Z 2025-03-14T03:51:41.6845898Z The second part is a list of users who are explicitly opted in to the LF fleet. 2025-03-14T03:51:41.6846735Z The user list is also a comma separated list of additional features or 2025-03-14T03:51:41.6847428Z experiments which the user could be opted in to. 2025-03-14T03:51:41.6847833Z 2025-03-14T03:51:41.6848024Z The user list has the following rules: 2025-03-14T03:51:41.6848361Z 2025-03-14T03:51:41.6848651Z - Users are GitHub usernames, which must start with the @ prefix 2025-03-14T03:51:41.6849463Z - Each user is also a comma-separated list of features/experiments to enable 2025-03-14T03:51:41.6850197Z - A "#" prefix opts the user out of all experiments 2025-03-14T03:51:41.6850576Z 2025-03-14T03:51:41.6850747Z Example config: 2025-03-14T03:51:41.6851177Z # A list of experiments that can be opted into. 2025-03-14T03:51:41.6852201Z # This defines the behavior they'll induce when opted into. 2025-03-14T03:51:41.6852803Z # Expected syntax is: 2025-03-14T03:51:41.6853416Z # [experiment_name]: # Name of the experiment. Also used for the label prefix. 2025-03-14T03:51:41.6854497Z # rollout_perc: [int] # % of workflows to run with this experiment when users are not opted in. 2025-03-14T03:51:41.6855079Z 2025-03-14T03:51:41.6855246Z experiments: 2025-03-14T03:51:41.6855640Z lf: 2025-03-14T03:51:41.6856008Z rollout_percent: 25 2025-03-14T03:51:41.6856459Z all_branches: false 2025-03-14T03:51:41.6856887Z default: true 2025-03-14T03:51:41.6857282Z --- 2025-03-14T03:51:41.6857487Z 2025-03-14T03:51:41.6857641Z # Opt-ins: 2025-03-14T03:51:41.6858203Z # Users can opt into the LF fleet by adding their GitHub username to this list 2025-03-14T03:51:41.6859030Z # and specifying experiments to enable in a comma-separated list. 2025-03-14T03:51:41.6859766Z # To always opt out of an experiment, prefix it with a "-". 2025-03-14T03:51:41.6860373Z # Experiments should be from the above list. 2025-03-14T03:51:41.6860740Z 2025-03-14T03:51:41.6860948Z @User1,-lf,split_build 2025-03-14T03:51:41.6861430Z @User2,lf 2025-03-14T03:51:41.6862017Z @User3,split_build 2025-03-14T03:51:41.6862418Z """ 2025-03-14T03:51:41.6862604Z 2025-03-14T03:51:41.6862765Z import json 2025-03-14T03:51:41.6863123Z import logging 2025-03-14T03:51:41.6863490Z import os 2025-03-14T03:51:41.6863837Z import random 2025-03-14T03:51:41.6864190Z import re 2025-03-14T03:51:41.6864525Z import sys 2025-03-14T03:51:41.6864907Z from argparse import ArgumentParser 2025-03-14T03:51:41.6865417Z from collections.abc import Iterable 2025-03-14T03:51:41.6865915Z from functools import cache 2025-03-14T03:51:41.6866365Z from logging import LogRecord 2025-03-14T03:51:41.6866829Z from typing import Any, NamedTuple 2025-03-14T03:51:41.6867337Z from urllib.request import Request, urlopen 2025-03-14T03:51:41.6867691Z 2025-03-14T03:51:41.6867848Z import yaml 2025-03-14T03:51:41.6868219Z from github import Auth, Github 2025-03-14T03:51:41.6868688Z from github.Issue import Issue 2025-03-14T03:51:41.6868975Z 2025-03-14T03:51:41.6868982Z 2025-03-14T03:51:41.6869194Z DEFAULT_LABEL_PREFIX = "" # use meta runners 2025-03-14T03:51:41.6869841Z WORKFLOW_LABEL_LF = "lf." # use runners from the linux foundation 2025-03-14T03:51:41.6870657Z WORKFLOW_LABEL_LF_CANARY = "lf.c." # use canary runners from the linux foundation 2025-03-14T03:51:41.6871330Z 2025-03-14T03:51:41.6871550Z GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT", "") 2025-03-14T03:51:41.6872325Z GH_OUTPUT_KEY_AMI = "runner-ami" 2025-03-14T03:51:41.6872817Z GH_OUTPUT_KEY_LABEL_TYPE = "label-type" 2025-03-14T03:51:41.6873331Z OPT_OUT_LABEL = "no-runner-experiments" 2025-03-14T03:51:41.6873672Z 2025-03-14T03:51:41.6873859Z SETTING_EXPERIMENTS = "experiments" 2025-03-14T03:51:41.6874177Z 2025-03-14T03:51:41.6874356Z LF_FLEET_EXPERIMENT = "lf" 2025-03-14T03:51:41.6874804Z CANARY_FLEET_SUFFIX = ".c" 2025-03-14T03:51:41.6875070Z 2025-03-14T03:51:41.6875077Z 2025-03-14T03:51:41.6875259Z class Experiment(NamedTuple): 2025-03-14T03:51:41.6875713Z rollout_perc: float = ( 2025-03-14T03:51:41.6876317Z 0 # Percentage of workflows to experiment on when user is not opted-in. 2025-03-14T03:51:41.6876956Z ) 2025-03-14T03:51:41.6877307Z all_branches: bool = ( 2025-03-14T03:51:41.6877909Z False # If True, the experiment is also enabled on the exception branches 2025-03-14T03:51:41.6878551Z ) 2025-03-14T03:51:41.6878889Z default: bool = ( 2025-03-14T03:51:41.6879433Z True # If True, the experiment is enabled by default for all queries 2025-03-14T03:51:41.6880046Z ) 2025-03-14T03:51:41.6880228Z 2025-03-14T03:51:41.6880407Z # Add more fields as needed 2025-03-14T03:51:41.6880692Z 2025-03-14T03:51:41.6880698Z 2025-03-14T03:51:41.6880886Z class Settings(NamedTuple): 2025-03-14T03:51:41.6881311Z """ 2025-03-14T03:51:41.6881943Z Settings for the experiments that can be opted into. 2025-03-14T03:51:41.6882498Z """ 2025-03-14T03:51:41.6882686Z 2025-03-14T03:51:41.6882890Z experiments: dict[str, Experiment] = {} 2025-03-14T03:51:41.6883235Z 2025-03-14T03:51:41.6883241Z 2025-03-14T03:51:41.6883582Z class ColorFormatter(logging.Formatter): 2025-03-14T03:51:41.6884194Z """Color codes the log messages based on the log level""" 2025-03-14T03:51:41.6884607Z 2025-03-14T03:51:41.6884766Z COLORS = { 2025-03-14T03:51:41.6885147Z "WARNING": "\033[33m", # Yellow 2025-03-14T03:51:41.6885641Z "ERROR": "\033[31m", # Red 2025-03-14T03:51:41.6886114Z "CRITICAL": "\033[31m", # Red 2025-03-14T03:51:41.6886598Z "INFO": "\033[0m", # Reset 2025-03-14T03:51:41.6887055Z "DEBUG": "\033[0m", # Reset 2025-03-14T03:51:41.6887503Z } 2025-03-14T03:51:41.6887696Z 2025-03-14T03:51:41.6887908Z def format(self, record: LogRecord) -> str: 2025-03-14T03:51:41.6888626Z log_color = self.COLORS.get(record.levelname, "\033[0m") # Default to reset 2025-03-14T03:51:41.6889364Z record.msg = f"{log_color}{record.msg}\033[0m" 2025-03-14T03:51:41.6889907Z return super().format(record) 2025-03-14T03:51:41.6890232Z 2025-03-14T03:51:41.6890238Z 2025-03-14T03:51:41.6890432Z handler = logging.StreamHandler() 2025-03-14T03:51:41.6891110Z handler.setFormatter(ColorFormatter(fmt="%(levelname)-8s: %(message)s")) 2025-03-14T03:51:41.6891822Z 2025-03-14T03:51:41.6892065Z log = logging.getLogger(os.path.basename(__file__)) 2025-03-14T03:51:41.6892623Z log.addHandler(handler) 2025-03-14T03:51:41.6893044Z log.setLevel(logging.INFO) 2025-03-14T03:51:41.6893317Z 2025-03-14T03:51:41.6893324Z 2025-03-14T03:51:41.6893567Z def set_github_output(key: str, value: str) -> None: 2025-03-14T03:51:41.6894105Z """ 2025-03-14T03:51:41.6894603Z Defines outputs of the github action that invokes this script 2025-03-14T03:51:41.6895227Z """ 2025-03-14T03:51:41.6895579Z if not GITHUB_OUTPUT: 2025-03-14T03:51:41.6896596Z # 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.6897672Z log.warning( 2025-03-14T03:51:41.6898489Z "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.6899363Z ) 2025-03-14T03:51:41.6909077Z print(f"::set-output name={key}::{value}") 2025-03-14T03:51:41.6909862Z return 2025-03-14T03:51:41.6910087Z 2025-03-14T03:51:41.6910280Z with open(GITHUB_OUTPUT, "a") as f: 2025-03-14T03:51:41.6910858Z log.info(f"Setting output: {key}='{value}'") 2025-03-14T03:51:41.6911414Z f.write(f"{key}={value}\n") 2025-03-14T03:51:41.6911990Z 2025-03-14T03:51:41.6911998Z 2025-03-14T03:51:41.6912302Z def _str_comma_separated_to_set(value: str) -> frozenset[str]: 2025-03-14T03:51:41.6912912Z return frozenset( 2025-03-14T03:51:41.6913488Z filter(lambda itm: itm != "", map(str.strip, value.strip(" \n\t").split(","))) 2025-03-14T03:51:41.6914148Z ) 2025-03-14T03:51:41.6914365Z 2025-03-14T03:51:41.6914382Z 2025-03-14T03:51:41.6914587Z def parse_args() -> Any: 2025-03-14T03:51:41.6915134Z parser = ArgumentParser("Get dynamic rollout settings") 2025-03-14T03:51:41.6915969Z parser.add_argument("--github-token", type=str, required=True, help="GitHub token") 2025-03-14T03:51:41.6916707Z parser.add_argument( 2025-03-14T03:51:41.6917155Z "--github-issue-repo", 2025-03-14T03:51:41.6917613Z type=str, 2025-03-14T03:51:41.6917991Z required=False, 2025-03-14T03:51:41.6918434Z default="pytorch/test-infra", 2025-03-14T03:51:41.6918965Z help="GitHub repo to get the issue", 2025-03-14T03:51:41.6919458Z ) 2025-03-14T03:51:41.6919817Z parser.add_argument( 2025-03-14T03:51:41.6920240Z "--github-repo", 2025-03-14T03:51:41.6920656Z type=str, 2025-03-14T03:51:41.6921045Z required=True, 2025-03-14T03:51:41.6921485Z help="GitHub repo where CI is running", 2025-03-14T03:51:41.6922206Z ) 2025-03-14T03:51:41.6922561Z parser.add_argument( 2025-03-14T03:51:41.6923146Z "--github-issue", type=int, required=True, help="GitHub issue number" 2025-03-14T03:51:41.6923913Z ) 2025-03-14T03:51:41.6924567Z parser.add_argument( 2025-03-14T03:51:41.6925416Z "--github-actor", type=str, required=True, help="GitHub triggering_actor" 2025-03-14T03:51:41.6926489Z ) 2025-03-14T03:51:41.6926876Z parser.add_argument( 2025-03-14T03:51:41.6927496Z "--github-issue-owner", type=str, required=True, help="GitHub issue owner" 2025-03-14T03:51:41.6928153Z ) 2025-03-14T03:51:41.6928509Z parser.add_argument( 2025-03-14T03:51:41.6929125Z "--github-branch", type=str, required=True, help="Current GitHub branch or tag" 2025-03-14T03:51:41.6929800Z ) 2025-03-14T03:51:41.6930142Z parser.add_argument( 2025-03-14T03:51:41.6930574Z "--github-ref-type", 2025-03-14T03:51:41.6931006Z type=str, 2025-03-14T03:51:41.6931382Z required=True, 2025-03-14T03:51:41.6932186Z help="Current GitHub ref type, branch or tag", 2025-03-14T03:51:41.6932722Z ) 2025-03-14T03:51:41.6933080Z parser.add_argument( 2025-03-14T03:51:41.6933527Z "--eligible-experiments", 2025-03-14T03:51:41.6934012Z type=_str_comma_separated_to_set, 2025-03-14T03:51:41.6934506Z required=False, 2025-03-14T03:51:41.6934908Z default="", 2025-03-14T03:51:41.6935702Z help="comma separated list of experiments to check, if omitted all experiments marked with default=True are checked", 2025-03-14T03:51:41.6936578Z ) 2025-03-14T03:51:41.6936925Z parser.add_argument( 2025-03-14T03:51:41.6937342Z "--pr-number", 2025-03-14T03:51:41.6937740Z type=str, 2025-03-14T03:51:41.6938124Z required=False, 2025-03-14T03:51:41.6938518Z default="", 2025-03-14T03:51:41.6938964Z help="the optional PR number where this is run", 2025-03-14T03:51:41.6939497Z ) 2025-03-14T03:51:41.6939686Z 2025-03-14T03:51:41.6939867Z return parser.parse_args() 2025-03-14T03:51:41.6940154Z 2025-03-14T03:51:41.6940160Z 2025-03-14T03:51:41.6940554Z def get_gh_client(github_token: str) -> Github: # type: ignore[no-any-unimported] 2025-03-14T03:51:41.6941278Z auth = Auth.Token(github_token) 2025-03-14T03:51:41.6941978Z return Github(auth=auth) 2025-03-14T03:51:41.6942443Z 2025-03-14T03:51:41.6942449Z 2025-03-14T03:51:41.6942879Z def get_issue(gh: Github, repo: str, issue_num: int) -> Issue: # type: ignore[no-any-unimported] 2025-03-14T03:51:41.6943646Z repo = gh.get_repo(repo) 2025-03-14T03:51:41.6944124Z return repo.get_issue(number=issue_num) 2025-03-14T03:51:41.6944475Z 2025-03-14T03:51:41.6944482Z 2025-03-14T03:51:41.6944666Z def get_potential_pr_author( 2025-03-14T03:51:41.6945274Z github_token: str, repo: str, username: str, ref_type: str, ref_name: str 2025-03-14T03:51:41.6945910Z ) -> str: 2025-03-14T03:51:41.6946403Z # If the trigger was a new tag added by a bot, this is a ciflow case 2025-03-14T03:51:41.6947163Z # Fetch the actual username from the original PR. The PR number is 2025-03-14T03:51:41.6947873Z # embedded in the tag name: ciflow// 2025-03-14T03:51:41.6948266Z 2025-03-14T03:51:41.6948454Z gh = get_gh_client(github_token) 2025-03-14T03:51:41.6948772Z 2025-03-14T03:51:41.6949029Z if username == "pytorch-bot[bot]" and ref_type == "tag": 2025-03-14T03:51:41.6949621Z split_tag = ref_name.split("/") 2025-03-14T03:51:41.6950103Z if ( 2025-03-14T03:51:41.6950623Z len(split_tag) == 3 2025-03-14T03:51:41.6951097Z and split_tag[0] == "ciflow" 2025-03-14T03:51:41.6951788Z and split_tag[2].isnumeric() 2025-03-14T03:51:41.6952282Z ): 2025-03-14T03:51:41.6952654Z pr_number = split_tag[2] 2025-03-14T03:51:41.6953113Z try: 2025-03-14T03:51:41.6953527Z repository = gh.get_repo(repo) 2025-03-14T03:51:41.6954108Z pull = repository.get_pull(number=int(pr_number)) 2025-03-14T03:51:41.6954673Z except Exception as e: 2025-03-14T03:51:41.6955173Z raise Exception( # noqa: TRY002 2025-03-14T03:51:41.6955949Z f"issue with pull request {pr_number} from repo {repository}" 2025-03-14T03:51:41.6956573Z ) from e 2025-03-14T03:51:41.6957095Z return pull.user.login # type: ignore[no-any-return] 2025-03-14T03:51:41.6957747Z # In all other cases, return the original input username 2025-03-14T03:51:41.6958314Z return username 2025-03-14T03:51:41.6958545Z 2025-03-14T03:51:41.6958551Z 2025-03-14T03:51:41.6958769Z def is_exception_branch(branch: str) -> bool: 2025-03-14T03:51:41.6959276Z """ 2025-03-14T03:51:41.6959876Z Branches that get opted out of experiments by default, until they're explicitly enabled. 2025-03-14T03:51:41.6960603Z """ 2025-03-14T03:51:41.6961121Z return branch.split("/")[0] in {"main", "nightly", "release", "landchecks"} 2025-03-14T03:51:41.6961728Z 2025-03-14T03:51:41.6961733Z 2025-03-14T03:51:41.6961921Z def load_yaml(yaml_text: str) -> Any: 2025-03-14T03:51:41.6962395Z try: 2025-03-14T03:51:41.6962767Z data = yaml.safe_load(yaml_text) 2025-03-14T03:51:41.6963251Z return data 2025-03-14T03:51:41.6963639Z except yaml.YAMLError: 2025-03-14T03:51:41.6964096Z log.exception("Error loading YAML") 2025-03-14T03:51:41.6964586Z raise 2025-03-14T03:51:41.6964793Z 2025-03-14T03:51:41.6964799Z 2025-03-14T03:51:41.6965190Z def extract_settings_user_opt_in_from_text(rollout_state: str) -> tuple[str, str]: 2025-03-14T03:51:41.6965891Z """ 2025-03-14T03:51:41.6966468Z Extracts the text with settings, if any, and the opted in users from the rollout state. 2025-03-14T03:51:41.6967040Z 2025-03-14T03:51:41.6967361Z If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:41.6968076Z and the text below is the list of opted in users. 2025-03-14T03:51:41.6968468Z 2025-03-14T03:51:41.6968824Z If it doesn't contain "---" then the settings are empty and the rest is the users. 2025-03-14T03:51:41.6969489Z """ 2025-03-14T03:51:41.6969919Z rollout_state_parts = rollout_state.split("---") 2025-03-14T03:51:41.6970483Z if len(rollout_state_parts) >= 2: 2025-03-14T03:51:41.6971059Z return rollout_state_parts[0], rollout_state_parts[1] 2025-03-14T03:51:41.6972010Z else: 2025-03-14T03:51:41.6972393Z return "", rollout_state 2025-03-14T03:51:41.6972694Z 2025-03-14T03:51:41.6972701Z 2025-03-14T03:51:41.6972895Z class UserOptins(dict[str, list[str]]): 2025-03-14T03:51:41.6973379Z """ 2025-03-14T03:51:41.6973873Z Dictionary of users with a list of features they have opted into 2025-03-14T03:51:41.6974479Z """ 2025-03-14T03:51:41.6974668Z 2025-03-14T03:51:41.6974674Z 2025-03-14T03:51:41.6974992Z def parse_user_opt_in_from_text(user_optin_text: str) -> UserOptins: 2025-03-14T03:51:41.6975618Z """ 2025-03-14T03:51:41.6976285Z 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.6976924Z 2025-03-14T03:51:41.6977504Z 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.6978438Z - Example line: "@User1,lf,split_build" 2025-03-14T03:51:41.6979097Z - A "#" prefix indicates the user is opted out of all experiments 2025-03-14T03:51:41.6979556Z 2025-03-14T03:51:41.6979562Z 2025-03-14T03:51:41.6979710Z """ 2025-03-14T03:51:41.6980067Z optins = UserOptins() 2025-03-14T03:51:41.6980539Z for user in user_optin_text.split("\n"): 2025-03-14T03:51:41.6981059Z user = user.strip("\r\n\t -") 2025-03-14T03:51:41.6981701Z if not user or not user.startswith("@"): 2025-03-14T03:51:41.6982243Z # Not a valid user. Skip 2025-03-14T03:51:41.6982717Z continue 2025-03-14T03:51:41.6982952Z 2025-03-14T03:51:41.6983109Z if user: 2025-03-14T03:51:41.6983530Z usr_name = user.split(",")[0].strip("@") 2025-03-14T03:51:41.6984185Z optins[usr_name] = [exp.strip(" ") for exp in user.split(",")[1:]] 2025-03-14T03:51:41.6984793Z 2025-03-14T03:51:41.6984962Z return optins 2025-03-14T03:51:41.6985196Z 2025-03-14T03:51:41.6985203Z 2025-03-14T03:51:41.6985478Z def is_valid_experiment_name(experiment_name: str) -> bool: 2025-03-14T03:51:41.6986050Z """ 2025-03-14T03:51:41.6986439Z Check if the experiment name is valid. 2025-03-14T03:51:41.6986927Z A valid name: 2025-03-14T03:51:41.6987537Z - Contains only alphanumeric characters and the special characters "_" & "-" 2025-03-14T03:51:41.6988414Z - The special characters "_" & "-" shouldn't be the first or last characters 2025-03-14T03:51:41.6989098Z - Cannot contain spaces 2025-03-14T03:51:41.6989535Z """ 2025-03-14T03:51:41.6989719Z 2025-03-14T03:51:41.6989967Z valid_char_regex = r"^[a-zA-Z0-9]([\w-]*[a-zA-Z0-9])?$" 2025-03-14T03:51:41.6990634Z valid = bool(re.match(valid_char_regex, experiment_name)) 2025-03-14T03:51:41.6991058Z 2025-03-14T03:51:41.6991213Z if valid: 2025-03-14T03:51:41.6991747Z return True 2025-03-14T03:51:41.6992028Z 2025-03-14T03:51:41.6992194Z log.error( 2025-03-14T03:51:41.6993554Z 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.6995086Z ) 2025-03-14T03:51:41.6995423Z return False 2025-03-14T03:51:41.6995650Z 2025-03-14T03:51:41.6995656Z 2025-03-14T03:51:41.6995943Z def parse_settings_from_text(settings_text: str) -> Settings: 2025-03-14T03:51:41.6996530Z """ 2025-03-14T03:51:41.6997088Z Parse the experiments from the issue body into a list of ExperimentSettings 2025-03-14T03:51:41.6997764Z """ 2025-03-14T03:51:41.6998097Z try: 2025-03-14T03:51:41.6998459Z if settings_text: 2025-03-14T03:51:41.6999141Z # 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.6999896Z # for easy reading 2025-03-14T03:51:41.7000640Z # Note: Using ascii for the backtick so that the cat step in _runner-determinator.yml doesn't choke on 2025-03-14T03:51:41.7001748Z # the backtick character in shell commands. 2025-03-14T03:51:41.7002325Z backtick = chr(96) # backtick character 2025-03-14T03:51:41.7002957Z settings_text = settings_text.strip(f"\r\n\t{backtick} ") 2025-03-14T03:51:41.7003577Z settings = load_yaml(settings_text) 2025-03-14T03:51:41.7003922Z 2025-03-14T03:51:41.7004306Z # For now we just load experiments. We can expand this if/when we add more settings 2025-03-14T03:51:41.7005013Z experiments = {} 2025-03-14T03:51:41.7005287Z 2025-03-14T03:51:41.7005626Z for exp_name, exp_settings in settings.get(SETTING_EXPERIMENTS).items(): 2025-03-14T03:51:41.7006338Z if not is_valid_experiment_name(exp_name): 2025-03-14T03:51:41.7007387Z # 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.7008368Z continue 2025-03-14T03:51:41.7008644Z 2025-03-14T03:51:41.7008821Z valid_settings = {} 2025-03-14T03:51:41.7009309Z for setting in exp_settings: 2025-03-14T03:51:41.7009857Z if setting not in Experiment._fields: 2025-03-14T03:51:41.7010378Z log.warning( 2025-03-14T03:51:41.7011043Z f"Unexpected setting in experiment: {setting} = {exp_settings[setting]}" 2025-03-14T03:51:41.7011938Z ) 2025-03-14T03:51:41.7012355Z else: 2025-03-14T03:51:41.7012843Z valid_settings[setting] = exp_settings[setting] 2025-03-14T03:51:41.7013242Z 2025-03-14T03:51:41.7013497Z experiments[exp_name] = Experiment(**valid_settings) 2025-03-14T03:51:41.7014232Z return Settings(experiments) 2025-03-14T03:51:41.7014577Z 2025-03-14T03:51:41.7014747Z except Exception: 2025-03-14T03:51:41.7015211Z log.exception("Failed to parse settings") 2025-03-14T03:51:41.7015582Z 2025-03-14T03:51:41.7015748Z return Settings() 2025-03-14T03:51:41.7015989Z 2025-03-14T03:51:41.7015995Z 2025-03-14T03:51:41.7016233Z def parse_settings(rollout_state: str) -> Settings: 2025-03-14T03:51:41.7016757Z """ 2025-03-14T03:51:41.7017164Z Parse settings, if any, from the rollout state. 2025-03-14T03:51:41.7017548Z 2025-03-14T03:51:41.7017874Z If the issue body contains "---" then the text above that is the settings 2025-03-14T03:51:41.7018589Z and the text below is the list of opted in users. 2025-03-14T03:51:41.7018986Z 2025-03-14T03:51:41.7019437Z If it doesn't contain "---" then the settings are empty and the default values are used. 2025-03-14T03:51:41.7020125Z """ 2025-03-14T03:51:41.7020651Z settings_text, _ = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:41.7021368Z return parse_settings_from_text(settings_text) 2025-03-14T03:51:41.7021860Z 2025-03-14T03:51:41.7021872Z 2025-03-14T03:51:41.7022106Z def parse_users(rollout_state: str) -> UserOptins: 2025-03-14T03:51:41.7022647Z """ 2025-03-14T03:51:41.7023035Z Parse users from the rollout state. 2025-03-14T03:51:41.7023371Z 2025-03-14T03:51:41.7023524Z """ 2025-03-14T03:51:41.7024027Z _, users_text = extract_settings_user_opt_in_from_text(rollout_state) 2025-03-14T03:51:41.7024722Z return parse_user_opt_in_from_text(users_text) 2025-03-14T03:51:41.7025121Z 2025-03-14T03:51:41.7025127Z 2025-03-14T03:51:41.7025526Z def is_user_opted_in(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:41.7026250Z """ 2025-03-14T03:51:41.7026645Z Check if a user is opted into an experiment 2025-03-14T03:51:41.7027146Z """ 2025-03-14T03:51:41.7027582Z return experiment_name in user_optins.get(user, []) 2025-03-14T03:51:41.7027982Z 2025-03-14T03:51:41.7027989Z 2025-03-14T03:51:41.7028384Z def is_user_opted_out(user: str, user_optins: UserOptins, experiment_name: str) -> bool: 2025-03-14T03:51:41.7029361Z """ 2025-03-14T03:51:41.7029812Z Check if a user explicitly opted out of an experiment 2025-03-14T03:51:41.7030378Z """ 2025-03-14T03:51:41.7030850Z # if the experiment is prefixed with a "-", then it's an opt-out 2025-03-14T03:51:41.7031492Z experiment_optout = "-" + experiment_name 2025-03-14T03:51:41.7032586Z if experiment_optout not in user_optins.get(user, []): 2025-03-14T03:51:41.7033168Z return False 2025-03-14T03:51:41.7033406Z 2025-03-14T03:51:41.7033663Z if is_user_opted_in(user, user_optins, experiment_name): 2025-03-14T03:51:41.7034217Z log.warning( 2025-03-14T03:51:41.7034959Z f"User {user} is opted into experiment {experiment_name}, but also opted out of it. Defaulting to opting out" 2025-03-14T03:51:41.7035775Z ) 2025-03-14T03:51:41.7035978Z 2025-03-14T03:51:41.7036145Z return True 2025-03-14T03:51:41.7036370Z 2025-03-14T03:51:41.7036376Z 2025-03-14T03:51:41.7036546Z def get_runner_prefix( 2025-03-14T03:51:41.7036960Z rollout_state: str, 2025-03-14T03:51:41.7037396Z workflow_requestors: Iterable[str], 2025-03-14T03:51:41.7037888Z branch: str, 2025-03-14T03:51:41.7038348Z eligible_experiments: frozenset[str] = frozenset(), 2025-03-14T03:51:41.7038909Z is_canary: bool = False, 2025-03-14T03:51:41.7039338Z ) -> str: 2025-03-14T03:51:41.7039733Z settings = parse_settings(rollout_state) 2025-03-14T03:51:41.7040278Z user_optins = parse_users(rollout_state) 2025-03-14T03:51:41.7040630Z 2025-03-14T03:51:41.7040794Z fleet_prefix = "" 2025-03-14T03:51:41.7041192Z prefixes = [] 2025-03-14T03:51:41.7041969Z for experiment_name, experiment_settings in settings.experiments.items(): 2025-03-14T03:51:41.7042846Z if not experiment_settings.all_branches and is_exception_branch(branch): 2025-03-14T03:51:41.7043665Z log.info( 2025-03-14T03:51:41.7044313Z f"Branch {branch} is an exception branch. Not enabling experiment {experiment_name}." 2025-03-14T03:51:41.7045025Z ) 2025-03-14T03:51:41.7045380Z continue 2025-03-14T03:51:41.7045612Z 2025-03-14T03:51:41.7045793Z if eligible_experiments: 2025-03-14T03:51:41.7046320Z if experiment_name not in eligible_experiments: 2025-03-14T03:51:41.7046914Z exp_list = ", ".join(eligible_experiments) 2025-03-14T03:51:41.7047434Z log.info( 2025-03-14T03:51:41.7048163Z f"Skipping experiment '{experiment_name}', as it is not in the eligible_experiments list: {exp_list}" 2025-03-14T03:51:41.7048943Z ) 2025-03-14T03:51:41.7049322Z continue 2025-03-14T03:51:41.7049799Z elif not experiment_settings.default: 2025-03-14T03:51:41.7050314Z log.info( 2025-03-14T03:51:41.7050934Z f"Skipping experiment '{experiment_name}', as it is not a default experiment" 2025-03-14T03:51:41.7051728Z ) 2025-03-14T03:51:41.7052086Z continue 2025-03-14T03:51:41.7052327Z 2025-03-14T03:51:41.7052585Z # Is any workflow_requestor opted out to this experiment? 2025-03-14T03:51:41.7053172Z opted_out_users = [ 2025-03-14T03:51:41.7053594Z requestor 2025-03-14T03:51:41.7054021Z for requestor in workflow_requestors 2025-03-14T03:51:41.7054647Z if is_user_opted_out(requestor, user_optins, experiment_name) 2025-03-14T03:51:41.7055235Z ] 2025-03-14T03:51:41.7055430Z 2025-03-14T03:51:41.7055594Z if opted_out_users: 2025-03-14T03:51:41.7056021Z log.info( 2025-03-14T03:51:41.7056587Z f"{', '.join(opted_out_users)} have opted out of experiment {experiment_name}." 2025-03-14T03:51:41.7057235Z ) 2025-03-14T03:51:41.7057593Z continue 2025-03-14T03:51:41.7057831Z 2025-03-14T03:51:41.7058089Z # Is any workflow_requestor opted in to this experiment? 2025-03-14T03:51:41.7058672Z opted_in_users = [ 2025-03-14T03:51:41.7059087Z requestor 2025-03-14T03:51:41.7059633Z for requestor in workflow_requestors 2025-03-14T03:51:41.7060262Z if is_user_opted_in(requestor, user_optins, experiment_name) 2025-03-14T03:51:41.7060852Z ] 2025-03-14T03:51:41.7061042Z 2025-03-14T03:51:41.7061215Z enabled = False 2025-03-14T03:51:41.7061717Z if opted_in_users: 2025-03-14T03:51:41.7062133Z log.info( 2025-03-14T03:51:41.7062693Z f"{', '.join(opted_in_users)} have opted into experiment {experiment_name}." 2025-03-14T03:51:41.7063332Z ) 2025-03-14T03:51:41.7063705Z enabled = True 2025-03-14T03:51:41.7063969Z 2025-03-14T03:51:41.7064182Z elif experiment_settings.rollout_perc: 2025-03-14T03:51:41.7064960Z # If no user is opted in, then we randomly enable the experiment based on the rollout percentage 2025-03-14T03:51:41.7065822Z if random.uniform(0, 100) <= experiment_settings.rollout_perc: 2025-03-14T03:51:41.7066438Z log.info( 2025-03-14T03:51:41.7067250Z f"Based on rollout percentage of {experiment_settings.rollout_perc}%, enabling experiment {experiment_name}." 2025-03-14T03:51:41.7068117Z ) 2025-03-14T03:51:41.7068505Z enabled = True 2025-03-14T03:51:41.7068780Z 2025-03-14T03:51:41.7068938Z if enabled: 2025-03-14T03:51:41.7069341Z label = experiment_name 2025-03-14T03:51:41.7069858Z if experiment_name == LF_FLEET_EXPERIMENT: 2025-03-14T03:51:41.7070624Z # We give some special treatment to the "lf" experiment since determines the fleet we use 2025-03-14T03:51:41.7071443Z # - If it's enabled, then we always list it's prefix first 2025-03-14T03:51:41.7072390Z # - If we're in the canary branch, then we append ".c" to the lf prefix 2025-03-14T03:51:41.7073019Z if is_canary: 2025-03-14T03:51:41.7073485Z label += CANARY_FLEET_SUFFIX 2025-03-14T03:51:41.7074009Z fleet_prefix = label 2025-03-14T03:51:41.7074660Z else: 2025-03-14T03:51:41.7075289Z prefixes.append(label) 2025-03-14T03:51:41.7075834Z 2025-03-14T03:51:41.7076048Z if len(prefixes) > 1: 2025-03-14T03:51:41.7076475Z log.error( 2025-03-14T03:51:41.7077431Z 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.7078473Z ) 2025-03-14T03:51:41.7078843Z prefixes = prefixes[:1] 2025-03-14T03:51:41.7079134Z 2025-03-14T03:51:41.7079310Z # Fleet always comes first 2025-03-14T03:51:41.7079755Z if fleet_prefix: 2025-03-14T03:51:41.7080182Z prefixes.insert(0, fleet_prefix) 2025-03-14T03:51:41.7080513Z 2025-03-14T03:51:41.7080767Z return ".".join(prefixes) + "." if prefixes else "" 2025-03-14T03:51:41.7081146Z 2025-03-14T03:51:41.7081153Z 2025-03-14T03:51:41.7081676Z def get_rollout_state_from_issue(github_token: str, repo: str, issue_num: int) -> str: 2025-03-14T03:51:41.7082570Z """ 2025-03-14T03:51:41.7083114Z Gets the first comment of the issue, which contains the desired rollout state. 2025-03-14T03:51:41.7083640Z 2025-03-14T03:51:41.7084000Z The default issue we use - https://github.com/pytorch/test-infra/issues/5132 2025-03-14T03:51:41.7084654Z """ 2025-03-14T03:51:41.7085016Z gh = get_gh_client(github_token) 2025-03-14T03:51:41.7085522Z issue = get_issue(gh, repo, issue_num) 2025-03-14T03:51:41.7086115Z return str(issue.get_comments()[0].body.strip("\n\t ")) 2025-03-14T03:51:41.7086523Z 2025-03-14T03:51:41.7086529Z 2025-03-14T03:51:41.7086899Z def download_json(url: str, headers: dict[str, str], num_retries: int = 3) -> Any: 2025-03-14T03:51:41.7087599Z for _ in range(num_retries): 2025-03-14T03:51:41.7088049Z try: 2025-03-14T03:51:41.7088448Z req = Request(url=url, headers=headers) 2025-03-14T03:51:41.7089095Z content = urlopen(req, timeout=5).read().decode("utf-8") 2025-03-14T03:51:41.7089846Z return json.loads(content) 2025-03-14T03:51:41.7090343Z except Exception as e: 2025-03-14T03:51:41.7090851Z log.warning(f"Could not download {url}: {e}") 2025-03-14T03:51:41.7091227Z 2025-03-14T03:51:41.7091692Z log.warning(f"All {num_retries} retries exhausted, downloading {url} failed") 2025-03-14T03:51:41.7092359Z return {} 2025-03-14T03:51:41.7092569Z 2025-03-14T03:51:41.7092574Z 2025-03-14T03:51:41.7092728Z @cache 2025-03-14T03:51:41.7093307Z def get_pr_info(github_repo: str, github_token: str, pr_number: int) -> dict[str, Any]: 2025-03-14T03:51:41.7094010Z """ 2025-03-14T03:51:41.7094381Z Dynamically get PR information 2025-03-14T03:51:41.7094872Z """ 2025-03-14T03:51:41.7095335Z github_api = f"https://api.github.com/repos/{github_repo}" 2025-03-14T03:51:41.7095920Z headers = { 2025-03-14T03:51:41.7096352Z "Accept": "application/vnd.github.v3+json", 2025-03-14T03:51:41.7096922Z "Authorization": f"token {github_token}", 2025-03-14T03:51:41.7097413Z } 2025-03-14T03:51:41.7097813Z json_response: dict[str, Any] = download_json( 2025-03-14T03:51:41.7098370Z url=f"{github_api}/issues/{pr_number}", 2025-03-14T03:51:41.7098884Z headers=headers, 2025-03-14T03:51:41.7099289Z ) 2025-03-14T03:51:41.7099471Z 2025-03-14T03:51:41.7099650Z if not json_response: 2025-03-14T03:51:41.7100183Z log.warning(f"Failed to get the labels for #{pr_number}") 2025-03-14T03:51:41.7100750Z return {} 2025-03-14T03:51:41.7100976Z 2025-03-14T03:51:41.7101144Z return json_response 2025-03-14T03:51:41.7101409Z 2025-03-14T03:51:41.7101414Z 2025-03-14T03:51:41.7101888Z def get_labels(github_repo: str, github_token: str, pr_number: int) -> set[str]: 2025-03-14T03:51:41.7102715Z """ 2025-03-14T03:51:41.7103225Z Dynamically get the latest list of labels from the pull request 2025-03-14T03:51:41.7103835Z """ 2025-03-14T03:51:41.7104285Z pr_info = get_pr_info(github_repo, github_token, pr_number) 2025-03-14T03:51:41.7104856Z return { 2025-03-14T03:51:41.7105404Z label.get("name") for label in pr_info.get("labels", []) if label.get("name") 2025-03-14T03:51:41.7106061Z } 2025-03-14T03:51:41.7106248Z 2025-03-14T03:51:41.7106254Z 2025-03-14T03:51:41.7106425Z def main() -> None: 2025-03-14T03:51:41.7106813Z args = parse_args() 2025-03-14T03:51:41.7107068Z 2025-03-14T03:51:41.7107276Z runner_label_prefix = DEFAULT_LABEL_PREFIX 2025-03-14T03:51:41.7107638Z 2025-03-14T03:51:41.7107816Z # Check if the PR is opt-out 2025-03-14T03:51:41.7108279Z if args.pr_number: 2025-03-14T03:51:41.7108886Z labels = get_labels(args.github_repo, args.github_token, int(args.pr_number)) 2025-03-14T03:51:41.7109586Z if OPT_OUT_LABEL in labels: 2025-03-14T03:51:41.7110058Z log.info( 2025-03-14T03:51:41.7110702Z f"Opt-out runner determinator because #{args.pr_number} has {OPT_OUT_LABEL} label" 2025-03-14T03:51:41.7111413Z ) 2025-03-14T03:51:41.7112019Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:41.7112645Z sys.exit() 2025-03-14T03:51:41.7112885Z 2025-03-14T03:51:41.7113033Z try: 2025-03-14T03:51:41.7113438Z rollout_state = get_rollout_state_from_issue( 2025-03-14T03:51:41.7114095Z args.github_token, args.github_issue_repo, args.github_issue 2025-03-14T03:51:41.7114687Z ) 2025-03-14T03:51:41.7114877Z 2025-03-14T03:51:41.7115074Z username = get_potential_pr_author( 2025-03-14T03:51:41.7115574Z args.github_token, 2025-03-14T03:51:41.7116024Z args.github_repo, 2025-03-14T03:51:41.7116470Z args.github_actor, 2025-03-14T03:51:41.7116923Z args.github_ref_type, 2025-03-14T03:51:41.7117390Z args.github_branch, 2025-03-14T03:51:41.7117814Z ) 2025-03-14T03:51:41.7118011Z 2025-03-14T03:51:41.7118277Z is_canary = args.github_repo == "pytorch/pytorch-canary" 2025-03-14T03:51:41.7118850Z 2025-03-14T03:51:41.7119055Z runner_label_prefix = get_runner_prefix( 2025-03-14T03:51:41.7119573Z rollout_state, 2025-03-14T03:51:41.7120031Z (args.github_issue_owner, username), 2025-03-14T03:51:41.7120541Z args.github_branch, 2025-03-14T03:51:41.7121006Z args.eligible_experiments, 2025-03-14T03:51:41.7121485Z is_canary, 2025-03-14T03:51:41.7122194Z ) 2025-03-14T03:51:41.7122391Z 2025-03-14T03:51:41.7122570Z except Exception as e: 2025-03-14T03:51:41.7122988Z log.error( 2025-03-14T03:51:41.7123610Z f"Failed to get issue. Defaulting to Meta runners and no experiments. Exception: {e}" 2025-03-14T03:51:41.7124313Z ) 2025-03-14T03:51:41.7124511Z 2025-03-14T03:51:41.7124831Z set_github_output(GH_OUTPUT_KEY_LABEL_TYPE, runner_label_prefix) 2025-03-14T03:51:41.7125291Z 2025-03-14T03:51:41.7125297Z 2025-03-14T03:51:41.7125477Z if __name__ == "__main__": 2025-03-14T03:51:41.7125890Z main() 2025-03-14T03:51:41.7126086Z 2025-03-14T03:51:41.7210322Z ##[group]Run python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-03-14T03:51:41.7211159Z python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0 2025-03-14T03:51:41.7256340Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:41.7256797Z env: 2025-03-14T03:51:41.7257366Z GITHUB_TOKEN: *** 2025-03-14T03:51:41.7257765Z ISSUE_NUMBER: 5132 2025-03-14T03:51:41.7258198Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:41.7258676Z ISSUE_OWNER: 2025-03-14T03:51:41.7259066Z CHECK_EXPERIMENTS: 2025-03-14T03:51:41.7259464Z PR_NUMBER: 2025-03-14T03:51:41.7259817Z ##[endgroup] 2025-03-14T03:51:42.0660494Z Defaulting to user installation because normal site-packages is not writeable 2025-03-14T03:51:42.3430412Z Collecting urllib3==1.26.18 2025-03-14T03:51:42.4024162Z Downloading urllib3-1.26.18-py2.py3-none-any.whl.metadata (48 kB) 2025-03-14T03:51:42.4268533Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 kB 4.3 MB/s eta 0:00:00 2025-03-14T03:51:42.4492196Z Collecting PyGithub==2.3.0 2025-03-14T03:51:42.4575137Z Downloading PyGithub-2.3.0-py3-none-any.whl.metadata (3.8 kB) 2025-03-14T03:51:42.5115460Z Collecting pynacl>=1.4.0 (from PyGithub==2.3.0) 2025-03-14T03:51:42.5194311Z 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:42.5243244Z 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:42.5259916Z 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:42.5274534Z 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:42.5570036Z Collecting Deprecated (from PyGithub==2.3.0) 2025-03-14T03:51:42.5644499Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl.metadata (5.7 kB) 2025-03-14T03:51:42.5874267Z 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:42.7020684Z Collecting cffi>=1.4.1 (from pynacl>=1.4.0->PyGithub==2.3.0) 2025-03-14T03:51:42.7096111Z Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.5 kB) 2025-03-14T03:51:42.8145408Z Collecting wrapt<2,>=1.10 (from Deprecated->PyGithub==2.3.0) 2025-03-14T03:51:42.8222878Z 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:42.8443923Z Collecting pycparser (from cffi>=1.4.1->pynacl>=1.4.0->PyGithub==2.3.0) 2025-03-14T03:51:42.8516668Z Downloading pycparser-2.22-py3-none-any.whl.metadata (943 bytes) 2025-03-14T03:51:42.8785751Z Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB) 2025-03-14T03:51:42.8881060Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.8/143.8 kB 17.5 MB/s eta 0:00:00 2025-03-14T03:51:42.8957040Z Downloading PyGithub-2.3.0-py3-none-any.whl (354 kB) 2025-03-14T03:51:42.9060179Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 354.4/354.4 kB 39.5 MB/s eta 0:00:00 2025-03-14T03:51:42.9135510Z 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:42.9248656Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 856.7/856.7 kB 86.7 MB/s eta 0:00:00 2025-03-14T03:51:42.9324899Z Downloading Deprecated-1.2.18-py2.py3-none-any.whl (10.0 kB) 2025-03-14T03:51:42.9439512Z Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479 kB) 2025-03-14T03:51:42.9505509Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 479.4/479.4 kB 98.2 MB/s eta 0:00:00 2025-03-14T03:51:42.9587431Z 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:42.9627199Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 89.2/89.2 kB 32.6 MB/s eta 0:00:00 2025-03-14T03:51:42.9697440Z Downloading pycparser-2.22-py3-none-any.whl (117 kB) 2025-03-14T03:51:42.9744140Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.6/117.6 kB 37.1 MB/s eta 0:00:00 2025-03-14T03:51:43.2722309Z Installing collected packages: wrapt, urllib3, pycparser, Deprecated, cffi, pynacl, PyGithub 2025-03-14T03:51:43.7995894Z 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:43.8679966Z ##[group]Run curr_branch="main" 2025-03-14T03:51:43.8680346Z curr_branch="main" 2025-03-14T03:51:43.8680630Z curr_ref_type="branch" 2025-03-14T03:51:43.8680946Z echo "Current branch is '$curr_branch'" 2025-03-14T03:51:43.8681272Z  2025-03-14T03:51:43.8681524Z python3 runner_determinator.py \ 2025-03-14T03:51:43.8682138Z  --github-token "$GITHUB_TOKEN" \ 2025-03-14T03:51:43.8682523Z  --github-issue "$ISSUE_NUMBER" \ 2025-03-14T03:51:43.8682840Z  --github-branch "$curr_branch" \ 2025-03-14T03:51:43.8683181Z  --github-actor "$TRIGGERING_ACTOR" \ 2025-03-14T03:51:43.8683534Z  --github-issue-owner "$ISSUE_OWNER" \ 2025-03-14T03:51:43.8683879Z  --github-ref-type "$curr_ref_type" \ 2025-03-14T03:51:43.8684211Z  --github-repo "$GITHUB_REPOSITORY" \ 2025-03-14T03:51:43.8684585Z  --eligible-experiments "$CHECK_EXPERIMENTS" \ 2025-03-14T03:51:43.8685012Z  --pr-number "${PR_NUMBER}" 2025-03-14T03:51:43.8733068Z shell: /usr/bin/bash -e {0} 2025-03-14T03:51:43.8733361Z env: 2025-03-14T03:51:43.8733920Z GITHUB_TOKEN: *** 2025-03-14T03:51:43.8734180Z ISSUE_NUMBER: 5132 2025-03-14T03:51:43.8734442Z TRIGGERING_ACTOR: pytorchmergebot 2025-03-14T03:51:43.8734748Z ISSUE_OWNER: 2025-03-14T03:51:43.8734984Z CHECK_EXPERIMENTS: 2025-03-14T03:51:43.8735239Z PR_NUMBER: 2025-03-14T03:51:43.8735469Z ##[endgroup] 2025-03-14T03:51:43.8800656Z Current branch is 'main' 2025-03-14T03:51:45.0556247Z INFO : Branch main is an exception branch. Not enabling experiment ephemeral. 2025-03-14T03:51:45.0557363Z INFO : Setting output: label-type='' 2025-03-14T03:51:45.0856705Z Evaluate and set job outputs 2025-03-14T03:51:45.0864003Z Cleaning up orphan processes