cassian-cli 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,15 +2,48 @@ import { createInterface } from "readline";
2
2
  import { writeFileSync, existsSync } from "fs";
3
3
  import { green, dim, bold } from "../lib/output.js";
4
4
  import { fatal } from "../lib/errors.js";
5
- const GPU_OPTIONS = [
6
- { label: "H100 SXM", value: "h100-sxm", hint: "80GB — best for large training" },
7
- { label: "H100 PCIe", value: "h100-pcie", hint: "80GB" },
8
- { label: "A100 SXM", value: "a100-sxm", hint: "80GB — reliable workhorse" },
9
- { label: "A100 PCIe", value: "a100-pcie", hint: "80GB" },
10
- { label: "L40S", value: "l40s", hint: "48GB — great for inference" },
11
- { label: "RTX 4090", value: "rtx4090", hint: "24GB fast, affordable" },
12
- { label: "RTX 3090", value: "rtx3090", hint: "24GB" },
5
+ import { AGENT_URL } from "../lib/constants.js";
6
+ const ALL_GPUS = [
7
+ { label: "H100 SXM", value: "h100-sxm", memory: "80GB", hint: "best for large training" },
8
+ { label: "H100 PCIe", value: "h100-pcie", memory: "80GB" },
9
+ { label: "A100 SXM", value: "a100-sxm", memory: "80GB", hint: "reliable workhorse" },
10
+ { label: "A100 PCIe", value: "a100-pcie", memory: "80GB" },
11
+ { label: "L40S", value: "l40s", memory: "48GB", hint: "great for inference" },
12
+ { label: "L4", value: "l4", memory: "24GB", hint: "efficient inference" },
13
+ { label: "A10G", value: "a10g", memory: "24GB", hint: "good all-rounder" },
14
+ { label: "RTX 4090", value: "rtx4090", memory: "24GB", hint: "fast, affordable" },
15
+ { label: "RTX 3090", value: "rtx3090", memory: "24GB" },
13
16
  ];
17
+ async function fetchAvailability() {
18
+ try {
19
+ const resp = await fetch(`${AGENT_URL}/v1/gpu-types`);
20
+ if (!resp.ok)
21
+ return {};
22
+ const { gpu_types } = await resp.json();
23
+ const map = {};
24
+ for (const g of gpu_types)
25
+ map[g.type.toLowerCase()] = g.available;
26
+ return map;
27
+ }
28
+ catch {
29
+ return {};
30
+ }
31
+ }
32
+ function buildGpuOptions(availability) {
33
+ return ALL_GPUS.map(gpu => {
34
+ const count = availability[gpu.value] ?? 0;
35
+ const parts = [gpu.memory];
36
+ if (gpu.hint)
37
+ parts.push(gpu.hint);
38
+ if (count > 0) {
39
+ parts.push(`${count} available`);
40
+ }
41
+ else {
42
+ parts.push("unavailable");
43
+ }
44
+ return { label: gpu.label, value: gpu.value, hint: parts.join(" — ") };
45
+ });
46
+ }
14
47
  function prompt(rl, question, fallback) {
15
48
  return new Promise((resolve) => {
16
49
  rl.question(question, (answer) => resolve(answer.trim() || fallback));
@@ -95,7 +128,11 @@ export async function init(options = {}) {
95
128
  console.log(dim(" Press enter to accept defaults. Or pass flags to skip: cassian init --help\n"));
96
129
  const name = options.name || await prompt(rl, ` Instance name ${dim(`[${dirName}]`)}: `, dirName);
97
130
  console.log();
98
- const gpuType = options.gpu || await promptChoice(rl, " GPU type:", GPU_OPTIONS, "rtx3090");
131
+ const availability = await fetchAvailability();
132
+ const gpuOptions = buildGpuOptions(availability);
133
+ const availableTypes = Object.keys(availability).filter(k => availability[k] > 0);
134
+ const defaultGpu = availableTypes[0] || "rtx3090";
135
+ const gpuType = options.gpu || await promptChoice(rl, " GPU type:", gpuOptions, defaultGpu);
99
136
  console.log();
100
137
  const gpuCountStr = options.gpuCount || await promptChoice(rl, " Number of GPUs:", [
101
138
  { label: "1", value: "1" }, { label: "2", value: "2" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cassian-cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "The Cassian GPU cloud CLI — provision GPUs, sync files, and run workloads from your terminal.",
5
5
  "type": "module",
6
6
  "bin": {