@llmindset/hf-mcp 0.2.35 → 0.2.36
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/jobs/commands/run.d.ts.map +1 -1
- package/dist/jobs/commands/run.js +3 -24
- package/dist/jobs/commands/run.js.map +1 -1
- package/dist/jobs/commands/scheduled.d.ts.map +1 -1
- package/dist/jobs/commands/scheduled.js +3 -20
- package/dist/jobs/commands/scheduled.js.map +1 -1
- package/dist/jobs/commands/uv-utils.d.ts +7 -0
- package/dist/jobs/commands/uv-utils.d.ts.map +1 -0
- package/dist/jobs/commands/uv-utils.js +23 -0
- package/dist/jobs/commands/uv-utils.js.map +1 -0
- package/package.json +1 -1
- package/src/jobs/commands/run.ts +3 -39
- package/src/jobs/commands/scheduled.ts +3 -33
- package/src/jobs/commands/uv-utils.ts +33 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/jobs/commands/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/jobs/commands/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAStD,wBAAsB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiDtG;AAMD,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiCpG"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createJobSpec } from './utils.js';
|
|
2
2
|
import { fetchJobLogs } from '../sse-handler.js';
|
|
3
|
+
import { buildUvCommand, UV_DEFAULT_IMAGE, wrapInlineScript } from './uv-utils.js';
|
|
3
4
|
export async function runCommand(args, client, token) {
|
|
4
5
|
const jobSpec = createJobSpec({
|
|
5
6
|
image: args.image,
|
|
@@ -40,20 +41,14 @@ To inspect: \`hf_jobs("inspect", {"job_id": "${job.id}"})\``;
|
|
|
40
41
|
return response;
|
|
41
42
|
}
|
|
42
43
|
export async function uvCommand(args, client, token) {
|
|
43
|
-
const image =
|
|
44
|
+
const image = UV_DEFAULT_IMAGE;
|
|
44
45
|
const scriptSource = args.script;
|
|
45
46
|
let command;
|
|
46
47
|
if (scriptSource.startsWith('http://') || scriptSource.startsWith('https://')) {
|
|
47
48
|
command = buildUvCommand(scriptSource, args);
|
|
48
49
|
}
|
|
49
50
|
else if (scriptSource.includes('\n')) {
|
|
50
|
-
const
|
|
51
|
-
const depsPart = args.with_deps && args.with_deps.length > 0
|
|
52
|
-
? args.with_deps.map(dep => `--with ${dep}`).join(' ')
|
|
53
|
-
: '';
|
|
54
|
-
const pythonPart = args.python ? `-p ${args.python}` : '';
|
|
55
|
-
const uvArgs = [depsPart, pythonPart].filter(Boolean).join(' ');
|
|
56
|
-
const shellSnippet = `echo "${encoded}" | base64 -d | uv run${uvArgs ? ` ${uvArgs}` : ''} -`;
|
|
51
|
+
const shellSnippet = wrapInlineScript(scriptSource, args);
|
|
57
52
|
command = ['/bin/sh', '-lc', shellSnippet];
|
|
58
53
|
}
|
|
59
54
|
else {
|
|
@@ -71,20 +66,4 @@ export async function uvCommand(args, client, token) {
|
|
|
71
66
|
};
|
|
72
67
|
return runCommand(runArgs, client, token);
|
|
73
68
|
}
|
|
74
|
-
function buildUvCommand(script, args) {
|
|
75
|
-
const parts = ['uv', 'run'];
|
|
76
|
-
if (args.with_deps && args.with_deps.length > 0) {
|
|
77
|
-
for (const dep of args.with_deps) {
|
|
78
|
-
parts.push('--with', dep);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (args.python) {
|
|
82
|
-
parts.push('-p', args.python);
|
|
83
|
-
}
|
|
84
|
-
parts.push(script);
|
|
85
|
-
if (args.script_args && args.script_args.length > 0) {
|
|
86
|
-
parts.push(...args.script_args);
|
|
87
|
-
}
|
|
88
|
-
return parts.join(' ');
|
|
89
|
-
}
|
|
90
69
|
//# sourceMappingURL=run.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/jobs/commands/run.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/jobs/commands/run.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAMnF,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAa,EAAE,MAAqB,EAAE,KAAc;IAEpF,MAAM,OAAO,GAAG,aAAa,CAAC;QAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,OAAO,EAAE,KAAK;KACd,CAAC,CAAC;IAGH,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,IA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,gBAAgB,CAAC;IAG/B,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,IAAI,OAA0B,CAAC;IAE/B,IAAI,YAAY,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,YAAY,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAE/E,OAAO,GAAG,cAAc,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;SAAM,IAAI,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAExC,MAAM,YAAY,GAAG,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAC1D,OAAO,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IAC5C,CAAC;SAAM,CAAC;QAEP,OAAO,GAAG,cAAc,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IAGD,MAAM,OAAO,GAAY;QACxB,KAAK;QACL,OAAO;QACP,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,SAAS,EAAE,IAAI,CAAC,SAAS;KACzB,CAAC;IAEF,OAAO,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduled.d.ts","sourceRoot":"","sources":["../../../src/jobs/commands/scheduled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"scheduled.d.ts","sourceRoot":"","sources":["../../../src/jobs/commands/scheduled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAStD,wBAAsB,mBAAmB,CACxC,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,aAAa,EACrB,KAAK,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC,CA+BjB;AAMD,wBAAsB,kBAAkB,CACvC,IAAI,EAAE,eAAe,EACrB,MAAM,EAAE,aAAa,EACrB,KAAK,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC,CA+BjB;AAMD,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBtG;AAMD,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAI5G;AAMD,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAI3G;AAMD,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAM5G;AAMD,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAM3G"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { formatScheduledJobsTable, formatScheduledJobDetails } from '../formatters.js';
|
|
2
2
|
import { createJobSpec } from './utils.js';
|
|
3
|
+
import { buildUvCommand, UV_DEFAULT_IMAGE, wrapInlineScript } from './uv-utils.js';
|
|
3
4
|
export async function scheduledRunCommand(args, client, token) {
|
|
4
5
|
const jobSpec = createJobSpec({
|
|
5
6
|
image: args.image,
|
|
@@ -27,16 +28,14 @@ To inspect: \`hf_jobs("scheduled inspect", {"scheduled_job_id": "${scheduledJob.
|
|
|
27
28
|
To list all: \`hf_jobs("scheduled ps")\``;
|
|
28
29
|
}
|
|
29
30
|
export async function scheduledUvCommand(args, client, token) {
|
|
30
|
-
const image =
|
|
31
|
+
const image = UV_DEFAULT_IMAGE;
|
|
31
32
|
const scriptSource = args.script;
|
|
32
33
|
let command;
|
|
33
34
|
if (scriptSource.startsWith('http://') || scriptSource.startsWith('https://')) {
|
|
34
35
|
command = buildUvCommand(scriptSource, args);
|
|
35
36
|
}
|
|
36
37
|
else if (scriptSource.includes('\n')) {
|
|
37
|
-
|
|
38
|
-
const deps = args.with_deps && args.with_deps.length > 0 ? args.with_deps.map((dep) => `--with ${dep}`).join(' ') + ' ' : '';
|
|
39
|
-
command = `echo "${encoded}" | base64 -d | uv run ${deps}${args.python ? `-p ${args.python}` : ''} -`;
|
|
38
|
+
command = wrapInlineScript(scriptSource, args);
|
|
40
39
|
}
|
|
41
40
|
else {
|
|
42
41
|
command = buildUvCommand(scriptSource, args);
|
|
@@ -55,22 +54,6 @@ export async function scheduledUvCommand(args, client, token) {
|
|
|
55
54
|
};
|
|
56
55
|
return scheduledRunCommand(scheduledRunArgs, client, token);
|
|
57
56
|
}
|
|
58
|
-
function buildUvCommand(script, args) {
|
|
59
|
-
const parts = ['uv', 'run'];
|
|
60
|
-
if (args.with_deps && args.with_deps.length > 0) {
|
|
61
|
-
for (const dep of args.with_deps) {
|
|
62
|
-
parts.push('--with', dep);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (args.python) {
|
|
66
|
-
parts.push('-p', args.python);
|
|
67
|
-
}
|
|
68
|
-
parts.push(script);
|
|
69
|
-
if (args.script_args && args.script_args.length > 0) {
|
|
70
|
-
parts.push(...args.script_args);
|
|
71
|
-
}
|
|
72
|
-
return parts.join(' ');
|
|
73
|
-
}
|
|
74
57
|
export async function scheduledPsCommand(args, client) {
|
|
75
58
|
const allJobs = await client.listScheduledJobs(args.namespace);
|
|
76
59
|
let jobs = allJobs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduled.js","sourceRoot":"","sources":["../../../src/jobs/commands/scheduled.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"scheduled.js","sourceRoot":"","sources":["../../../src/jobs/commands/scheduled.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAMnF,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,IAAsB,EACtB,MAAqB,EACrB,KAAc;IAGd,MAAM,OAAO,GAAG,aAAa,CAAC;QAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,OAAO,EAAE,KAAK;KACd,CAAC,CAAC;IAGH,MAAM,aAAa,GAAqB;QACvC,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,OAAO;KACP,CAAC;IAGF,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAEpF,OAAO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AC,KAAK,UAAU,uBAAuB,CAAC,IAAsB,EAAE,MAAqB;IAC1F,MAAM,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAExE,OAAO,mBAAmB,IAAI,CAAC,gBAAgB;;iEAEiB,IAAI,CAAC,gBAAgB,OAAO,CAAC;AAC9F,CAAC;AAMD,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,IAAsB,EAAE,MAAqB;IACzF,MAAM,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAEvE,OAAO,mBAAmB,IAAI,CAAC,gBAAgB;;mEAEmB,IAAI,CAAC,gBAAgB,OAAO,CAAC;AAChG,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UvArgs } from '../types.js';
|
|
2
|
+
export declare const UV_DEFAULT_IMAGE = "ghcr.io/astral-sh/uv:python3.12-bookworm";
|
|
3
|
+
type UvCommandOptions = Pick<UvArgs, 'with_deps' | 'python' | 'script_args'>;
|
|
4
|
+
export declare function buildUvCommand(script: string, args: UvCommandOptions): string;
|
|
5
|
+
export declare function wrapInlineScript(script: string, args: UvCommandOptions): string;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=uv-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uv-utils.d.ts","sourceRoot":"","sources":["../../../src/jobs/commands/uv-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,eAAO,MAAM,gBAAgB,6CAA6C,CAAC;AAE3E,KAAK,gBAAgB,GAAG,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,aAAa,CAAC,CAAC;AAE7E,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAoB7E;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAI/E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const UV_DEFAULT_IMAGE = 'ghcr.io/astral-sh/uv:python3.12-bookworm';
|
|
2
|
+
export function buildUvCommand(script, args) {
|
|
3
|
+
const parts = ['uv', 'run'];
|
|
4
|
+
if (args.with_deps && args.with_deps.length > 0) {
|
|
5
|
+
for (const dep of args.with_deps) {
|
|
6
|
+
parts.push('--with', dep);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
if (args.python) {
|
|
10
|
+
parts.push('-p', args.python);
|
|
11
|
+
}
|
|
12
|
+
parts.push(script);
|
|
13
|
+
if (args.script_args && args.script_args.length > 0) {
|
|
14
|
+
parts.push(...args.script_args);
|
|
15
|
+
}
|
|
16
|
+
return parts.join(' ');
|
|
17
|
+
}
|
|
18
|
+
export function wrapInlineScript(script, args) {
|
|
19
|
+
const encoded = Buffer.from(script).toString('base64');
|
|
20
|
+
const baseCommand = buildUvCommand('-', args);
|
|
21
|
+
return `echo "${encoded}" | base64 -d | ${baseCommand}`;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=uv-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uv-utils.js","sourceRoot":"","sources":["../../../src/jobs/commands/uv-utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAG,0CAA0C,CAAC;AAI3E,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,IAAsB;IACpE,MAAM,KAAK,GAAa,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAEtC,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAClC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC3B,CAAC;IACF,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QACjB,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEnB,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrD,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAc,EAAE,IAAsB;IACtE,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvD,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC9C,OAAO,SAAS,OAAO,mBAAmB,WAAW,EAAE,CAAC;AACzD,CAAC"}
|
package/package.json
CHANGED
package/src/jobs/commands/run.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { RunArgs, UvArgs } from '../types.js';
|
|
|
2
2
|
import type { JobsApiClient } from '../api-client.js';
|
|
3
3
|
import { createJobSpec } from './utils.js';
|
|
4
4
|
import { fetchJobLogs } from '../sse-handler.js';
|
|
5
|
+
import { buildUvCommand, UV_DEFAULT_IMAGE, wrapInlineScript } from './uv-utils.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Execute the 'run' command
|
|
@@ -64,26 +65,18 @@ To inspect: \`hf_jobs("inspect", {"job_id": "${job.id}"})\``;
|
|
|
64
65
|
*/
|
|
65
66
|
export async function uvCommand(args: UvArgs, client: JobsApiClient, token?: string): Promise<string> {
|
|
66
67
|
// UV jobs use a standard UV image unless overridden
|
|
67
|
-
const image =
|
|
68
|
+
const image = UV_DEFAULT_IMAGE;
|
|
68
69
|
|
|
69
70
|
// Detect script source and build command
|
|
70
71
|
const scriptSource = args.script;
|
|
71
72
|
let command: string | string[];
|
|
72
73
|
|
|
73
|
-
// Check if script is a URL
|
|
74
74
|
if (scriptSource.startsWith('http://') || scriptSource.startsWith('https://')) {
|
|
75
75
|
// URL - download and run
|
|
76
76
|
command = buildUvCommand(scriptSource, args);
|
|
77
77
|
} else if (scriptSource.includes('\n')) {
|
|
78
78
|
// Inline multi-line script - encode it
|
|
79
|
-
const
|
|
80
|
-
const depsPart =
|
|
81
|
-
args.with_deps && args.with_deps.length > 0
|
|
82
|
-
? args.with_deps.map(dep => `--with ${dep}`).join(' ')
|
|
83
|
-
: '';
|
|
84
|
-
const pythonPart = args.python ? `-p ${args.python}` : '';
|
|
85
|
-
const uvArgs = [depsPart, pythonPart].filter(Boolean).join(' ');
|
|
86
|
-
const shellSnippet = `echo "${encoded}" | base64 -d | uv run${uvArgs ? ` ${uvArgs}` : ''} -`;
|
|
79
|
+
const shellSnippet = wrapInlineScript(scriptSource, args);
|
|
87
80
|
command = ['/bin/sh', '-lc', shellSnippet];
|
|
88
81
|
} else {
|
|
89
82
|
// Assume it's a URL or path - UV will handle it
|
|
@@ -104,32 +97,3 @@ export async function uvCommand(args: UvArgs, client: JobsApiClient, token?: str
|
|
|
104
97
|
|
|
105
98
|
return runCommand(runArgs, client, token);
|
|
106
99
|
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Build UV command with options
|
|
110
|
-
*/
|
|
111
|
-
function buildUvCommand(script: string, args: UvArgs): string {
|
|
112
|
-
const parts: string[] = ['uv', 'run'];
|
|
113
|
-
|
|
114
|
-
// Add dependencies
|
|
115
|
-
if (args.with_deps && args.with_deps.length > 0) {
|
|
116
|
-
for (const dep of args.with_deps) {
|
|
117
|
-
parts.push('--with', dep);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Add Python version
|
|
122
|
-
if (args.python) {
|
|
123
|
-
parts.push('-p', args.python);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Add script
|
|
127
|
-
parts.push(script);
|
|
128
|
-
|
|
129
|
-
// Add script arguments
|
|
130
|
-
if (args.script_args && args.script_args.length > 0) {
|
|
131
|
-
parts.push(...args.script_args);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return parts.join(' ');
|
|
135
|
-
}
|
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
import type { JobsApiClient } from '../api-client.js';
|
|
9
9
|
import { formatScheduledJobsTable, formatScheduledJobDetails } from '../formatters.js';
|
|
10
10
|
import { createJobSpec } from './utils.js';
|
|
11
|
+
import { buildUvCommand, UV_DEFAULT_IMAGE, wrapInlineScript } from './uv-utils.js';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Execute 'scheduled run' command
|
|
@@ -60,7 +61,7 @@ export async function scheduledUvCommand(
|
|
|
60
61
|
token?: string
|
|
61
62
|
): Promise<string> {
|
|
62
63
|
// For UV, use standard UV image
|
|
63
|
-
const image =
|
|
64
|
+
const image = UV_DEFAULT_IMAGE;
|
|
64
65
|
|
|
65
66
|
// Build UV command (similar to regular uv command)
|
|
66
67
|
const scriptSource = args.script;
|
|
@@ -69,10 +70,7 @@ export async function scheduledUvCommand(
|
|
|
69
70
|
if (scriptSource.startsWith('http://') || scriptSource.startsWith('https://')) {
|
|
70
71
|
command = buildUvCommand(scriptSource, args);
|
|
71
72
|
} else if (scriptSource.includes('\n')) {
|
|
72
|
-
|
|
73
|
-
const deps =
|
|
74
|
-
args.with_deps && args.with_deps.length > 0 ? args.with_deps.map((dep) => `--with ${dep}`).join(' ') + ' ' : '';
|
|
75
|
-
command = `echo "${encoded}" | base64 -d | uv run ${deps}${args.python ? `-p ${args.python}` : ''} -`;
|
|
73
|
+
command = wrapInlineScript(scriptSource, args);
|
|
76
74
|
} else {
|
|
77
75
|
command = buildUvCommand(scriptSource, args);
|
|
78
76
|
}
|
|
@@ -94,34 +92,6 @@ export async function scheduledUvCommand(
|
|
|
94
92
|
return scheduledRunCommand(scheduledRunArgs, client, token);
|
|
95
93
|
}
|
|
96
94
|
|
|
97
|
-
/**
|
|
98
|
-
* Build UV command with options
|
|
99
|
-
*/
|
|
100
|
-
function buildUvCommand(
|
|
101
|
-
script: string,
|
|
102
|
-
args: { with_deps?: string[]; python?: string; script_args?: string[] }
|
|
103
|
-
): string {
|
|
104
|
-
const parts: string[] = ['uv', 'run'];
|
|
105
|
-
|
|
106
|
-
if (args.with_deps && args.with_deps.length > 0) {
|
|
107
|
-
for (const dep of args.with_deps) {
|
|
108
|
-
parts.push('--with', dep);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (args.python) {
|
|
113
|
-
parts.push('-p', args.python);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
parts.push(script);
|
|
117
|
-
|
|
118
|
-
if (args.script_args && args.script_args.length > 0) {
|
|
119
|
-
parts.push(...args.script_args);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return parts.join(' ');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
95
|
/**
|
|
126
96
|
* Execute 'scheduled ps' command
|
|
127
97
|
* Lists scheduled jobs
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { UvArgs } from '../types.js';
|
|
2
|
+
|
|
3
|
+
export const UV_DEFAULT_IMAGE = 'ghcr.io/astral-sh/uv:python3.12-bookworm';
|
|
4
|
+
|
|
5
|
+
type UvCommandOptions = Pick<UvArgs, 'with_deps' | 'python' | 'script_args'>;
|
|
6
|
+
|
|
7
|
+
export function buildUvCommand(script: string, args: UvCommandOptions): string {
|
|
8
|
+
const parts: string[] = ['uv', 'run'];
|
|
9
|
+
|
|
10
|
+
if (args.with_deps && args.with_deps.length > 0) {
|
|
11
|
+
for (const dep of args.with_deps) {
|
|
12
|
+
parts.push('--with', dep);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (args.python) {
|
|
17
|
+
parts.push('-p', args.python);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
parts.push(script);
|
|
21
|
+
|
|
22
|
+
if (args.script_args && args.script_args.length > 0) {
|
|
23
|
+
parts.push(...args.script_args);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return parts.join(' ');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function wrapInlineScript(script: string, args: UvCommandOptions): string {
|
|
30
|
+
const encoded = Buffer.from(script).toString('base64');
|
|
31
|
+
const baseCommand = buildUvCommand('-', args);
|
|
32
|
+
return `echo "${encoded}" | base64 -d | ${baseCommand}`;
|
|
33
|
+
}
|