-
Notifications
You must be signed in to change notification settings - Fork 100
Try using UV for faster installs #1112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d7de256
bfaceed
aa122e2
72c62db
b2626f6
921bb1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,53 @@ | ||||||||||||||||||||||||||||||||||||||||
| <#! | ||||||||||||||||||||||||||||||||||||||||
| .SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||
| Activates a virtual environment for a CI machine. Any further usages of "python" will utilize this virtual environment. | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| .DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||
| When activating a virtual environment, only a few things are actually functionally changed on the machine. | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # 1. PATH = path to the bin directory of the virtual env. "Scripts" on windows machines | ||||||||||||||||||||||||||||||||||||||||
| # 2. VIRTUAL_ENV = path to root of the virtual env | ||||||||||||||||||||||||||||||||||||||||
| # 3. VIRTUAL_ENV_PROMPT = the prompt that is displayed next to the CLI cursor when the virtual env is active | ||||||||||||||||||||||||||||||||||||||||
| # within a CI machine, we only need the PATH and VIRTUAL_ENV variables to be set. | ||||||||||||||||||||||||||||||||||||||||
| # 4. (optional and inconsistently) _OLD_VIRTUAL_PATH = the PATH before the virtual env was activated. This is not set in this script. | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| .PARAMETER VenvName | ||||||||||||||||||||||||||||||||||||||||
| The name of the virtual environment to activate. | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| .PARAMETER RepoRoot | ||||||||||||||||||||||||||||||||||||||||
| The root of the repository. | ||||||||||||||||||||||||||||||||||||||||
| #> | ||||||||||||||||||||||||||||||||||||||||
| param ( | ||||||||||||||||||||||||||||||||||||||||
| [string]$VenvName = "venv" | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Set-StrictMode -Version 4 | ||||||||||||||||||||||||||||||||||||||||
| $ErrorActionPreference = "Stop" | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| $repoRoot = Join-Path $PSScriptRoot ".." ".." -Resolve | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+27
|
||||||||||||||||||||||||||||||||||||||||
| [string]$VenvName = "venv" | |
| ) | |
| Set-StrictMode -Version 4 | |
| $ErrorActionPreference = "Stop" | |
| $repoRoot = Join-Path $PSScriptRoot ".." ".." -Resolve | |
| [string]$VenvName = "venv", | |
| [string]$RepoRoot | |
| ) | |
| Set-StrictMode -Version 4 | |
| $ErrorActionPreference = "Stop" | |
| if ($RepoRoot) { | |
| $repoRoot = $RepoRoot | |
| } else { | |
| $repoRoot = Join-Path $PSScriptRoot ".." ".." -Resolve | |
| } |
Copilot
AI
Mar 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this script is intended to be dot-sourced, calling exit 1 will terminate the entire PowerShell session immediately, which makes it hard for the caller to handle/report errors consistently. Prefer throw here so the calling script can fail naturally (and optionally catch/log) while still stopping execution.
| exit 1 | |
| throw |
Copilot
AI
Mar 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log message has an extra trailing apostrophe after the venv path (... at $venvPath.'). This looks like a typo and can be confusing when reading pipeline logs.
| Write-Host "Activating virtual environment '$VenvName' via VIRTUAL_ENV variable at $venvPath.'" | |
| Write-Host "Activating virtual environment '$VenvName' via VIRTUAL_ENV variable at $venvPath." |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||||||||||||||||||||||||||||
| <#! | ||||||||||||||||||||||||||||||
| .SYNOPSIS | ||||||||||||||||||||||||||||||
| Creates a virtual environment for a CI machine. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| .DESCRIPTION | ||||||||||||||||||||||||||||||
| If the virtual environment directory already exists, it will skip the creation. The location of the virtual environment will be stored in a variable | ||||||||||||||||||||||||||||||
| named <VenvName>_LOCATION. The location will be RepoRoot + VenvName. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| .PARAMETER VenvName | ||||||||||||||||||||||||||||||
| The name of the virtual environment which will be created. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| .PARAMETER RepoRoot | ||||||||||||||||||||||||||||||
| The root of the repository. | ||||||||||||||||||||||||||||||
| #> | ||||||||||||||||||||||||||||||
| param( | ||||||||||||||||||||||||||||||
| [string] $VenvName = "venv" | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| $repoRoot = Join-Path $PSScriptRoot ".." ".." -Resolve | ||||||||||||||||||||||||||||||
|
Comment on lines
+16
to
+19
|
||||||||||||||||||||||||||||||
| [string] $VenvName = "venv" | |
| ) | |
| $repoRoot = Join-Path $PSScriptRoot ".." ".." -Resolve | |
| [string] $VenvName = "venv", | |
| [string] $RepoRoot | |
| ) | |
| if ($PSBoundParameters.ContainsKey('RepoRoot') -and $RepoRoot) { | |
| $repoRoot = $RepoRoot | |
| } | |
| else { | |
| $repoRoot = Join-Path $PSScriptRoot ".." ".." -Resolve | |
| } |
Copilot
AI
Mar 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Native command failures in this script aren’t checked. uv venv, python -m pip install ..., and python -m virtualenv ... can fail without throwing, and the script will continue (PowerShell doesn’t automatically stop on non-zero exit codes from native commands). Consider checking $LASTEXITCODE/$? after each native command and throwing on failure to avoid silently continuing with a missing/broken venv.
Copilot
AI
Mar 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$pythonVersion = python --version will report the invoking shell’s python, not necessarily the interpreter used to create the venv (especially in the uv venv path). If the intent is to log the venv’s Python version, query the venv interpreter directly (e.g., $venvPath/bin/python or $venvPath/Scripts/python.exe).
| $pythonVersion = python --version | |
| if ($IsWindows) { | |
| $venvPython = Join-Path $venvPath "Scripts/python.exe" | |
| } | |
| else { | |
| $venvPython = Join-Path $venvPath "bin/python" | |
| } | |
| $pythonVersion = & $venvPython --version |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,97 +24,104 @@ | |||||||||
| .LINK | ||||||||||
| https://github.com/devdiv-microsoft/MicrosoftSweBench/wiki | ||||||||||
| #> | ||||||||||
| param( | ||||||||||
| [string]$Benchmark = "azure", | ||||||||||
| [string]$Model = "claude-sonnet-4.5-autodev-test", | ||||||||||
| [switch]$NoWait | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| param( | ||||||||||
| [string]$Benchmark = "azure", | ||||||||||
| [string]$Model = "claude-sonnet-4.5-autodev-test", | ||||||||||
| [switch]$NoWait | ||||||||||
| ) | ||||||||||
| Set-StrictMode -Version Latest | ||||||||||
| $ErrorActionPreference = "Stop" | ||||||||||
|
|
||||||||||
| Set-StrictMode -Version Latest | ||||||||||
| $ErrorActionPreference = "Stop" | ||||||||||
| if (!$Benchmark) { | ||||||||||
| throw "Benchmark parameter is required." | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (!$Benchmark) { | ||||||||||
| throw "Benchmark parameter is required." | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (!$Model) { | ||||||||||
| throw "Model parameter is required." | ||||||||||
| } | ||||||||||
|
|
||||||||||
| $vaultName = "kv-msbench-eval-azuremcp" | ||||||||||
| $secretName = "azure-eval-gh-pat" | ||||||||||
| if (!$Model) { | ||||||||||
| throw "Model parameter is required." | ||||||||||
| } | ||||||||||
|
|
||||||||||
| Write-Host "Benchmark: $Benchmark" | ||||||||||
| Write-Host "Model: $Model" | ||||||||||
| Write-Host "NoWait: $NoWait" | ||||||||||
| $repoRoot = Join-Path $PSScriptRoot ".." ".." -Resolve | ||||||||||
| $vaultName = "kv-msbench-eval-azuremcp" | ||||||||||
| $secretName = "azure-eval-gh-pat" | ||||||||||
|
|
||||||||||
| $pipelineRun = $env:TF_BUILD -eq "True" | ||||||||||
| Write-Host "Benchmark: $Benchmark" | ||||||||||
| Write-Host "Model: $Model" | ||||||||||
| Write-Host "NoWait: $NoWait" | ||||||||||
|
|
||||||||||
| # --- Retrieve GitHub PAT from KeyVault --- | ||||||||||
| try { | ||||||||||
| Write-Host "Retrieving GitHub PAT from KeyVault $vaultName secret $secretName" | ||||||||||
| $pat = az keyvault secret show --vault-name $vaultName --name $secretName --query value -o tsv | ||||||||||
| $pipelineRun = $env:TF_BUILD -eq "True" | ||||||||||
|
|
||||||||||
| if (!$pat) { | ||||||||||
| throw "Secret $secretName not found in KeyVault $vaultName." | ||||||||||
| } | ||||||||||
| . "$PSScriptRoot/Create-Venv.ps1" -VenvName "venv" -RepoRoot $repoRoot | ||||||||||
| . "$PSScriptRoot/Activate-Venv.ps1" -VenvName "venv" -RepoRoot $repoRoot | ||||||||||
|
Comment on lines
+54
to
+55
|
||||||||||
| . "$PSScriptRoot/Create-Venv.ps1" -VenvName "venv" -RepoRoot $repoRoot | |
| . "$PSScriptRoot/Activate-Venv.ps1" -VenvName "venv" -RepoRoot $repoRoot | |
| . "$PSScriptRoot/Create-Venv.ps1" -VenvName "venv" | |
| . "$PSScriptRoot/Activate-Venv.ps1" -VenvName "venv" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| steps: | ||
| - task: Bash@3 | ||
| displayName: 'Install uv (Linux/macOS)' | ||
| inputs: | ||
| targetType: inline | ||
| script: | | ||
| curl -LsSf https://astral.sh/uv/install.sh | sh | ||
| condition: or(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.OS'], 'Darwin')) | ||
hallipr marked this conversation as resolved.
Show resolved
Hide resolved
hallipr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - task: Bash@3 | ||
| inputs: | ||
| targetType: inline | ||
| script: | | ||
| echo "##vso[task.prependpath]$HOME/.local/bin" | ||
| displayName: 'Prepend path for MacOS' | ||
| condition: eq(variables['Agent.OS'], 'Darwin') | ||
hallipr marked this conversation as resolved.
Show resolved
Hide resolved
hallipr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - task: PowerShell@2 | ||
| displayName: 'Install uv (Windows)' | ||
| inputs: | ||
| targetType: inline | ||
| script: | | ||
| iex (irm https://astral.sh/uv/install.ps1) | ||
hallipr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Write-Host "##vso[task.prependpath]$env:USERPROFILE\.local\bin" | ||
hallipr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| condition: eq(variables['Agent.OS'], 'Windows_NT') | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uv python install 3.12installs a Python runtime, but nothing here ensures subsequentuv pip/uv runcommands will actually use 3.12 (andUsePythonVersion@0was removed). Consider explicitly selecting the interpreter (e.g., passing--python 3.12to theuvcommands or setting the appropriate env var) so the benchmark runs against the intended Python version.