cassian-cli 0.3.5 → 0.3.7
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.d.ts +0 -1
- package/dist/commands/init.js +104 -103
- package/dist/commands/up.js +4 -4
- package/dist/index.js +0 -2
- package/dist/types.d.ts +1 -1
- package/package.json +2 -1
package/dist/commands/init.d.ts
CHANGED
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,43 +28,8 @@ 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
|
-
const
|
|
68
|
-
? `\nstorage:\n${opts.storage.map(p => ` - ${p}`).join("\n")}\n` : "";
|
|
32
|
+
const storageLine = opts.storage ? "\nstorage: true\n" : "";
|
|
69
33
|
const excludeLines = opts.exclude.length
|
|
70
34
|
? `\nworkspace:\n exclude:\n${opts.exclude.map(p => ` - "${p}"`).join("\n")}\n` : "";
|
|
71
35
|
return `name: ${opts.name}
|
|
@@ -75,76 +39,113 @@ gpu:
|
|
|
75
39
|
type: ${opts.gpuType}
|
|
76
40
|
|
|
77
41
|
disk: ${opts.diskSize}
|
|
78
|
-
${
|
|
42
|
+
${storageLine}${excludeLines}`;
|
|
79
43
|
}
|
|
80
44
|
export async function init(options = {}) {
|
|
81
45
|
if (existsSync("cassian.yaml")) {
|
|
82
|
-
|
|
46
|
+
p.log.error("cassian.yaml already exists in this directory.");
|
|
47
|
+
process.exit(1);
|
|
83
48
|
}
|
|
84
49
|
const dirName = process.cwd().split("/").pop().toLowerCase().replace(/[^a-z0-9-]/g, "-");
|
|
85
|
-
|
|
86
|
-
if (skipPrompts) {
|
|
50
|
+
if (options.yes) {
|
|
87
51
|
const yaml = buildYaml({
|
|
88
52
|
name: options.name || dirName,
|
|
89
53
|
gpuType: options.gpu || "rtx3090",
|
|
90
54
|
gpuCount: parseInt(options.gpuCount || "1"),
|
|
91
55
|
diskSize: options.disk || "50G",
|
|
92
|
-
storage:
|
|
56
|
+
storage: true,
|
|
93
57
|
exclude: ["node_modules/", ".venv/", "__pycache__/", "*.pyc", "wandb/"],
|
|
94
58
|
});
|
|
95
59
|
writeFileSync("cassian.yaml", yaml);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
console.log();
|
|
99
|
-
console.log(` Run ${green("cassian up")} to start your instance.`);
|
|
100
|
-
console.log();
|
|
60
|
+
p.log.success("Created cassian.yaml");
|
|
61
|
+
p.log.info("Run \x1b[32mcassian up\x1b[0m to start your instance.");
|
|
101
62
|
return;
|
|
102
63
|
}
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
64
|
+
p.intro("\x1b[36m⚡ Cassian Setup\x1b[0m");
|
|
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
|
+
}
|
|
110
78
|
const availability = await fetchAvailability();
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
+
}
|
|
120
114
|
const gpuCount = parseInt(gpuCountStr);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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 });
|
|
144
149
|
writeFileSync("cassian.yaml", yaml);
|
|
145
|
-
|
|
146
|
-
console.log(` ${green("✓")} Created cassian.yaml`);
|
|
147
|
-
console.log();
|
|
148
|
-
console.log(` Run ${green("cassian up")} to start your instance.`);
|
|
149
|
-
console.log();
|
|
150
|
+
p.outro(`\x1b[32m✓\x1b[0m Created cassian.yaml — run \x1b[32mcassian up\x1b[0m to start`);
|
|
150
151
|
}
|
package/dist/commands/up.js
CHANGED
|
@@ -58,10 +58,10 @@ export async function up() {
|
|
|
58
58
|
info("Disk", config.disk);
|
|
59
59
|
}
|
|
60
60
|
else if (config.volumes?.length) {
|
|
61
|
-
info("
|
|
61
|
+
info("Disk", config.volumes.map((v) => `${v.size} at ${v.mount}`).join(", "));
|
|
62
62
|
}
|
|
63
|
-
if (config.storage
|
|
64
|
-
info("Storage",
|
|
63
|
+
if (config.storage) {
|
|
64
|
+
info("Storage", "enabled (/workspace/storage)");
|
|
65
65
|
}
|
|
66
66
|
console.log();
|
|
67
67
|
const vm = dev.vm;
|
|
@@ -125,7 +125,7 @@ export async function up() {
|
|
|
125
125
|
},
|
|
126
126
|
workspace: {
|
|
127
127
|
no_sync: config.workspace?.no_sync || [],
|
|
128
|
-
storage: config.storage
|
|
128
|
+
storage: config.storage === true ? ["storage"] : (Array.isArray(config.storage) ? config.storage : config.workspace?.storage || []),
|
|
129
129
|
exclude: config.workspace?.exclude || config.workspace?.syncignore || [],
|
|
130
130
|
},
|
|
131
131
|
});
|
package/dist/index.js
CHANGED
|
@@ -88,14 +88,12 @@ program
|
|
|
88
88
|
.option("--gpu <type>", "GPU type (e.g. h100-sxm, a100-sxm, rtx3090)")
|
|
89
89
|
.option("--gpu-count <n>", "Number of GPUs")
|
|
90
90
|
.option("--disk <size>", "Disk size (e.g. 50G, 200G)")
|
|
91
|
-
.option("--storage <folders>", "Comma-separated storage folders (e.g. datasets/,models/)")
|
|
92
91
|
.option("-y, --yes", "Skip all prompts, use defaults")
|
|
93
92
|
.action((opts) => init({
|
|
94
93
|
name: opts.name,
|
|
95
94
|
gpu: opts.gpu,
|
|
96
95
|
gpuCount: opts.gpuCount,
|
|
97
96
|
disk: opts.disk,
|
|
98
|
-
storage: opts.storage,
|
|
99
97
|
yes: opts.yes,
|
|
100
98
|
}));
|
|
101
99
|
program.parse();
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cassian-cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
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",
|