@blaxel/core 0.2.4-dev.73 → 0.2.4-dev2
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/batches.d.ts +32 -0
- package/dist/jobs/batches.js +40 -0
- package/dist/jobs/job.d.ts +33 -0
- package/dist/jobs/job.js +51 -0
- package/dist/jobs/jobs.d.ts +3 -2
- package/dist/jobs/jobs.js +3 -1
- package/dist/jobs/start.d.ts +1 -1
- package/dist/jobs/start.js +7 -31
- package/dist/telemetry/telemetry.d.ts +1 -4
- package/dist/telemetry/telemetry.js +2 -9
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare class BlBatch {
|
|
2
|
+
/**
|
|
3
|
+
* Lists all remote batch jobs for a given name
|
|
4
|
+
* @param name - The name of the job to list
|
|
5
|
+
*/
|
|
6
|
+
list(name: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new remote batch job configuration.
|
|
9
|
+
* This is used for remote execution management, not for local execution.
|
|
10
|
+
* @param name - The name of the job
|
|
11
|
+
* @param args - Array of argument arrays for each job in the batch
|
|
12
|
+
* @returns The batch configuration object
|
|
13
|
+
*/
|
|
14
|
+
create(name: string, args: any[][]): {
|
|
15
|
+
name: string;
|
|
16
|
+
args: any[][];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Kills a remote batch job
|
|
20
|
+
* @param name - The name of the job
|
|
21
|
+
* @param batchId - The ID of the batch to kill
|
|
22
|
+
*/
|
|
23
|
+
kill(name: string, batchId: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Retrieves information about a remote batch job
|
|
26
|
+
* @param name - The name of the job
|
|
27
|
+
* @param batchId - The ID of the batch to get information for
|
|
28
|
+
*/
|
|
29
|
+
get(name: string, batchId: string): void;
|
|
30
|
+
}
|
|
31
|
+
export declare const blBatch: BlBatch;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.blBatch = void 0;
|
|
4
|
+
class BlBatch {
|
|
5
|
+
/**
|
|
6
|
+
* Lists all remote batch jobs for a given name
|
|
7
|
+
* @param name - The name of the job to list
|
|
8
|
+
*/
|
|
9
|
+
list(name) {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new remote batch job configuration.
|
|
13
|
+
* This is used for remote execution management, not for local execution.
|
|
14
|
+
* @param name - The name of the job
|
|
15
|
+
* @param args - Array of argument arrays for each job in the batch
|
|
16
|
+
* @returns The batch configuration object
|
|
17
|
+
*/
|
|
18
|
+
create(name, args) {
|
|
19
|
+
const batch = {
|
|
20
|
+
name,
|
|
21
|
+
args,
|
|
22
|
+
};
|
|
23
|
+
return batch;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Kills a remote batch job
|
|
27
|
+
* @param name - The name of the job
|
|
28
|
+
* @param batchId - The ID of the batch to kill
|
|
29
|
+
*/
|
|
30
|
+
kill(name, batchId) {
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves information about a remote batch job
|
|
34
|
+
* @param name - The name of the job
|
|
35
|
+
* @param batchId - The ID of the batch to get information for
|
|
36
|
+
*/
|
|
37
|
+
get(name, batchId) {
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.blBatch = new BlBatch();
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare class BlJob {
|
|
2
|
+
start(func: (...args: any[]) => Promise<void>): void;
|
|
3
|
+
/**
|
|
4
|
+
* Lists all remote batch jobs for a given name
|
|
5
|
+
* @param name - The name of the job to list
|
|
6
|
+
*/
|
|
7
|
+
list(name: string): void;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new remote batch job configuration.
|
|
10
|
+
* This is used for remote execution management, not for local execution.
|
|
11
|
+
* @param name - The name of the job
|
|
12
|
+
* @param args - Array of argument arrays for each job in the batch
|
|
13
|
+
* @returns The batch configuration object
|
|
14
|
+
*/
|
|
15
|
+
create(name: string, args: any[][]): {
|
|
16
|
+
name: string;
|
|
17
|
+
args: any[][];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Kills a remote batch job
|
|
21
|
+
* @param name - The name of the job
|
|
22
|
+
* @param batchId - The ID of the batch to kill
|
|
23
|
+
*/
|
|
24
|
+
kill(name: string, batchId: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves information about a remote batch job
|
|
27
|
+
* @param name - The name of the job
|
|
28
|
+
* @param batchId - The ID of the batch to get information for
|
|
29
|
+
*/
|
|
30
|
+
get(name: string, batchId: string): void;
|
|
31
|
+
}
|
|
32
|
+
export declare const blJob: BlJob;
|
|
33
|
+
export {};
|
package/dist/jobs/job.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.blJob = void 0;
|
|
4
|
+
function retrieveArguments() {
|
|
5
|
+
const args = process.argv.slice(2);
|
|
6
|
+
return args;
|
|
7
|
+
}
|
|
8
|
+
class BlJob {
|
|
9
|
+
/*
|
|
10
|
+
Run a job defined in a function, it's run in the current process
|
|
11
|
+
*/
|
|
12
|
+
start(func) {
|
|
13
|
+
const args = retrieveArguments();
|
|
14
|
+
func(...args);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Lists all remote batch jobs for a given name
|
|
18
|
+
* @param name - The name of the job to list
|
|
19
|
+
*/
|
|
20
|
+
list(name) {
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new remote batch job configuration.
|
|
24
|
+
* This is used for remote execution management, not for local execution.
|
|
25
|
+
* @param name - The name of the job
|
|
26
|
+
* @param args - Array of argument arrays for each job in the batch
|
|
27
|
+
* @returns The batch configuration object
|
|
28
|
+
*/
|
|
29
|
+
create(name, args) {
|
|
30
|
+
const batch = {
|
|
31
|
+
name,
|
|
32
|
+
args,
|
|
33
|
+
};
|
|
34
|
+
return batch;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Kills a remote batch job
|
|
38
|
+
* @param name - The name of the job
|
|
39
|
+
* @param batchId - The ID of the batch to kill
|
|
40
|
+
*/
|
|
41
|
+
kill(name, batchId) {
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves information about a remote batch job
|
|
45
|
+
* @param name - The name of the job
|
|
46
|
+
* @param batchId - The ID of the batch to get information for
|
|
47
|
+
*/
|
|
48
|
+
get(name, batchId) {
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.blJob = new BlJob();
|
package/dist/jobs/jobs.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ExecutionArgs } from "./types.js";
|
|
1
2
|
declare class BlJob {
|
|
2
3
|
jobName: string;
|
|
3
4
|
constructor(jobName: string);
|
|
@@ -6,8 +7,8 @@ declare class BlJob {
|
|
|
6
7
|
get internalUrl(): import("url").URL;
|
|
7
8
|
get forcedUrl(): import("url").URL | null;
|
|
8
9
|
get url(): import("url").URL;
|
|
9
|
-
call(url: URL, tasks:
|
|
10
|
-
run(tasks:
|
|
10
|
+
call(url: URL, tasks: ExecutionArgs): Promise<Response>;
|
|
11
|
+
run(tasks: ExecutionArgs): Promise<string>;
|
|
11
12
|
}
|
|
12
13
|
export declare const blJob: (jobName: string) => BlJob;
|
|
13
14
|
export {};
|
package/dist/jobs/jobs.js
CHANGED
|
@@ -42,7 +42,7 @@ class BlJob {
|
|
|
42
42
|
let body = {
|
|
43
43
|
tasks: tasks
|
|
44
44
|
};
|
|
45
|
-
const response = await fetch(url + "/
|
|
45
|
+
const response = await fetch(url + "/execute", {
|
|
46
46
|
method: "POST",
|
|
47
47
|
headers: {
|
|
48
48
|
...settings_js_1.settings.headers,
|
|
@@ -63,6 +63,7 @@ class BlJob {
|
|
|
63
63
|
});
|
|
64
64
|
try {
|
|
65
65
|
const response = await this.call(this.url, tasks);
|
|
66
|
+
span.setAttribute("job.run.result", await response.text());
|
|
66
67
|
return await response.text();
|
|
67
68
|
}
|
|
68
69
|
catch (err) {
|
|
@@ -73,6 +74,7 @@ class BlJob {
|
|
|
73
74
|
}
|
|
74
75
|
try {
|
|
75
76
|
const response = await this.call(this.fallbackUrl, tasks);
|
|
77
|
+
span.setAttribute("job.run.result", await response.text());
|
|
76
78
|
return await response.text();
|
|
77
79
|
}
|
|
78
80
|
catch (err) {
|
package/dist/jobs/start.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const startJob: (func: (args: any) => Promise<void>) => void;
|
package/dist/jobs/start.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const autoload_js_1 = require("../common/autoload.js");
|
|
3
|
+
exports.startJob = void 0;
|
|
5
4
|
const env_js_1 = require("../common/env.js");
|
|
6
|
-
const telemetry_js_1 = require("../telemetry/telemetry.js");
|
|
7
5
|
class BlJobWrapper {
|
|
8
6
|
async getArguments() {
|
|
9
7
|
if (!env_js_1.env.BL_EXECUTION_DATA_URL) {
|
|
@@ -43,41 +41,19 @@ class BlJobWrapper {
|
|
|
43
41
|
Run a job defined in a function, it's run in the current process
|
|
44
42
|
*/
|
|
45
43
|
async start(func) {
|
|
46
|
-
await (0, autoload_js_1.authenticate)();
|
|
47
|
-
let span = (0, telemetry_js_1.startSpan)(`blStartJob-${func.name}`, {
|
|
48
|
-
attributes: {
|
|
49
|
-
'job.name': func.name,
|
|
50
|
-
'job.index': this.index,
|
|
51
|
-
'job.args': JSON.stringify(this.getArguments()),
|
|
52
|
-
},
|
|
53
|
-
isRoot: true,
|
|
54
|
-
});
|
|
55
44
|
try {
|
|
56
45
|
const parsedArgs = await this.getArguments();
|
|
57
46
|
await func(parsedArgs);
|
|
58
|
-
|
|
59
|
-
span.end();
|
|
47
|
+
process.exit(0);
|
|
60
48
|
}
|
|
61
49
|
catch (error) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
span.end();
|
|
65
|
-
throw error;
|
|
50
|
+
console.error('Job execution failed:', error);
|
|
51
|
+
process.exit(1);
|
|
66
52
|
}
|
|
67
53
|
}
|
|
68
54
|
}
|
|
69
|
-
const
|
|
55
|
+
const startJob = (func) => {
|
|
70
56
|
const job = new BlJobWrapper();
|
|
71
|
-
job.start(func)
|
|
72
|
-
try {
|
|
73
|
-
await (0, telemetry_js_1.flush)();
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
console.error('Error flushing telemetry:', error);
|
|
77
|
-
}
|
|
78
|
-
}).catch((error) => {
|
|
79
|
-
console.error('Job execution failed:', error);
|
|
80
|
-
process.exit(1);
|
|
81
|
-
});
|
|
57
|
+
job.start(func);
|
|
82
58
|
};
|
|
83
|
-
exports.
|
|
59
|
+
exports.startJob = startJob;
|
|
@@ -32,8 +32,6 @@ export interface BlaxelSpan {
|
|
|
32
32
|
export interface BlaxelTelemetryProvider {
|
|
33
33
|
/** Create a new span */
|
|
34
34
|
startSpan(name: string, options?: BlaxelSpanOptions): BlaxelSpan;
|
|
35
|
-
/** Flush the telemetry provider */
|
|
36
|
-
flush(): Promise<void>;
|
|
37
35
|
}
|
|
38
36
|
/**
|
|
39
37
|
* Registry for managing the global telemetry provider
|
|
@@ -57,6 +55,5 @@ export declare const telemetryRegistry: TelemetryRegistry;
|
|
|
57
55
|
* Create a span with the registered provider
|
|
58
56
|
*/
|
|
59
57
|
export declare function startSpan(name: string, options?: BlaxelSpanOptions): BlaxelSpan;
|
|
60
|
-
export declare function withSpan<T>(name: string, fn: () =>
|
|
61
|
-
export declare function flush(): Promise<void>;
|
|
58
|
+
export declare function withSpan<T>(name: string, fn: () => T, options?: BlaxelSpanOptions): T;
|
|
62
59
|
export {};
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.telemetryRegistry = void 0;
|
|
5
5
|
exports.startSpan = startSpan;
|
|
6
6
|
exports.withSpan = withSpan;
|
|
7
|
-
exports.flush = flush;
|
|
8
7
|
/**
|
|
9
8
|
* No-operation implementation of Span
|
|
10
9
|
*/
|
|
@@ -23,9 +22,6 @@ class NoopTelemetryProvider {
|
|
|
23
22
|
startSpan() {
|
|
24
23
|
return new NoopSpan();
|
|
25
24
|
}
|
|
26
|
-
flush() {
|
|
27
|
-
return Promise.resolve();
|
|
28
|
-
}
|
|
29
25
|
}
|
|
30
26
|
/**
|
|
31
27
|
* Registry for managing the global telemetry provider
|
|
@@ -62,10 +58,10 @@ exports.telemetryRegistry = TelemetryRegistry.getInstance();
|
|
|
62
58
|
function startSpan(name, options) {
|
|
63
59
|
return exports.telemetryRegistry.getProvider().startSpan(name, options);
|
|
64
60
|
}
|
|
65
|
-
|
|
61
|
+
function withSpan(name, fn, options) {
|
|
66
62
|
const span = startSpan(name, options);
|
|
67
63
|
try {
|
|
68
|
-
const result =
|
|
64
|
+
const result = fn();
|
|
69
65
|
span.end();
|
|
70
66
|
return result;
|
|
71
67
|
}
|
|
@@ -75,6 +71,3 @@ async function withSpan(name, fn, options) {
|
|
|
75
71
|
throw error;
|
|
76
72
|
}
|
|
77
73
|
}
|
|
78
|
-
async function flush() {
|
|
79
|
-
await exports.telemetryRegistry.getProvider().flush();
|
|
80
|
-
}
|