-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: use current Brev create flags #1383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
13ernkastel
wants to merge
10
commits into
NVIDIA:main
Choose a base branch
from
13ernkastel:codex/issue-1377-brev-deploy-flags
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+259
−8
Open
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cf3742c
fix: use current Brev create flags
13ernkastel 1566292
Merge branch 'main' into codex/issue-1377-brev-deploy-flags
13ernkastel 4034eab
Merge branch 'main' into codex/issue-1377-brev-deploy-flags
13ernkastel f40319d
fix: harden Brev deploy env parsing
13ernkastel 51b0f8f
Merge branch 'main' into codex/issue-1377-brev-deploy-flags
13ernkastel 42c3bf8
Merge branch 'main' into codex/issue-1377-brev-deploy-flags
13ernkastel 0fbeedf
fix: normalize Brev GPU fallback candidates
13ernkastel fb8cd07
Merge branch 'main' into codex/issue-1377-brev-deploy-flags
13ernkastel b52f9a5
Merge branch 'main' into codex/issue-1377-brev-deploy-flags
13ernkastel 36575dd
Merge origin/main into codex/issue-1377-brev-deploy-flags
13ernkastel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, expect, it } from "vitest"; | ||
| import { execSync } from "node:child_process"; | ||
| import fs from "node:fs"; | ||
| import os from "node:os"; | ||
| import path from "node:path"; | ||
|
|
||
| const CLI = path.join(import.meta.dirname, "..", "bin", "nemoclaw.js"); | ||
|
|
||
| function runWithEnv(args: string, env: Record<string, string> = {}, timeout = 25_000) { | ||
| try { | ||
| const out = execSync(`node "${CLI}" ${args}`, { | ||
| encoding: "utf-8", | ||
| timeout, | ||
| env: { | ||
| ...process.env, | ||
| HOME: fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-cli-brev-home-")), | ||
| NEMOCLAW_HEALTH_POLL_COUNT: "1", | ||
| NEMOCLAW_HEALTH_POLL_INTERVAL: "0", | ||
| ...env, | ||
| }, | ||
| }); | ||
| return { code: 0, out }; | ||
| } catch (err: any) { | ||
| return { code: err.status, out: (err.stdout || "") + (err.stderr || "") }; | ||
| } | ||
| } | ||
|
|
||
| function writeStub(binDir: string, name: string, lines: string[]) { | ||
| fs.writeFileSync(path.join(binDir, name), lines.join("\n"), { mode: 0o755 }); | ||
| } | ||
|
|
||
| function readBrevCalls(markerFile: string) { | ||
| return fs.readFileSync(markerFile, "utf8").trim().split("\n").filter(Boolean); | ||
| } | ||
|
|
||
| function setupDeployStubs({ brevLsOutput = "" }: { brevLsOutput?: string } = {}) { | ||
| const home = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-cli-deploy-brev-")); | ||
| const localBin = path.join(home, "bin"); | ||
| const markerFile = path.join(home, "brev-args"); | ||
|
|
||
| fs.mkdirSync(localBin, { recursive: true }); | ||
|
|
||
| writeStub(localBin, "brev", [ | ||
| "#!/usr/bin/env bash", | ||
| `marker_file=${JSON.stringify(markerFile)}`, | ||
| 'printf \'%s\\n\' "$*" >> "$marker_file"', | ||
| 'if [ "$1" = "ls" ]; then', | ||
| ` printf '%s' ${JSON.stringify(brevLsOutput)}`, | ||
| " exit 0", | ||
| "fi", | ||
| "exit 0", | ||
| ]); | ||
| writeStub(localBin, "ssh", ["#!/usr/bin/env bash", "exit 0"]); | ||
| writeStub(localBin, "rsync", ["#!/usr/bin/env bash", "exit 0"]); | ||
| writeStub(localBin, "scp", ["#!/usr/bin/env bash", "exit 0"]); | ||
|
|
||
| return { | ||
| home, | ||
| localBin, | ||
| markerFile, | ||
| }; | ||
| } | ||
|
|
||
| describe("deploy brev compatibility", () => { | ||
| it("uses --type and --gpu-name for legacy combined NEMOCLAW_GPU", () => { | ||
| const { home, localBin, markerFile } = setupDeployStubs(); | ||
|
|
||
| const result = runWithEnv("deploy pr-1377-legacy", { | ||
| HOME: home, | ||
| PATH: `${localBin}:${process.env.PATH || ""}`, | ||
| NVIDIA_API_KEY: "nvapi-test", | ||
| NEMOCLAW_GPU: "a2-highgpu-1g:nvidia-tesla-a100:1", | ||
| }); | ||
|
|
||
| expect(result.code).toBe(0); | ||
| const calls = readBrevCalls(markerFile); | ||
| expect(calls).toContain("ls"); | ||
| expect(calls).toContain("create pr-1377-legacy --type a2-highgpu-1g --gpu-name A100"); | ||
| expect(calls.join("\n")).not.toContain("--gpu "); | ||
| }); | ||
|
|
||
| it("prefers explicit Brev override env vars over the legacy combined value", () => { | ||
| const { home, localBin, markerFile } = setupDeployStubs(); | ||
|
|
||
| const result = runWithEnv("deploy pr-1377-overrides", { | ||
| HOME: home, | ||
| PATH: `${localBin}:${process.env.PATH || ""}`, | ||
| NVIDIA_API_KEY: "nvapi-test", | ||
| NEMOCLAW_GPU: "a2-highgpu-1g:nvidia-tesla-a100:1", | ||
| NEMOCLAW_BREV_TYPE: "a3-highgpu-1g", | ||
| NEMOCLAW_BREV_GPU_NAME: "h100", | ||
| }); | ||
|
|
||
| expect(result.code).toBe(0); | ||
| const calls = readBrevCalls(markerFile); | ||
| expect(calls).toContain("create pr-1377-overrides --type a3-highgpu-1g --gpu-name H100"); | ||
| expect(calls.join("\n")).not.toContain("--gpu "); | ||
| }); | ||
|
|
||
| it("falls back to default Brev type and GPU name when no env vars are set", () => { | ||
| const { home, localBin, markerFile } = setupDeployStubs(); | ||
|
|
||
| const result = runWithEnv("deploy pr-1377-defaults", { | ||
| HOME: home, | ||
| PATH: `${localBin}:${process.env.PATH || ""}`, | ||
| NVIDIA_API_KEY: "nvapi-test", | ||
| }); | ||
|
|
||
| expect(result.code).toBe(0); | ||
| const calls = readBrevCalls(markerFile); | ||
| expect(calls).toContain("create pr-1377-defaults --type a2-highgpu-1g --gpu-name A100"); | ||
| expect(calls.join("\n")).not.toContain("--gpu "); | ||
| }); | ||
|
|
||
| it("treats whitespace-only overrides as unset and normalizes generic nvidia GPU names", () => { | ||
| const { home, localBin, markerFile } = setupDeployStubs(); | ||
|
|
||
| const result = runWithEnv("deploy pr-1377-l40s", { | ||
| HOME: home, | ||
| PATH: `${localBin}:${process.env.PATH || ""}`, | ||
| NVIDIA_API_KEY: "nvapi-test", | ||
| NEMOCLAW_GPU: "a3-highgpu-1g:nvidia-l40s:1", | ||
| NEMOCLAW_BREV_TYPE: " ", | ||
| NEMOCLAW_BREV_GPU_NAME: " ", | ||
| }); | ||
|
|
||
| expect(result.code).toBe(0); | ||
| const calls = readBrevCalls(markerFile); | ||
| expect(calls).toContain("create pr-1377-l40s --type a3-highgpu-1g --gpu-name L40S"); | ||
| expect(calls.join("\n")).not.toContain("--gpu "); | ||
| }); | ||
|
|
||
| it("skips brev create when the instance already exists", () => { | ||
| const { home, localBin, markerFile } = setupDeployStubs({ | ||
| brevLsOutput: "pr-1377-existing\n", | ||
| }); | ||
|
|
||
| const result = runWithEnv("deploy pr-1377-existing", { | ||
| HOME: home, | ||
| PATH: `${localBin}:${process.env.PATH || ""}`, | ||
| NVIDIA_API_KEY: "nvapi-test", | ||
| }); | ||
|
|
||
| expect(result.code).toBe(0); | ||
| const calls = readBrevCalls(markerFile); | ||
| expect(calls).toContain("ls"); | ||
| expect(calls).toContain("refresh"); | ||
| expect(calls.some((call) => call.startsWith("create "))).toBe(false); | ||
| }); | ||
|
|
||
| it("falls back to the default GPU name when normalization produces an empty value", () => { | ||
| const { home, localBin, markerFile } = setupDeployStubs(); | ||
|
|
||
| const result = runWithEnv("deploy pr-1377-empty-gpu-name", { | ||
| HOME: home, | ||
| PATH: `${localBin}:${process.env.PATH || ""}`, | ||
| NVIDIA_API_KEY: "nvapi-test", | ||
| NEMOCLAW_BREV_TYPE: "a3-highgpu-1g", | ||
| NEMOCLAW_BREV_GPU_NAME: "nvidia-", | ||
| }); | ||
|
|
||
| expect(result.code).toBe(0); | ||
| const calls = readBrevCalls(markerFile); | ||
| expect(calls).toContain("create pr-1377-empty-gpu-name --type a3-highgpu-1g --gpu-name A100"); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.