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/db-schema/jupyter.ts
Views: 687
1
import { Table } from "./types";
2
import { CREATED_BY, ID, CREATED } from "./crm";
3
import { SCHEMA as schema } from "./index";
4
5
// The jupyter api log has one entry each time a computation
6
// actually gets performed. Nothing is logged when a request
7
// is satisfied using the cache.
8
9
Table({
10
name: "jupyter_api_log",
11
fields: {
12
id: ID,
13
created: CREATED,
14
analytics_cookie: {
15
title: "Analytics Cookie",
16
type: "string",
17
desc: "The analytics cookie for the user that asked this question.",
18
},
19
account_id: CREATED_BY,
20
hash: {
21
type: "string",
22
desc: "Hash of the input history, input, kernel, project_id, and path.",
23
},
24
total_time_s: {
25
type: "number",
26
desc: "Total amount of time the API call took in seconds.",
27
},
28
tag: {
29
type: "string",
30
desc: "A string that the client can include that is useful for analytics later",
31
},
32
project_id: {
33
desc: "Optional project that is used for this evaluation.",
34
type: "uuid",
35
render: { type: "project_link" },
36
},
37
path: {
38
desc: "Optional path that is used for this evaluation.",
39
type: "string",
40
},
41
kernel: {
42
type: "string",
43
},
44
history: {
45
title: "History",
46
type: "array",
47
pg_type: "TEXT[]",
48
desc: "The previous inputs",
49
render: {
50
type: "json",
51
},
52
},
53
input: {
54
title: "Input",
55
type: "string",
56
desc: "Input text that was sent to kernel",
57
render: {
58
type: "code",
59
},
60
},
61
expire: {
62
type: "timestamp",
63
desc: "expire a log entry after 1 month",
64
},
65
},
66
rules: {
67
desc: "Jupyter Kernel Execution Log",
68
primary_key: "id",
69
pg_indexes: ["created", "hash"],
70
},
71
});
72
73
Table({
74
name: "crm_jupyter_api_log",
75
rules: {
76
virtual: "jupyter_api_log",
77
primary_key: "id",
78
user_query: {
79
get: {
80
pg_where: [],
81
admin: true,
82
fields: {
83
id: null,
84
created: null,
85
hash: null,
86
account_id: null,
87
analytics_cookie: null,
88
project_id: null,
89
path: null,
90
kernel: null,
91
history: null,
92
input: null,
93
tag: null,
94
total_time_s: null,
95
},
96
},
97
},
98
},
99
fields: schema.jupyter_api_log.fields,
100
});
101
102
Table({
103
name: "jupyter_api_cache",
104
fields: {
105
id: ID,
106
hash: {
107
type: "string",
108
desc: "Hash of the input history, input, kernel, project_id, and path.",
109
},
110
created: CREATED,
111
last_active: {
112
type: "timestamp",
113
desc: "When this cache entry was last requested",
114
},
115
output: {
116
title: "Output",
117
type: "array",
118
pg_type: "JSONB[]",
119
desc: "Output from running the computation",
120
render: {
121
type: "json",
122
},
123
},
124
expire: {
125
type: "timestamp",
126
desc: "this is last_active + 1 month",
127
},
128
},
129
rules: {
130
desc: "Jupyter Kernel Execution Log",
131
primary_key: "id",
132
pg_indexes: ["created", "hash"],
133
},
134
});
135
136
Table({
137
name: "crm_jupyter_api_cache",
138
rules: {
139
virtual: "jupyter_api_cache",
140
primary_key: "id",
141
user_query: {
142
get: {
143
pg_where: [],
144
admin: true,
145
fields: {
146
id: null,
147
hash: null,
148
created: null,
149
last_active: null,
150
count: null,
151
output: null,
152
},
153
},
154
},
155
},
156
fields: schema.jupyter_api_cache.fields,
157
});
158
159