@milaboratories/pl-model-middle-layer 1.36.0 → 1.38.0
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/block_status.cjs +69 -0
- package/dist/block_status.cjs.map +1 -0
- package/dist/block_status.d.ts +118 -0
- package/dist/block_status.d.ts.map +1 -0
- package/dist/block_status.js +63 -0
- package/dist/block_status.js.map +1 -0
- package/dist/index.cjs +8 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/instance_stats.cjs +1 -1
- package/dist/instance_stats.cjs.map +1 -1
- package/dist/instance_stats.d.ts +4 -4
- package/dist/instance_stats.d.ts.map +1 -1
- package/dist/instance_stats.js +1 -1
- package/dist/instance_stats.js.map +1 -1
- package/package.json +2 -2
- package/src/block_status.ts +147 -0
- package/src/index.ts +1 -0
- package/src/instance_stats.ts +5 -5
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// src/block_status.ts
|
|
2
|
+
/**
|
|
3
|
+
* The status of a running block, as the middle layer hands it to the Desktop App.
|
|
4
|
+
*
|
|
5
|
+
* The backend keeps a tree of status contexts, one per render, and writes each reporter's
|
|
6
|
+
* transitions into the context of the render it belongs to. The middle layer folds that tree into
|
|
7
|
+
* a {@link BlockStatusSummary}.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* The node states this build knows, spelled as the backend and the workflow SDK write them into a
|
|
11
|
+
* transition value. The names match `plapi.ActionState` on the backend and `STATES` in
|
|
12
|
+
* workflow-tengo's action-context library.
|
|
13
|
+
*
|
|
14
|
+
* The backend owns the list: a reporter may write a state added after this release, and the middle
|
|
15
|
+
* layer passes it on as written. Only the lifecycle (`Completed`, `Terminated`, and `Running`
|
|
16
|
+
* reported by a command) carries meaning in the fold; the rest exists for the user.
|
|
17
|
+
*/
|
|
18
|
+
const blockStatusStatesRecord = {
|
|
19
|
+
WaitingForInputs: "WaitingForInputs",
|
|
20
|
+
Running: "Running",
|
|
21
|
+
WaitingWorkdirGate: "WaitingWorkdirGate",
|
|
22
|
+
WaitingSubmissionGate: "WaitingSubmissionGate",
|
|
23
|
+
PopulatingWorkdir: "PopulatingWorkdir",
|
|
24
|
+
CollectingOutputs: "CollectingOutputs",
|
|
25
|
+
WaitingForScheduler: "WaitingForScheduler",
|
|
26
|
+
WaitingForMachine: "WaitingForMachine",
|
|
27
|
+
Terminated: "Terminated",
|
|
28
|
+
Completed: "Completed"
|
|
29
|
+
};
|
|
30
|
+
/** Every state, in the order above. */
|
|
31
|
+
const blockStatusStates = Object.values(blockStatusStatesRecord);
|
|
32
|
+
/** True for a state a node cannot leave. */
|
|
33
|
+
function isTerminalBlockStatusState(state) {
|
|
34
|
+
return state === blockStatusStatesRecord.Terminated || state === blockStatusStatesRecord.Completed;
|
|
35
|
+
}
|
|
36
|
+
/** No jobs yet. */
|
|
37
|
+
const EmptyBlockStatusJobs = {
|
|
38
|
+
total: 0,
|
|
39
|
+
done: 0,
|
|
40
|
+
failed: 0,
|
|
41
|
+
byState: []
|
|
42
|
+
};
|
|
43
|
+
/** A summary for a block whose run has not reported anything yet. */
|
|
44
|
+
const EmptyBlockStatusSummary = {
|
|
45
|
+
availability: "read",
|
|
46
|
+
activeContexts: 0,
|
|
47
|
+
totalContexts: 0,
|
|
48
|
+
jobs: EmptyBlockStatusJobs,
|
|
49
|
+
done: false
|
|
50
|
+
};
|
|
51
|
+
/** A summary for a context that could not be read; its counters are unknown, not zero. */
|
|
52
|
+
const UnreadableBlockStatusSummary = {
|
|
53
|
+
...EmptyBlockStatusSummary,
|
|
54
|
+
availability: "unreadable"
|
|
55
|
+
};
|
|
56
|
+
/** A summary for a backend that does not accept status reports. */
|
|
57
|
+
const UnsupportedBlockStatusSummary = {
|
|
58
|
+
...EmptyBlockStatusSummary,
|
|
59
|
+
availability: "unsupported"
|
|
60
|
+
};
|
|
61
|
+
exports.EmptyBlockStatusJobs = EmptyBlockStatusJobs;
|
|
62
|
+
exports.EmptyBlockStatusSummary = EmptyBlockStatusSummary;
|
|
63
|
+
exports.UnreadableBlockStatusSummary = UnreadableBlockStatusSummary;
|
|
64
|
+
exports.UnsupportedBlockStatusSummary = UnsupportedBlockStatusSummary;
|
|
65
|
+
exports.blockStatusStates = blockStatusStates;
|
|
66
|
+
exports.blockStatusStatesRecord = blockStatusStatesRecord;
|
|
67
|
+
exports.isTerminalBlockStatusState = isTerminalBlockStatusState;
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=block_status.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block_status.cjs","names":[],"sources":["../src/block_status.ts"],"sourcesContent":["/**\n * The status of a running block, as the middle layer hands it to the Desktop App.\n *\n * The backend keeps a tree of status contexts, one per render, and writes each reporter's\n * transitions into the context of the render it belongs to. The middle layer folds that tree into\n * a {@link BlockStatusSummary}.\n */\n\n/**\n * The node states this build knows, spelled as the backend and the workflow SDK write them into a\n * transition value. The names match `plapi.ActionState` on the backend and `STATES` in\n * workflow-tengo's action-context library.\n *\n * The backend owns the list: a reporter may write a state added after this release, and the middle\n * layer passes it on as written. Only the lifecycle (`Completed`, `Terminated`, and `Running`\n * reported by a command) carries meaning in the fold; the rest exists for the user.\n */\nexport const blockStatusStatesRecord = {\n WaitingForInputs: \"WaitingForInputs\",\n Running: \"Running\",\n WaitingWorkdirGate: \"WaitingWorkdirGate\",\n WaitingSubmissionGate: \"WaitingSubmissionGate\",\n PopulatingWorkdir: \"PopulatingWorkdir\",\n CollectingOutputs: \"CollectingOutputs\",\n WaitingForScheduler: \"WaitingForScheduler\",\n WaitingForMachine: \"WaitingForMachine\",\n Terminated: \"Terminated\",\n Completed: \"Completed\",\n} as const;\n\n/** Every state, in the order above. */\nexport const blockStatusStates = Object.values(blockStatusStatesRecord);\n\n/** A node state name this build knows, e.g. `\"PopulatingWorkdir\"`. */\nexport type BlockStatusState = (typeof blockStatusStates)[number];\n\n/** True for a state a node cannot leave. */\nexport function isTerminalBlockStatusState(state: string): boolean {\n return (\n state === blockStatusStatesRecord.Terminated || state === blockStatusStatesRecord.Completed\n );\n}\n\n/** Jobs held by one state: the transition holding each of them has this namespace and state. */\nexport type BlockStatusJobGroup = {\n /** Who reported the state: `exec` for a command, `workdir` for its work folder, `render`. */\n readonly namespace: string;\n /** As the reporter wrote it, which can be a state this build does not know. */\n readonly state: string;\n readonly count: number;\n /** When the earliest of them entered the state, ms since the epoch. */\n readonly since?: number;\n /** Files done and all, summed over the jobs whose work folders report their progress. */\n readonly files?: { readonly done: number; readonly total: number };\n};\n\n/**\n * The block's jobs: the commands it runs on a machine, each counted once by where it is now.\n *\n * A job is a context that a command or its work folder reports in. Jobs the run has not created yet\n * are not counted, so `total` grows while the run fans out.\n */\nexport type BlockStatusJobs = {\n readonly total: number;\n readonly done: number;\n /**\n * Jobs that failed, and renders that failed on their own (not by passing up a failure under\n * them), e.g. one whose command could not start.\n */\n readonly failed: number;\n /** The jobs not ended, by the state holding each, largest group first. */\n readonly byState: readonly BlockStatusJobGroup[];\n};\n\n/** Why a summary carries no counters. */\nexport type BlockStatusAvailability =\n /** The tree was read and the run has reported what the summary holds. */\n | \"read\"\n /** The context could not be read: it is gone, or reading it raised. The counters are unknown,\n * which is not the same as a run that has reported nothing. */\n | \"unreadable\"\n /** The backend cannot take the `actionContext` link, so no context is created and nothing is\n * ever reported. */\n | \"unsupported\";\n\n/** The status of one block run, folded from its status-context tree. */\nexport type BlockStatusSummary = {\n /** Whether the counters below describe the run, or could not be read at all. */\n readonly availability: BlockStatusAvailability;\n /** The block's own `run-id`: two clicks of Run give two different values. */\n readonly runId?: string;\n /** Action contexts that have not ended. */\n readonly activeContexts: number;\n /** Every action context of the run, active or ended. */\n readonly totalContexts: number;\n /** The run's jobs, counted apart from the template renders that only prepare them. */\n readonly jobs: BlockStatusJobs;\n /** The first transition anywhere in the tree, ms since the epoch. */\n readonly startedAt?: number;\n /** The most recent transition anywhere in the tree, ms since the epoch. */\n readonly lastChangeAt?: number;\n /**\n * True once the root render has ended and nothing in the tree is still running, or once a render\n * failed and no job is still working.\n */\n readonly done: boolean;\n /**\n * Set when any render of the run terminated: the innermost message of the earliest one's reason,\n * one line, empty when it gave none. The full reason stays on the node's transitions. Commands\n * that fail are counted in {@link BlockStatusJobs.failed} instead.\n */\n readonly failure?: string;\n /**\n * True when the user stopped the run. The tree is kept as it was when it stopped, so the counters\n * say where each node was, but nothing in it runs any more.\n */\n readonly cancelled?: boolean;\n};\n\n/** No jobs yet. */\nexport const EmptyBlockStatusJobs: BlockStatusJobs = {\n total: 0,\n done: 0,\n failed: 0,\n byState: [],\n};\n\n/** A summary for a block whose run has not reported anything yet. */\nexport const EmptyBlockStatusSummary: BlockStatusSummary = {\n availability: \"read\",\n activeContexts: 0,\n totalContexts: 0,\n jobs: EmptyBlockStatusJobs,\n done: false,\n};\n\n/** A summary for a context that could not be read; its counters are unknown, not zero. */\nexport const UnreadableBlockStatusSummary: BlockStatusSummary = {\n ...EmptyBlockStatusSummary,\n availability: \"unreadable\",\n};\n\n/** A summary for a backend that does not accept status reports. */\nexport const UnsupportedBlockStatusSummary: BlockStatusSummary = {\n ...EmptyBlockStatusSummary,\n availability: \"unsupported\",\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,0BAA0B;CACrC,kBAAkB;CAClB,SAAS;CACT,oBAAoB;CACpB,uBAAuB;CACvB,mBAAmB;CACnB,mBAAmB;CACnB,qBAAqB;CACrB,mBAAmB;CACnB,YAAY;CACZ,WAAW;AACb;;AAGA,MAAa,oBAAoB,OAAO,OAAO,uBAAuB;;AAMtE,SAAgB,2BAA2B,OAAwB;CACjE,OACE,UAAU,wBAAwB,cAAc,UAAU,wBAAwB;AAEtF;;AA+EA,MAAa,uBAAwC;CACnD,OAAO;CACP,MAAM;CACN,QAAQ;CACR,SAAS,CAAC;AACZ;;AAGA,MAAa,0BAA8C;CACzD,cAAc;CACd,gBAAgB;CAChB,eAAe;CACf,MAAM;CACN,MAAM;AACR;;AAGA,MAAa,+BAAmD;CAC9D,GAAG;CACH,cAAc;AAChB;;AAGA,MAAa,gCAAoD;CAC/D,GAAG;CACH,cAAc;AAChB"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The status of a running block, as the middle layer hands it to the Desktop App.
|
|
3
|
+
*
|
|
4
|
+
* The backend keeps a tree of status contexts, one per render, and writes each reporter's
|
|
5
|
+
* transitions into the context of the render it belongs to. The middle layer folds that tree into
|
|
6
|
+
* a {@link BlockStatusSummary}.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The node states this build knows, spelled as the backend and the workflow SDK write them into a
|
|
10
|
+
* transition value. The names match `plapi.ActionState` on the backend and `STATES` in
|
|
11
|
+
* workflow-tengo's action-context library.
|
|
12
|
+
*
|
|
13
|
+
* The backend owns the list: a reporter may write a state added after this release, and the middle
|
|
14
|
+
* layer passes it on as written. Only the lifecycle (`Completed`, `Terminated`, and `Running`
|
|
15
|
+
* reported by a command) carries meaning in the fold; the rest exists for the user.
|
|
16
|
+
*/
|
|
17
|
+
export declare const blockStatusStatesRecord: {
|
|
18
|
+
readonly WaitingForInputs: "WaitingForInputs";
|
|
19
|
+
readonly Running: "Running";
|
|
20
|
+
readonly WaitingWorkdirGate: "WaitingWorkdirGate";
|
|
21
|
+
readonly WaitingSubmissionGate: "WaitingSubmissionGate";
|
|
22
|
+
readonly PopulatingWorkdir: "PopulatingWorkdir";
|
|
23
|
+
readonly CollectingOutputs: "CollectingOutputs";
|
|
24
|
+
readonly WaitingForScheduler: "WaitingForScheduler";
|
|
25
|
+
readonly WaitingForMachine: "WaitingForMachine";
|
|
26
|
+
readonly Terminated: "Terminated";
|
|
27
|
+
readonly Completed: "Completed";
|
|
28
|
+
};
|
|
29
|
+
/** Every state, in the order above. */
|
|
30
|
+
export declare const blockStatusStates: ("CollectingOutputs" | "Completed" | "PopulatingWorkdir" | "Running" | "Terminated" | "WaitingForInputs" | "WaitingForMachine" | "WaitingForScheduler" | "WaitingSubmissionGate" | "WaitingWorkdirGate")[];
|
|
31
|
+
/** A node state name this build knows, e.g. `"PopulatingWorkdir"`. */
|
|
32
|
+
export type BlockStatusState = (typeof blockStatusStates)[number];
|
|
33
|
+
/** True for a state a node cannot leave. */
|
|
34
|
+
export declare function isTerminalBlockStatusState(state: string): boolean;
|
|
35
|
+
/** Jobs held by one state: the transition holding each of them has this namespace and state. */
|
|
36
|
+
export type BlockStatusJobGroup = {
|
|
37
|
+
/** Who reported the state: `exec` for a command, `workdir` for its work folder, `render`. */
|
|
38
|
+
readonly namespace: string;
|
|
39
|
+
/** As the reporter wrote it, which can be a state this build does not know. */
|
|
40
|
+
readonly state: string;
|
|
41
|
+
readonly count: number;
|
|
42
|
+
/** When the earliest of them entered the state, ms since the epoch. */
|
|
43
|
+
readonly since?: number;
|
|
44
|
+
/** Files done and all, summed over the jobs whose work folders report their progress. */
|
|
45
|
+
readonly files?: {
|
|
46
|
+
readonly done: number;
|
|
47
|
+
readonly total: number;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The block's jobs: the commands it runs on a machine, each counted once by where it is now.
|
|
52
|
+
*
|
|
53
|
+
* A job is a context that a command or its work folder reports in. Jobs the run has not created yet
|
|
54
|
+
* are not counted, so `total` grows while the run fans out.
|
|
55
|
+
*/
|
|
56
|
+
export type BlockStatusJobs = {
|
|
57
|
+
readonly total: number;
|
|
58
|
+
readonly done: number;
|
|
59
|
+
/**
|
|
60
|
+
* Jobs that failed, and renders that failed on their own (not by passing up a failure under
|
|
61
|
+
* them), e.g. one whose command could not start.
|
|
62
|
+
*/
|
|
63
|
+
readonly failed: number;
|
|
64
|
+
/** The jobs not ended, by the state holding each, largest group first. */
|
|
65
|
+
readonly byState: readonly BlockStatusJobGroup[];
|
|
66
|
+
};
|
|
67
|
+
/** Why a summary carries no counters. */
|
|
68
|
+
export type BlockStatusAvailability =
|
|
69
|
+
/** The tree was read and the run has reported what the summary holds. */
|
|
70
|
+
"read" |
|
|
71
|
+
/** The context could not be read: it is gone, or reading it raised. The counters are unknown,
|
|
72
|
+
* which is not the same as a run that has reported nothing. */
|
|
73
|
+
"unreadable" |
|
|
74
|
+
/** The backend cannot take the `actionContext` link, so no context is created and nothing is
|
|
75
|
+
* ever reported. */
|
|
76
|
+
"unsupported";
|
|
77
|
+
/** The status of one block run, folded from its status-context tree. */
|
|
78
|
+
export type BlockStatusSummary = {
|
|
79
|
+
/** Whether the counters below describe the run, or could not be read at all. */
|
|
80
|
+
readonly availability: BlockStatusAvailability;
|
|
81
|
+
/** The block's own `run-id`: two clicks of Run give two different values. */
|
|
82
|
+
readonly runId?: string;
|
|
83
|
+
/** Action contexts that have not ended. */
|
|
84
|
+
readonly activeContexts: number;
|
|
85
|
+
/** Every action context of the run, active or ended. */
|
|
86
|
+
readonly totalContexts: number;
|
|
87
|
+
/** The run's jobs, counted apart from the template renders that only prepare them. */
|
|
88
|
+
readonly jobs: BlockStatusJobs;
|
|
89
|
+
/** The first transition anywhere in the tree, ms since the epoch. */
|
|
90
|
+
readonly startedAt?: number;
|
|
91
|
+
/** The most recent transition anywhere in the tree, ms since the epoch. */
|
|
92
|
+
readonly lastChangeAt?: number;
|
|
93
|
+
/**
|
|
94
|
+
* True once the root render has ended and nothing in the tree is still running, or once a render
|
|
95
|
+
* failed and no job is still working.
|
|
96
|
+
*/
|
|
97
|
+
readonly done: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Set when any render of the run terminated: the innermost message of the earliest one's reason,
|
|
100
|
+
* one line, empty when it gave none. The full reason stays on the node's transitions. Commands
|
|
101
|
+
* that fail are counted in {@link BlockStatusJobs.failed} instead.
|
|
102
|
+
*/
|
|
103
|
+
readonly failure?: string;
|
|
104
|
+
/**
|
|
105
|
+
* True when the user stopped the run. The tree is kept as it was when it stopped, so the counters
|
|
106
|
+
* say where each node was, but nothing in it runs any more.
|
|
107
|
+
*/
|
|
108
|
+
readonly cancelled?: boolean;
|
|
109
|
+
};
|
|
110
|
+
/** No jobs yet. */
|
|
111
|
+
export declare const EmptyBlockStatusJobs: BlockStatusJobs;
|
|
112
|
+
/** A summary for a block whose run has not reported anything yet. */
|
|
113
|
+
export declare const EmptyBlockStatusSummary: BlockStatusSummary;
|
|
114
|
+
/** A summary for a context that could not be read; its counters are unknown, not zero. */
|
|
115
|
+
export declare const UnreadableBlockStatusSummary: BlockStatusSummary;
|
|
116
|
+
/** A summary for a backend that does not accept status reports. */
|
|
117
|
+
export declare const UnsupportedBlockStatusSummary: BlockStatusSummary;
|
|
118
|
+
//# sourceMappingURL=block_status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block_status.d.ts","names":[],"sources":["../src/block_status.ts"],"mappings":";;;;;;;;;;;;;;;;qBAiBa;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;qBAIW;;YAGD,2BAA2B;;wBAGvB,2BAA2B;;YAO/B;;WAED;;WAEA;WACA;;WAEA;;WAEA;aAAmB;aAAuB;;;;;;;;;YASzC;WACD;WACA;;;;;WAKA;;WAEA,kBAAkB;;;YAIjB;;;;;;;;;;YAWA;;WAED,cAAc;;WAEd;;WAEA;;WAEA;;WAEA,MAAM;;WAEN;;WAEA;;;;;WAKA;;;;;;WAMA;;;;;WAKA;;;qBAIE,sBAAsB;;qBAQtB,yBAAyB;;qBASzB,8BAA8B;;qBAM9B,+BAA+B"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// src/block_status.ts
|
|
2
|
+
/**
|
|
3
|
+
* The status of a running block, as the middle layer hands it to the Desktop App.
|
|
4
|
+
*
|
|
5
|
+
* The backend keeps a tree of status contexts, one per render, and writes each reporter's
|
|
6
|
+
* transitions into the context of the render it belongs to. The middle layer folds that tree into
|
|
7
|
+
* a {@link BlockStatusSummary}.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* The node states this build knows, spelled as the backend and the workflow SDK write them into a
|
|
11
|
+
* transition value. The names match `plapi.ActionState` on the backend and `STATES` in
|
|
12
|
+
* workflow-tengo's action-context library.
|
|
13
|
+
*
|
|
14
|
+
* The backend owns the list: a reporter may write a state added after this release, and the middle
|
|
15
|
+
* layer passes it on as written. Only the lifecycle (`Completed`, `Terminated`, and `Running`
|
|
16
|
+
* reported by a command) carries meaning in the fold; the rest exists for the user.
|
|
17
|
+
*/
|
|
18
|
+
const blockStatusStatesRecord = {
|
|
19
|
+
WaitingForInputs: "WaitingForInputs",
|
|
20
|
+
Running: "Running",
|
|
21
|
+
WaitingWorkdirGate: "WaitingWorkdirGate",
|
|
22
|
+
WaitingSubmissionGate: "WaitingSubmissionGate",
|
|
23
|
+
PopulatingWorkdir: "PopulatingWorkdir",
|
|
24
|
+
CollectingOutputs: "CollectingOutputs",
|
|
25
|
+
WaitingForScheduler: "WaitingForScheduler",
|
|
26
|
+
WaitingForMachine: "WaitingForMachine",
|
|
27
|
+
Terminated: "Terminated",
|
|
28
|
+
Completed: "Completed"
|
|
29
|
+
};
|
|
30
|
+
/** Every state, in the order above. */
|
|
31
|
+
const blockStatusStates = Object.values(blockStatusStatesRecord);
|
|
32
|
+
/** True for a state a node cannot leave. */
|
|
33
|
+
function isTerminalBlockStatusState(state) {
|
|
34
|
+
return state === blockStatusStatesRecord.Terminated || state === blockStatusStatesRecord.Completed;
|
|
35
|
+
}
|
|
36
|
+
/** No jobs yet. */
|
|
37
|
+
const EmptyBlockStatusJobs = {
|
|
38
|
+
total: 0,
|
|
39
|
+
done: 0,
|
|
40
|
+
failed: 0,
|
|
41
|
+
byState: []
|
|
42
|
+
};
|
|
43
|
+
/** A summary for a block whose run has not reported anything yet. */
|
|
44
|
+
const EmptyBlockStatusSummary = {
|
|
45
|
+
availability: "read",
|
|
46
|
+
activeContexts: 0,
|
|
47
|
+
totalContexts: 0,
|
|
48
|
+
jobs: EmptyBlockStatusJobs,
|
|
49
|
+
done: false
|
|
50
|
+
};
|
|
51
|
+
/** A summary for a context that could not be read; its counters are unknown, not zero. */
|
|
52
|
+
const UnreadableBlockStatusSummary = {
|
|
53
|
+
...EmptyBlockStatusSummary,
|
|
54
|
+
availability: "unreadable"
|
|
55
|
+
};
|
|
56
|
+
/** A summary for a backend that does not accept status reports. */
|
|
57
|
+
const UnsupportedBlockStatusSummary = {
|
|
58
|
+
...EmptyBlockStatusSummary,
|
|
59
|
+
availability: "unsupported"
|
|
60
|
+
};
|
|
61
|
+
export { EmptyBlockStatusJobs, EmptyBlockStatusSummary, UnreadableBlockStatusSummary, UnsupportedBlockStatusSummary, blockStatusStates, blockStatusStatesRecord, isTerminalBlockStatusState };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=block_status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block_status.js","names":[],"sources":["../src/block_status.ts"],"sourcesContent":["/**\n * The status of a running block, as the middle layer hands it to the Desktop App.\n *\n * The backend keeps a tree of status contexts, one per render, and writes each reporter's\n * transitions into the context of the render it belongs to. The middle layer folds that tree into\n * a {@link BlockStatusSummary}.\n */\n\n/**\n * The node states this build knows, spelled as the backend and the workflow SDK write them into a\n * transition value. The names match `plapi.ActionState` on the backend and `STATES` in\n * workflow-tengo's action-context library.\n *\n * The backend owns the list: a reporter may write a state added after this release, and the middle\n * layer passes it on as written. Only the lifecycle (`Completed`, `Terminated`, and `Running`\n * reported by a command) carries meaning in the fold; the rest exists for the user.\n */\nexport const blockStatusStatesRecord = {\n WaitingForInputs: \"WaitingForInputs\",\n Running: \"Running\",\n WaitingWorkdirGate: \"WaitingWorkdirGate\",\n WaitingSubmissionGate: \"WaitingSubmissionGate\",\n PopulatingWorkdir: \"PopulatingWorkdir\",\n CollectingOutputs: \"CollectingOutputs\",\n WaitingForScheduler: \"WaitingForScheduler\",\n WaitingForMachine: \"WaitingForMachine\",\n Terminated: \"Terminated\",\n Completed: \"Completed\",\n} as const;\n\n/** Every state, in the order above. */\nexport const blockStatusStates = Object.values(blockStatusStatesRecord);\n\n/** A node state name this build knows, e.g. `\"PopulatingWorkdir\"`. */\nexport type BlockStatusState = (typeof blockStatusStates)[number];\n\n/** True for a state a node cannot leave. */\nexport function isTerminalBlockStatusState(state: string): boolean {\n return (\n state === blockStatusStatesRecord.Terminated || state === blockStatusStatesRecord.Completed\n );\n}\n\n/** Jobs held by one state: the transition holding each of them has this namespace and state. */\nexport type BlockStatusJobGroup = {\n /** Who reported the state: `exec` for a command, `workdir` for its work folder, `render`. */\n readonly namespace: string;\n /** As the reporter wrote it, which can be a state this build does not know. */\n readonly state: string;\n readonly count: number;\n /** When the earliest of them entered the state, ms since the epoch. */\n readonly since?: number;\n /** Files done and all, summed over the jobs whose work folders report their progress. */\n readonly files?: { readonly done: number; readonly total: number };\n};\n\n/**\n * The block's jobs: the commands it runs on a machine, each counted once by where it is now.\n *\n * A job is a context that a command or its work folder reports in. Jobs the run has not created yet\n * are not counted, so `total` grows while the run fans out.\n */\nexport type BlockStatusJobs = {\n readonly total: number;\n readonly done: number;\n /**\n * Jobs that failed, and renders that failed on their own (not by passing up a failure under\n * them), e.g. one whose command could not start.\n */\n readonly failed: number;\n /** The jobs not ended, by the state holding each, largest group first. */\n readonly byState: readonly BlockStatusJobGroup[];\n};\n\n/** Why a summary carries no counters. */\nexport type BlockStatusAvailability =\n /** The tree was read and the run has reported what the summary holds. */\n | \"read\"\n /** The context could not be read: it is gone, or reading it raised. The counters are unknown,\n * which is not the same as a run that has reported nothing. */\n | \"unreadable\"\n /** The backend cannot take the `actionContext` link, so no context is created and nothing is\n * ever reported. */\n | \"unsupported\";\n\n/** The status of one block run, folded from its status-context tree. */\nexport type BlockStatusSummary = {\n /** Whether the counters below describe the run, or could not be read at all. */\n readonly availability: BlockStatusAvailability;\n /** The block's own `run-id`: two clicks of Run give two different values. */\n readonly runId?: string;\n /** Action contexts that have not ended. */\n readonly activeContexts: number;\n /** Every action context of the run, active or ended. */\n readonly totalContexts: number;\n /** The run's jobs, counted apart from the template renders that only prepare them. */\n readonly jobs: BlockStatusJobs;\n /** The first transition anywhere in the tree, ms since the epoch. */\n readonly startedAt?: number;\n /** The most recent transition anywhere in the tree, ms since the epoch. */\n readonly lastChangeAt?: number;\n /**\n * True once the root render has ended and nothing in the tree is still running, or once a render\n * failed and no job is still working.\n */\n readonly done: boolean;\n /**\n * Set when any render of the run terminated: the innermost message of the earliest one's reason,\n * one line, empty when it gave none. The full reason stays on the node's transitions. Commands\n * that fail are counted in {@link BlockStatusJobs.failed} instead.\n */\n readonly failure?: string;\n /**\n * True when the user stopped the run. The tree is kept as it was when it stopped, so the counters\n * say where each node was, but nothing in it runs any more.\n */\n readonly cancelled?: boolean;\n};\n\n/** No jobs yet. */\nexport const EmptyBlockStatusJobs: BlockStatusJobs = {\n total: 0,\n done: 0,\n failed: 0,\n byState: [],\n};\n\n/** A summary for a block whose run has not reported anything yet. */\nexport const EmptyBlockStatusSummary: BlockStatusSummary = {\n availability: \"read\",\n activeContexts: 0,\n totalContexts: 0,\n jobs: EmptyBlockStatusJobs,\n done: false,\n};\n\n/** A summary for a context that could not be read; its counters are unknown, not zero. */\nexport const UnreadableBlockStatusSummary: BlockStatusSummary = {\n ...EmptyBlockStatusSummary,\n availability: \"unreadable\",\n};\n\n/** A summary for a backend that does not accept status reports. */\nexport const UnsupportedBlockStatusSummary: BlockStatusSummary = {\n ...EmptyBlockStatusSummary,\n availability: \"unsupported\",\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,0BAA0B;CACrC,kBAAkB;CAClB,SAAS;CACT,oBAAoB;CACpB,uBAAuB;CACvB,mBAAmB;CACnB,mBAAmB;CACnB,qBAAqB;CACrB,mBAAmB;CACnB,YAAY;CACZ,WAAW;AACb;;AAGA,MAAa,oBAAoB,OAAO,OAAO,uBAAuB;;AAMtE,SAAgB,2BAA2B,OAAwB;CACjE,OACE,UAAU,wBAAwB,cAAc,UAAU,wBAAwB;AAEtF;;AA+EA,MAAa,uBAAwC;CACnD,OAAO;CACP,MAAM;CACN,QAAQ;CACR,SAAS,CAAC;AACZ;;AAGA,MAAa,0BAA8C;CACzD,cAAc;CACd,gBAAgB;CAChB,eAAe;CACf,MAAM;CACN,MAAM;AACR;;AAGA,MAAa,+BAAmD;CAC9D,GAAG;CACH,cAAc;AAChB;;AAGA,MAAa,gCAAoD;CAC/D,GAAG;CACH,cAAc;AAChB"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_block_settings = require("./block_settings.cjs");
|
|
3
3
|
const require_instance_stats = require("./instance_stats.cjs");
|
|
4
|
+
const require_block_status = require("./block_status.cjs");
|
|
4
5
|
const require_project = require("./project.cjs");
|
|
5
6
|
const require_document = require("./folders/document.cjs");
|
|
6
7
|
const require_decode = require("./folders/decode.cjs");
|
|
@@ -63,6 +64,8 @@ exports.ContentRelativeText = require_content_types.ContentRelativeText;
|
|
|
63
64
|
exports.CreateBlockPackDescriptionSchema = require_block_description.CreateBlockPackDescriptionSchema;
|
|
64
65
|
exports.DescriptionContentBinary = require_content_types.DescriptionContentBinary;
|
|
65
66
|
exports.DescriptionContentText = require_content_types.DescriptionContentText;
|
|
67
|
+
exports.EmptyBlockStatusJobs = require_block_status.EmptyBlockStatusJobs;
|
|
68
|
+
exports.EmptyBlockStatusSummary = require_block_status.EmptyBlockStatusSummary;
|
|
66
69
|
exports.FOLDERS_SCHEMA_VERSION = require_document.FOLDERS_SCHEMA_VERSION;
|
|
67
70
|
exports.FeatureFlags = require_block_description.FeatureFlags;
|
|
68
71
|
exports.FolderEntry = require_document.FolderEntry;
|
|
@@ -86,6 +89,8 @@ exports.SemVer = require_semver.SemVer;
|
|
|
86
89
|
exports.Sha256Schema = require_block_manifest.Sha256Schema;
|
|
87
90
|
exports.SingleBlockPackOverview = require_overview.SingleBlockPackOverview;
|
|
88
91
|
exports.StableChannel = require_overview.StableChannel;
|
|
92
|
+
exports.UnreadableBlockStatusSummary = require_block_status.UnreadableBlockStatusSummary;
|
|
93
|
+
exports.UnsupportedBlockStatusSummary = require_block_status.UnsupportedBlockStatusSummary;
|
|
89
94
|
exports.UnsupportedInstanceStats = require_instance_stats.UnsupportedInstanceStats;
|
|
90
95
|
exports.VersionWithChannels = require_overview.VersionWithChannels;
|
|
91
96
|
exports.WorkflowSchemaV1 = require_block_components.WorkflowSchemaV1;
|
|
@@ -98,6 +103,8 @@ exports.blockPackIdNoVersionEquals = require_block_id.blockPackIdNoVersionEquals
|
|
|
98
103
|
exports.blockPackIdNoVersionToString = require_block_id.blockPackIdNoVersionToString;
|
|
99
104
|
exports.blockPackIdToString = require_block_id.blockPackIdToString;
|
|
100
105
|
exports.blockPackOverviewToLegacy = require_overview.blockPackOverviewToLegacy;
|
|
106
|
+
exports.blockStatusStates = require_block_status.blockStatusStates;
|
|
107
|
+
exports.blockStatusStatesRecord = require_block_status.blockStatusStatesRecord;
|
|
101
108
|
exports.commitFoldersMove = require_commit.commitFoldersMove;
|
|
102
109
|
exports.commitFoldersRemoval = require_commit.commitFoldersRemoval;
|
|
103
110
|
exports.decodeFoldersDocument = require_decode.decodeFoldersDocument;
|
|
@@ -118,6 +125,7 @@ exports.formatFoldersViolation = require_invariants.formatFoldersViolation;
|
|
|
118
125
|
exports.hashJson = require_json.hashJson;
|
|
119
126
|
exports.healFolders = require_view.healFolders;
|
|
120
127
|
exports.inheritedFolder = require_inheritance.inheritedFolder;
|
|
128
|
+
exports.isTerminalBlockStatusState = require_block_status.isTerminalBlockStatusState;
|
|
121
129
|
exports.mapRemoteToAbsolute = require_content_conversion.mapRemoteToAbsolute;
|
|
122
130
|
exports.normalizeDescription = require_project.normalizeDescription;
|
|
123
131
|
exports.normalizeProjectMeta = require_project.normalizeProjectMeta;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { AuthorMarker } from "./author_marker.js";
|
|
|
2
2
|
import { BlockSettings, InitialBlockSettings, VersionLock } from "./block_settings.js";
|
|
3
3
|
import { StorageDebugView } from "./storage_debug_view.js";
|
|
4
4
|
import { BlockStateInternal, BlockStateInternalV3 } from "./block_state.js";
|
|
5
|
-
import { InstanceStats,
|
|
5
|
+
import { InstanceStats, InstanceStatsCapacity, InstanceStatsStatus, UnsupportedInstanceStats } from "./instance_stats.js";
|
|
6
|
+
import { BlockStatusAvailability, BlockStatusJobGroup, BlockStatusJobs, BlockStatusState, BlockStatusSummary, EmptyBlockStatusJobs, EmptyBlockStatusSummary, UnreadableBlockStatusSummary, UnsupportedBlockStatusSummary, blockStatusStates, blockStatusStatesRecord, isTerminalBlockStatusState } from "./block_status.js";
|
|
6
7
|
import { ProjectMeta, normalizeDescription, normalizeProjectMeta } from "./project.js";
|
|
7
8
|
import { ProjectListEntry } from "./project_list.js";
|
|
8
9
|
import { BlockPackDevV1, BlockPackDevV2, BlockPackFromPackV2, BlockPackFromRegistryV1, BlockPackFromRegistryV2, BlockPackSpec } from "./block_registry/block_pack_spec.js";
|
|
@@ -34,4 +35,4 @@ import "./block_meta/index.js";
|
|
|
34
35
|
import { index_d_exports } from "./pframe/internal_api/index.js";
|
|
35
36
|
import "./pframe/index.js";
|
|
36
37
|
import { HashedJson, hashJson, readJson, readJsonSync } from "./json.js";
|
|
37
|
-
export { AnyChannel, type AuthorMarker, BlockCalculationStatus, BlockComponents, BlockComponentsDescriptionRaw, BlockComponentsManifest, BlockKindRef, BlockPackDescription, BlockPackDescriptionFromPackageJsonRaw, BlockPackDescriptionManifest, BlockPackDescriptionRaw, BlockPackDevV1, BlockPackDevV2, BlockPackFromPackV2, BlockPackFromRegistryV1, BlockPackFromRegistryV2, BlockPackId, BlockPackIdNoVersion, BlockPackListing, BlockPackManifest, BlockPackManifestFile, BlockPackMeta, BlockPackMetaDescriptionRaw, BlockPackMetaEmbeddedBase64, BlockPackMetaEmbeddedBytes, BlockPackMetaManifest, BlockPackOverview, BlockPackOverviewLegacy, BlockPackOverviewNoRegistryId, BlockPackOverviewRaw, BlockPackSpec, BlockPlatform, BlockSettings, BlockStateInternal, BlockStateInternalV3, BlockStateOverview, Content, ContentAbsoluteBinaryLocal, ContentAbsoluteFile, ContentAbsoluteFolder, ContentAbsoluteTextLocal, ContentAbsoluteUrl, ContentAnyBinaryLocal, ContentAnyLocal, ContentAnyTextLocal, ContentExplicitBase64, ContentExplicitBytes, ContentExplicitOrRelative, ContentExplicitString, ContentRelative, ContentRelativeBinary, ContentRelativeText, ContentType, ContextType, CreateBlockPackDescriptionSchema, DescriptionContentBinary, DescriptionContentText, FOLDERS_SCHEMA_VERSION, FeatureFlags, FolderEntry, FolderId, FolderView, FoldersDecoded, FoldersDocument, FoldersDocumentProblem, FoldersEdit, FoldersItem, FoldersItemInput, FoldersItemView, FoldersLabelRename, FoldersLeafItem, FoldersMoveApplication, FoldersMoveEntry, FoldersMoveIssue, FoldersMoveOutcome, FoldersMovePlan, FoldersMovePlanResult, FoldersPlacement, FoldersProjectInput, FoldersProjectView, FoldersRemoval, FoldersRemovalIssue, FoldersRemovalOutcome, FoldersRemovalPlanResult, FoldersStoredDocument, FoldersTemplateInput, FoldersTemplateView, FoldersView, FoldersViolation, HashedJson, InitialBlockSettings, InstanceStats,
|
|
38
|
+
export { AnyChannel, type AuthorMarker, BlockCalculationStatus, BlockComponents, BlockComponentsDescriptionRaw, BlockComponentsManifest, BlockKindRef, BlockPackDescription, BlockPackDescriptionFromPackageJsonRaw, BlockPackDescriptionManifest, BlockPackDescriptionRaw, BlockPackDevV1, BlockPackDevV2, BlockPackFromPackV2, BlockPackFromRegistryV1, BlockPackFromRegistryV2, BlockPackId, BlockPackIdNoVersion, BlockPackListing, BlockPackManifest, BlockPackManifestFile, BlockPackMeta, BlockPackMetaDescriptionRaw, BlockPackMetaEmbeddedBase64, BlockPackMetaEmbeddedBytes, BlockPackMetaManifest, BlockPackOverview, BlockPackOverviewLegacy, BlockPackOverviewNoRegistryId, BlockPackOverviewRaw, BlockPackSpec, BlockPlatform, BlockSettings, BlockStateInternal, BlockStateInternalV3, BlockStateOverview, BlockStatusAvailability, BlockStatusJobGroup, BlockStatusJobs, BlockStatusState, BlockStatusSummary, Content, ContentAbsoluteBinaryLocal, ContentAbsoluteFile, ContentAbsoluteFolder, ContentAbsoluteTextLocal, ContentAbsoluteUrl, ContentAnyBinaryLocal, ContentAnyLocal, ContentAnyTextLocal, ContentExplicitBase64, ContentExplicitBytes, ContentExplicitOrRelative, ContentExplicitString, ContentRelative, ContentRelativeBinary, ContentRelativeText, ContentType, ContextType, CreateBlockPackDescriptionSchema, DescriptionContentBinary, DescriptionContentText, EmptyBlockStatusJobs, EmptyBlockStatusSummary, FOLDERS_SCHEMA_VERSION, FeatureFlags, FolderEntry, FolderId, FolderView, FoldersDecoded, FoldersDocument, FoldersDocumentProblem, FoldersEdit, FoldersItem, FoldersItemInput, FoldersItemView, FoldersLabelRename, FoldersLeafItem, FoldersMoveApplication, FoldersMoveEntry, FoldersMoveIssue, FoldersMoveOutcome, FoldersMovePlan, FoldersMovePlanResult, FoldersPlacement, FoldersProjectInput, FoldersProjectView, FoldersRemoval, FoldersRemovalIssue, FoldersRemovalOutcome, FoldersRemovalPlanResult, FoldersStoredDocument, FoldersTemplateInput, FoldersTemplateView, FoldersView, FoldersViolation, HashedJson, InitialBlockSettings, InstanceStats, InstanceStatsCapacity, InstanceStatsStatus, LocalDevFolder, ManifestFileInfo, index_d_exports as PFrameInternal, ProjectListEntry, ProjectMeta, ProjectOverview, RegistryEntry, RegistryList, RegistrySpec, RegistryStatus, RemoteRegistryV1Spec, RemoteRegistryV2Spec, SemVer, Sha256Schema, SingleBlockPackOverview, StableChannel, StorageDebugView, UnreadableBlockStatusSummary, UnsupportedBlockStatusSummary, UnsupportedInstanceStats, UpdateSuggestion, UpdateSuggestions, VersionLock, VersionWithChannels, Workflow, WorkflowSchemaV1, WorkflowV1, addPrefixToRelative, applyFoldersMove, applyFoldersRemoval, asFolderId, blockPackIdEquals, blockPackIdNoVersionEquals, blockPackIdNoVersionToString, blockPackIdToString, blockPackOverviewToLegacy, blockStatusStates, blockStatusStatesRecord, commitFoldersMove, commitFoldersRemoval, decodeFoldersDocument, decodeStoredFoldersDocument, emptyFoldersDocument, encodeFoldersDocument, foldersChildren, foldersDocumentFromView, foldersMovePlansEqual, foldersNameBlank, foldersNameTaken, foldersRemovalsEqual, foldersSiblingNames, foldersSubtree, foldersUniqueName, foldersViewFromDocument, formatFoldersViolation, hashJson, healFolders, inheritedFolder, isTerminalBlockStatusState, mapRemoteToAbsolute, normalizeDescription, normalizeProjectMeta, overrideDescriptionVersion, overrideManifestVersion, planFoldersMove, planFoldersRemoval, readJson, readJsonSync, validateFoldersDocument };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InitialBlockSettings } from "./block_settings.js";
|
|
2
2
|
import { UnsupportedInstanceStats } from "./instance_stats.js";
|
|
3
|
+
import { EmptyBlockStatusJobs, EmptyBlockStatusSummary, UnreadableBlockStatusSummary, UnsupportedBlockStatusSummary, blockStatusStates, blockStatusStatesRecord, isTerminalBlockStatusState } from "./block_status.js";
|
|
3
4
|
import { normalizeDescription, normalizeProjectMeta } from "./project.js";
|
|
4
5
|
import { FOLDERS_SCHEMA_VERSION, FolderEntry, FoldersDocument, asFolderId, emptyFoldersDocument } from "./folders/document.js";
|
|
5
6
|
import { decodeFoldersDocument, decodeStoredFoldersDocument, encodeFoldersDocument } from "./folders/decode.js";
|
|
@@ -26,4 +27,4 @@ import { AnyChannel, BlockPackListing, BlockPackOverview, BlockPackOverviewLegac
|
|
|
26
27
|
import "./block_registry/index.js";
|
|
27
28
|
import { internal_api_exports } from "./pframe/internal_api/index.js";
|
|
28
29
|
import { hashJson, readJson, readJsonSync } from "./json.js";
|
|
29
|
-
export { AnyChannel, BlockComponentsDescriptionRaw, BlockComponentsManifest, BlockKindRef, BlockPackDescriptionFromPackageJsonRaw, BlockPackDescriptionManifest, BlockPackDescriptionRaw, BlockPackDevV1, BlockPackDevV2, BlockPackFromPackV2, BlockPackFromRegistryV1, BlockPackFromRegistryV2, BlockPackId, BlockPackIdNoVersion, BlockPackListing, BlockPackManifest, BlockPackManifestFile, BlockPackMeta, BlockPackMetaDescriptionRaw, BlockPackMetaEmbeddedBase64, BlockPackMetaEmbeddedBytes, BlockPackMetaManifest, BlockPackOverview, BlockPackOverviewLegacy, BlockPackOverviewNoRegistryId, BlockPackOverviewRaw, BlockPackSpec, BlockPlatform, ContentExplicitBase64, ContentExplicitBytes, ContentRelative, ContentRelativeBinary, ContentRelativeText, CreateBlockPackDescriptionSchema, DescriptionContentBinary, DescriptionContentText, FOLDERS_SCHEMA_VERSION, FeatureFlags, FolderEntry, FoldersDocument, InitialBlockSettings, LocalDevFolder, ManifestFileInfo, internal_api_exports as PFrameInternal, RegistryEntry, RegistryList, RegistrySpec, RegistryStatus, RemoteRegistryV1Spec, RemoteRegistryV2Spec, SemVer, Sha256Schema, SingleBlockPackOverview, StableChannel, UnsupportedInstanceStats, VersionWithChannels, WorkflowSchemaV1, addPrefixToRelative, applyFoldersMove, applyFoldersRemoval, asFolderId, blockPackIdEquals, blockPackIdNoVersionEquals, blockPackIdNoVersionToString, blockPackIdToString, blockPackOverviewToLegacy, commitFoldersMove, commitFoldersRemoval, decodeFoldersDocument, decodeStoredFoldersDocument, emptyFoldersDocument, encodeFoldersDocument, foldersChildren, foldersDocumentFromView, foldersMovePlansEqual, foldersNameBlank, foldersNameTaken, foldersRemovalsEqual, foldersSiblingNames, foldersSubtree, foldersUniqueName, foldersViewFromDocument, formatFoldersViolation, hashJson, healFolders, inheritedFolder, mapRemoteToAbsolute, normalizeDescription, normalizeProjectMeta, overrideDescriptionVersion, overrideManifestVersion, planFoldersMove, planFoldersRemoval, readJson, readJsonSync, validateFoldersDocument };
|
|
30
|
+
export { AnyChannel, BlockComponentsDescriptionRaw, BlockComponentsManifest, BlockKindRef, BlockPackDescriptionFromPackageJsonRaw, BlockPackDescriptionManifest, BlockPackDescriptionRaw, BlockPackDevV1, BlockPackDevV2, BlockPackFromPackV2, BlockPackFromRegistryV1, BlockPackFromRegistryV2, BlockPackId, BlockPackIdNoVersion, BlockPackListing, BlockPackManifest, BlockPackManifestFile, BlockPackMeta, BlockPackMetaDescriptionRaw, BlockPackMetaEmbeddedBase64, BlockPackMetaEmbeddedBytes, BlockPackMetaManifest, BlockPackOverview, BlockPackOverviewLegacy, BlockPackOverviewNoRegistryId, BlockPackOverviewRaw, BlockPackSpec, BlockPlatform, ContentExplicitBase64, ContentExplicitBytes, ContentRelative, ContentRelativeBinary, ContentRelativeText, CreateBlockPackDescriptionSchema, DescriptionContentBinary, DescriptionContentText, EmptyBlockStatusJobs, EmptyBlockStatusSummary, FOLDERS_SCHEMA_VERSION, FeatureFlags, FolderEntry, FoldersDocument, InitialBlockSettings, LocalDevFolder, ManifestFileInfo, internal_api_exports as PFrameInternal, RegistryEntry, RegistryList, RegistrySpec, RegistryStatus, RemoteRegistryV1Spec, RemoteRegistryV2Spec, SemVer, Sha256Schema, SingleBlockPackOverview, StableChannel, UnreadableBlockStatusSummary, UnsupportedBlockStatusSummary, UnsupportedInstanceStats, VersionWithChannels, WorkflowSchemaV1, addPrefixToRelative, applyFoldersMove, applyFoldersRemoval, asFolderId, blockPackIdEquals, blockPackIdNoVersionEquals, blockPackIdNoVersionToString, blockPackIdToString, blockPackOverviewToLegacy, blockStatusStates, blockStatusStatesRecord, commitFoldersMove, commitFoldersRemoval, decodeFoldersDocument, decodeStoredFoldersDocument, emptyFoldersDocument, encodeFoldersDocument, foldersChildren, foldersDocumentFromView, foldersMovePlansEqual, foldersNameBlank, foldersNameTaken, foldersRemovalsEqual, foldersSiblingNames, foldersSubtree, foldersUniqueName, foldersViewFromDocument, formatFoldersViolation, hashJson, healFolders, inheritedFolder, isTerminalBlockStatusState, mapRemoteToAbsolute, normalizeDescription, normalizeProjectMeta, overrideDescriptionVersion, overrideManifestVersion, planFoldersMove, planFoldersRemoval, readJson, readJsonSync, validateFoldersDocument };
|
package/dist/instance_stats.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/instance_stats.ts
|
|
2
2
|
/** Stats for a backend without the instance statistics context. */
|
|
3
|
-
const UnsupportedInstanceStats = {
|
|
3
|
+
const UnsupportedInstanceStats = { status: "unsupported" };
|
|
4
4
|
exports.UnsupportedInstanceStats = UnsupportedInstanceStats;
|
|
5
5
|
|
|
6
6
|
//# sourceMappingURL=instance_stats.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instance_stats.cjs","names":[],"sources":["../src/instance_stats.ts"],"sourcesContent":["/**\n * The load of the whole Platforma instance, as the Desktop App shows it in its top bar.\n *\n * The backend keeps one instance statistics context per instance, and its executor runner writes\n * the scheduler's readings into it every few seconds. The middle layer reads them; the numbers are\n * what the scheduler has allocated, not measured use.\n */\n\n/** CPU or RAM: what is allocated now, out of the configured capacity when the backend knows it. */\nexport type InstanceStatsCapacity = {\n /** Configured capacity, undefined when the source does not know it. */\n readonly total?: number;\n /** Allocated now. Can exceed `total`: local CPU can be overcommitted. */\n readonly current: number;\n};\n\n/**
|
|
1
|
+
{"version":3,"file":"instance_stats.cjs","names":[],"sources":["../src/instance_stats.ts"],"sourcesContent":["/**\n * The load of the whole Platforma instance, as the Desktop App shows it in its top bar.\n *\n * The backend keeps one instance statistics context per instance, and its executor runner writes\n * the scheduler's readings into it every few seconds. The middle layer reads them; the numbers are\n * what the scheduler has allocated, not measured use.\n */\n\n/** CPU or RAM: what is allocated now, out of the configured capacity when the backend knows it. */\nexport type InstanceStatsCapacity = {\n /** Configured capacity, undefined when the source does not know it. */\n readonly total?: number;\n /** Allocated now. Can exceed `total`: local CPU can be overcommitted. */\n readonly current: number;\n};\n\n/** Whether the stats were read, and why they carry no numbers when not. */\nexport type InstanceStatsStatus =\n /** Read from the instance statistics context. */\n | \"ok\"\n /** The backend has no instance statistics context. */\n | \"unsupported\"\n /** The context exists but could not be read. */\n | \"unreadable\";\n\n/** One sample of the instance statistics. */\nexport type InstanceStats = {\n readonly status: InstanceStatsStatus;\n /** In millicores. */\n readonly cpu?: InstanceStatsCapacity;\n /** In bytes. */\n readonly ram?: InstanceStatsCapacity;\n /**\n * GPUs. On Kueue, devices held by jobs out of the quota. Locally, jobs that use a GPU on the\n * detected cards; jobs share cards, so `current` can exceed `total`. Undefined when no GPU count\n * is known: a local install without a GPU, or Kubernetes without a GPU pool.\n */\n readonly gpu?: InstanceStatsCapacity;\n /** GPU memory allocated to jobs, in bytes. Set only on a local install with a detected GPU. */\n readonly gpuMemory?: InstanceStatsCapacity;\n /** Jobs holding an allocation, and jobs waiting for one. */\n readonly jobs?: { readonly running: number; readonly queued: number };\n /** Where the numbers come from, `scheduler` or `kueue`. A label only. */\n readonly source?: string;\n};\n\n/** Stats for a backend without the instance statistics context. */\nexport const UnsupportedInstanceStats: InstanceStats = { status: \"unsupported\" };\n"],"mappings":";;AA+CA,MAAa,2BAA0C,EAAE,QAAQ,cAAc"}
|
package/dist/instance_stats.d.ts
CHANGED
|
@@ -12,17 +12,17 @@ export type InstanceStatsCapacity = {
|
|
|
12
12
|
/** Allocated now. Can exceed `total`: local CPU can be overcommitted. */
|
|
13
13
|
readonly current: number;
|
|
14
14
|
};
|
|
15
|
-
/**
|
|
16
|
-
export type
|
|
15
|
+
/** Whether the stats were read, and why they carry no numbers when not. */
|
|
16
|
+
export type InstanceStatsStatus =
|
|
17
17
|
/** Read from the instance statistics context. */
|
|
18
|
-
"
|
|
18
|
+
"ok" |
|
|
19
19
|
/** The backend has no instance statistics context. */
|
|
20
20
|
"unsupported" |
|
|
21
21
|
/** The context exists but could not be read. */
|
|
22
22
|
"unreadable";
|
|
23
23
|
/** One sample of the instance statistics. */
|
|
24
24
|
export type InstanceStats = {
|
|
25
|
-
readonly
|
|
25
|
+
readonly status: InstanceStatsStatus;
|
|
26
26
|
/** In millicores. */
|
|
27
27
|
readonly cpu?: InstanceStatsCapacity;
|
|
28
28
|
/** In bytes. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instance_stats.d.ts","names":[],"sources":["../src/instance_stats.ts"],"mappings":";;;;;;;;YASY;;WAED;;WAEA;;;YAIC;;;;;;;;YASA;WACD,
|
|
1
|
+
{"version":3,"file":"instance_stats.d.ts","names":[],"sources":["../src/instance_stats.ts"],"mappings":";;;;;;;;YASY;;WAED;;WAEA;;;YAIC;;;;;;;;YASA;WACD,QAAQ;;WAER,MAAM;;WAEN,MAAM;;;;;;WAMN,MAAM;;WAEN,YAAY;;WAEZ;aAAkB;aAA0B;;;WAE5C;;;qBAIE,0BAA0B"}
|
package/dist/instance_stats.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/instance_stats.ts
|
|
2
2
|
/** Stats for a backend without the instance statistics context. */
|
|
3
|
-
const UnsupportedInstanceStats = {
|
|
3
|
+
const UnsupportedInstanceStats = { status: "unsupported" };
|
|
4
4
|
export { UnsupportedInstanceStats };
|
|
5
5
|
|
|
6
6
|
//# sourceMappingURL=instance_stats.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instance_stats.js","names":[],"sources":["../src/instance_stats.ts"],"sourcesContent":["/**\n * The load of the whole Platforma instance, as the Desktop App shows it in its top bar.\n *\n * The backend keeps one instance statistics context per instance, and its executor runner writes\n * the scheduler's readings into it every few seconds. The middle layer reads them; the numbers are\n * what the scheduler has allocated, not measured use.\n */\n\n/** CPU or RAM: what is allocated now, out of the configured capacity when the backend knows it. */\nexport type InstanceStatsCapacity = {\n /** Configured capacity, undefined when the source does not know it. */\n readonly total?: number;\n /** Allocated now. Can exceed `total`: local CPU can be overcommitted. */\n readonly current: number;\n};\n\n/**
|
|
1
|
+
{"version":3,"file":"instance_stats.js","names":[],"sources":["../src/instance_stats.ts"],"sourcesContent":["/**\n * The load of the whole Platforma instance, as the Desktop App shows it in its top bar.\n *\n * The backend keeps one instance statistics context per instance, and its executor runner writes\n * the scheduler's readings into it every few seconds. The middle layer reads them; the numbers are\n * what the scheduler has allocated, not measured use.\n */\n\n/** CPU or RAM: what is allocated now, out of the configured capacity when the backend knows it. */\nexport type InstanceStatsCapacity = {\n /** Configured capacity, undefined when the source does not know it. */\n readonly total?: number;\n /** Allocated now. Can exceed `total`: local CPU can be overcommitted. */\n readonly current: number;\n};\n\n/** Whether the stats were read, and why they carry no numbers when not. */\nexport type InstanceStatsStatus =\n /** Read from the instance statistics context. */\n | \"ok\"\n /** The backend has no instance statistics context. */\n | \"unsupported\"\n /** The context exists but could not be read. */\n | \"unreadable\";\n\n/** One sample of the instance statistics. */\nexport type InstanceStats = {\n readonly status: InstanceStatsStatus;\n /** In millicores. */\n readonly cpu?: InstanceStatsCapacity;\n /** In bytes. */\n readonly ram?: InstanceStatsCapacity;\n /**\n * GPUs. On Kueue, devices held by jobs out of the quota. Locally, jobs that use a GPU on the\n * detected cards; jobs share cards, so `current` can exceed `total`. Undefined when no GPU count\n * is known: a local install without a GPU, or Kubernetes without a GPU pool.\n */\n readonly gpu?: InstanceStatsCapacity;\n /** GPU memory allocated to jobs, in bytes. Set only on a local install with a detected GPU. */\n readonly gpuMemory?: InstanceStatsCapacity;\n /** Jobs holding an allocation, and jobs waiting for one. */\n readonly jobs?: { readonly running: number; readonly queued: number };\n /** Where the numbers come from, `scheduler` or `kueue`. A label only. */\n readonly source?: string;\n};\n\n/** Stats for a backend without the instance statistics context. */\nexport const UnsupportedInstanceStats: InstanceStats = { status: \"unsupported\" };\n"],"mappings":";;AA+CA,MAAa,2BAA0C,EAAE,QAAQ,cAAc"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-model-middle-layer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.38.0",
|
|
4
4
|
"description": "Common model between middle layer and non-block UI code",
|
|
5
5
|
"files": [
|
|
6
6
|
"./dist/**/*",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@milaboratories/helpers": "1.14.7",
|
|
21
|
-
"@milaboratories/pl-model-common": "1.55.
|
|
21
|
+
"@milaboratories/pl-model-common": "1.55.2",
|
|
22
22
|
"es-toolkit": "^1.39.10",
|
|
23
23
|
"utility-types": "^3.11.0",
|
|
24
24
|
"zod": "~3.25.76"
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The status of a running block, as the middle layer hands it to the Desktop App.
|
|
3
|
+
*
|
|
4
|
+
* The backend keeps a tree of status contexts, one per render, and writes each reporter's
|
|
5
|
+
* transitions into the context of the render it belongs to. The middle layer folds that tree into
|
|
6
|
+
* a {@link BlockStatusSummary}.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The node states this build knows, spelled as the backend and the workflow SDK write them into a
|
|
11
|
+
* transition value. The names match `plapi.ActionState` on the backend and `STATES` in
|
|
12
|
+
* workflow-tengo's action-context library.
|
|
13
|
+
*
|
|
14
|
+
* The backend owns the list: a reporter may write a state added after this release, and the middle
|
|
15
|
+
* layer passes it on as written. Only the lifecycle (`Completed`, `Terminated`, and `Running`
|
|
16
|
+
* reported by a command) carries meaning in the fold; the rest exists for the user.
|
|
17
|
+
*/
|
|
18
|
+
export const blockStatusStatesRecord = {
|
|
19
|
+
WaitingForInputs: "WaitingForInputs",
|
|
20
|
+
Running: "Running",
|
|
21
|
+
WaitingWorkdirGate: "WaitingWorkdirGate",
|
|
22
|
+
WaitingSubmissionGate: "WaitingSubmissionGate",
|
|
23
|
+
PopulatingWorkdir: "PopulatingWorkdir",
|
|
24
|
+
CollectingOutputs: "CollectingOutputs",
|
|
25
|
+
WaitingForScheduler: "WaitingForScheduler",
|
|
26
|
+
WaitingForMachine: "WaitingForMachine",
|
|
27
|
+
Terminated: "Terminated",
|
|
28
|
+
Completed: "Completed",
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
/** Every state, in the order above. */
|
|
32
|
+
export const blockStatusStates = Object.values(blockStatusStatesRecord);
|
|
33
|
+
|
|
34
|
+
/** A node state name this build knows, e.g. `"PopulatingWorkdir"`. */
|
|
35
|
+
export type BlockStatusState = (typeof blockStatusStates)[number];
|
|
36
|
+
|
|
37
|
+
/** True for a state a node cannot leave. */
|
|
38
|
+
export function isTerminalBlockStatusState(state: string): boolean {
|
|
39
|
+
return (
|
|
40
|
+
state === blockStatusStatesRecord.Terminated || state === blockStatusStatesRecord.Completed
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Jobs held by one state: the transition holding each of them has this namespace and state. */
|
|
45
|
+
export type BlockStatusJobGroup = {
|
|
46
|
+
/** Who reported the state: `exec` for a command, `workdir` for its work folder, `render`. */
|
|
47
|
+
readonly namespace: string;
|
|
48
|
+
/** As the reporter wrote it, which can be a state this build does not know. */
|
|
49
|
+
readonly state: string;
|
|
50
|
+
readonly count: number;
|
|
51
|
+
/** When the earliest of them entered the state, ms since the epoch. */
|
|
52
|
+
readonly since?: number;
|
|
53
|
+
/** Files done and all, summed over the jobs whose work folders report their progress. */
|
|
54
|
+
readonly files?: { readonly done: number; readonly total: number };
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The block's jobs: the commands it runs on a machine, each counted once by where it is now.
|
|
59
|
+
*
|
|
60
|
+
* A job is a context that a command or its work folder reports in. Jobs the run has not created yet
|
|
61
|
+
* are not counted, so `total` grows while the run fans out.
|
|
62
|
+
*/
|
|
63
|
+
export type BlockStatusJobs = {
|
|
64
|
+
readonly total: number;
|
|
65
|
+
readonly done: number;
|
|
66
|
+
/**
|
|
67
|
+
* Jobs that failed, and renders that failed on their own (not by passing up a failure under
|
|
68
|
+
* them), e.g. one whose command could not start.
|
|
69
|
+
*/
|
|
70
|
+
readonly failed: number;
|
|
71
|
+
/** The jobs not ended, by the state holding each, largest group first. */
|
|
72
|
+
readonly byState: readonly BlockStatusJobGroup[];
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** Why a summary carries no counters. */
|
|
76
|
+
export type BlockStatusAvailability =
|
|
77
|
+
/** The tree was read and the run has reported what the summary holds. */
|
|
78
|
+
| "read"
|
|
79
|
+
/** The context could not be read: it is gone, or reading it raised. The counters are unknown,
|
|
80
|
+
* which is not the same as a run that has reported nothing. */
|
|
81
|
+
| "unreadable"
|
|
82
|
+
/** The backend cannot take the `actionContext` link, so no context is created and nothing is
|
|
83
|
+
* ever reported. */
|
|
84
|
+
| "unsupported";
|
|
85
|
+
|
|
86
|
+
/** The status of one block run, folded from its status-context tree. */
|
|
87
|
+
export type BlockStatusSummary = {
|
|
88
|
+
/** Whether the counters below describe the run, or could not be read at all. */
|
|
89
|
+
readonly availability: BlockStatusAvailability;
|
|
90
|
+
/** The block's own `run-id`: two clicks of Run give two different values. */
|
|
91
|
+
readonly runId?: string;
|
|
92
|
+
/** Action contexts that have not ended. */
|
|
93
|
+
readonly activeContexts: number;
|
|
94
|
+
/** Every action context of the run, active or ended. */
|
|
95
|
+
readonly totalContexts: number;
|
|
96
|
+
/** The run's jobs, counted apart from the template renders that only prepare them. */
|
|
97
|
+
readonly jobs: BlockStatusJobs;
|
|
98
|
+
/** The first transition anywhere in the tree, ms since the epoch. */
|
|
99
|
+
readonly startedAt?: number;
|
|
100
|
+
/** The most recent transition anywhere in the tree, ms since the epoch. */
|
|
101
|
+
readonly lastChangeAt?: number;
|
|
102
|
+
/**
|
|
103
|
+
* True once the root render has ended and nothing in the tree is still running, or once a render
|
|
104
|
+
* failed and no job is still working.
|
|
105
|
+
*/
|
|
106
|
+
readonly done: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Set when any render of the run terminated: the innermost message of the earliest one's reason,
|
|
109
|
+
* one line, empty when it gave none. The full reason stays on the node's transitions. Commands
|
|
110
|
+
* that fail are counted in {@link BlockStatusJobs.failed} instead.
|
|
111
|
+
*/
|
|
112
|
+
readonly failure?: string;
|
|
113
|
+
/**
|
|
114
|
+
* True when the user stopped the run. The tree is kept as it was when it stopped, so the counters
|
|
115
|
+
* say where each node was, but nothing in it runs any more.
|
|
116
|
+
*/
|
|
117
|
+
readonly cancelled?: boolean;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/** No jobs yet. */
|
|
121
|
+
export const EmptyBlockStatusJobs: BlockStatusJobs = {
|
|
122
|
+
total: 0,
|
|
123
|
+
done: 0,
|
|
124
|
+
failed: 0,
|
|
125
|
+
byState: [],
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/** A summary for a block whose run has not reported anything yet. */
|
|
129
|
+
export const EmptyBlockStatusSummary: BlockStatusSummary = {
|
|
130
|
+
availability: "read",
|
|
131
|
+
activeContexts: 0,
|
|
132
|
+
totalContexts: 0,
|
|
133
|
+
jobs: EmptyBlockStatusJobs,
|
|
134
|
+
done: false,
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/** A summary for a context that could not be read; its counters are unknown, not zero. */
|
|
138
|
+
export const UnreadableBlockStatusSummary: BlockStatusSummary = {
|
|
139
|
+
...EmptyBlockStatusSummary,
|
|
140
|
+
availability: "unreadable",
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/** A summary for a backend that does not accept status reports. */
|
|
144
|
+
export const UnsupportedBlockStatusSummary: BlockStatusSummary = {
|
|
145
|
+
...EmptyBlockStatusSummary,
|
|
146
|
+
availability: "unsupported",
|
|
147
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./author_marker";
|
|
|
2
2
|
export * from "./block_settings";
|
|
3
3
|
export * from "./block_state";
|
|
4
4
|
export * from "./instance_stats";
|
|
5
|
+
export * from "./block_status";
|
|
5
6
|
export * from "./project";
|
|
6
7
|
export * from "./project_list";
|
|
7
8
|
export * from "./project_overview";
|
package/src/instance_stats.ts
CHANGED
|
@@ -14,10 +14,10 @@ export type InstanceStatsCapacity = {
|
|
|
14
14
|
readonly current: number;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
export type
|
|
17
|
+
/** Whether the stats were read, and why they carry no numbers when not. */
|
|
18
|
+
export type InstanceStatsStatus =
|
|
19
19
|
/** Read from the instance statistics context. */
|
|
20
|
-
| "
|
|
20
|
+
| "ok"
|
|
21
21
|
/** The backend has no instance statistics context. */
|
|
22
22
|
| "unsupported"
|
|
23
23
|
/** The context exists but could not be read. */
|
|
@@ -25,7 +25,7 @@ export type InstanceStatsAvailability =
|
|
|
25
25
|
|
|
26
26
|
/** One sample of the instance statistics. */
|
|
27
27
|
export type InstanceStats = {
|
|
28
|
-
readonly
|
|
28
|
+
readonly status: InstanceStatsStatus;
|
|
29
29
|
/** In millicores. */
|
|
30
30
|
readonly cpu?: InstanceStatsCapacity;
|
|
31
31
|
/** In bytes. */
|
|
@@ -45,4 +45,4 @@ export type InstanceStats = {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
/** Stats for a backend without the instance statistics context. */
|
|
48
|
-
export const UnsupportedInstanceStats: InstanceStats = {
|
|
48
|
+
export const UnsupportedInstanceStats: InstanceStats = { status: "unsupported" };
|