@thermai/flightdeck-cli 0.1.0-pilot.7 → 0.1.0-pilot.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/README.md +30 -14
- package/dist/index.js +181 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ requires a backend advertising `X-Flightdeck-Accounting: credits-v1`. Upgrade
|
|
|
28
28
|
with the install command below before accessing account/job data. An incompatible
|
|
29
29
|
backend is rejected before job submission; login and credential revocation do not require
|
|
30
30
|
the accounting contract. See the
|
|
31
|
-
|
|
31
|
+
operator rollout checklist (`flightdeck-ops/runbooks/customer-credits-rollout.md`).
|
|
32
32
|
|
|
33
33
|
**`0.1.0-pilot.5`**, published on 21 September 2026, fixes result downloads redirected to signed object
|
|
34
34
|
storage ([#157](https://github.com/ThermAI-Group/thermai_flightdeck/issues/157))
|
|
@@ -46,17 +46,27 @@ was confirmed by the operator on 24 September. These are historical pilot.6
|
|
|
46
46
|
results, not pilot.7 publication evidence. This update does not modify the
|
|
47
47
|
README inside the already-published immutable tarball.
|
|
48
48
|
|
|
49
|
-
**`0.1.0-pilot.7
|
|
50
|
-
`tui`), flight details/events/logs, name
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
**`0.1.0-pilot.7`**, published on 1 October 2026, adds the read-only
|
|
50
|
+
`flightdeck atc` terminal view (alias `tui`), flight details/events/logs, name
|
|
51
|
+
filtering and local sbatch-array tracking from
|
|
52
|
+
[PR #206](https://github.com/ThermAI-Group/thermai_flightdeck/pull/206).
|
|
53
|
+
Downloads/cancellation inside ATC remain deferred to #205; stale
|
|
54
|
+
fallback-status indication is tracked in #207.
|
|
55
|
+
|
|
56
|
+
**`0.1.0-pilot.8`** adds `flightdeck admin flights` for organisation and
|
|
57
|
+
platform administrators ([PR #281](https://github.com/ThermAI-Group/thermai_flightdeck/pull/281)).
|
|
58
|
+
It needs a credential approved through `flightdeck login --admin`; existing
|
|
59
|
+
credentials keep working for every other command, so administrators run
|
|
60
|
+
`flightdeck logout` then `flightdeck login --admin` only when they want the
|
|
61
|
+
admin view. `flightdeck login` now defaults the credential name to
|
|
62
|
+
`flightdeck-cli@<hostname>` so a second machine no longer collides (#254), and
|
|
63
|
+
`flightdeck sbatch` prints a runnable status hint with the submitted flight ID
|
|
64
|
+
and labels the job ID on the ATC hint (#257, #259). The required backend is
|
|
65
|
+
already deployed; there are no new runtime dependencies. Publication requires the
|
|
66
|
+
approved `cli-v0.1.0-pilot.8` GitHub prerelease and a successful release workflow.
|
|
67
|
+
After publication, use the generated `@next` command below, or pin
|
|
68
|
+
`@thermai/flightdeck-cli@0.1.0-pilot.8`, and confirm `flightdeck --version`
|
|
69
|
+
reports `0.1.0-pilot.8`.
|
|
60
70
|
|
|
61
71
|
Members and organization administrators receive whole-credit balances,
|
|
62
72
|
estimates and actual customer charges, without provider-cost information.
|
|
@@ -96,7 +106,11 @@ permissions. Never share that file or include it in a workload bundle. Use
|
|
|
96
106
|
`flightdeck logout` to remove the local login and attempt server revocation.
|
|
97
107
|
Portal credential management can revoke an individual workstation as well.
|
|
98
108
|
|
|
99
|
-
`--name` labels a credential, not a local account profile.
|
|
109
|
+
`--name` labels a credential, not a local account profile. It defaults to
|
|
110
|
+
`flightdeck-cli@<short hostname>`, which is shown on the approval page, in
|
|
111
|
+
credential lists, and in the audit history; pass `--name` to choose another
|
|
112
|
+
label. Active credential names must be unique per account, so machines that
|
|
113
|
+
share a short hostname need distinct `--name` values. There is one saved
|
|
100
114
|
login per OS user. If already logged in, use `whoami` to inspect it; `login`
|
|
101
115
|
refuses to replace it. Use a separate OS user to preserve an operator's working
|
|
102
116
|
credential, or explicitly choose logout/re-login on the same workstation.
|
|
@@ -233,7 +247,9 @@ flightdeck atc --demo # a simulated array; no account or credits nee
|
|
|
233
247
|
|
|
234
248
|
`flightdeck sbatch` records each array's flight IDs under
|
|
235
249
|
`~/.flightdeck/batches/` and ends with `Watch live: flightdeck atc <job-id>`;
|
|
236
|
-
that job ID is the one to pass.
|
|
250
|
+
that job ID is the one to pass. It is a local sbatch job ID, not a flight ID:
|
|
251
|
+
`status`, `logs`, `outputs`, `download` and `cancel` take the `fl-…` flight
|
|
252
|
+
IDs printed for each task. The record exists only on the machine that
|
|
237
253
|
submitted it (if it could not be written, sbatch says so; use `--name`). Name
|
|
238
254
|
patterns are case-sensitive. Leaving the view does not stop any job. In
|
|
239
255
|
scripts, keep using `status` and `logs`.
|
package/dist/index.js
CHANGED
|
@@ -104,6 +104,7 @@ Diagnostic: ${details.join("; ") || "unknown error type"}`;
|
|
|
104
104
|
// src/client.ts
|
|
105
105
|
var DEFAULT_API_URL = "https://api.flightdeck.thermai.uk";
|
|
106
106
|
var CONFIG_PATH = join(homedir(), ".flightdeck", "config.json");
|
|
107
|
+
var ADMIN_SCOPE_MESSAGE = "Run `flightdeck login --admin` to authorise this workstation for administrator views.";
|
|
107
108
|
var ACCOUNTING_HEADER = "X-Flightdeck-Accounting";
|
|
108
109
|
var ACCOUNTING_CONTRACT = "credits-v1";
|
|
109
110
|
var ARTIFACT_REDIRECTS = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
@@ -265,6 +266,11 @@ async function authenticatedRequest(config, method, path, body, redirect = "foll
|
|
|
265
266
|
signal
|
|
266
267
|
});
|
|
267
268
|
if (response.status === 403) {
|
|
269
|
+
const raw = await response.clone().json().catch(() => null);
|
|
270
|
+
const body2 = raw && typeof raw === "object" ? raw : {};
|
|
271
|
+
if (body2.error === "admin_scope_required" || body2.error === "credential_scope_required" && (body2.required_scope === "admin:jobs:read" || body2.required_scope === void 0 && /^\/(?:admin|platform)\/flights(?:\?|$)/.test(path))) {
|
|
272
|
+
throw new CliError(ADMIN_SCOPE_MESSAGE);
|
|
273
|
+
}
|
|
268
274
|
throw await suspensionError(response) ?? httpError("Access denied", response.status);
|
|
269
275
|
}
|
|
270
276
|
if (path !== "/auth/credential/revoke" && (response.ok || response.status === 402)) assertAccountingContract(response);
|
|
@@ -348,9 +354,9 @@ function environmentContractIssues(value, mode = "customer") {
|
|
|
348
354
|
return ["environment must be a string record"];
|
|
349
355
|
}
|
|
350
356
|
const entries = Object.entries(value);
|
|
351
|
-
const
|
|
352
|
-
const maximumEntries =
|
|
353
|
-
const maximumBytes =
|
|
357
|
+
const runtime2 = mode === "runtime";
|
|
358
|
+
const maximumEntries = runtime2 ? MAX_RUNTIME_ENV_ENTRIES : MAX_CUSTOMER_ENV_ENTRIES;
|
|
359
|
+
const maximumBytes = runtime2 ? MAX_RUNTIME_ENV_UTF8_BYTES : MAX_CUSTOMER_ENV_UTF8_BYTES;
|
|
354
360
|
const issues = [];
|
|
355
361
|
let aggregateBytes = 0;
|
|
356
362
|
if (entries.length > maximumEntries) {
|
|
@@ -367,7 +373,7 @@ function environmentContractIssues(value, mode = "customer") {
|
|
|
367
373
|
if (name.length > MAX_ENV_KEY_CHARACTERS) {
|
|
368
374
|
issues.push(`${name} exceeds ${MAX_ENV_KEY_CHARACTERS} characters`);
|
|
369
375
|
}
|
|
370
|
-
if (!
|
|
376
|
+
if (!runtime2 && RESERVED.has(name)) {
|
|
371
377
|
issues.push(`${name} is reserved by Flightdeck`);
|
|
372
378
|
}
|
|
373
379
|
const valueBytes = utf8Bytes(rawValue);
|
|
@@ -1035,6 +1041,13 @@ function buildSbatchPlans(args) {
|
|
|
1035
1041
|
}
|
|
1036
1042
|
}));
|
|
1037
1043
|
}
|
|
1044
|
+
function trackWithLine(submitted) {
|
|
1045
|
+
const hint = `Track with: flightdeck status ${submitted[0].flightId}`;
|
|
1046
|
+
return submitted.length > 1 ? `${hint} (or any flight ID above)` : hint;
|
|
1047
|
+
}
|
|
1048
|
+
function watchLiveLine(jobId) {
|
|
1049
|
+
return `Watch live: flightdeck atc ${jobId} (sbatch job ID, not a flight ID; works on this machine only)`;
|
|
1050
|
+
}
|
|
1038
1051
|
function batchRecorder(jobId, jobName, target = { apiUrl: readConfig()?.api_url }) {
|
|
1039
1052
|
const apiUrl = target.apiUrl;
|
|
1040
1053
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -1166,8 +1179,8 @@ Packaging files...`);
|
|
|
1166
1179
|
console.log(`
|
|
1167
1180
|
${submitted.length} submitted, ${failures} failed.`);
|
|
1168
1181
|
if (submitted.length > 0) {
|
|
1169
|
-
console.log(
|
|
1170
|
-
if (batch.saved) console.log(
|
|
1182
|
+
console.log(trackWithLine(submitted));
|
|
1183
|
+
if (batch.saved) console.log(watchLiveLine(jobId));
|
|
1171
1184
|
}
|
|
1172
1185
|
if (failures > 0) process.exit(1);
|
|
1173
1186
|
return { submitted, failures };
|
|
@@ -2966,11 +2979,37 @@ Slurm provider conformance passed for ${submitted.length} array tasks.`);
|
|
|
2966
2979
|
}
|
|
2967
2980
|
|
|
2968
2981
|
// src/commands/login.ts
|
|
2982
|
+
import { hostname } from "node:os";
|
|
2969
2983
|
var SCOPES = ["jobs:read", "jobs:submit", "jobs:cancel", "account:read"];
|
|
2984
|
+
function loginScopes(admin = false) {
|
|
2985
|
+
return admin ? [...SCOPES, "admin:jobs:read"] : [...SCOPES];
|
|
2986
|
+
}
|
|
2987
|
+
var HOST_LABEL_MAX_LENGTH = 60;
|
|
2988
|
+
function shortHostname(rawHostname) {
|
|
2989
|
+
const trimmed = rawHostname.trim();
|
|
2990
|
+
const isAddress = /^[\d.]+$/.test(trimmed) || trimmed.includes(":");
|
|
2991
|
+
const label = (isAddress ? trimmed : trimmed.split(".")[0]).replace(/[^\p{L}\p{M}\p{N}_-]+/gu, "-").replace(/^-+/, "");
|
|
2992
|
+
let capped = "";
|
|
2993
|
+
for (const character of label) {
|
|
2994
|
+
if (capped.length + character.length > HOST_LABEL_MAX_LENGTH) break;
|
|
2995
|
+
capped += character;
|
|
2996
|
+
}
|
|
2997
|
+
return capped.replace(/-+$/, "");
|
|
2998
|
+
}
|
|
2999
|
+
function defaultCredentialName(rawHostname = hostname()) {
|
|
3000
|
+
const host = shortHostname(rawHostname);
|
|
3001
|
+
return host ? `flightdeck-cli@${host}` : "flightdeck-cli";
|
|
3002
|
+
}
|
|
3003
|
+
function credentialNameInUseMessage(credentialName, rawHostname = hostname(), now = /* @__PURE__ */ new Date()) {
|
|
3004
|
+
const timestamp2 = now.toISOString().slice(0, 16).replace("T", "-").replace(":", "");
|
|
3005
|
+
let suggestedName = `${shortHostname(rawHostname) || "workstation"}-${timestamp2}`;
|
|
3006
|
+
if (suggestedName.toLowerCase() === credentialName.trim().toLowerCase()) suggestedName += "-2";
|
|
3007
|
+
return `Login was approved, but no credential was created: your account already has an active CLI credential named "${credentialName.trim()}". Each machine needs its own credential name. Run login again with a new name and approve it in the browser, e.g. flightdeck login --name ${suggestedName} (or revoke the old credential in the portal first).`;
|
|
3008
|
+
}
|
|
2970
3009
|
function sleep(milliseconds) {
|
|
2971
3010
|
return new Promise((resolve4) => setTimeout(resolve4, milliseconds));
|
|
2972
3011
|
}
|
|
2973
|
-
async function loginFailure(response) {
|
|
3012
|
+
async function loginFailure(response, credentialName) {
|
|
2974
3013
|
const suspended = await suspensionError(response);
|
|
2975
3014
|
if (suspended) return suspended;
|
|
2976
3015
|
try {
|
|
@@ -2978,11 +3017,14 @@ async function loginFailure(response) {
|
|
|
2978
3017
|
if (body.error === "device_authorization_denied") {
|
|
2979
3018
|
return new CliError("Login was not approved. Run flightdeck login to try again.");
|
|
2980
3019
|
}
|
|
3020
|
+
if (body.error === "admin_role_required") {
|
|
3021
|
+
return new CliError("This account is not an administrator; run flightdeck login without --admin.");
|
|
3022
|
+
}
|
|
2981
3023
|
if (body.error === "expired_device_code") {
|
|
2982
3024
|
return new CliError("Login expired before it was approved. Run flightdeck login to try again.");
|
|
2983
3025
|
}
|
|
2984
3026
|
if (body.error === "credential_name_in_use") {
|
|
2985
|
-
return new CliError(
|
|
3027
|
+
return new CliError(credentialNameInUseMessage(credentialName));
|
|
2986
3028
|
}
|
|
2987
3029
|
} catch {
|
|
2988
3030
|
}
|
|
@@ -2993,9 +3035,10 @@ async function login(options) {
|
|
|
2993
3035
|
throw new CliError("Already logged in. Run flightdeck whoami to check the account, or flightdeck logout before signing in again.");
|
|
2994
3036
|
}
|
|
2995
3037
|
const apiUrl = normalizeApiUrl(options.apiUrl ?? DEFAULT_API_URL);
|
|
3038
|
+
const credentialName = options.name ?? defaultCredentialName();
|
|
2996
3039
|
const started = await publicApiRequest(apiUrl, "POST", "/auth/device/code", {
|
|
2997
|
-
credential_name:
|
|
2998
|
-
scopes:
|
|
3040
|
+
credential_name: credentialName,
|
|
3041
|
+
scopes: loginScopes(options.admin)
|
|
2999
3042
|
});
|
|
3000
3043
|
if (!started.ok) throw httpError("Unable to start login", started.status);
|
|
3001
3044
|
const authorization = await started.json();
|
|
@@ -3016,7 +3059,7 @@ Verification code: ${authorization.user_code}`);
|
|
|
3016
3059
|
if (Number.isFinite(retryAfter) && retryAfter > 0) intervalSeconds = retryAfter;
|
|
3017
3060
|
continue;
|
|
3018
3061
|
}
|
|
3019
|
-
if (!response.ok) throw await loginFailure(response);
|
|
3062
|
+
if (!response.ok) throw await loginFailure(response, credentialName);
|
|
3020
3063
|
const token = await response.json();
|
|
3021
3064
|
saveConfig({ api_url: apiUrl, api_key: token.access_token, credential_id: token.credential_id });
|
|
3022
3065
|
console.log("Logged in. The credential was stored in ~/.flightdeck/config.json.");
|
|
@@ -3064,15 +3107,139 @@ async function balance() {
|
|
|
3064
3107
|
console.log(JSON.stringify(await response.json(), null, 2));
|
|
3065
3108
|
}
|
|
3066
3109
|
|
|
3110
|
+
// src/commands/admin-flights-format.ts
|
|
3111
|
+
function plain(value) {
|
|
3112
|
+
return value.replace(/[\u0000-\u001f\u007f-\u009f]/g, " ");
|
|
3113
|
+
}
|
|
3114
|
+
function runtime(flight, now) {
|
|
3115
|
+
if (!flight.started_at) return "-";
|
|
3116
|
+
const seconds = Math.max(0, Math.floor(((flight.completed_at ? Date.parse(flight.completed_at) : now) - Date.parse(flight.started_at)) / 1e3));
|
|
3117
|
+
return `${Math.floor(seconds / 3600)}h ${Math.floor(seconds / 60) % 60}m ${seconds % 60}s`;
|
|
3118
|
+
}
|
|
3119
|
+
function formatAdminFlights(flights, platform, now = Date.now()) {
|
|
3120
|
+
if (!flights.length) return "No flights in this time window.";
|
|
3121
|
+
const organizations = /* @__PURE__ */ new Map();
|
|
3122
|
+
for (const flight of flights) {
|
|
3123
|
+
const key = platform ? flight.organization?.id ?? "" : "";
|
|
3124
|
+
if (!organizations.has(key)) organizations.set(key, {
|
|
3125
|
+
label: flight.organization ? `${plain(flight.organization.name)} (${plain(flight.organization.slug)})` : "(no organisation)",
|
|
3126
|
+
members: /* @__PURE__ */ new Map()
|
|
3127
|
+
});
|
|
3128
|
+
const group = organizations.get(key);
|
|
3129
|
+
const memberKey = flight.account?.id ?? "";
|
|
3130
|
+
if (!group.members.has(memberKey)) group.members.set(memberKey, {
|
|
3131
|
+
label: flight.account ? `${plain(flight.account.name || flight.account.email)} <${plain(flight.account.email)}>` : "(deleted account)",
|
|
3132
|
+
flights: []
|
|
3133
|
+
});
|
|
3134
|
+
group.members.get(memberKey).flights.push(flight);
|
|
3135
|
+
}
|
|
3136
|
+
const lines = [];
|
|
3137
|
+
for (const group of [...organizations.values()].sort((a, b) => a.label.localeCompare(b.label))) {
|
|
3138
|
+
const count2 = [...group.members.values()].reduce((sum, member) => sum + member.flights.length, 0);
|
|
3139
|
+
if (platform) lines.push(`${group.label} \u2014 ${count2} flight${count2 === 1 ? "" : "s"}`);
|
|
3140
|
+
for (const member of [...group.members.values()].sort((a, b) => a.label.localeCompare(b.label))) {
|
|
3141
|
+
lines.push(`${platform ? " " : ""}${member.label} \u2014 ${member.flights.length} flight${member.flights.length === 1 ? "" : "s"}`);
|
|
3142
|
+
const headers = [
|
|
3143
|
+
"Flight ID",
|
|
3144
|
+
"Name",
|
|
3145
|
+
"Status",
|
|
3146
|
+
"Shape",
|
|
3147
|
+
"Provider",
|
|
3148
|
+
"Queued (UTC)",
|
|
3149
|
+
"Runtime",
|
|
3150
|
+
...platform ? ["Provider cost", "Charge", "Reserved"] : ["Credits", "Reserved credits"]
|
|
3151
|
+
];
|
|
3152
|
+
const rows = member.flights.slice().sort((a, b) => b.queued_at.localeCompare(a.queued_at)).map((flight) => [
|
|
3153
|
+
flight.flight_id,
|
|
3154
|
+
flight.name,
|
|
3155
|
+
flight.status,
|
|
3156
|
+
flight.compute_type === "cpu" ? `CPU x${flight.cpu_count} / ${flight.memory_mib} MiB` : `${flight.gpu_type ?? "GPU"} x${flight.gpu_count}`,
|
|
3157
|
+
flight.provider ?? "-",
|
|
3158
|
+
flight.queued_at,
|
|
3159
|
+
runtime(flight, now),
|
|
3160
|
+
...platform ? [flight.cost_pence == null ? "-" : `${flight.cost_pence}p`, `${flight.charge_pence ?? 0}p`, `${flight.reserved_pence ?? 0}p`] : [String(flight.charge_credits ?? 0), String(flight.reserved_credits ?? 0)]
|
|
3161
|
+
].map(plain));
|
|
3162
|
+
const widths = headers.map((header, index) => rows.reduce((width, row) => Math.max(width, row[index].length), header.length));
|
|
3163
|
+
const indent = platform ? " " : " ";
|
|
3164
|
+
for (const row of [headers, ...rows]) lines.push(indent + row.map((cell, index) => cell.padEnd(widths[index])).join(" ").trimEnd());
|
|
3165
|
+
lines.push("");
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
return lines.join("\n").trimEnd();
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
// src/commands/admin-flights.ts
|
|
3172
|
+
function adminFlightEndpoint(identity) {
|
|
3173
|
+
const endpoint2 = identity.platform_admin ? "/platform/flights" : identity.organization?.role === "org_admin" ? "/admin/flights" : null;
|
|
3174
|
+
if (!endpoint2) throw new CliError("Your account is not an organisation or platform administrator.");
|
|
3175
|
+
if (!identity.credential_scopes?.includes("admin:jobs:read")) {
|
|
3176
|
+
throw new CliError(ADMIN_SCOPE_MESSAGE);
|
|
3177
|
+
}
|
|
3178
|
+
return endpoint2;
|
|
3179
|
+
}
|
|
3180
|
+
function adminFlightWindow(options, now = /* @__PURE__ */ new Date()) {
|
|
3181
|
+
if (options.since !== void 0 && (options.from !== void 0 || options.to !== void 0)) {
|
|
3182
|
+
throw new CliError("Use either --since or --from with --to.");
|
|
3183
|
+
}
|
|
3184
|
+
if (options.from !== void 0 || options.to !== void 0) {
|
|
3185
|
+
if (!options.from || !options.to) throw new CliError("Supply both --from and --to.");
|
|
3186
|
+
const iso = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/;
|
|
3187
|
+
const from2 = new Date(options.from), to = new Date(options.to);
|
|
3188
|
+
if (!iso.test(options.from) || !iso.test(options.to) || !Number.isFinite(from2.getTime()) || !Number.isFinite(to.getTime()) || from2 > to) throw new CliError("Use ISO timestamps with --from before --to.");
|
|
3189
|
+
return { from: from2.toISOString(), to: to.toISOString() };
|
|
3190
|
+
}
|
|
3191
|
+
const duration = /^(\d+)([smhdw])$/.exec(options.since ?? "7d");
|
|
3192
|
+
const units = { s: 1e3, m: 6e4, h: 36e5, d: 864e5, w: 6048e5 };
|
|
3193
|
+
const milliseconds = duration ? Number(duration[1]) * units[duration[2]] : NaN;
|
|
3194
|
+
const from = new Date(now.getTime() - milliseconds);
|
|
3195
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0 || !Number.isFinite(from.getTime())) {
|
|
3196
|
+
throw new CliError("Use a positive duration for --since, e.g. 7d or 24h.");
|
|
3197
|
+
}
|
|
3198
|
+
return { from: from.toISOString(), to: now.toISOString() };
|
|
3199
|
+
}
|
|
3200
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
3201
|
+
var STATUSES = ["queued", "dispatching", "running", "finalizing", "completed", "failed", "cancelled"];
|
|
3202
|
+
async function adminFlights(options) {
|
|
3203
|
+
const window = adminFlightWindow(options);
|
|
3204
|
+
const limitText = options.limit ?? "100";
|
|
3205
|
+
const limit = Number(limitText);
|
|
3206
|
+
if (!/^\d+$/.test(limitText) || !Number.isSafeInteger(limit) || limit < 1) throw new CliError("--limit must be a positive integer.");
|
|
3207
|
+
if (options.status && !STATUSES.includes(options.status)) throw new CliError(`--status must be one of: ${STATUSES.join(", ")}.`);
|
|
3208
|
+
const me = await apiRequest("GET", "/auth/me");
|
|
3209
|
+
if (!me.ok) throw httpError("Unable to read account", me.status);
|
|
3210
|
+
const identity = await me.json();
|
|
3211
|
+
const endpoint2 = adminFlightEndpoint(identity);
|
|
3212
|
+
if (options.org && endpoint2 !== "/platform/flights") throw new CliError("--org is available only to platform administrators.");
|
|
3213
|
+
const query = new URLSearchParams(window);
|
|
3214
|
+
if (options.org) query.set(UUID.test(options.org) ? "organization_id" : "organization_slug", options.org);
|
|
3215
|
+
if (options.member) query.set(UUID.test(options.member) ? "account_id" : "account_email", options.member);
|
|
3216
|
+
if (options.status) query.set("status", options.status);
|
|
3217
|
+
const flights = [];
|
|
3218
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
3219
|
+
while (flights.length < limit) {
|
|
3220
|
+
query.set("limit", String(Math.min(500, limit - flights.length)));
|
|
3221
|
+
const response = await apiRequest("GET", `${endpoint2}?${query}`);
|
|
3222
|
+
if (!response.ok) throw httpError("Unable to list administrator flights", response.status);
|
|
3223
|
+
const page = await response.json();
|
|
3224
|
+
flights.push(...page.flights.slice(0, limit - flights.length));
|
|
3225
|
+
if (!page.next_cursor) break;
|
|
3226
|
+
if (cursors.has(page.next_cursor) || !page.flights.length) throw new CliError("The flight list returned an invalid pagination cursor.");
|
|
3227
|
+
cursors.add(page.next_cursor);
|
|
3228
|
+
query.set("cursor", page.next_cursor);
|
|
3229
|
+
}
|
|
3230
|
+
console.log(options.json ? JSON.stringify(flights, null, 2) : formatAdminFlights(flights, identity.platform_admin));
|
|
3231
|
+
}
|
|
3232
|
+
|
|
3067
3233
|
// src/index.ts
|
|
3068
3234
|
var program = new Command();
|
|
3069
3235
|
program.name("flightdeck").description("FlightDeck CLI \u2014 submit GPU compute jobs").option("--debug", "include safe error type/code and CLI frame diagnostics (no raw stack or credentials)").version(JSON.parse(readFileSync5(new URL("../package.json", import.meta.url), "utf8")).version);
|
|
3070
|
-
program.command("login").description("Log in through the FlightDeck portal").option("--api-url <url>", "FlightDeck API URL", DEFAULT_API_URL).option("--name <name>", "name for this CLI credential
|
|
3236
|
+
program.command("login").description("Log in through the FlightDeck portal").option("--api-url <url>", "FlightDeck API URL", DEFAULT_API_URL).option("--name <name>", "name for this CLI credential (default: flightdeck-cli@<hostname>)").option("--admin", "authorise this workstation to list flights as an administrator").action(login);
|
|
3071
3237
|
program.command("logout").description("Remove the local login and attempt server credential revocation").option("--local", "remove the local login without revoking the credential").action(logout);
|
|
3072
3238
|
program.command("whoami").description("Show the current FlightDeck account").action(whoami);
|
|
3073
3239
|
program.command("balance").description("Show the current credit balance").action(balance);
|
|
3074
|
-
program.command("
|
|
3075
|
-
program.command("
|
|
3240
|
+
program.command("admin").description("Administrator views").command("flights").description("List member flights. Organisations retain flights submitted before a member leaves.").option("--org <slug|id>", "organisation filter (platform administrators only)").option("--member <email|id>", "member filter").option("--status <status>", "flight status").option("--since <duration>", "look back, e.g. 7d or 24h (default: 7d)").option("--from <iso>", "start of the UTC time window").option("--to <iso>", "end of the UTC time window").option("--limit <n>", "maximum flights, following cursors", "100").option("--json", "print raw, ungrouped rows").action(adminFlights);
|
|
3241
|
+
program.command("submit").description("Submit a job from local files").argument("<entrypoint>", 'command to run (e.g. "python train.py --epochs 50")').option("-n, --name <name>", "job name", "cli-job").option("-f, --files <glob...>", "files to include (default: current directory)").option("-r, --requirements <file>", "pip requirements file", "requirements.txt").option("--gpu <type>", "GPU type (e.g. A100, H100)").option("--gpu-count <n>", "number of GPUs", "1").option("--time <duration>", "max duration (e.g. 1h, 30m, 3600s)", "1h").option("--base-image <image>", "runner image built FROM flightdeck-runner (see /docs/images)").option("--provider <id>", "pin the flight to one compute provider (default: operator's order)").option("-e, --env <vars...>", "environment variables (KEY=VALUE)").action(submit);
|
|
3242
|
+
program.command("sbatch").description("Submit a Slurm batch script (#SBATCH directives, incl. job arrays)").argument("<script>", "path to the .slurm/.sh batch script").option("-f, --files <glob...>", "files to include (default: current directory)").option("-r, --requirements <file>", "pip requirements file to install before the script runs").option("--base-image <image>", "runner image built FROM flightdeck-runner (see /docs/images)").option("--provider <id>", "pin every task to one compute provider (default: operator's order)").option("-n, --name <name>", "override job name (default: #SBATCH --job-name)").option("-e, --env <vars...>", "extra environment variables (KEY=VALUE)").option("--dry-run", "parse and show what would be submitted, without submitting").action(async (script, options) => {
|
|
3076
3243
|
await sbatch(script, options);
|
|
3077
3244
|
});
|
|
3078
3245
|
program.command("slurm-test").description("Run the provider-neutral Slurm conformance workload").option("--timeout <seconds>", "maximum time to wait for all tasks", "1800").option("--poll-interval <seconds>", "status polling interval", "5").action(slurmTest);
|