@milaboratories/pl-drivers 1.5.12 → 1.5.13
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/drivers/logs.d.ts +6 -0
- package/dist/drivers/logs.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1615 -1589
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/drivers/logs.test.ts +5 -2
- package/src/drivers/logs.ts +43 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-drivers",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.13",
|
|
4
4
|
"description": "Drivers and a low-level clients for log streaming, downloading and uploading files from and to pl",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@milaboratories/computable": "^2.3.4",
|
|
32
32
|
"@milaboratories/pl-client": "^2.7.3",
|
|
33
33
|
"@milaboratories/pl-tree": "^1.4.22",
|
|
34
|
-
"@milaboratories/pl-model-common": "^1.10.
|
|
34
|
+
"@milaboratories/pl-model-common": "^1.10.5"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"eslint": "^9.16.0",
|
package/src/drivers/logs.test.ts
CHANGED
|
@@ -97,7 +97,7 @@ test('should get last line with a prefix', async () => {
|
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
return logs.
|
|
100
|
+
return logs.getProgressLogWithInfo(streamManager, 'PREFIX', ctx);
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
expect(await c.getValue()).toBeUndefined();
|
|
@@ -113,7 +113,10 @@ test('should get last line with a prefix', async () => {
|
|
|
113
113
|
|
|
114
114
|
logger.info(`got result: ${JSON.stringify(result)}`);
|
|
115
115
|
if (result.stable) {
|
|
116
|
-
expect(result.value).
|
|
116
|
+
expect(result.value).toMatchObject({
|
|
117
|
+
progressLine: 'PREFIX4\n',
|
|
118
|
+
live: false,
|
|
119
|
+
});
|
|
117
120
|
return;
|
|
118
121
|
}
|
|
119
122
|
}
|
package/src/drivers/logs.ts
CHANGED
|
@@ -75,6 +75,49 @@ export class LogsDriver implements sdk.LogsDriver {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/** Same as getProgressLog but also returns a liveliness of the log.
|
|
79
|
+
* The previous getProgressLog couldn't be extended.
|
|
80
|
+
* Returns a last line that has patternToSearch.
|
|
81
|
+
* Notifies when a new line appeared or EOF reached. */
|
|
82
|
+
getProgressLogWithInfo(res: PlTreeEntry, patternToSearch: string): Computable<sdk.ProgressLogWithInfo | undefined>;
|
|
83
|
+
getProgressLogWithInfo(res: PlTreeEntry, patternToSearch: string, ctx: ComputableCtx): sdk.ProgressLogWithInfo | undefined;
|
|
84
|
+
getProgressLogWithInfo(
|
|
85
|
+
res: PlTreeEntry,
|
|
86
|
+
patternToSearch: string,
|
|
87
|
+
ctx?: ComputableCtx,
|
|
88
|
+
): Computable<sdk.ProgressLogWithInfo | undefined> | sdk.ProgressLogWithInfo | undefined {
|
|
89
|
+
if (ctx === undefined)
|
|
90
|
+
return Computable.make((ctx) => this.getProgressLogWithInfo(res, patternToSearch, ctx));
|
|
91
|
+
|
|
92
|
+
const stream = streamManagerGetStream(ctx, res);
|
|
93
|
+
if (stream === undefined) {
|
|
94
|
+
ctx.markUnstable('no stream in stream manager');
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (isBlob(stream)) {
|
|
99
|
+
const log = this.downloadDriver.getProgressLog(stream, patternToSearch, ctx);
|
|
100
|
+
return {
|
|
101
|
+
progressLine: log,
|
|
102
|
+
live: false,
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
const log = this.logsStreamDriver.getProgressLog(stream, patternToSearch, ctx);
|
|
108
|
+
return {
|
|
109
|
+
progressLine: log,
|
|
110
|
+
live: true,
|
|
111
|
+
}
|
|
112
|
+
} catch (e: any) {
|
|
113
|
+
if (e.name == 'RpcError' && e.code == 'NOT_FOUND') {
|
|
114
|
+
ctx.markUnstable(`NOT_FOUND in logs stream driver while getting a progress log with info: ${e}`);
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
throw e;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
78
121
|
/** Returns an Id of a smart object, that can read logs directly from
|
|
79
122
|
* the platform. */
|
|
80
123
|
getLogHandle(res: ResourceInfo | PlTreeEntry): Computable<sdk.AnyLogHandle | undefined>;
|