Skip to content

Commit 285f189

Browse files
prathikrPrathik Rao
andauthored
adjusts js winml sdk to depend on standard sdk and replace dependencies with winml binaries (#596)
- allows users to do `npm install foundry-local-sdk-winml` and then do `import { FoundryLocalManager } from 'foundry-local-sdk';` like the other SDKs do - creates a compute version stage at the beginning of mega pipeline so all artifacts are generated with the same version string down to the timestamp minute - new node_modules/ structure: <img width="341" height="396" alt="image" src="https://github.com/user-attachments/assets/2c228a14-1e34-406d-9802-c752190d4c53" /> --------- Co-authored-by: Prathik Rao <prathikrao@microsoft.com>
1 parent e4230b4 commit 285f189

File tree

13 files changed

+152
-78
lines changed

13 files changed

+152
-78
lines changed

.pipelines/foundry-local-packaging.yml

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,67 @@ extends:
7070
- repository: neutron-server
7171
- repository: test-data-shared
7272
stages:
73+
# ── Compute Version ──
74+
# A single version string is computed once and shared across all stages.
75+
# This prevents timestamp drift between standard and WinML builds.
76+
# Outputs three format variants:
77+
# sdkVersion – semver for JS, C#, Rust (e.g. 1.0.0-dev.202604061234)
78+
# pyVersion – PEP 440 for Python (e.g. 1.0.0.dev202604061234)
79+
# flcVersion – NuGet/FLC style (e.g. 1.0.0-dev-202604061234-ab12cd34)
80+
- stage: compute_version
81+
displayName: 'Compute Version'
82+
dependsOn: []
83+
jobs:
84+
- job: version
85+
displayName: 'Compute Version'
86+
pool:
87+
name: onnxruntime-Win-CPU-2022
88+
os: windows
89+
templateContext:
90+
outputs:
91+
- output: pipelineArtifact
92+
artifactName: 'version-info'
93+
targetPath: '$(Build.ArtifactStagingDirectory)/version-info'
94+
steps:
95+
- checkout: none
96+
- task: PowerShell@2
97+
displayName: 'Compute and write version files'
98+
inputs:
99+
targetType: inline
100+
script: |
101+
$base = "${{ parameters.version }}"
102+
$preId = "${{ parameters.prereleaseId }}"
103+
$ts = Get-Date -Format "yyyyMMddHHmm"
104+
$commitId = "$(Build.SourceVersion)".Substring(0, 8)
105+
106+
if ($preId -ne '' -and $preId -ne 'none') {
107+
$sdkVersion = "$base-$preId"
108+
$pyVersion = "$base$preId"
109+
$flcVersion = "$base-$preId"
110+
} elseif ("${{ parameters.isRelease }}" -ne "True") {
111+
$sdkVersion = "$base-dev.$ts"
112+
$pyVersion = "$base.dev$ts"
113+
$flcVersion = "$base-dev-$ts-$commitId"
114+
} else {
115+
$sdkVersion = $base
116+
$pyVersion = $base
117+
$flcVersion = $base
118+
}
119+
120+
$outDir = "$(Build.ArtifactStagingDirectory)/version-info"
121+
New-Item -ItemType Directory -Path $outDir -Force | Out-Null
122+
Set-Content -Path "$outDir/sdkVersion.txt" -Value $sdkVersion -NoNewline
123+
Set-Content -Path "$outDir/pyVersion.txt" -Value $pyVersion -NoNewline
124+
Set-Content -Path "$outDir/flcVersion.txt" -Value $flcVersion -NoNewline
125+
126+
Write-Host "SDK version: $sdkVersion"
127+
Write-Host "Python version: $pyVersion"
128+
Write-Host "FLC version: $flcVersion"
129+
73130
# ── Build & Test FLC ──
74131
- stage: build_core
75132
displayName: 'Build & Test FLC'
133+
dependsOn: compute_version
76134
jobs:
77135
- job: flc_win_x64
78136
displayName: 'FLC win-x64'
@@ -160,6 +218,10 @@ extends:
160218
name: onnxruntime-Win-CPU-2022
161219
os: windows
162220
templateContext:
221+
inputs:
222+
- input: pipelineArtifact
223+
artifactName: 'version-info'
224+
targetPath: '$(Pipeline.Workspace)/version-info'
163225
outputs:
164226
- output: pipelineArtifact
165227
artifactName: 'flc-nuget'
@@ -229,6 +291,9 @@ extends:
229291
os: windows
230292
templateContext:
231293
inputs:
294+
- input: pipelineArtifact
295+
artifactName: 'version-info'
296+
targetPath: '$(Pipeline.Workspace)/version-info'
232297
- input: pipelineArtifact
233298
artifactName: 'flc-nuget'
234299
targetPath: '$(Pipeline.Workspace)/flc-nuget'
@@ -261,6 +326,9 @@ extends:
261326
os: windows
262327
templateContext:
263328
inputs:
329+
- input: pipelineArtifact
330+
artifactName: 'version-info'
331+
targetPath: '$(Pipeline.Workspace)/version-info'
264332
- input: pipelineArtifact
265333
artifactName: 'flc-nuget'
266334
targetPath: '$(Pipeline.Workspace)/flc-nuget'
@@ -293,6 +361,9 @@ extends:
293361
os: windows
294362
templateContext:
295363
inputs:
364+
- input: pipelineArtifact
365+
artifactName: 'version-info'
366+
targetPath: '$(Pipeline.Workspace)/version-info'
296367
- input: pipelineArtifact
297368
artifactName: 'flc-wheels'
298369
targetPath: '$(Pipeline.Workspace)/flc-wheels'
@@ -325,6 +396,9 @@ extends:
325396
os: windows
326397
templateContext:
327398
inputs:
399+
- input: pipelineArtifact
400+
artifactName: 'version-info'
401+
targetPath: '$(Pipeline.Workspace)/version-info'
328402
- input: pipelineArtifact
329403
artifactName: 'flc-nuget'
330404
targetPath: '$(Pipeline.Workspace)/flc-nuget'
@@ -467,7 +541,7 @@ extends:
467541
# ── Build & Test FLC (WinML) ──
468542
- stage: build_core_winml
469543
displayName: 'Build & Test FLC WinML'
470-
dependsOn: []
544+
dependsOn: compute_version
471545
jobs:
472546
- job: flc_winml_win_x64
473547
displayName: 'FLC win-x64 (WinML)'
@@ -520,6 +594,10 @@ extends:
520594
name: onnxruntime-Win-CPU-2022
521595
os: windows
522596
templateContext:
597+
inputs:
598+
- input: pipelineArtifact
599+
artifactName: 'version-info'
600+
targetPath: '$(Pipeline.Workspace)/version-info'
523601
outputs:
524602
- output: pipelineArtifact
525603
artifactName: 'flc-nuget-winml'
@@ -575,6 +653,9 @@ extends:
575653
os: windows
576654
templateContext:
577655
inputs:
656+
- input: pipelineArtifact
657+
artifactName: 'version-info'
658+
targetPath: '$(Pipeline.Workspace)/version-info'
578659
- input: pipelineArtifact
579660
artifactName: 'flc-nuget-winml'
580661
targetPath: '$(Pipeline.Workspace)/flc-nuget-winml'
@@ -608,6 +689,9 @@ extends:
608689
os: windows
609690
templateContext:
610691
inputs:
692+
- input: pipelineArtifact
693+
artifactName: 'version-info'
694+
targetPath: '$(Pipeline.Workspace)/version-info'
611695
- input: pipelineArtifact
612696
artifactName: 'flc-nuget-winml'
613697
targetPath: '$(Pipeline.Workspace)/flc-nuget-winml'
@@ -640,6 +724,9 @@ extends:
640724
os: windows
641725
templateContext:
642726
inputs:
727+
- input: pipelineArtifact
728+
artifactName: 'version-info'
729+
targetPath: '$(Pipeline.Workspace)/version-info'
643730
- input: pipelineArtifact
644731
artifactName: 'flc-wheels-winml'
645732
targetPath: '$(Pipeline.Workspace)/flc-wheels-winml'
@@ -673,6 +760,9 @@ extends:
673760
os: windows
674761
templateContext:
675762
inputs:
763+
- input: pipelineArtifact
764+
artifactName: 'version-info'
765+
targetPath: '$(Pipeline.Workspace)/version-info'
676766
- input: pipelineArtifact
677767
artifactName: 'flc-nuget-winml'
678768
targetPath: '$(Pipeline.Workspace)/flc-nuget-winml'

.pipelines/templates/build-cs-steps.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,15 @@ steps:
3838
packageType: sdk
3939
version: '9.0.x'
4040

41-
# Compute package version
41+
# Read version from the version-info artifact produced by compute_version stage.
4242
- task: PowerShell@2
4343
displayName: 'Set package version'
4444
inputs:
4545
targetType: inline
4646
script: |
47-
$v = "${{ parameters.version }}"
48-
$preId = "${{ parameters.prereleaseId }}"
49-
if ($preId -ne '' -and $preId -ne 'none') {
50-
$v = "$v-$preId"
51-
} elseif ("${{ parameters.isRelease }}" -ne "True") {
52-
$ts = Get-Date -Format "yyyyMMddHHmm"
53-
$v = "$v-dev.$ts"
54-
}
55-
Write-Host "##vso[task.setvariable variable=packageVersion]$v"
47+
$v = (Get-Content "$(Pipeline.Workspace)/version-info/sdkVersion.txt" -Raw).Trim()
5648
Write-Host "Package version: $v"
49+
Write-Host "##vso[task.setvariable variable=packageVersion]$v"
5750
5851
# List downloaded artifact for debugging
5952
- task: PowerShell@2

.pipelines/templates/build-js-steps.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,14 @@ steps:
4545
inputs:
4646
versionSpec: '20.x'
4747

48-
# Compute version
48+
# Read version from the version-info artifact produced by compute_version stage.
4949
- task: PowerShell@2
5050
displayName: 'Set package version'
5151
inputs:
5252
targetType: inline
5353
script: |
54-
$v = "${{ parameters.version }}"
55-
$preId = "${{ parameters.prereleaseId }}"
56-
if ($preId -ne '' -and $preId -ne 'none') {
57-
$v = "$v-$preId"
58-
} elseif ("${{ parameters.isRelease }}" -ne "True") {
59-
$ts = Get-Date -Format "yyyyMMddHHmm"
60-
$v = "$v-dev.$ts"
61-
}
54+
$v = (Get-Content "$(Pipeline.Workspace)/version-info/sdkVersion.txt" -Raw).Trim()
55+
Write-Host "Package version: $v"
6256
Write-Host "##vso[task.setvariable variable=packageVersion]$v"
6357
6458
# Install dependencies including native binaries (FLC, ORT, GenAI) from NuGet feeds
@@ -102,7 +96,8 @@ steps:
10296
Expand-Archive -Path $zip -DestinationPath $extractDir -Force
10397
10498
# Overwrite FLC binary in the npm-installed location
105-
$destDir = "$(repoRoot)/sdk/js/packages/@foundry-local-core/$platformKey"
99+
$destDir = "$(repoRoot)/sdk/js/node_modules/@foundry-local-core/$platformKey"
100+
New-Item -ItemType Directory -Path $destDir -Force | Out-Null
106101
$nativeDir = "$extractDir/runtimes/$rid/native"
107102
if (Test-Path $nativeDir) {
108103
Get-ChildItem $nativeDir -File | ForEach-Object {

.pipelines/templates/build-python-steps.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,15 @@ steps:
4747
Write-Host "Contents of ${{ parameters.flcWheelsDir }}:"
4848
Get-ChildItem "${{ parameters.flcWheelsDir }}" -Recurse | ForEach-Object { Write-Host $_.FullName }
4949
50-
# Compute package version
50+
# Read version from the version-info artifact produced by compute_version stage.
5151
- task: PowerShell@2
5252
displayName: 'Set package version'
5353
inputs:
5454
targetType: inline
5555
script: |
56-
$v = "${{ parameters.version }}"
57-
$preId = "${{ parameters.prereleaseId }}"
58-
if ($preId -ne '' -and $preId -ne 'none') {
59-
$v = "$v-$preId"
60-
} elseif ("${{ parameters.isRelease }}" -ne "True") {
61-
$ts = Get-Date -Format "yyyyMMddHHmm"
62-
$v = "$v-dev.$ts"
63-
}
64-
Write-Host "##vso[task.setvariable variable=packageVersion]$v"
56+
$v = (Get-Content "$(Pipeline.Workspace)/version-info/pyVersion.txt" -Raw).Trim()
6557
Write-Host "Package version: $v"
58+
Write-Host "##vso[task.setvariable variable=packageVersion]$v"
6659
6760
# Configure pip to use ORT-Nightly feed (plus PyPI as fallback)
6861
- task: PowerShell@2

.pipelines/templates/build-rust-steps.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,13 @@ steps:
3232
Write-Host "##vso[task.setvariable variable=repoRoot]$repoRoot"
3333
Write-Host "##vso[task.setvariable variable=testDataDir]$testDataDir"
3434
35-
# Compute package version and patch Cargo.toml
35+
# Read version from the version-info artifact produced by compute_version stage.
3636
- task: PowerShell@2
3737
displayName: 'Set crate version'
3838
inputs:
3939
targetType: inline
4040
script: |
41-
$v = "${{ parameters.version }}"
42-
$preId = "${{ parameters.prereleaseId }}"
43-
if ($preId -ne '' -and $preId -ne 'none') {
44-
$v = "$v-$preId"
45-
} elseif ("${{ parameters.isRelease }}" -ne "True") {
46-
$ts = Get-Date -Format "yyyyMMddHHmm"
47-
$v = "$v-dev.$ts"
48-
}
41+
$v = (Get-Content "$(Pipeline.Workspace)/version-info/sdkVersion.txt" -Raw).Trim()
4942
Write-Host "Crate version: $v"
5043
5144
# Patch Cargo.toml version field

.pipelines/templates/package-core-steps.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,15 @@ steps:
7474
Copy-Item $license "$unifiedPath/LICENSE.txt" -Force
7575
}
7676
77-
# Compute version
77+
# Read version from the version-info artifact produced by compute_version stage.
7878
- task: PowerShell@2
7979
displayName: 'Set FLC package version'
8080
inputs:
8181
targetType: inline
8282
script: |
83-
$v = "${{ parameters.version }}"
84-
$preId = "${{ parameters.prereleaseId }}"
85-
if ($preId -ne '' -and $preId -ne 'none') {
86-
$v = "$v-$preId"
87-
} elseif ("${{ parameters.isRelease }}" -ne "True") {
88-
$ts = Get-Date -Format "yyyyMMddHHmm"
89-
$commitId = "$(Build.SourceVersion)".Substring(0, 8)
90-
$v = "$v-dev-$ts-$commitId"
91-
}
92-
Write-Host "##vso[task.setvariable variable=flcVersion]$v"
83+
$v = (Get-Content "$(Pipeline.Workspace)/version-info/flcVersion.txt" -Raw).Trim()
9384
Write-Host "FLC version: $v"
85+
Write-Host "##vso[task.setvariable variable=flcVersion]$v"
9486
9587
# Pack NuGet
9688
- task: PowerShell@2

.pipelines/templates/test-js-steps.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ steps:
9393
Copy-Item $nupkg.FullName $zip -Force
9494
Expand-Archive -Path $zip -DestinationPath $extractDir -Force
9595
96-
$destDir = "$(repoRoot)/sdk/js/packages/@foundry-local-core/$platformKey"
96+
$destDir = "$(repoRoot)/sdk/js/node_modules/@foundry-local-core/$platformKey"
97+
New-Item -ItemType Directory -Path $destDir -Force | Out-Null
9798
$nativeDir = "$extractDir/runtimes/$rid/native"
9899
if (Test-Path $nativeDir) {
99100
Get-ChildItem $nativeDir -File | ForEach-Object {

sdk/js/package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@
2727
"koffi": "^2.9.0",
2828
"adm-zip": "^0.5.16"
2929
},
30-
"optionalDependencies": {
31-
"@foundry-local-core/darwin-arm64": "file:packages/@foundry-local-core/darwin-arm64",
32-
"@foundry-local-core/linux-x64": "file:packages/@foundry-local-core/linux-x64",
33-
"@foundry-local-core/win32-arm64": "file:packages/@foundry-local-core/win32-arm64",
34-
"@foundry-local-core/win32-x64": "file:packages/@foundry-local-core/win32-x64"
35-
},
3630
"devDependencies": {
3731
"@types/chai": "^5.2.3",
3832
"@types/mocha": "^10.0.10",

0 commit comments

Comments
 (0)