CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/util/compute-states.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { defineMessage } from "react-intl";
7
8
import { IntlMessage } from "./i18n/types";
9
10
// Compute related schema stuff (see compute.coffee)
11
//
12
// Here's a picture of the finite state machine defined below:
13
//
14
// ----------[closing] ------- --------- [stopping] <--------
15
// \|/ \|/ |
16
// [archived] <--> [closed] --> [opening] --> [opened] --> [starting] --> [running]
17
//
18
// [unarchiving] [pending]
19
// [archiving]
20
//
21
//
22
// The icon names below refer to font-awesome, and are used in the UI.
23
24
export type State =
25
| "archived"
26
| "archiving"
27
| "closed"
28
| "closing"
29
| "opened"
30
| "opening"
31
| "pending"
32
| "running"
33
| "starting"
34
| "stopping"
35
| "unarchiving";
36
37
// @hsy: completely unclear what this is for.
38
type Operation =
39
| "open"
40
| "archived"
41
| "unarchive"
42
| "start"
43
| "stop"
44
| "close"
45
| "closed";
46
47
export type ComputeState = {
48
desc: IntlMessage; // shows up in the UI (default)
49
desc_cocalccom?: IntlMessage; // if set, use this string instead of desc in "cocalc.com" mode
50
icon: string;
51
display: IntlMessage;
52
stable?: boolean;
53
to: { [key in Operation]?: State };
54
timeout?: number;
55
commands: Readonly<string[]>;
56
};
57
58
type ComputeStates = Readonly<{
59
[key in State]: ComputeState;
60
}>;
61
62
// ATTN: in the frontend, all "display" and "desc" strings are translated in the components/project-state file.
63
64
export const COMPUTE_STATES: ComputeStates = {
65
archived: {
66
desc: defineMessage({
67
id: "util.compute-states.archived.desc",
68
defaultMessage:
69
"Project is stored in longterm storage, and will take even longer to start.",
70
}),
71
icon: "file-archive",
72
display: defineMessage({
73
id: "util.compute-states.archived.display",
74
defaultMessage: "Archived", // displayed name for users
75
}),
76
stable: true,
77
to: {
78
closed: "unarchiving",
79
},
80
commands: ["unarchive"],
81
},
82
83
unarchiving: {
84
desc: defineMessage({
85
id: "util.compute-states.unarchiving.desc",
86
defaultMessage:
87
"Project is being copied from longterm storage; this may take several minutes depending on how many files you have.",
88
}),
89
icon: "download",
90
display: defineMessage({
91
id: "util.compute-states.unarchiving.display",
92
defaultMessage: "Restoring",
93
}),
94
to: {},
95
timeout: 30 * 60,
96
commands: ["status", "mintime"],
97
},
98
99
archiving: {
100
desc: defineMessage({
101
id: "util.compute-states.archiving.desc",
102
defaultMessage: "Project is being archived to longterm storage.",
103
}),
104
icon: "paper-plane",
105
display: defineMessage({
106
id: "util.compute-states.archiving.display",
107
defaultMessage: "Archiving",
108
}),
109
to: {},
110
timeout: 5 * 60,
111
commands: ["status", "mintime"],
112
},
113
114
closed: {
115
desc: defineMessage({
116
id: "util.compute-states.closed.desc",
117
defaultMessage:
118
"Project is archived and needs to be decompressed, so it will take longer to start.",
119
}),
120
icon: "file-archive", // font awesome icon
121
display: defineMessage({
122
id: "util.compute-states.closed.display",
123
defaultMessage: "Closed", // displayed name for users
124
}),
125
stable: true,
126
to: {
127
open: "opening",
128
archived: "archiving",
129
},
130
commands: ["open", "move", "status", "destroy", "mintime", "archive"],
131
},
132
133
opening: {
134
desc: defineMessage({
135
id: "util.compute-states.opening.desc",
136
defaultMessage:
137
"Project is being imported; this may take several minutes depending on size.",
138
}),
139
icon: "gears",
140
display: defineMessage({
141
id: "util.compute-states.opening.display",
142
defaultMessage: "Opening",
143
}),
144
to: {},
145
timeout: 30 * 60,
146
commands: ["status", "mintime"],
147
},
148
149
closing: {
150
desc: defineMessage({
151
id: "util.compute-states.closing.desc",
152
defaultMessage: "Project is in the process of being closed.",
153
}),
154
icon: "download",
155
display: defineMessage({
156
id: "util.compute-states.closing.display",
157
defaultMessage: "Closing",
158
}),
159
to: {},
160
timeout: 5 * 60,
161
commands: ["status", "mintime"],
162
},
163
164
opened: {
165
desc: defineMessage({
166
id: "util.compute-states.opened.desc",
167
defaultMessage: "Project is available and ready to try to run.",
168
}),
169
icon: "stop",
170
display: defineMessage({
171
id: "util.compute-states.opened.display",
172
defaultMessage: "Stopped",
173
}),
174
stable: true,
175
to: {
176
start: "starting",
177
close: "closing",
178
},
179
commands: [
180
"start",
181
"close",
182
"save",
183
"copy_path",
184
"mkdir",
185
"directory_listing",
186
"read_file",
187
"network",
188
"mintime",
189
"disk_quota",
190
"compute_quota",
191
"status",
192
"migrate_live",
193
"ephemeral_state",
194
"ephemeral_disk",
195
],
196
},
197
198
pending: {
199
desc_cocalccom: defineMessage({
200
id: "util.compute-states.pending.desc_cocalccom",
201
defaultMessage:
202
"Finding a place to run your project. If nothing becomes available, reduce RAM or CPU, pay for members only hosting, or contact support.",
203
}),
204
desc: defineMessage({
205
id: "util.compute-states.pending.desc",
206
defaultMessage:
207
"Finding a place to run your project. If nothing becomes available, contact your administrator.",
208
}),
209
icon: "times-rectangle",
210
display: defineMessage({
211
id: "util.compute-states.pending.display",
212
defaultMessage: "Pending",
213
}),
214
stable: true,
215
to: {
216
stop: "stopping",
217
},
218
commands: ["stop"],
219
},
220
221
starting: {
222
desc: defineMessage({
223
id: "util.compute-states.starting.desc",
224
defaultMessage: "Project is starting up.",
225
}),
226
icon: "flash",
227
display: defineMessage({
228
id: "util.compute-states.starting.display",
229
defaultMessage: "Starting",
230
}),
231
to: {},
232
timeout: 60,
233
commands: [
234
"save",
235
"copy_path",
236
"mkdir",
237
"directory_listing",
238
"read_file",
239
"network",
240
"mintime",
241
"disk_quota",
242
"compute_quota",
243
"status",
244
],
245
},
246
247
stopping: {
248
desc: defineMessage({
249
id: "util.compute-states.stopping.desc",
250
defaultMessage: "Project is stopping.",
251
}),
252
icon: "hand-stop",
253
display: defineMessage({
254
id: "util.compute-states.stopping.display",
255
defaultMessage: "Stopping",
256
}),
257
timeout: 60,
258
to: {},
259
commands: [
260
"save",
261
"copy_path",
262
"mkdir",
263
"directory_listing",
264
"read_file",
265
"network",
266
"mintime",
267
"disk_quota",
268
"compute_quota",
269
"status",
270
],
271
},
272
273
running: {
274
desc: defineMessage({
275
id: "util.compute-states.running.desc",
276
defaultMessage: "Project is running.",
277
}),
278
icon: "run",
279
display: defineMessage({
280
id: "util.compute-states.running.display",
281
defaultMessage: "Running",
282
}),
283
stable: true,
284
to: {
285
stop: "stopping",
286
},
287
commands: [
288
"stop",
289
"save",
290
"address",
291
"copy_path",
292
"mkdir",
293
"directory_listing",
294
"read_file",
295
"network",
296
"mintime",
297
"disk_quota",
298
"compute_quota",
299
"status",
300
"migrate_live",
301
],
302
},
303
} as const;
304
305