hypha-cli 0.1.3 → 0.1.4
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/README.md +35 -33
- package/package.json +1 -2
- package/bin/postinstall.mjs +0 -78
package/README.md
CHANGED
|
@@ -10,23 +10,25 @@ npm install -g hypha-cli
|
|
|
10
10
|
|
|
11
11
|
Requires **Node.js >= 22** (for native WebSocket support).
|
|
12
12
|
|
|
13
|
+
> **Note:** The Python `hypha` package also installs a `hypha` command. If you have both installed, use `npx hypha-cli` to run the Node.js CLI without conflicts.
|
|
14
|
+
|
|
13
15
|
## Quick Start
|
|
14
16
|
|
|
15
17
|
```bash
|
|
16
18
|
# Login (opens browser for OAuth)
|
|
17
|
-
hypha login
|
|
19
|
+
npx hypha-cli login
|
|
18
20
|
|
|
19
21
|
# Check workspace info
|
|
20
|
-
hypha info
|
|
22
|
+
npx hypha-cli info
|
|
21
23
|
|
|
22
24
|
# List services
|
|
23
|
-
hypha services
|
|
25
|
+
npx hypha-cli services
|
|
24
26
|
|
|
25
27
|
# List artifacts
|
|
26
|
-
hypha artifacts ls
|
|
28
|
+
npx hypha-cli artifacts ls
|
|
27
29
|
|
|
28
30
|
# Upload a file
|
|
29
|
-
hypha artifacts cp ./data.csv my-model:data/train.csv
|
|
31
|
+
npx hypha-cli artifacts cp ./data.csv my-model:data/train.csv
|
|
30
32
|
```
|
|
31
33
|
|
|
32
34
|
## Configuration
|
|
@@ -42,7 +44,7 @@ HYPHA_WORKSPACE=<your-workspace>
|
|
|
42
44
|
You can also set these as environment variables, or use global flags:
|
|
43
45
|
|
|
44
46
|
```bash
|
|
45
|
-
hypha --server https://hypha.aicell.io --workspace my-ws artifacts ls
|
|
47
|
+
npx hypha-cli --server https://hypha.aicell.io --workspace my-ws artifacts ls
|
|
46
48
|
```
|
|
47
49
|
|
|
48
50
|
## Commands
|
|
@@ -50,10 +52,10 @@ hypha --server https://hypha.aicell.io --workspace my-ws artifacts ls
|
|
|
50
52
|
### Workspace Management
|
|
51
53
|
|
|
52
54
|
```bash
|
|
53
|
-
hypha login [server-url] # OAuth login (opens browser)
|
|
54
|
-
hypha token [--expires-in N] [--permission P] [--workspace W] [--json]
|
|
55
|
-
hypha services [--type T] [--include-unlisted] [--json]
|
|
56
|
-
hypha info [--json]
|
|
55
|
+
npx hypha-cli login [server-url] # OAuth login (opens browser)
|
|
56
|
+
npx hypha-cli token [--expires-in N] [--permission P] [--workspace W] [--json]
|
|
57
|
+
npx hypha-cli services [--type T] [--include-unlisted] [--json]
|
|
58
|
+
npx hypha-cli info [--json]
|
|
57
59
|
```
|
|
58
60
|
|
|
59
61
|
### Apps — Server App Lifecycle
|
|
@@ -61,14 +63,14 @@ hypha info [--json]
|
|
|
61
63
|
Manage server app definitions (like Docker images) and running instances (like containers).
|
|
62
64
|
|
|
63
65
|
```bash
|
|
64
|
-
hypha apps list [--json] # List installed app definitions
|
|
65
|
-
hypha apps info <app-id> [--json] # Show app details
|
|
66
|
-
hypha apps install <source> [--id ID] [--manifest P] [--files D...] [--overwrite]
|
|
67
|
-
hypha apps uninstall <app-id> # Remove app definition
|
|
68
|
-
hypha apps start <app-id> [--timeout N] [--wait] # Start instance
|
|
69
|
-
hypha apps stop <id> [--all] # Stop instance(s)
|
|
70
|
-
hypha apps ps [--json] # List running instances
|
|
71
|
-
hypha apps logs <instance-id> [--tail N] [--type T]
|
|
66
|
+
npx hypha-cli apps list [--json] # List installed app definitions
|
|
67
|
+
npx hypha-cli apps info <app-id> [--json] # Show app details
|
|
68
|
+
npx hypha-cli apps install <source> [--id ID] [--manifest P] [--files D...] [--overwrite]
|
|
69
|
+
npx hypha-cli apps uninstall <app-id> # Remove app definition
|
|
70
|
+
npx hypha-cli apps start <app-id> [--timeout N] [--wait] # Start instance
|
|
71
|
+
npx hypha-cli apps stop <id> [--all] # Stop instance(s)
|
|
72
|
+
npx hypha-cli apps ps [--json] # List running instances
|
|
73
|
+
npx hypha-cli apps logs <instance-id> [--tail N] [--type T]
|
|
72
74
|
```
|
|
73
75
|
|
|
74
76
|
**Aliases**: `ls` = `list`, `rm` = `uninstall`
|
|
@@ -80,36 +82,36 @@ hypha apps logs <instance-id> [--tail N] [--type T]
|
|
|
80
82
|
Linux-style commands for managing artifacts (datasets, models, files). Artifact paths use `alias:path/to/file` notation.
|
|
81
83
|
|
|
82
84
|
```bash
|
|
83
|
-
hypha artifacts ls [artifact[:path]] [--json] [--long]
|
|
84
|
-
hypha artifacts cat <artifact:path>
|
|
85
|
-
hypha artifacts cp <src> <dest> [-r] [--commit]
|
|
86
|
-
hypha artifacts rm <artifact[:path]> [-r] [--force]
|
|
87
|
-
hypha artifacts create <alias> [--type T] [--parent P]
|
|
88
|
-
hypha artifacts info <artifact> [--json]
|
|
89
|
-
hypha artifacts search <query> [--type T] [--limit N] [--json]
|
|
90
|
-
hypha artifacts commit <artifact> [--version V] [--message M]
|
|
91
|
-
hypha artifacts edit <artifact> [--name N] [--description D]
|
|
92
|
-
hypha artifacts discard <artifact>
|
|
85
|
+
npx hypha-cli artifacts ls [artifact[:path]] [--json] [--long]
|
|
86
|
+
npx hypha-cli artifacts cat <artifact:path>
|
|
87
|
+
npx hypha-cli artifacts cp <src> <dest> [-r] [--commit]
|
|
88
|
+
npx hypha-cli artifacts rm <artifact[:path]> [-r] [--force]
|
|
89
|
+
npx hypha-cli artifacts create <alias> [--type T] [--parent P]
|
|
90
|
+
npx hypha-cli artifacts info <artifact> [--json]
|
|
91
|
+
npx hypha-cli artifacts search <query> [--type T] [--limit N] [--json]
|
|
92
|
+
npx hypha-cli artifacts commit <artifact> [--version V] [--message M]
|
|
93
|
+
npx hypha-cli artifacts edit <artifact> [--name N] [--description D]
|
|
94
|
+
npx hypha-cli artifacts discard <artifact>
|
|
93
95
|
```
|
|
94
96
|
|
|
95
97
|
**Aliases**: `list` = `ls`, `mkdir` = `create`, `find` = `search`
|
|
96
98
|
|
|
97
|
-
**Shorthand**: `hypha art` = `hypha artifacts`
|
|
99
|
+
**Shorthand**: `npx hypha-cli art` = `npx hypha-cli artifacts`
|
|
98
100
|
|
|
99
101
|
#### Copy Examples
|
|
100
102
|
|
|
101
103
|
```bash
|
|
102
104
|
# Upload a single file
|
|
103
|
-
hypha artifacts cp ./data.csv my-model:data/train.csv
|
|
105
|
+
npx hypha-cli artifacts cp ./data.csv my-model:data/train.csv
|
|
104
106
|
|
|
105
107
|
# Download a file
|
|
106
|
-
hypha artifacts cp my-model:weights.bin ./local/
|
|
108
|
+
npx hypha-cli artifacts cp my-model:weights.bin ./local/
|
|
107
109
|
|
|
108
110
|
# Upload a directory (recursive)
|
|
109
|
-
hypha artifacts cp ./dataset/ my-model:data/ -r
|
|
111
|
+
npx hypha-cli artifacts cp ./dataset/ my-model:data/ -r
|
|
110
112
|
|
|
111
113
|
# Upload and auto-commit
|
|
112
|
-
hypha artifacts cp ./results.json my-model:results.json --commit
|
|
114
|
+
npx hypha-cli artifacts cp ./results.json my-model:results.json --commit
|
|
113
115
|
```
|
|
114
116
|
|
|
115
117
|
## Programmatic API
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hypha-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Hypha Cloud CLI — manage workspaces, apps, and artifacts",
|
|
5
5
|
"author": "Amun AI AB",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"./cli": "./dist/cli.mjs"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"postinstall": "node bin/postinstall.mjs",
|
|
22
21
|
"build": "tsc --noEmit && pkgroll",
|
|
23
22
|
"typecheck": "tsc --noEmit",
|
|
24
23
|
"test": "npx tsx test/test-cli-routing.mjs && npx tsx test/test-artifact-path.mjs && npx tsx test/test-apps-commands.mjs && npx tsx test/test-artifacts-commands.mjs && npx tsx test/test-helpers.mjs",
|
package/bin/postinstall.mjs
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* postinstall script for hypha-cli
|
|
5
|
-
*
|
|
6
|
-
* Detects and removes conflicting Python 'hypha' command.
|
|
7
|
-
* The Python hypha package installs a 'hypha' console_script for starting
|
|
8
|
-
* the server, but `python -m hypha.server` is the preferred way to do that.
|
|
9
|
-
*
|
|
10
|
-
* npm runs postinstall in a stripped shell (no ~/.zshrc, no conda init, etc),
|
|
11
|
-
* so `which` can't see all PATH entries. We solve this by running `which -a`
|
|
12
|
-
* inside a login shell to get the user's full PATH.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { execSync } from 'child_process';
|
|
16
|
-
import { existsSync, readFileSync, unlinkSync } from 'fs';
|
|
17
|
-
|
|
18
|
-
function isPythonHyphaScript(filePath) {
|
|
19
|
-
try {
|
|
20
|
-
const head = readFileSync(filePath, 'utf-8').slice(0, 500);
|
|
21
|
-
return head.includes('python') && head.includes('from hypha');
|
|
22
|
-
} catch {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function findConflictingBinaries() {
|
|
28
|
-
const found = new Set();
|
|
29
|
-
|
|
30
|
-
// Detect user's shell
|
|
31
|
-
const shell = process.env.SHELL || '/bin/sh';
|
|
32
|
-
|
|
33
|
-
// npm runs postinstall in a stripped environment. `zsh -l` (login non-interactive)
|
|
34
|
-
// skips .zshrc where conda/pyenv add PATH entries. We must use `-i` (interactive)
|
|
35
|
-
// to source .zshrc, or explicitly source the rc files.
|
|
36
|
-
for (const cmd of [
|
|
37
|
-
`${shell} -i -c 'which -a hypha' 2>/dev/null`, // interactive shell (sources .zshrc/.bashrc)
|
|
38
|
-
`${shell} -l -c 'which -a hypha' 2>/dev/null`, // login shell fallback
|
|
39
|
-
'which -a hypha 2>/dev/null', // plain fallback
|
|
40
|
-
]) {
|
|
41
|
-
try {
|
|
42
|
-
const output = execSync(cmd, { encoding: 'utf-8', timeout: 10000 }).trim();
|
|
43
|
-
for (const line of output.split('\n')) {
|
|
44
|
-
const p = line.trim();
|
|
45
|
-
if (p && existsSync(p) && isPythonHyphaScript(p)) {
|
|
46
|
-
found.add(p);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
} catch {
|
|
50
|
-
// Shell or which not available
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return [...found];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function main() {
|
|
58
|
-
const conflicts = findConflictingBinaries();
|
|
59
|
-
if (conflicts.length === 0) return;
|
|
60
|
-
|
|
61
|
-
for (const binPath of conflicts) {
|
|
62
|
-
try {
|
|
63
|
-
unlinkSync(binPath);
|
|
64
|
-
console.log(`hypha-cli: removed conflicting Python 'hypha' at ${binPath}`);
|
|
65
|
-
} catch (err) {
|
|
66
|
-
if (err.code === 'EACCES') {
|
|
67
|
-
console.log(`hypha-cli: conflicting Python 'hypha' at ${binPath}`);
|
|
68
|
-
console.log(` remove it manually: rm ${binPath}`);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (conflicts.length > 0) {
|
|
74
|
-
console.log(` (use 'python -m hypha.server' to start the Hypha server instead)`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
main();
|