-
Notifications
You must be signed in to change notification settings - Fork 290
Expand file tree
/
Copy pathtest-python-steps.yml
More file actions
136 lines (116 loc) · 4.82 KB
/
test-python-steps.yml
File metadata and controls
136 lines (116 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# Lightweight test-only steps for the Python SDK.
# Builds from source and runs tests — no artifact staging.
parameters:
- name: version
type: string
- name: isWinML
type: boolean
default: false
- name: flcWheelsDir
type: string
displayName: 'Path to directory containing the FLC wheels'
steps:
- task: PowerShell@2
displayName: 'Set source paths'
inputs:
targetType: inline
script: |
$repoRoot = "$(Build.SourcesDirectory)/Foundry-Local"
$testDataDir = "$(Build.SourcesDirectory)/test-data-shared"
Write-Host "##vso[task.setvariable variable=repoRoot]$repoRoot"
Write-Host "##vso[task.setvariable variable=testDataDir]$testDataDir"
- ${{ if eq(parameters.isWinML, true) }}:
- task: PowerShell@2
displayName: 'Install Windows App SDK Runtime'
inputs:
targetType: 'inline'
script: |
$installerUrl = "https://aka.ms/windowsappsdk/1.8/latest/windowsappruntimeinstall-x64.exe"
$installerPath = "$env:TEMP\windowsappruntimeinstall.exe"
Write-Host "Downloading Windows App SDK Runtime installer from $installerUrl..."
Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath
Write-Host "Installing Windows App SDK Runtime..."
& $installerPath --quiet --force
if ($LASTEXITCODE -ne 0) {
Write-Error "Installation failed with exit code $LASTEXITCODE"
exit 1
}
Write-Host "Windows App SDK Runtime installed successfully."
errorActionPreference: 'stop'
- task: UsePythonVersion@0
displayName: 'Use Python 3.12'
inputs:
versionSpec: '3.12'
- task: PowerShell@2
displayName: 'List downloaded FLC wheels'
condition: and(succeeded(), ne('${{ parameters.flcWheelsDir }}', ''))
inputs:
targetType: inline
script: |
Write-Host "Contents of ${{ parameters.flcWheelsDir }}:"
Get-ChildItem "${{ parameters.flcWheelsDir }}" -Recurse | ForEach-Object { Write-Host $_.FullName }
- task: PowerShell@2
displayName: 'Configure pip for Azure Artifacts'
inputs:
targetType: inline
script: |
pip config set global.index-url https://pkgs.dev.azure.com/aiinfra/PublicPackages/_packaging/ORT-Nightly/pypi/simple/
pip config set global.extra-index-url https://pypi.org/simple/
pip config set global.pre true
- script: python -m pip install build
displayName: 'Install build tool'
- task: PowerShell@2
displayName: 'Set SDK version'
inputs:
targetType: inline
script: |
Set-Content -Path "$(repoRoot)/sdk/python/src/version.py" -Value '__version__ = "${{ parameters.version }}"'
- task: PowerShell@2
displayName: 'Pre-install pipeline-built FLC wheel'
condition: and(succeeded(), ne('${{ parameters.flcWheelsDir }}', ''))
inputs:
targetType: inline
script: |
# Determine platform wheel tag for the current machine
$arch = if ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq 'Arm64') { 'arm64' } else { 'amd64' }
if ($IsLinux) { $platTag = "manylinux*x86_64" }
elseif ($IsMacOS) { $platTag = "macosx*$arch" }
else { $platTag = "win_$arch" }
$filter = if ("${{ parameters.isWinML }}" -eq "True") { "foundry_local_core_winml*$platTag.whl" } else { "foundry_local_core-*$platTag.whl" }
$wheel = Get-ChildItem "${{ parameters.flcWheelsDir }}" -Recurse -Filter $filter | Select-Object -First 1
if ($wheel) {
Write-Host "Installing pipeline-built FLC wheel: $($wheel.FullName)"
pip install $($wheel.FullName)
} else {
Write-Warning "No FLC wheel found matching $filter"
}
- ${{ if eq(parameters.isWinML, true) }}:
- script: pip install onnxruntime-core==1.23.2.3 onnxruntime-genai-core==0.12.1
displayName: 'Install ORT native packages (WinML)'
- ${{ else }}:
- script: pip install onnxruntime-core==1.24.3 onnxruntime-genai-core==0.12.1
displayName: 'Install ORT native packages'
- script: pip install "pydantic>=2.0.0" "requests>=2.32.4" "openai>=2.24.0"
displayName: 'Install pure python dependencies'
- ${{ if not(parameters.isWinML) }}:
- script: python -m build --wheel --outdir dist/
displayName: 'Build wheel'
workingDirectory: $(repoRoot)/sdk/python
- ${{ if parameters.isWinML }}:
- script: python -m build --wheel -C winml=true --outdir dist/
displayName: 'Build wheel (WinML)'
workingDirectory: $(repoRoot)/sdk/python
- task: PowerShell@2
displayName: 'Install built wheel'
inputs:
targetType: inline
script: |
$wheel = (Get-ChildItem "$(repoRoot)/sdk/python/dist/*.whl" | Select-Object -First 1).FullName
pip install --no-deps $wheel
- script: pip install coverage pytest>=7.0.0 pytest-timeout>=2.1.0
displayName: 'Install test dependencies'
- script: python -m pytest test/ -v
displayName: 'Run tests'
workingDirectory: $(repoRoot)/sdk/python
env:
TF_BUILD: 'true'