cassian-cli 0.3.6 → 0.3.8
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.
- package/dist/commands/init.js +101 -94
- package/package.json +2 -1
package/dist/commands/init.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { writeFileSync
|
|
3
|
-
import
|
|
4
|
-
import { fatal } from "../lib/errors.js";
|
|
1
|
+
import { existsSync } from "fs";
|
|
2
|
+
import { writeFileSync } from "fs";
|
|
3
|
+
import * as p from "@clack/prompts";
|
|
5
4
|
import { AGENT_URL } from "../lib/constants.js";
|
|
6
5
|
const ALL_GPUS = [
|
|
7
|
-
{
|
|
8
|
-
{
|
|
9
|
-
{
|
|
10
|
-
{
|
|
11
|
-
{
|
|
12
|
-
{
|
|
13
|
-
{
|
|
14
|
-
{
|
|
15
|
-
{
|
|
6
|
+
{ value: "h100-sxm", label: "H100 SXM", memory: "80GB", hint: "best for large training" },
|
|
7
|
+
{ value: "h100-pcie", label: "H100 PCIe", memory: "80GB" },
|
|
8
|
+
{ value: "a100-sxm", label: "A100 SXM", memory: "80GB", hint: "reliable workhorse" },
|
|
9
|
+
{ value: "a100-pcie", label: "A100 PCIe", memory: "80GB" },
|
|
10
|
+
{ value: "l40s", label: "L40S", memory: "48GB", hint: "great for inference" },
|
|
11
|
+
{ value: "l4", label: "L4", memory: "24GB", hint: "efficient inference" },
|
|
12
|
+
{ value: "a10g", label: "A10G", memory: "24GB", hint: "good all-rounder" },
|
|
13
|
+
{ value: "rtx4090", label: "RTX 4090", memory: "24GB", hint: "fast, affordable" },
|
|
14
|
+
{ value: "rtx3090", label: "RTX 3090", memory: "24GB" },
|
|
16
15
|
];
|
|
17
16
|
async function fetchAvailability() {
|
|
18
17
|
try {
|
|
@@ -29,40 +28,6 @@ async function fetchAvailability() {
|
|
|
29
28
|
return {};
|
|
30
29
|
}
|
|
31
30
|
}
|
|
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
|
-
}
|
|
47
|
-
function prompt(rl, question, fallback) {
|
|
48
|
-
return new Promise((resolve) => {
|
|
49
|
-
rl.question(question, (answer) => resolve(answer.trim() || fallback));
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function promptChoice(rl, question, choices, fallback) {
|
|
53
|
-
return new Promise((resolve) => {
|
|
54
|
-
console.log(question);
|
|
55
|
-
choices.forEach((c, i) => {
|
|
56
|
-
const marker = c.value === fallback ? green("›") : " ";
|
|
57
|
-
const hint = c.hint ? dim(` — ${c.hint}`) : "";
|
|
58
|
-
console.log(` ${marker} ${i + 1}) ${c.label}${hint}`);
|
|
59
|
-
});
|
|
60
|
-
rl.question(dim(` [1-${choices.length}, default ${choices.findIndex(c => c.value === fallback) + 1}]: `), (answer) => {
|
|
61
|
-
const idx = parseInt(answer.trim()) - 1;
|
|
62
|
-
resolve(idx >= 0 && idx < choices.length ? choices[idx].value : fallback);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
31
|
function buildYaml(opts) {
|
|
67
32
|
const storageLine = opts.storage ? "\nstorage: true\n" : "";
|
|
68
33
|
const excludeLines = opts.exclude.length
|
|
@@ -78,11 +43,11 @@ ${storageLine}${excludeLines}`;
|
|
|
78
43
|
}
|
|
79
44
|
export async function init(options = {}) {
|
|
80
45
|
if (existsSync("cassian.yaml")) {
|
|
81
|
-
|
|
46
|
+
p.log.error("cassian.yaml already exists in this directory.");
|
|
47
|
+
process.exit(1);
|
|
82
48
|
}
|
|
83
49
|
const dirName = process.cwd().split("/").pop().toLowerCase().replace(/[^a-z0-9-]/g, "-");
|
|
84
|
-
|
|
85
|
-
if (skipPrompts) {
|
|
50
|
+
if (options.yes) {
|
|
86
51
|
const yaml = buildYaml({
|
|
87
52
|
name: options.name || dirName,
|
|
88
53
|
gpuType: options.gpu || "rtx3090",
|
|
@@ -92,56 +57,98 @@ export async function init(options = {}) {
|
|
|
92
57
|
exclude: ["node_modules/", ".venv/", "__pycache__/", "*.pyc", "wandb/"],
|
|
93
58
|
});
|
|
94
59
|
writeFileSync("cassian.yaml", yaml);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
console.log();
|
|
98
|
-
console.log(` Run ${green("cassian up")} to start your instance.`);
|
|
99
|
-
console.log();
|
|
60
|
+
p.log.success("Created cassian.yaml");
|
|
61
|
+
p.log.info("Run \x1b[32mcassian up\x1b[0m to start your instance.");
|
|
100
62
|
return;
|
|
101
63
|
}
|
|
102
|
-
// Interactive wizard
|
|
103
|
-
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
104
|
-
console.log();
|
|
105
|
-
console.log(bold(" Let's set up your Cassian project."));
|
|
106
|
-
console.log(dim(" Press enter to accept defaults.\n"));
|
|
107
|
-
const name = options.name || await prompt(rl, ` Instance name ${dim(`[${dirName}]`)}: `, dirName);
|
|
108
64
|
console.log();
|
|
65
|
+
const name = options.name || await p.text({
|
|
66
|
+
message: "Instance name",
|
|
67
|
+
placeholder: dirName,
|
|
68
|
+
defaultValue: dirName,
|
|
69
|
+
validate: (v) => {
|
|
70
|
+
if (!v || !/^[a-z0-9][a-z0-9-]*$/.test(v))
|
|
71
|
+
return "Lowercase letters, numbers, and hyphens only";
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
if (p.isCancel(name)) {
|
|
75
|
+
p.cancel("Setup cancelled.");
|
|
76
|
+
process.exit(0);
|
|
77
|
+
}
|
|
109
78
|
const availability = await fetchAvailability();
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
79
|
+
const gpuType = options.gpu || await p.select({
|
|
80
|
+
message: "GPU type",
|
|
81
|
+
options: ALL_GPUS.map(gpu => {
|
|
82
|
+
const count = availability[gpu.value] ?? 0;
|
|
83
|
+
const parts = [gpu.memory];
|
|
84
|
+
if (gpu.hint)
|
|
85
|
+
parts.push(gpu.hint);
|
|
86
|
+
if (count > 0) {
|
|
87
|
+
parts.push(`\x1b[32m${count} available\x1b[0m`);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
parts.push(`\x1b[90munavailable\x1b[0m`);
|
|
91
|
+
}
|
|
92
|
+
return { value: gpu.value, label: gpu.label, hint: parts.join(" · ") };
|
|
93
|
+
}),
|
|
94
|
+
initialValue: Object.keys(availability).find(k => availability[k] > 0) || "rtx3090",
|
|
95
|
+
});
|
|
96
|
+
if (p.isCancel(gpuType)) {
|
|
97
|
+
p.cancel("Setup cancelled.");
|
|
98
|
+
process.exit(0);
|
|
99
|
+
}
|
|
100
|
+
const gpuCountStr = options.gpuCount || await p.select({
|
|
101
|
+
message: "Number of GPUs",
|
|
102
|
+
options: [
|
|
103
|
+
{ value: "1", label: "1" },
|
|
104
|
+
{ value: "2", label: "2" },
|
|
105
|
+
{ value: "4", label: "4" },
|
|
106
|
+
{ value: "8", label: "8" },
|
|
107
|
+
],
|
|
108
|
+
initialValue: "1",
|
|
109
|
+
});
|
|
110
|
+
if (p.isCancel(gpuCountStr)) {
|
|
111
|
+
p.cancel("Setup cancelled.");
|
|
112
|
+
process.exit(0);
|
|
113
|
+
}
|
|
119
114
|
const gpuCount = parseInt(gpuCountStr);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
115
|
+
const diskSize = options.disk || await p.select({
|
|
116
|
+
message: "Disk size (fast NVMe storage)",
|
|
117
|
+
options: [
|
|
118
|
+
{ value: "20G", label: "20 GB" },
|
|
119
|
+
{ value: "50G", label: "50 GB", hint: "recommended" },
|
|
120
|
+
{ value: "100G", label: "100 GB" },
|
|
121
|
+
{ value: "200G", label: "200 GB" },
|
|
122
|
+
{ value: "500G", label: "500 GB" },
|
|
123
|
+
],
|
|
124
|
+
initialValue: "50G",
|
|
125
|
+
});
|
|
126
|
+
if (p.isCancel(diskSize)) {
|
|
127
|
+
p.cancel("Setup cancelled.");
|
|
128
|
+
process.exit(0);
|
|
129
|
+
}
|
|
130
|
+
const storageEnabled = await p.confirm({
|
|
131
|
+
message: "Enable cloud storage? \x1b[90m(unlimited, persists at /workspace/storage)\x1b[0m",
|
|
132
|
+
initialValue: true,
|
|
133
|
+
});
|
|
134
|
+
if (p.isCancel(storageEnabled)) {
|
|
135
|
+
p.cancel("Setup cancelled.");
|
|
136
|
+
process.exit(0);
|
|
137
|
+
}
|
|
138
|
+
const excludeRaw = await p.text({
|
|
139
|
+
message: "Exclude patterns \x1b[90m(comma-separated, not persisted)\x1b[0m",
|
|
140
|
+
placeholder: "node_modules/, .venv/, __pycache__/, *.pyc, wandb/",
|
|
141
|
+
defaultValue: "node_modules/, .venv/, __pycache__/, *.pyc, wandb/",
|
|
142
|
+
});
|
|
143
|
+
if (p.isCancel(excludeRaw)) {
|
|
144
|
+
p.cancel("Setup cancelled.");
|
|
145
|
+
process.exit(0);
|
|
146
|
+
}
|
|
147
|
+
const exclude = excludeRaw.split(",").map(s => s.trim()).filter(Boolean);
|
|
148
|
+
const yaml = buildYaml({ name, gpuType, gpuCount, diskSize, storage: storageEnabled, exclude });
|
|
141
149
|
writeFileSync("cassian.yaml", yaml);
|
|
142
150
|
console.log();
|
|
143
|
-
console.log(`
|
|
144
|
-
console.log();
|
|
145
|
-
console.log(` Run ${green("cassian up")} to start your instance.`);
|
|
151
|
+
console.log(` \x1b[32m✓\x1b[0m Created \x1b[1mcassian.yaml\x1b[0m`);
|
|
152
|
+
console.log(` Run \x1b[32mcassian up\x1b[0m to start your instance.`);
|
|
146
153
|
console.log();
|
|
147
154
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cassian-cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
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": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"node": ">=18"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"@clack/prompts": "^1.4.0",
|
|
31
32
|
"@types/tar": "^6.1.13",
|
|
32
33
|
"chalk": "^5.3.0",
|
|
33
34
|
"chokidar": "^5.0.0",
|