Skip to content

Commit ac0fa98

Browse files
committed
fix(mxc): address inference demo review feedback
Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
1 parent 72bf4ff commit ac0fa98

3 files changed

Lines changed: 40 additions & 13 deletions

File tree

crates/openshell-driver-mxc/examples/run-inference-test.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
[CmdletBinding()]
77
param(
8-
[string] $ApiKey = $env:NV_API_KEY,
98
[string] $WxcExecPath,
109
[string] $GatewayPath,
1110
[string] $CliPath,
@@ -135,10 +134,11 @@ $failure = $null
135134
$oldGatewayConfig = $env:OPENSHELL_GATEWAY_CONFIG
136135
$oldComputeDriver = $env:OPENSHELL_COMPUTE_DRIVER
137136
$oldApiKey = $env:NV_API_KEY
137+
$apiKey = $env:NV_API_KEY
138138

139139
try {
140-
if ([string]::IsNullOrWhiteSpace($ApiKey)) {
141-
throw "NV_API_KEY is missing. Set `$env:NV_API_KEY or pass -ApiKey; the key is forwarded with --env-from and is never written to disk."
140+
if ([string]::IsNullOrWhiteSpace($apiKey)) {
141+
throw "NV_API_KEY is missing. Set `$env:NV_API_KEY; the key is forwarded with --env-from and is never written to disk or placed in argv."
142142
}
143143
$gateway = Resolve-Executable $GatewayPath "openshell-gateway.exe" ""
144144
$cli = Resolve-Executable $CliPath "openshell.exe" ""
@@ -219,7 +219,7 @@ try {
219219
try {
220220
$gatewayProcess = Start-Process -FilePath $gateway -ArgumentList @("--disable-tls", "--db-url", "sqlite::memory:", "--port", "$Port", "--log-level", "info") -WorkingDirectory $here -PassThru -WindowStyle Hidden -RedirectStandardOutput $gwLog -RedirectStandardError $gwErrLog
221221
} finally {
222-
$env:NV_API_KEY = $ApiKey
222+
$env:NV_API_KEY = $apiKey
223223
}
224224
$deadline = (Get-Date).AddSeconds(30)
225225
while ((Get-Date) -lt $deadline -and -not (Test-Port $Port)) {
@@ -252,7 +252,7 @@ try {
252252
}
253253
$curlDetail = if (Test-Path -LiteralPath $errorPath) { ([System.IO.File]::ReadAllText($errorPath)).Trim() } else { "no curl diagnostic was produced" }
254254
$diagnostic = "sandbox was created, but cloud inference failed (HTTP $httpStatus): $apiDetail $curlDetail".Trim()
255-
throw $diagnostic.Replace($ApiKey, "***REDACTED***")
255+
throw $diagnostic.Replace($apiKey, "***REDACTED***")
256256
}
257257
Start-Sleep -Milliseconds 500
258258
}

crates/openshell-driver-mxc/tests/demo_examples.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn read_example(name: &str) -> String {
3939
}
4040

4141
#[test]
42-
fn shipped_inference_configs_follow_current_gateway_contract() {
42+
fn shipped_inference_configs_declare_required_mxc_settings() {
4343
for name in ["mxc-ollama.toml", "mxc-inference.toml"] {
4444
let source = read_example(name);
4545
let parsed: Value = toml::from_str(&source)
@@ -83,18 +83,18 @@ fn shipped_inference_configs_follow_current_gateway_contract() {
8383

8484
#[test]
8585
fn shipped_inference_policies_are_narrow_and_valid_after_rendering() {
86+
let share = if cfg!(windows) {
87+
"C:/portable/demo"
88+
} else {
89+
"/portable/demo"
90+
};
8691
let fixtures = [
87-
(
88-
"ollama.yaml",
89-
"local_ollama",
90-
"127.0.0.1",
91-
"C:/portable/demo",
92-
),
92+
("ollama.yaml", "local_ollama", "127.0.0.1", share),
9393
(
9494
"inference.yaml",
9595
"nvidia_inference",
9696
"integrate.api.nvidia.com",
97-
"C:/portable/demo",
97+
share,
9898
),
9999
];
100100
for (name, rule_name, endpoint, share) in fixtures {
@@ -152,6 +152,8 @@ fn shipped_runners_supply_sandbox_scoped_workload_configuration() {
152152
let cloud = read_example("run-inference-test.ps1");
153153
assert!(cloud.contains("--env-from"));
154154
assert!(cloud.contains("NV_API_KEY"));
155+
assert!(!cloud.contains("[string] $ApiKey"));
156+
assert!(!cloud.contains("pass -ApiKey"));
155157
assert!(cloud.contains("nvidia/nemotron-3.5-lightning-30b-a3b"));
156158
assert!(!cloud.contains("nvidia/nvidia-nemotron-nano-9b-v2"));
157159
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#[cfg(target_os = "windows")]
5+
#[test]
6+
fn shipped_mxc_inference_configs_pass_gateway_preflight() {
7+
let examples =
8+
std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../openshell-driver-mxc/examples");
9+
10+
for name in ["mxc-ollama.toml", "mxc-inference.toml"] {
11+
let path = examples.join(name);
12+
let output = std::process::Command::new(env!("CARGO_BIN_EXE_openshell-gateway"))
13+
.args(["config", "preflight", "--path"])
14+
.arg(&path)
15+
.output()
16+
.unwrap_or_else(|error| panic!("failed to run gateway preflight for {name}: {error}"));
17+
18+
assert!(
19+
output.status.success(),
20+
"gateway preflight rejected {name}:\nstdout:\n{}\nstderr:\n{}",
21+
String::from_utf8_lossy(&output.stdout),
22+
String::from_utf8_lossy(&output.stderr)
23+
);
24+
}
25+
}

0 commit comments

Comments
 (0)