Skip to content

Commit 63bc479

Browse files
bmehta001Copilot
andauthored
Fix progress display (#580)
Improve EP progress download printing in samples --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e99ff06 commit 63bc479

6 files changed

Lines changed: 16 additions & 23 deletions

File tree

samples/cs/native-chat-completions/Program.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,22 @@
2121

2222
// Discover available execution providers and their registration status.
2323
var eps = mgr.DiscoverEps();
24+
int maxNameLen = 30;
2425
Console.WriteLine("Available execution providers:");
26+
Console.WriteLine($" {"Name".PadRight(maxNameLen)} Registered");
27+
Console.WriteLine($" {new string('─', maxNameLen)} {"──────────"}");
2528
foreach (var ep in eps)
2629
{
27-
Console.WriteLine($" {ep.Name} (registered: {ep.IsRegistered})");
30+
Console.WriteLine($" {ep.Name.PadRight(maxNameLen)} {ep.IsRegistered}");
2831
}
2932

3033
// Download and register all execution providers with per-EP progress.
3134
// EP packages include dependencies and may be large.
3235
// Download is only required again if a new version of the EP is released.
3336
// For cross platform builds there is no dynamic EP download and this will return immediately.
37+
Console.WriteLine("\nDownloading execution providers:");
3438
if (eps.Length > 0)
3539
{
36-
int maxNameLen = eps.Max(e => e.Name.Length);
3740
string currentEp = "";
3841
await mgr.DownloadAndRegisterEpsAsync((epName, percent) =>
3942
{
@@ -46,11 +49,8 @@ await mgr.DownloadAndRegisterEpsAsync((epName, percent) =>
4649
currentEp = epName;
4750
}
4851
Console.Write($"\r {epName.PadRight(maxNameLen)} {percent,6:F1}%");
49-
if (percent >= 100)
50-
{
51-
Console.WriteLine();
52-
}
5352
});
53+
Console.WriteLine();
5454
}
5555
else
5656
{

samples/js/native-chat-completions/app.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@ console.log('✓ SDK initialized successfully');
1616

1717
// Discover available execution providers and their registration status.
1818
const eps = manager.discoverEps();
19+
const maxNameLen = 30;
1920
console.log('\nAvailable execution providers:');
21+
console.log(` ${'Name'.padEnd(maxNameLen)} Registered`);
22+
console.log(` ${'─'.repeat(maxNameLen)} ──────────`);
2023
for (const ep of eps) {
21-
console.log(` ${ep.name} (registered: ${ep.isRegistered})`);
24+
console.log(` ${ep.name.padEnd(maxNameLen)} ${ep.isRegistered}`);
2225
}
2326

2427
// Download and register all execution providers with per-EP progress.
2528
// EP packages include dependencies and may be large.
2629
// Download is only required again if a new version of the EP is released.
30+
console.log('\nDownloading execution providers:');
2731
if (eps.length > 0) {
28-
const maxNameLen = Math.max(...eps.map(e => e.name.length));
2932
let currentEp = '';
3033
await manager.downloadAndRegisterEps((epName, percent) => {
3134
if (epName !== currentEp) {
@@ -35,10 +38,8 @@ if (eps.length > 0) {
3538
currentEp = epName;
3639
}
3740
process.stdout.write(`\r ${epName.padEnd(maxNameLen)} ${percent.toFixed(1).padStart(5)}%`);
38-
if (percent >= 100) {
39-
process.stdout.write('\n');
40-
}
4141
});
42+
process.stdout.write('\n');
4243
} else {
4344
console.log('No execution providers to download.');
4445
}

sdk/cs/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,8 @@ await mgr.DownloadAndRegisterEpsAsync((epName, percent) =>
9494
currentEp = epName;
9595
}
9696
Console.Write($"\r {epName} {percent,6:F1}%");
97-
if (percent >= 100)
98-
{
99-
Console.WriteLine();
100-
}
10197
});
98+
Console.WriteLine();
10299
```
103100

104101
Catalog access no longer blocks on EP downloads. Call `DownloadAndRegisterEpsAsync` explicitly when you need hardware-accelerated execution providers.

sdk/js/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ await manager.downloadAndRegisterEps((epName, percent) => {
6767
currentEp = epName;
6868
}
6969
process.stdout.write(`\r ${epName} ${percent.toFixed(1)}%`);
70-
if (percent >= 100) {
71-
process.stdout.write('\n');
72-
}
7370
});
71+
process.stdout.write('\n');
7472
```
7573

7674
Catalog access does not block on EP downloads. Call `downloadAndRegisterEps()` when you need hardware-accelerated execution providers.

sdk/python/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,9 @@ def on_progress(ep_name: str, percent: float) -> None:
102102
print()
103103
current_ep = ep_name
104104
print(f"\r {ep_name} {percent:5.1f}%", end="", flush=True)
105-
if percent >= 100:
106-
print()
107105

108106
manager.download_and_register_eps(progress_callback=on_progress)
107+
print()
109108
```
110109

111110
Catalog access does not block on EP downloads. Call `download_and_register_eps()` when you need hardware-accelerated execution providers.

sdk/rust/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,8 @@ manager.download_and_register_eps_with_progress(None, move |ep_name: &str, perce
102102
*current = ep_name.to_string();
103103
}
104104
print!("\r {} {:5.1}%", ep_name, percent);
105-
if percent >= 100.0 {
106-
println!();
107-
}
108105
}).await?;
106+
println!();
109107
```
110108

111109
Catalog access does not block on EP downloads. Call `download_and_register_eps` when you need hardware-accelerated execution providers.

0 commit comments

Comments
 (0)