@fnndsc/cumin 3.2.4
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/LICENSE +21 -0
- package/README.md +78 -0
- package/dist/activities/chrisActivity.d.ts +19 -0
- package/dist/activities/chrisActivity.js +29 -0
- package/dist/activities/chrisActivity.js.map +1 -0
- package/dist/cache/index.d.ts +9 -0
- package/dist/cache/index.js +15 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/listCache.d.ts +182 -0
- package/dist/cache/listCache.js +266 -0
- package/dist/cache/listCache.js.map +1 -0
- package/dist/cache/procCache.d.ts +150 -0
- package/dist/cache/procCache.js +257 -0
- package/dist/cache/procCache.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +43 -0
- package/dist/cli.js.map +1 -0
- package/dist/compute/computeResources.d.ts +65 -0
- package/dist/compute/computeResources.js +113 -0
- package/dist/compute/computeResources.js.map +1 -0
- package/dist/config/config.d.ts +221 -0
- package/dist/config/config.js +350 -0
- package/dist/config/config.js.map +1 -0
- package/dist/connect/chrisConnection.d.ts +121 -0
- package/dist/connect/chrisConnection.js +303 -0
- package/dist/connect/chrisConnection.js.map +1 -0
- package/dist/context/chrisContext.d.ts +110 -0
- package/dist/context/chrisContext.js +324 -0
- package/dist/context/chrisContext.js.map +1 -0
- package/dist/error/errorStack.d.ts +115 -0
- package/dist/error/errorStack.js +175 -0
- package/dist/error/errorStack.js.map +1 -0
- package/dist/feeds/chrisFeed.d.ts +188 -0
- package/dist/feeds/chrisFeed.js +432 -0
- package/dist/feeds/chrisFeed.js.map +1 -0
- package/dist/filebrowser/chrisFileBrowser.d.ts +77 -0
- package/dist/filebrowser/chrisFileBrowser.js +134 -0
- package/dist/filebrowser/chrisFileBrowser.js.map +1 -0
- package/dist/filebrowser/chrisFiles.d.ts +67 -0
- package/dist/filebrowser/chrisFiles.js +130 -0
- package/dist/filebrowser/chrisFiles.js.map +1 -0
- package/dist/filebrowser/chrisPACS.d.ts +43 -0
- package/dist/filebrowser/chrisPACS.js +103 -0
- package/dist/filebrowser/chrisPACS.js.map +1 -0
- package/dist/filebrowser/chrisPipeline.d.ts +47 -0
- package/dist/filebrowser/chrisPipeline.js +118 -0
- package/dist/filebrowser/chrisPipeline.js.map +1 -0
- package/dist/groups/chrisGroups.d.ts +11 -0
- package/dist/groups/chrisGroups.js +18 -0
- package/dist/groups/chrisGroups.js.map +1 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.js +86 -0
- package/dist/index.js.map +1 -0
- package/dist/io/browser_io.d.ts +97 -0
- package/dist/io/browser_io.js +149 -0
- package/dist/io/browser_io.js.map +1 -0
- package/dist/io/chrisIO.d.ts +110 -0
- package/dist/io/chrisIO.js +415 -0
- package/dist/io/chrisIO.js.map +1 -0
- package/dist/io/io.d.ts +21 -0
- package/dist/io/io.js +6 -0
- package/dist/io/io.js.map +1 -0
- package/dist/io/node_io.d.ts +30 -0
- package/dist/io/node_io.js +188 -0
- package/dist/io/node_io.js.map +1 -0
- package/dist/jobs/chrisJob.d.ts +43 -0
- package/dist/jobs/chrisJob.js +169 -0
- package/dist/jobs/chrisJob.js.map +1 -0
- package/dist/jobs/index.d.ts +7 -0
- package/dist/jobs/index.js +24 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/jobMonitor.d.ts +46 -0
- package/dist/jobs/jobMonitor.js +102 -0
- package/dist/jobs/jobMonitor.js.map +1 -0
- package/dist/pacs/chrisPACS.d.ts +200 -0
- package/dist/pacs/chrisPACS.js +562 -0
- package/dist/pacs/chrisPACS.js.map +1 -0
- package/dist/path/chrisPath.d.ts +78 -0
- package/dist/path/chrisPath.js +190 -0
- package/dist/path/chrisPath.js.map +1 -0
- package/dist/pipelines/chrisPipeline.d.ts +86 -0
- package/dist/pipelines/chrisPipeline.js +180 -0
- package/dist/pipelines/chrisPipeline.js.map +1 -0
- package/dist/pluginmetas/chrisPluginMetas.d.ts +11 -0
- package/dist/pluginmetas/chrisPluginMetas.js +18 -0
- package/dist/pluginmetas/chrisPluginMetas.js.map +1 -0
- package/dist/plugins/chrisPluginMetaPlugins.d.ts +12 -0
- package/dist/plugins/chrisPluginMetaPlugins.js +19 -0
- package/dist/plugins/chrisPluginMetaPlugins.js.map +1 -0
- package/dist/plugins/chrisPlugins.d.ts +127 -0
- package/dist/plugins/chrisPlugins.js +528 -0
- package/dist/plugins/chrisPlugins.js.map +1 -0
- package/dist/resources/chrisEmbeddedResourceGroup.d.ts +73 -0
- package/dist/resources/chrisEmbeddedResourceGroup.js +148 -0
- package/dist/resources/chrisEmbeddedResourceGroup.js.map +1 -0
- package/dist/resources/chrisObjContext.d.ts +16 -0
- package/dist/resources/chrisObjContext.js +109 -0
- package/dist/resources/chrisObjContext.js.map +1 -0
- package/dist/resources/chrisResourceGroup.d.ts +30 -0
- package/dist/resources/chrisResourceGroup.js +47 -0
- package/dist/resources/chrisResourceGroup.js.map +1 -0
- package/dist/resources/chrisResources.d.ts +163 -0
- package/dist/resources/chrisResources.js +415 -0
- package/dist/resources/chrisResources.js.map +1 -0
- package/dist/tags/chrisTags.d.ts +11 -0
- package/dist/tags/chrisTags.js +18 -0
- package/dist/tags/chrisTags.js.map +1 -0
- package/dist/users/chrisUsers.d.ts +34 -0
- package/dist/users/chrisUsers.js +57 -0
- package/dist/users/chrisUsers.js.map +1 -0
- package/dist/utils/keypair.d.ts +77 -0
- package/dist/utils/keypair.js +144 -0
- package/dist/utils/keypair.js.map +1 -0
- package/dist/utils/result.d.ts +77 -0
- package/dist/utils/result.js +58 -0
- package/dist/utils/result.js.map +1 -0
- package/dist/utils/searchable.d.ts +143 -0
- package/dist/utils/searchable.js +212 -0
- package/dist/utils/searchable.js.map +1 -0
- package/dist/workflows/chrisWorkflows.d.ts +11 -0
- package/dist/workflows/chrisWorkflows.js +18 -0
- package/dist/workflows/chrisWorkflows.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Process Cache
|
|
3
|
+
*
|
|
4
|
+
* Session-scoped cache of ChRIS feed topology. Separates permanent data
|
|
5
|
+
* (instance DAG structure) from volatile data (status — never stored).
|
|
6
|
+
*
|
|
7
|
+
* Design decisions:
|
|
8
|
+
* - Topology (id, feedID, parentID, pluginName) is permanent once written.
|
|
9
|
+
* - Status is always fetched live from the API — never stored here.
|
|
10
|
+
* - Feed job counters (finishedJobs etc.) give aggregate feed status
|
|
11
|
+
* without per-instance API calls.
|
|
12
|
+
* - topologyLoaded distinguishes "loaded but 0 instances" from "not yet loaded".
|
|
13
|
+
* - loading map prevents duplicate API calls when background loader and
|
|
14
|
+
* user navigation race on the same feed.
|
|
15
|
+
* - warmupComplete enables pure in-memory path for proc find <name>.
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Feed-level metadata including job count fields for aggregate status.
|
|
21
|
+
*/
|
|
22
|
+
export interface ProcFeed {
|
|
23
|
+
id: number;
|
|
24
|
+
title: string;
|
|
25
|
+
creationDate: string;
|
|
26
|
+
finishedJobs: number;
|
|
27
|
+
erroredJobs: number;
|
|
28
|
+
startedJobs: number;
|
|
29
|
+
scheduledJobs: number;
|
|
30
|
+
cancelledJobs: number;
|
|
31
|
+
createdJobs: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Topology-only instance entry. Status is never stored — always fetched live.
|
|
35
|
+
*/
|
|
36
|
+
export interface ProcInstance {
|
|
37
|
+
id: number;
|
|
38
|
+
feedID: number;
|
|
39
|
+
/** null for root nodes (direct children of a feed). */
|
|
40
|
+
parentID: number | null;
|
|
41
|
+
pluginName: string;
|
|
42
|
+
/** null until first cat — immutable once populated. */
|
|
43
|
+
params: Record<string, unknown> | null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Warm-up progress counters for the prompt indicator.
|
|
47
|
+
* total is always 0 during global sweep (unknown upfront).
|
|
48
|
+
* active transitions false→true when sweep starts, true→false when done.
|
|
49
|
+
*/
|
|
50
|
+
export interface ProcWarmupProgress {
|
|
51
|
+
loaded: number;
|
|
52
|
+
total: number;
|
|
53
|
+
active: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Session-scoped cache of feed and instance topology.
|
|
57
|
+
* Status is never stored — always fetched live from the API.
|
|
58
|
+
*/
|
|
59
|
+
export declare class ProcCache {
|
|
60
|
+
private static _instance;
|
|
61
|
+
private feeds;
|
|
62
|
+
private instances;
|
|
63
|
+
private feedRoots;
|
|
64
|
+
private children;
|
|
65
|
+
/** Feed IDs whose instance topology has been fully fetched. */
|
|
66
|
+
private topologyLoaded;
|
|
67
|
+
/** In-flight topology fetch promises — prevents duplicate API calls. */
|
|
68
|
+
private loading;
|
|
69
|
+
/** True when background warm-up has finished all feeds. */
|
|
70
|
+
private _warmupComplete;
|
|
71
|
+
private _warmupProgress;
|
|
72
|
+
/** Whether initial feed index has been built. */
|
|
73
|
+
private _built;
|
|
74
|
+
private constructor();
|
|
75
|
+
static instance_get(): ProcCache;
|
|
76
|
+
get built(): boolean;
|
|
77
|
+
get warmupComplete(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Adds or updates a feed entry.
|
|
80
|
+
*/
|
|
81
|
+
feed_add(feed: ProcFeed): void;
|
|
82
|
+
feed_get(feedID: number): ProcFeed | undefined;
|
|
83
|
+
feedIDs_get(): number[];
|
|
84
|
+
feedRoots_get(feedID: number): number[];
|
|
85
|
+
/**
|
|
86
|
+
* Removes a feed and all its instances from the cache.
|
|
87
|
+
*/
|
|
88
|
+
feed_remove(feedID: number): void;
|
|
89
|
+
/**
|
|
90
|
+
* Adds a plugin instance to the topology cache.
|
|
91
|
+
*/
|
|
92
|
+
instance_add(inst: ProcInstance): void;
|
|
93
|
+
instance_get(id: number): ProcInstance | undefined;
|
|
94
|
+
instances_count(): number;
|
|
95
|
+
instancesForFeed_count(feedID: number): number;
|
|
96
|
+
children_get(parentID: number): number[];
|
|
97
|
+
/**
|
|
98
|
+
* Removes an instance from the topology cache.
|
|
99
|
+
*/
|
|
100
|
+
instance_remove(id: number): void;
|
|
101
|
+
/**
|
|
102
|
+
* Updates cached params for an instance (on first cat).
|
|
103
|
+
*/
|
|
104
|
+
params_update(id: number, params: Record<string, unknown>): void;
|
|
105
|
+
topologyLoaded_mark(feedID: number): void;
|
|
106
|
+
topologyLoaded_has(feedID: number): boolean;
|
|
107
|
+
loading_set(feedID: number, promise: Promise<void>): void;
|
|
108
|
+
loading_get(feedID: number): Promise<void> | undefined;
|
|
109
|
+
loading_clear(feedID: number): void;
|
|
110
|
+
warmup_complete(): void;
|
|
111
|
+
warmup_progress(loaded: number, total: number): void;
|
|
112
|
+
warmupProgress_get(): ProcWarmupProgress;
|
|
113
|
+
/**
|
|
114
|
+
* Reconstructs the full /proc/jobs path for a given instance ID.
|
|
115
|
+
*
|
|
116
|
+
* @param id - Instance ID.
|
|
117
|
+
* @returns Full path string, or null if instance not in cache.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* cache.path_build(64306)
|
|
122
|
+
* // '/proc/jobs/feed_1107/pl-dircopy_64267/.../pl-neurofiles-push_64306'
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
path_build(id: number): string | null;
|
|
126
|
+
/**
|
|
127
|
+
* Searches cached feeds by title substring (case-insensitive).
|
|
128
|
+
*/
|
|
129
|
+
feeds_find(term: string): ProcFeed[];
|
|
130
|
+
/**
|
|
131
|
+
* Searches cached instances by numeric ID or plugin name substring.
|
|
132
|
+
*/
|
|
133
|
+
instances_find(term: string): ProcInstance[];
|
|
134
|
+
built_set(): void;
|
|
135
|
+
/**
|
|
136
|
+
* Clears all cache data. Called before a full rebuild.
|
|
137
|
+
*/
|
|
138
|
+
cache_clear(): void;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Returns the singleton ProcCache instance.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* const cache = procCache_get();
|
|
146
|
+
* cache.instance_add({ id: 789, feedID: 123, parentID: 456,
|
|
147
|
+
* pluginName: 'pl-fshack', params: null });
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export declare function procCache_get(): ProcCache;
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Process Cache
|
|
4
|
+
*
|
|
5
|
+
* Session-scoped cache of ChRIS feed topology. Separates permanent data
|
|
6
|
+
* (instance DAG structure) from volatile data (status — never stored).
|
|
7
|
+
*
|
|
8
|
+
* Design decisions:
|
|
9
|
+
* - Topology (id, feedID, parentID, pluginName) is permanent once written.
|
|
10
|
+
* - Status is always fetched live from the API — never stored here.
|
|
11
|
+
* - Feed job counters (finishedJobs etc.) give aggregate feed status
|
|
12
|
+
* without per-instance API calls.
|
|
13
|
+
* - topologyLoaded distinguishes "loaded but 0 instances" from "not yet loaded".
|
|
14
|
+
* - loading map prevents duplicate API calls when background loader and
|
|
15
|
+
* user navigation race on the same feed.
|
|
16
|
+
* - warmupComplete enables pure in-memory path for proc find <name>.
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.ProcCache = void 0;
|
|
22
|
+
exports.procCache_get = procCache_get;
|
|
23
|
+
/**
|
|
24
|
+
* Session-scoped cache of feed and instance topology.
|
|
25
|
+
* Status is never stored — always fetched live from the API.
|
|
26
|
+
*/
|
|
27
|
+
class ProcCache {
|
|
28
|
+
constructor() {
|
|
29
|
+
this.feeds = new Map();
|
|
30
|
+
this.instances = new Map();
|
|
31
|
+
this.feedRoots = new Map();
|
|
32
|
+
this.children = new Map();
|
|
33
|
+
/** Feed IDs whose instance topology has been fully fetched. */
|
|
34
|
+
this.topologyLoaded = new Set();
|
|
35
|
+
/** In-flight topology fetch promises — prevents duplicate API calls. */
|
|
36
|
+
this.loading = new Map();
|
|
37
|
+
/** True when background warm-up has finished all feeds. */
|
|
38
|
+
this._warmupComplete = false;
|
|
39
|
+
this._warmupProgress = { loaded: 0, total: 0, active: false };
|
|
40
|
+
/** Whether initial feed index has been built. */
|
|
41
|
+
this._built = false;
|
|
42
|
+
}
|
|
43
|
+
static instance_get() {
|
|
44
|
+
if (!ProcCache._instance) {
|
|
45
|
+
ProcCache._instance = new ProcCache();
|
|
46
|
+
}
|
|
47
|
+
return ProcCache._instance;
|
|
48
|
+
}
|
|
49
|
+
get built() { return this._built; }
|
|
50
|
+
get warmupComplete() { return this._warmupComplete; }
|
|
51
|
+
// ── Feed ──────────────────────────────────────────────────────────────────
|
|
52
|
+
/**
|
|
53
|
+
* Adds or updates a feed entry.
|
|
54
|
+
*/
|
|
55
|
+
feed_add(feed) {
|
|
56
|
+
this.feeds.set(feed.id, feed);
|
|
57
|
+
if (!this.feedRoots.has(feed.id)) {
|
|
58
|
+
this.feedRoots.set(feed.id, []);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
feed_get(feedID) {
|
|
62
|
+
return this.feeds.get(feedID);
|
|
63
|
+
}
|
|
64
|
+
feedIDs_get() {
|
|
65
|
+
return Array.from(this.feeds.keys());
|
|
66
|
+
}
|
|
67
|
+
feedRoots_get(feedID) {
|
|
68
|
+
return this.feedRoots.get(feedID) ?? [];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Removes a feed and all its instances from the cache.
|
|
72
|
+
*/
|
|
73
|
+
feed_remove(feedID) {
|
|
74
|
+
this.feeds.delete(feedID);
|
|
75
|
+
this.topologyLoaded.delete(feedID);
|
|
76
|
+
const allInstances = Array.from(this.instances.values())
|
|
77
|
+
.filter((i) => i.feedID === feedID);
|
|
78
|
+
for (const inst of allInstances) {
|
|
79
|
+
this.instance_remove(inst.id);
|
|
80
|
+
}
|
|
81
|
+
this.feedRoots.delete(feedID);
|
|
82
|
+
}
|
|
83
|
+
// ── Instance ──────────────────────────────────────────────────────────────
|
|
84
|
+
/**
|
|
85
|
+
* Adds a plugin instance to the topology cache.
|
|
86
|
+
*/
|
|
87
|
+
instance_add(inst) {
|
|
88
|
+
this.instances.set(inst.id, inst);
|
|
89
|
+
if (inst.parentID === null) {
|
|
90
|
+
const roots = this.feedRoots.get(inst.feedID) ?? [];
|
|
91
|
+
if (!roots.includes(inst.id)) {
|
|
92
|
+
roots.push(inst.id);
|
|
93
|
+
this.feedRoots.set(inst.feedID, roots);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
const kids = this.children.get(inst.parentID) ?? [];
|
|
98
|
+
if (!kids.includes(inst.id)) {
|
|
99
|
+
kids.push(inst.id);
|
|
100
|
+
this.children.set(inst.parentID, kids);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
instance_get(id) {
|
|
105
|
+
return this.instances.get(id);
|
|
106
|
+
}
|
|
107
|
+
instances_count() {
|
|
108
|
+
return this.instances.size;
|
|
109
|
+
}
|
|
110
|
+
instancesForFeed_count(feedID) {
|
|
111
|
+
let n = 0;
|
|
112
|
+
for (const inst of this.instances.values()) {
|
|
113
|
+
if (inst.feedID === feedID)
|
|
114
|
+
n++;
|
|
115
|
+
}
|
|
116
|
+
return n;
|
|
117
|
+
}
|
|
118
|
+
children_get(parentID) {
|
|
119
|
+
return this.children.get(parentID) ?? [];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Removes an instance from the topology cache.
|
|
123
|
+
*/
|
|
124
|
+
instance_remove(id) {
|
|
125
|
+
const inst = this.instances.get(id);
|
|
126
|
+
if (!inst)
|
|
127
|
+
return;
|
|
128
|
+
this.instances.delete(id);
|
|
129
|
+
if (inst.parentID === null) {
|
|
130
|
+
const roots = this.feedRoots.get(inst.feedID) ?? [];
|
|
131
|
+
this.feedRoots.set(inst.feedID, roots.filter((r) => r !== id));
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
const kids = this.children.get(inst.parentID) ?? [];
|
|
135
|
+
this.children.set(inst.parentID, kids.filter((k) => k !== id));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Updates cached params for an instance (on first cat).
|
|
140
|
+
*/
|
|
141
|
+
params_update(id, params) {
|
|
142
|
+
const inst = this.instances.get(id);
|
|
143
|
+
if (inst)
|
|
144
|
+
inst.params = params;
|
|
145
|
+
}
|
|
146
|
+
// ── Topology loaded tracking ───────────────────────────────────────────────
|
|
147
|
+
topologyLoaded_mark(feedID) {
|
|
148
|
+
this.topologyLoaded.add(feedID);
|
|
149
|
+
}
|
|
150
|
+
topologyLoaded_has(feedID) {
|
|
151
|
+
return this.topologyLoaded.has(feedID);
|
|
152
|
+
}
|
|
153
|
+
// ── In-flight map ─────────────────────────────────────────────────────────
|
|
154
|
+
loading_set(feedID, promise) {
|
|
155
|
+
this.loading.set(feedID, promise);
|
|
156
|
+
}
|
|
157
|
+
loading_get(feedID) {
|
|
158
|
+
return this.loading.get(feedID);
|
|
159
|
+
}
|
|
160
|
+
loading_clear(feedID) {
|
|
161
|
+
this.loading.delete(feedID);
|
|
162
|
+
}
|
|
163
|
+
// ── Warm-up state ─────────────────────────────────────────────────────────
|
|
164
|
+
warmup_complete() {
|
|
165
|
+
this._warmupComplete = true;
|
|
166
|
+
this._warmupProgress = { loaded: this._warmupProgress.loaded, total: 0, active: false };
|
|
167
|
+
}
|
|
168
|
+
warmup_progress(loaded, total) {
|
|
169
|
+
this._warmupProgress = { loaded, total, active: true };
|
|
170
|
+
}
|
|
171
|
+
warmupProgress_get() {
|
|
172
|
+
return { ...this._warmupProgress };
|
|
173
|
+
}
|
|
174
|
+
// ── Path reconstruction ───────────────────────────────────────────────────
|
|
175
|
+
/**
|
|
176
|
+
* Reconstructs the full /proc/jobs path for a given instance ID.
|
|
177
|
+
*
|
|
178
|
+
* @param id - Instance ID.
|
|
179
|
+
* @returns Full path string, or null if instance not in cache.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* cache.path_build(64306)
|
|
184
|
+
* // '/proc/jobs/feed_1107/pl-dircopy_64267/.../pl-neurofiles-push_64306'
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
path_build(id) {
|
|
188
|
+
const inst = this.instances.get(id);
|
|
189
|
+
if (!inst)
|
|
190
|
+
return null;
|
|
191
|
+
const segments = [];
|
|
192
|
+
let current = inst;
|
|
193
|
+
while (current) {
|
|
194
|
+
segments.unshift(`${current.pluginName}_${current.id}`);
|
|
195
|
+
if (current.parentID === null)
|
|
196
|
+
break;
|
|
197
|
+
current = this.instances.get(current.parentID);
|
|
198
|
+
}
|
|
199
|
+
return `/proc/jobs/feed_${inst.feedID}/${segments.join('/')}`;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Searches cached feeds by title substring (case-insensitive).
|
|
203
|
+
*/
|
|
204
|
+
feeds_find(term) {
|
|
205
|
+
const lower = term.toLowerCase();
|
|
206
|
+
return Array.from(this.feeds.values())
|
|
207
|
+
.filter((f) => f.title.toLowerCase().includes(lower));
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Searches cached instances by numeric ID or plugin name substring.
|
|
211
|
+
*/
|
|
212
|
+
instances_find(term) {
|
|
213
|
+
const numeric = parseInt(term, 10);
|
|
214
|
+
const isID = !isNaN(numeric) && String(numeric) === term;
|
|
215
|
+
if (isID) {
|
|
216
|
+
const hit = this.instances.get(numeric);
|
|
217
|
+
return hit ? [hit] : [];
|
|
218
|
+
}
|
|
219
|
+
const lower = term.toLowerCase();
|
|
220
|
+
return Array.from(this.instances.values())
|
|
221
|
+
.filter((i) => i.pluginName.toLowerCase().includes(lower));
|
|
222
|
+
}
|
|
223
|
+
// ── Lifecycle ─────────────────────────────────────────────────────────────
|
|
224
|
+
built_set() {
|
|
225
|
+
this._built = true;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Clears all cache data. Called before a full rebuild.
|
|
229
|
+
*/
|
|
230
|
+
cache_clear() {
|
|
231
|
+
this.feeds.clear();
|
|
232
|
+
this.instances.clear();
|
|
233
|
+
this.feedRoots.clear();
|
|
234
|
+
this.children.clear();
|
|
235
|
+
this.topologyLoaded.clear();
|
|
236
|
+
this.loading.clear();
|
|
237
|
+
this._warmupComplete = false;
|
|
238
|
+
this._warmupProgress = { loaded: 0, total: 0, active: false };
|
|
239
|
+
this._built = false;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
exports.ProcCache = ProcCache;
|
|
243
|
+
ProcCache._instance = null;
|
|
244
|
+
/**
|
|
245
|
+
* Returns the singleton ProcCache instance.
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```typescript
|
|
249
|
+
* const cache = procCache_get();
|
|
250
|
+
* cache.instance_add({ id: 789, feedID: 123, parentID: 456,
|
|
251
|
+
* pluginName: 'pl-fshack', params: null });
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
function procCache_get() {
|
|
255
|
+
return ProcCache.instance_get();
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=procCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procCache.js","sourceRoot":"","sources":["../../src/cache/procCache.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAiTH,sCAEC;AA1QD;;;GAGG;AACH,MAAa,SAAS;IAsBpB;QAnBQ,UAAK,GAA0B,IAAI,GAAG,EAAE,CAAC;QACzC,cAAS,GAA8B,IAAI,GAAG,EAAE,CAAC;QACjD,cAAS,GAA0B,IAAI,GAAG,EAAE,CAAC;QAC7C,aAAQ,GAA0B,IAAI,GAAG,EAAE,CAAC;QAEpD,+DAA+D;QACvD,mBAAc,GAAgB,IAAI,GAAG,EAAE,CAAC;QAEhD,wEAAwE;QAChE,YAAO,GAA+B,IAAI,GAAG,EAAE,CAAC;QAExD,2DAA2D;QACnD,o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C9D,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;;AAvPH,8BAwPC;AAvPgB,mBAAS,GAAqB,IAAI,AAAzB,CAA0B;AAyPpD;;;;;;;;;GASG;AACH,SAAgB,aAAa;IAC3B,OAAO,SAAS,CAAC,YAAY,EAAE,CAAC;AAClC,CAAC"}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* @file Command-line entry point for the cumin utility library.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const figlet_1 = __importDefault(require("figlet"));
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const path_1 = require("path");
|
|
15
|
+
const chrisConnection_1 = require("./connect/chrisConnection");
|
|
16
|
+
const config_1 = require("./config/config");
|
|
17
|
+
const node_io_js_1 = require("./io/node_io.js");
|
|
18
|
+
// Read package.json
|
|
19
|
+
const packageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, "..", "package.json"), "utf-8"));
|
|
20
|
+
const version = packageJson.version;
|
|
21
|
+
/**
|
|
22
|
+
* Main entry point for the cumin CLI.
|
|
23
|
+
* Initializes the connection and prints version/config info.
|
|
24
|
+
*/
|
|
25
|
+
async function main() {
|
|
26
|
+
const nodeStorageProvider = new node_io_js_1.NodeStorageProvider();
|
|
27
|
+
await (0, chrisConnection_1.chrisConnection_init)(nodeStorageProvider);
|
|
28
|
+
console.log(figlet_1.default.textSync("cumin"));
|
|
29
|
+
console.log(" -- CUbe Management INterface --");
|
|
30
|
+
console.log(" == version ", version, "==");
|
|
31
|
+
console.log("\n");
|
|
32
|
+
console.log("Welcome to cumin! Also known as the basis for any good chili.\n\n");
|
|
33
|
+
console.log("Note that cumin isn't really intended to be used as standalone program;");
|
|
34
|
+
console.log("rather, it is a support interface providing useful services especially");
|
|
35
|
+
console.log("the ChILI project.");
|
|
36
|
+
console.log("\n");
|
|
37
|
+
console.log("For this set of configuration values read during initialization,");
|
|
38
|
+
console.log("the authorization token is: ", await chrisConnection_1.chrisConnection.authToken_get());
|
|
39
|
+
console.log("the chris URL is ", await chrisConnection_1.chrisConnection.chrisURL_get());
|
|
40
|
+
console.log(config_1.connectionConfig);
|
|
41
|
+
}
|
|
42
|
+
main().catch(console.error);
|
|
43
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AACA;;;;GAIG;;;;;AAEH,oDAA4B;AAE5B,2BAAkC;AAClC,+BAA4B;AAG5B,+DAAkF;AAClF,4CAAmD;AACnD,gDAAsD;AAOtD,oBAAoB;AACpB,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC5B,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAC7D,CAAC;AACF,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;AAEpC;;;GAGG;AACH,KAAK,UAAU,IAAI;IACjB,MAAM,mBAAmB,GAAwB,IAAI,gCAAmB,EAAE,CAAC;IAC3E,MAAM,IAAA,sCAAoB,EAAC,mBAAmB,CAAC,CAAC;IAEhD,OAAO,CAAC,GAAG,CAAC,gBAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IAChD,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAChD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,CAAC,GAAG,CACT,mEAAmE,CACpE,CAAC;IACF,OAAO,CAAC,GAAG,CACT,yEAAyE,CAC1E,CAAC;IACF,OAAO,CAAC,GAAG,CACT,wEAAwE,CACzE,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAClC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,CAAC,GAAG,CACT,kEAAkE,CACnE,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,8BAA8B,EAAE,MAAM,iCAAe,CAAC,aAAa,EAAE,CAAC,CAAC;IACnF,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,MAAM,iCAAe,CAAC,YAAY,EAAE,CAAC,CAAC;IACvE,OAAO,CAAC,GAAG,CAAC,yBAAgB,CAAC,CAAC;AAChC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Compute Resource Validation and Management
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions for validating and managing compute resources
|
|
5
|
+
* in ChRIS CUBE. Used by plugin registration to ensure compute resources exist
|
|
6
|
+
* before attempting to assign plugins to them.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { ChRISResourceGroup } from '../resources/chrisResourceGroup.js';
|
|
11
|
+
import { Result } from '../utils/result.js';
|
|
12
|
+
/**
|
|
13
|
+
* Group handler for ChRIS compute resources.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ChRISComputeResourceGroup extends ChRISResourceGroup {
|
|
16
|
+
constructor();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Interface representing a compute resource.
|
|
20
|
+
*/
|
|
21
|
+
export interface ComputeResource {
|
|
22
|
+
id: number;
|
|
23
|
+
name: string;
|
|
24
|
+
compute_url: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Validates that specified compute resources exist in ChRIS CUBE.
|
|
30
|
+
*
|
|
31
|
+
* @param resourceNames - Array of compute resource names to validate.
|
|
32
|
+
* @returns A Result containing valid resource names, or Err with available resources in errorStack.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```
|
|
36
|
+
* const result = await computeResources_validate(['host', 'gpu']);
|
|
37
|
+
* if (!result.ok) {
|
|
38
|
+
* // Check errorStack for available resources
|
|
39
|
+
* const errors = errorStack.allOfType_get('error');
|
|
40
|
+
* console.error(errors);
|
|
41
|
+
* return;
|
|
42
|
+
* }
|
|
43
|
+
* // Proceed with valid resources
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function computeResources_validate(resourceNames: string[]): Promise<Result<string[]>>;
|
|
47
|
+
/**
|
|
48
|
+
* Fetches all available compute resources from ChRIS CUBE.
|
|
49
|
+
*
|
|
50
|
+
* @returns A Result containing array of compute resources, or Err on failure.
|
|
51
|
+
*/
|
|
52
|
+
export declare function computeResources_getAll(): Promise<Result<ComputeResource[]>>;
|
|
53
|
+
/**
|
|
54
|
+
* Gets compute resource names from a comma-separated string or array.
|
|
55
|
+
*
|
|
56
|
+
* @param computeInput - Comma-separated string or array of compute resource names.
|
|
57
|
+
* @returns Array of trimmed compute resource names.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```
|
|
61
|
+
* computeResourceNames_parse('host, gpu, remote') // ['host', 'gpu', 'remote']
|
|
62
|
+
* computeResourceNames_parse(['host', 'gpu']) // ['host', 'gpu']
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function computeResourceNames_parse(computeInput: string | string[]): string[];
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Compute Resource Validation and Management
|
|
4
|
+
*
|
|
5
|
+
* This module provides functions for validating and managing compute resources
|
|
6
|
+
* in ChRIS CUBE. Used by plugin registration to ensure compute resources exist
|
|
7
|
+
* before attempting to assign plugins to them.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ChRISComputeResourceGroup = void 0;
|
|
13
|
+
exports.computeResources_validate = computeResources_validate;
|
|
14
|
+
exports.computeResources_getAll = computeResources_getAll;
|
|
15
|
+
exports.computeResourceNames_parse = computeResourceNames_parse;
|
|
16
|
+
const chrisConnection_js_1 = require("../connect/chrisConnection.js");
|
|
17
|
+
const chrisResourceGroup_js_1 = require("../resources/chrisResourceGroup.js");
|
|
18
|
+
const errorStack_js_1 = require("../error/errorStack.js");
|
|
19
|
+
const result_js_1 = require("../utils/result.js");
|
|
20
|
+
/**
|
|
21
|
+
* Group handler for ChRIS compute resources.
|
|
22
|
+
*/
|
|
23
|
+
class ChRISComputeResourceGroup extends chrisResourceGroup_js_1.ChRISResourceGroup {
|
|
24
|
+
constructor() {
|
|
25
|
+
super('ComputeResources', 'getComputeResources');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.ChRISComputeResourceGroup = ChRISComputeResourceGroup;
|
|
29
|
+
/**
|
|
30
|
+
* Validates that specified compute resources exist in ChRIS CUBE.
|
|
31
|
+
*
|
|
32
|
+
* @param resourceNames - Array of compute resource names to validate.
|
|
33
|
+
* @returns A Result containing valid resource names, or Err with available resources in errorStack.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```
|
|
37
|
+
* const result = await computeResources_validate(['host', 'gpu']);
|
|
38
|
+
* if (!result.ok) {
|
|
39
|
+
* // Check errorStack for available resources
|
|
40
|
+
* const errors = errorStack.allOfType_get('error');
|
|
41
|
+
* console.error(errors);
|
|
42
|
+
* return;
|
|
43
|
+
* }
|
|
44
|
+
* // Proceed with valid resources
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
async function computeResources_validate(resourceNames) {
|
|
48
|
+
try {
|
|
49
|
+
const client = await chrisConnection_js_1.chrisConnection.client_get();
|
|
50
|
+
if (!client) {
|
|
51
|
+
errorStack_js_1.errorStack.stack_push('error', 'Not connected to ChRIS. Please log in.');
|
|
52
|
+
return (0, result_js_1.Err)();
|
|
53
|
+
}
|
|
54
|
+
const computeResourceList = await client.getComputeResources();
|
|
55
|
+
const resources = computeResourceList.data || [];
|
|
56
|
+
const availableNames = new Set(resources.map((r) => r.name));
|
|
57
|
+
// Validate requested resources
|
|
58
|
+
const invalidResources = resourceNames.filter((name) => !availableNames.has(name));
|
|
59
|
+
if (invalidResources.length > 0) {
|
|
60
|
+
const availableList = Array.from(availableNames).join(', ');
|
|
61
|
+
errorStack_js_1.errorStack.stack_push('error', `Invalid compute resource(s): ${invalidResources.join(', ')}`);
|
|
62
|
+
errorStack_js_1.errorStack.stack_push('error', `Available compute resources: ${availableList}`);
|
|
63
|
+
return (0, result_js_1.Err)();
|
|
64
|
+
}
|
|
65
|
+
return (0, result_js_1.Ok)(resourceNames);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
69
|
+
errorStack_js_1.errorStack.stack_push('error', `Failed to validate compute resources: ${errorMessage}`);
|
|
70
|
+
return (0, result_js_1.Err)();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Fetches all available compute resources from ChRIS CUBE.
|
|
75
|
+
*
|
|
76
|
+
* @returns A Result containing array of compute resources, or Err on failure.
|
|
77
|
+
*/
|
|
78
|
+
async function computeResources_getAll() {
|
|
79
|
+
try {
|
|
80
|
+
const client = await chrisConnection_js_1.chrisConnection.client_get();
|
|
81
|
+
if (!client) {
|
|
82
|
+
errorStack_js_1.errorStack.stack_push('error', 'Not connected to ChRIS. Please log in.');
|
|
83
|
+
return (0, result_js_1.Err)();
|
|
84
|
+
}
|
|
85
|
+
const computeResourceList = await client.getComputeResources();
|
|
86
|
+
const resources = computeResourceList.data || [];
|
|
87
|
+
return (0, result_js_1.Ok)(resources);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
91
|
+
errorStack_js_1.errorStack.stack_push('error', `Failed to fetch compute resources: ${errorMessage}`);
|
|
92
|
+
return (0, result_js_1.Err)();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Gets compute resource names from a comma-separated string or array.
|
|
97
|
+
*
|
|
98
|
+
* @param computeInput - Comma-separated string or array of compute resource names.
|
|
99
|
+
* @returns Array of trimmed compute resource names.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```
|
|
103
|
+
* computeResourceNames_parse('host, gpu, remote') // ['host', 'gpu', 'remote']
|
|
104
|
+
* computeResourceNames_parse(['host', 'gpu']) // ['host', 'gpu']
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
function computeResourceNames_parse(computeInput) {
|
|
108
|
+
if (Array.isArray(computeInput)) {
|
|
109
|
+
return computeInput.map((name) => name.trim());
|
|
110
|
+
}
|
|
111
|
+
return computeInput.split(',').map((name) => name.trim());
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=computeResources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeResources.js","sourceRoot":"","sources":["../../src/compute/computeResources.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA8CH,8DAqCC;AAOD,0DAiBC;AAcD,gEAKC;AA5HD,sEAAgE;AAEhE,8EAAwE;AACxE,0DAAoD;AACpD,kDAAqD;AAErD;;GAEG;AACH,MAAa,yBAA0B,SAAQ,0CAAkB;IAC/D;QACE,KAAK,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,CAAC;IACnD,CAAC;CACF;AAJD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