@nosana/node 1.0.12-rc → 1.0.13-rc
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/package.json +1 -1
- package/dist/src/NodeManager/monitoring/log/NodeLog.d.ts +1 -0
- package/dist/src/NodeManager/monitoring/log/NodeLog.js +24 -0
- package/dist/src/NodeManager/monitoring/log/console/ConsoleLogger.d.ts +2 -0
- package/dist/src/NodeManager/monitoring/log/console/ConsoleLogger.js +16 -1
- package/dist/src/NodeManager/node/expiry/expiryHandler.d.ts +1 -1
- package/dist/src/NodeManager/node/expiry/expiryHandler.js +11 -2
- package/dist/src/NodeManager/utils/formatTime.d.ts +6 -0
- package/dist/src/NodeManager/utils/formatTime.js +20 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -56,6 +56,9 @@ class NodeLog {
|
|
|
56
56
|
log: '',
|
|
57
57
|
timestamp: Date.now(),
|
|
58
58
|
type: 'process',
|
|
59
|
+
payload: {
|
|
60
|
+
expiry: this.expiry
|
|
61
|
+
}
|
|
59
62
|
});
|
|
60
63
|
}
|
|
61
64
|
if (data.type === 'return') {
|
|
@@ -469,6 +472,21 @@ class NodeLog {
|
|
|
469
472
|
this.shared.expiry = data.result;
|
|
470
473
|
}
|
|
471
474
|
}
|
|
475
|
+
if (data.method === 'extendExpiryTime') {
|
|
476
|
+
if (data.type === 'call') {
|
|
477
|
+
this.expiry = data.arguments[0];
|
|
478
|
+
this.addLog({
|
|
479
|
+
method: `Job:ExpiryUpdated`,
|
|
480
|
+
job: this.job,
|
|
481
|
+
log: 'Job expiry time extended',
|
|
482
|
+
timestamp: Date.now(),
|
|
483
|
+
type: 'update',
|
|
484
|
+
payload: {
|
|
485
|
+
expiry: this.expiry
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
}
|
|
472
490
|
if (data.method === 'waitUntilExpired') {
|
|
473
491
|
if (data.type === 'call') {
|
|
474
492
|
if (this.shared.exposed) {
|
|
@@ -1082,6 +1100,12 @@ class NodeLog {
|
|
|
1082
1100
|
}
|
|
1083
1101
|
}
|
|
1084
1102
|
}
|
|
1103
|
+
if (data.method === 'register') {
|
|
1104
|
+
if (data.type === 'call') {
|
|
1105
|
+
const timeout = data.arguments[2].timeout;
|
|
1106
|
+
this.expiry = typeof timeout === 'number' ? timeout : Number(timeout);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1085
1109
|
if (data.method === 'claim') {
|
|
1086
1110
|
if (data.type === 'call') {
|
|
1087
1111
|
this.job = data.arguments[0];
|
|
@@ -12,6 +12,8 @@ export declare class ConsoleLogger implements LogObserver {
|
|
|
12
12
|
private benchmarking;
|
|
13
13
|
private taskManagerActive;
|
|
14
14
|
private running;
|
|
15
|
+
private expiry;
|
|
16
|
+
private taskManagerRunInterval;
|
|
15
17
|
spinner: Ora;
|
|
16
18
|
constructor(isNode?: boolean);
|
|
17
19
|
addObserver(): void;
|
|
@@ -3,6 +3,7 @@ import ora from 'ora';
|
|
|
3
3
|
import { MultiBar, Presets, SingleBar } from 'cli-progress';
|
|
4
4
|
import { log } from '../NodeLog.js';
|
|
5
5
|
import { convertFromBytes } from '../../../utils/convertFromBytes.js';
|
|
6
|
+
import { formatTime } from '../../../utils/formatTime.js';
|
|
6
7
|
export const consoleLogging = (() => {
|
|
7
8
|
let instance = null;
|
|
8
9
|
return () => {
|
|
@@ -64,6 +65,9 @@ export class ConsoleLogger {
|
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
66
67
|
if (isNode) {
|
|
68
|
+
if (log.method === 'Job:ExpiryUpdated') {
|
|
69
|
+
this.expiry = log.payload?.expiry;
|
|
70
|
+
}
|
|
67
71
|
// --- TaskManager quiet window ---
|
|
68
72
|
if (log.method === 'TaskManager.start' && log.type === 'process') {
|
|
69
73
|
// Stop anything currently animating
|
|
@@ -75,7 +79,18 @@ export class ConsoleLogger {
|
|
|
75
79
|
this.multiProgressBar.stop();
|
|
76
80
|
this.taskManagerActive = true;
|
|
77
81
|
this.pending = true;
|
|
78
|
-
this.
|
|
82
|
+
this.expiry = log.payload?.expiry;
|
|
83
|
+
const startTime = Date.now();
|
|
84
|
+
this.spinner = ora(chalk.magenta(`${chalk.bgMagenta.bold(' TASKMANAGER ')} ${chalk.bgGreen.bold(' Duration: 0s ')} ${chalk.bgCyan.bold(` Max Duration: ${formatTime(this.expiry ?? 0)} `)}`)).start();
|
|
85
|
+
this.taskManagerRunInterval = setInterval(() => {
|
|
86
|
+
if (this.taskManagerActive) {
|
|
87
|
+
const duration = (Date.now() - startTime) / 1000;
|
|
88
|
+
this.spinner.text = chalk.magenta(`${chalk.bgMagenta.bold(' TASKMANAGER ')} ${chalk.bgGreen.bold(` Duration: ${formatTime(duration)} `)} ${chalk.bgCyan.bold(` Max Duration: ${formatTime((this.expiry ?? 0))} `)}`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
clearInterval(this.taskManagerRunInterval);
|
|
92
|
+
}
|
|
93
|
+
}, 5000);
|
|
79
94
|
// Block everything else until we see TaskManager.stop
|
|
80
95
|
return;
|
|
81
96
|
}
|
|
@@ -17,7 +17,7 @@ export declare class ExpiryHandler {
|
|
|
17
17
|
start(): void;
|
|
18
18
|
stop(): void;
|
|
19
19
|
private startOrResetTimer;
|
|
20
|
-
extendExpiryTime(additionalTimeMs: number): void;
|
|
20
|
+
extendExpiryTime(additionalTimeMs: number, timeout: number): void;
|
|
21
21
|
expired(run: Run, job: Job): boolean;
|
|
22
22
|
waitUntilExpired(): Promise<void>;
|
|
23
23
|
private shortenedExpiry;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import BN from 'bn.js';
|
|
2
2
|
import ApiEventEmitter from '../api/ApiEventEmitter.js';
|
|
3
|
+
import { logEmitter } from '../../monitoring/proxy/loggingProxy.js';
|
|
3
4
|
export class ExpiryHandler {
|
|
4
5
|
constructor(sdk) {
|
|
5
6
|
this.sdk = sdk;
|
|
@@ -33,7 +34,7 @@ export class ExpiryHandler {
|
|
|
33
34
|
.mul(new BN(1000))
|
|
34
35
|
.toNumber();
|
|
35
36
|
if (newExpiryTime != this.expiryEndTime) {
|
|
36
|
-
this.extendExpiryTime(newExpiryTime - this.expiryEndTime);
|
|
37
|
+
this.extendExpiryTime(newExpiryTime - this.expiryEndTime, timeout);
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
40
|
this.onExpireCallback = onExpireCallback;
|
|
@@ -75,7 +76,15 @@ export class ExpiryHandler {
|
|
|
75
76
|
}
|
|
76
77
|
}, remainingTime);
|
|
77
78
|
}
|
|
78
|
-
extendExpiryTime(additionalTimeMs) {
|
|
79
|
+
extendExpiryTime(additionalTimeMs, timeout) {
|
|
80
|
+
// Manually emit log event since internal calls bypass the proxy
|
|
81
|
+
logEmitter.emit('log', {
|
|
82
|
+
class: 'ExpiryHandler',
|
|
83
|
+
method: 'extendExpiryTime',
|
|
84
|
+
arguments: [timeout],
|
|
85
|
+
timestamp: new Date().toISOString(),
|
|
86
|
+
type: 'call',
|
|
87
|
+
});
|
|
79
88
|
this.expiryEndTime += additionalTimeMs;
|
|
80
89
|
this.startOrResetTimer();
|
|
81
90
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts seconds into a formatted time string (e.g., "1h 23m 45s", "5m 30s", "45s")
|
|
3
|
+
* @param seconds - The number of seconds to format
|
|
4
|
+
* @returns Formatted time string with hours, minutes, and/or seconds
|
|
5
|
+
*/
|
|
6
|
+
export declare function formatTime(seconds: number): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts seconds into a formatted time string (e.g., "1h 23m 45s", "5m 30s", "45s")
|
|
3
|
+
* @param seconds - The number of seconds to format
|
|
4
|
+
* @returns Formatted time string with hours, minutes, and/or seconds
|
|
5
|
+
*/
|
|
6
|
+
export function formatTime(seconds) {
|
|
7
|
+
const totalSeconds = Math.floor(seconds);
|
|
8
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
9
|
+
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
10
|
+
const secs = totalSeconds % 60;
|
|
11
|
+
const parts = [];
|
|
12
|
+
if (hours > 0) {
|
|
13
|
+
parts.push(`${hours}h`);
|
|
14
|
+
}
|
|
15
|
+
if (minutes > 0 || hours > 0) {
|
|
16
|
+
parts.push(`${minutes}m`);
|
|
17
|
+
}
|
|
18
|
+
parts.push(`${secs}s`);
|
|
19
|
+
return parts.join(' ');
|
|
20
|
+
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nosana/node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13-rc",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@nosana/node",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.13-rc",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@coral-xyz/anchor": "^0.28.1-beta.1",
|