Skip to content

Try using UV for faster installs#1112

Open
hallipr wants to merge 6 commits intomainfrom
users/pahallis/run-bench
Open

Try using UV for faster installs#1112
hallipr wants to merge 6 commits intomainfrom
users/pahallis/run-bench

Conversation

@hallipr
Copy link
Member

@hallipr hallipr commented Mar 3, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 3, 2026 19:45
@github-project-automation github-project-automation bot moved this to Untriaged in Azure MCP Server Mar 3, 2026
@hallipr hallipr moved this from Untriaged to In Progress in Azure MCP Server Mar 3, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR switches the Azure benchmark pipeline from a preinstalled Python toolchain (UsePythonVersion) to using uv for installing Python and the msbench-cli, aiming to speed up dependency installs and support local runs with authenticated private-feed access.

Changes:

  • Add an Azure Pipelines step template to install uv across OSes.
  • Update the benchmark pipeline to install Python 3.12 via uv instead of UsePythonVersion.
  • Update the benchmark runner script to install/run msbench-cli via uv and add a local-feed-auth fallback using az.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
pipelines/templates/steps/install-uv.yml Adds cross-platform uv installation steps for pipelines.
pipelines/scripts/Invoke-CopilotBenchmarks.ps1 Switches msbench-cli install/run to uv and adds local feed auth fallback.
pipelines/azure-benchmarks.yml Replaces UsePythonVersion@0 with uv install + uv python install 3.12.

python -m pip install msbench-cli --no-input
uv pip install msbench-cli --no-input
if ($LASTEXITCODE -ne 0) {
throw "pip install msbench-cli failed with exit code $LASTEXITCODE"
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failure message still says pip install msbench-cli failed..., but the command is now uv pip install .... This makes debugging harder because logs will reference the wrong tool; update the error text to match the actual command being executed.

Suggested change
throw "pip install msbench-cli failed with exit code $LASTEXITCODE"
throw "uv pip install msbench-cli failed with exit code $LASTEXITCODE"

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings March 3, 2026 22:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

Copilot AI review requested due to automatic review settings March 3, 2026 22:28
@hallipr hallipr force-pushed the users/pahallis/run-bench branch from ec75ecf to 72c62db Compare March 3, 2026 22:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

Comment on lines +22 to +25
- template: /pipelines/templates/steps/install-uv.yml

- pwsh: uv python install 3.12
displayName: 'Install Python 3.12 with uv'
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv python install 3.12 installs a Python runtime, but nothing here ensures subsequent uv pip/uv run commands will actually use 3.12 (and UsePythonVersion@0 was removed). Consider explicitly selecting the interpreter (e.g., passing --python 3.12 to the uv commands or setting the appropriate env var) so the benchmark runs against the intended Python version.

Copilot uses AI. Check for mistakes.
hallipr and others added 2 commits March 3, 2026 14:58
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 3, 2026 23:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Comment on lines +16 to +19
[string] $VenvName = "venv"
)

$repoRoot = Join-Path $PSScriptRoot ".." ".." -Resolve
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The help text documents a RepoRoot parameter, but the script only accepts VenvName. This mismatch is also what causes callers to pass -RepoRoot and fail. Either add a RepoRoot parameter (and honor it when building $venvPath) or remove the RepoRoot documentation.

Suggested change
[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 uses AI. Check for mistakes.
exit 1
}

Write-Host "Activating virtual environment '$VenvName' via VIRTUAL_ENV variable at $venvPath.'"
Copy link

Copilot AI Mar 3, 2026

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.

Suggested change
Write-Host "Activating virtual environment '$VenvName' via VIRTUAL_ENV variable at $venvPath.'"
Write-Host "Activating virtual environment '$VenvName' via VIRTUAL_ENV variable at $venvPath."

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +33
if (!(Test-Path $venvPath)) {
if (Get-Command uv -ErrorAction SilentlyContinue) {
Write-Host "Creating virtual environment '$VenvName' using uv."
uv venv $venvPath --verbose
}
else {
$invokingPython = (Get-Command "python").Source

Write-Host "Creating virtual environment '$VenvName' using virtualenv and python located at '$invokingPython'."
python -m pip install virtualenv==20.25.1
python -m virtualenv $venvPath
}
Copy link

Copilot AI Mar 3, 2026

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 uses AI. Check for mistakes.
python -m pip install virtualenv==20.25.1
python -m virtualenv $venvPath
}
$pythonVersion = python --version
Copy link

Copilot AI Mar 3, 2026

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).

Suggested change
$pythonVersion = python --version
if ($IsWindows) {
$venvPython = Join-Path $venvPath "Scripts/python.exe"
}
else {
$venvPython = Join-Path $venvPath "bin/python"
}
$pythonVersion = & $venvPython --version

Copilot uses AI. Check for mistakes.
Comment on lines +54 to +55
. "$PSScriptRoot/Create-Venv.ps1" -VenvName "venv" -RepoRoot $repoRoot
. "$PSScriptRoot/Activate-Venv.ps1" -VenvName "venv" -RepoRoot $repoRoot
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dot-sourced venv scripts are invoked with -RepoRoot $repoRoot, but neither Create-Venv.ps1 nor Activate-Venv.ps1 defines a RepoRoot parameter. This will fail with “A parameter cannot be found…” before the benchmark runs. Either add a [string]$RepoRoot param to both scripts (and use it instead of recomputing $repoRoot), or remove -RepoRoot from these calls.

Suggested change
. "$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"

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +27
[string]$VenvName = "venv"
)

Set-StrictMode -Version 4
$ErrorActionPreference = "Stop"

$repoRoot = Join-Path $PSScriptRoot ".." ".." -Resolve
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The help text documents a RepoRoot parameter, but the script only accepts VenvName. Since this script is dot-sourced by the benchmark runner, callers passing -RepoRoot will error. Add a RepoRoot parameter (and use it for $venvPath) or remove the RepoRoot documentation and update callers accordingly.

Suggested change
[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 uses AI. Check for mistakes.

if (-not (Test-Path $venvPath)) {
Write-Error "Virtual environment '$venvPath' does not exist at $venvPath"
exit 1
Copy link

Copilot AI Mar 3, 2026

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.

Suggested change
exit 1
throw

Copilot uses AI. Check for mistakes.
@hallipr
Copy link
Member Author

hallipr commented Mar 5, 2026

@copilot, can you iterate on this until it can install and run via UV?

Copy link
Contributor

Copilot AI commented Mar 5, 2026

@hallipr I've opened a new pull request, #1148, to work on those changes. Once the pull request is ready, I'll request review from you.

@JasonYeMSFT
Copy link
Member

@hallipr Do you still want to merge this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

4 participants