@datalayer/agent-runtimes 1.0.25 → 1.0.26
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/lib/components/agents/index.d.ts +6 -0
- package/lib/components/{students → agents}/index.js +6 -1
- package/lib/components/{NotificationEventCard.js → cards/NotificationEventCard.js} +1 -1
- package/lib/components/{OutputCard.js → cards/OutputCard.js} +1 -1
- package/lib/components/cards/index.d.ts +9 -0
- package/lib/components/cards/index.js +13 -0
- package/lib/components/{runtimes/RuntimeCellVariables.d.ts → code-sandboxes/CodeSandboxCellVariables.d.ts} +3 -3
- package/lib/components/{runtimes/RuntimeCellVariables.js → code-sandboxes/CodeSandboxCellVariables.js} +2 -2
- package/lib/components/{runtimes/RuntimeCellVariablesDialog.d.ts → code-sandboxes/CodeSandboxCellVariablesDialog.d.ts} +4 -4
- package/lib/components/{runtimes/RuntimeCellVariablesDialog.js → code-sandboxes/CodeSandboxCellVariablesDialog.js} +4 -4
- package/lib/components/code-sandboxes/CodeSandboxLauncher.d.ts +0 -2
- package/lib/components/code-sandboxes/CodeSandboxLauncher.js +0 -2
- package/lib/components/code-sandboxes/CodeSandboxPicker.d.ts +30 -5
- package/lib/components/code-sandboxes/CodeSandboxPicker.js +188 -55
- package/lib/components/{runtimes/RuntimePickerCell.d.ts → code-sandboxes/CodeSandboxPickerCell.d.ts} +5 -5
- package/lib/components/{runtimes/RuntimePickerCell.js → code-sandboxes/CodeSandboxPickerCell.js} +6 -6
- package/lib/components/{runtimes/RuntimeReservationControl.d.ts → code-sandboxes/CodeSandboxReservationControl.d.ts} +3 -3
- package/lib/components/{runtimes/RuntimeReservationControl.js → code-sandboxes/CodeSandboxReservationControl.js} +5 -5
- package/lib/components/{runtimes/RuntimeTransfer.d.ts → code-sandboxes/CodeSandboxTransfer.d.ts} +1 -1
- package/lib/components/{runtimes/RuntimeUtils.d.ts → code-sandboxes/CodeSandboxUtils.d.ts} +3 -3
- package/lib/components/{runtimes/RuntimeUtils.js → code-sandboxes/CodeSandboxUtils.js} +1 -1
- package/lib/components/code-sandboxes/CodeSandboxVariables.d.ts +71 -0
- package/lib/components/{runtimes/RuntimeVariables.js → code-sandboxes/CodeSandboxVariables.js} +77 -2
- package/lib/components/code-sandboxes/NewCodeSandboxControls.js +3 -3
- package/lib/components/code-sandboxes/index.d.ts +19 -1
- package/lib/components/code-sandboxes/index.js +19 -1
- package/lib/components/index.d.ts +4 -6
- package/lib/components/index.js +4 -6
- package/lib/components/progress/CreditsIndicator.js +1 -1
- package/package.json +2 -2
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +0 -7
- package/lib/components/runtimes/RuntimeLauncherDialog.js +0 -11
- package/lib/components/runtimes/RuntimePickerBase.d.ts +0 -8
- package/lib/components/runtimes/RuntimePickerBase.js +0 -12
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +0 -42
- package/lib/components/runtimes/RuntimePickerNotebook.js +0 -197
- package/lib/components/runtimes/RuntimeSimplePicker.d.ts +0 -38
- package/lib/components/runtimes/RuntimeSimplePicker.js +0 -156
- package/lib/components/runtimes/RuntimeVariables.d.ts +0 -38
- package/lib/components/runtimes/index.d.ts +0 -12
- package/lib/components/runtimes/index.js +0 -17
- package/lib/components/students/StudentItemStatus.d.ts +0 -7
- package/lib/components/students/StudentItemStatus.js +0 -68
- package/lib/components/students/index.d.ts +0 -1
- package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
- /package/lib/components/{AgentSummary.d.ts → agents/AgentSummary.d.ts} +0 -0
- /package/lib/components/{AgentSummary.js → agents/AgentSummary.js} +0 -0
- /package/lib/components/{NotificationEventCard.d.ts → cards/NotificationEventCard.d.ts} +0 -0
- /package/lib/components/{OutputCard.d.ts → cards/OutputCard.d.ts} +0 -0
- /package/lib/components/{ToolApprovalCard.d.ts → cards/ToolApprovalCard.d.ts} +0 -0
- /package/lib/components/{ToolApprovalCard.js → cards/ToolApprovalCard.js} +0 -0
- /package/lib/components/{runtimes/RuntimeTransfer.js → code-sandboxes/CodeSandboxTransfer.js} +0 -0
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
-
* Distributed under the terms of the Modified BSD License.
|
|
5
|
-
*/
|
|
6
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
7
|
-
import { ActionList } from '@primer/react';
|
|
8
|
-
import { Box } from '@datalayer/primer-addons';
|
|
9
|
-
import { JSONExt } from '@lumino/coreutils';
|
|
10
|
-
import { KernelExecutor } from '@datalayer/jupyter-react';
|
|
11
|
-
import { RuntimeSnippetsFacade } from '../../jupyter';
|
|
12
|
-
import { ExternalTokenSilentLogin } from '@datalayer/core/lib/components/iam';
|
|
13
|
-
import { useIAMStore } from '../../state/substates';
|
|
14
|
-
import { RuntimeVariables } from './RuntimeVariables';
|
|
15
|
-
import { CodeSandboxPicker } from '../code-sandboxes/CodeSandboxPicker';
|
|
16
|
-
import { creditsLimitFor, NewCodeSandboxControls, useNewCodeSandboxAllowance, } from '../code-sandboxes/NewCodeSandboxControls';
|
|
17
|
-
/**
|
|
18
|
-
* Runtime Picker components for a Notebook.
|
|
19
|
-
*/
|
|
20
|
-
export function RuntimePickerNotebook(props) {
|
|
21
|
-
const { multiServiceManager, sessionContext, setValue, translator } = props;
|
|
22
|
-
const { refreshCredits, token } = useIAMStore();
|
|
23
|
-
const [selectedRuntimeDesc, setSelectedRuntimeDesc] = useState();
|
|
24
|
-
const [timeLimit, setTimeLimit] = useState(10);
|
|
25
|
-
const [userStorage, setUserStorage] = useState(false);
|
|
26
|
-
const [canTransferFrom, setTransferFrom] = useState(false);
|
|
27
|
-
const [canTransferTo, setTransferTo] = useState(false);
|
|
28
|
-
const [transferVariables, setTransferVariables] = useState(false);
|
|
29
|
-
const [hasLoadedVariables, setHasLoadedVariables] = useState(false);
|
|
30
|
-
const [kernelVariables, setRuntimeVariables] = useState();
|
|
31
|
-
const [toTransfer, setToTransfer] = useState([]);
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
refreshCredits();
|
|
34
|
-
}, []);
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
const specs = sessionContext.specsManager.specs?.kernelspecs;
|
|
37
|
-
if (sessionContext.session?.kernel?.name && specs) {
|
|
38
|
-
const spec = Object.values(specs).find(spec => spec?.name === sessionContext.session.kernel.name);
|
|
39
|
-
if (spec) {
|
|
40
|
-
setSelectedRuntimeDesc({
|
|
41
|
-
name: spec.name,
|
|
42
|
-
kernelId: sessionContext.session.kernel.id,
|
|
43
|
-
location: sessionContext.location,
|
|
44
|
-
language: spec.language,
|
|
45
|
-
displayName: sessionContext.kernelDisplayName,
|
|
46
|
-
});
|
|
47
|
-
setTransferFrom(RuntimeSnippetsFacade.supports(spec.language));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}, [sessionContext]);
|
|
51
|
-
const listRuntimeVariables = useCallback(async () => {
|
|
52
|
-
if (hasLoadedVariables) {
|
|
53
|
-
return Promise.resolve();
|
|
54
|
-
}
|
|
55
|
-
setHasLoadedVariables(true);
|
|
56
|
-
const connection = sessionContext.session.kernel;
|
|
57
|
-
const spec = sessionContext.specsManager.specs.kernelspecs[connection.model.name];
|
|
58
|
-
const snippets = new RuntimeSnippetsFacade(spec.language);
|
|
59
|
-
const outputs = await new KernelExecutor({ connection }).execute(snippets.listVariables());
|
|
60
|
-
const content = outputs.get(0).data['text/plain'];
|
|
61
|
-
if (content) {
|
|
62
|
-
setRuntimeVariables(JSON.parse(
|
|
63
|
-
// We need to remove the quotes prior to parsing.
|
|
64
|
-
content.slice(1, content.length - 1)));
|
|
65
|
-
if (toTransfer.length) {
|
|
66
|
-
const candidates = Object.keys(kernelVariables ?? {});
|
|
67
|
-
setToTransfer(toTransfer.filter(n => candidates.includes(n)));
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
// By default select all variables.
|
|
71
|
-
setToTransfer(Object.keys(kernelVariables ?? {}));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
setRuntimeVariables({});
|
|
76
|
-
}
|
|
77
|
-
}, [hasLoadedVariables, kernelVariables, toTransfer]);
|
|
78
|
-
const setSelectedVariables = useCallback((l) => {
|
|
79
|
-
if (!JSONExt.deepEqual(toTransfer, l)) {
|
|
80
|
-
setToTransfer(l);
|
|
81
|
-
}
|
|
82
|
-
}, [toTransfer]);
|
|
83
|
-
const setTransferVariable = useCallback((value) => {
|
|
84
|
-
if (transferVariables !== value) {
|
|
85
|
-
if (value) {
|
|
86
|
-
listRuntimeVariables().catch(error => {
|
|
87
|
-
console.error('Failed to list the runtime variable', error);
|
|
88
|
-
setHasLoadedVariables(false);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
setTransferVariables(value);
|
|
92
|
-
}
|
|
93
|
-
}, [transferVariables]);
|
|
94
|
-
const setRuntimeDesc = useCallback((runtimeDesc) => {
|
|
95
|
-
if (!runtimeDesc) {
|
|
96
|
-
if (selectedRuntimeDesc) {
|
|
97
|
-
setSelectedRuntimeDesc(undefined);
|
|
98
|
-
setTransferTo(false);
|
|
99
|
-
}
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (selectedRuntimeDesc?.displayName !== runtimeDesc.displayName ||
|
|
103
|
-
selectedRuntimeDesc?.kernelId !== runtimeDesc.kernelId) {
|
|
104
|
-
setSelectedRuntimeDesc({ ...runtimeDesc });
|
|
105
|
-
setTransferTo(RuntimeSnippetsFacade.supports(runtimeDesc.language));
|
|
106
|
-
}
|
|
107
|
-
}, [selectedRuntimeDesc]);
|
|
108
|
-
// The burning rate of the choice, and what the account allows for it —
|
|
109
|
-
// the same one copy of the arithmetic the launcher uses.
|
|
110
|
-
const resolvedBurningRate = selectedRuntimeDesc?.burningRate ??
|
|
111
|
-
multiServiceManager.remote?.environments
|
|
112
|
-
.get()
|
|
113
|
-
.find(env => env.name === selectedRuntimeDesc?.name)?.burning_rate;
|
|
114
|
-
const allowance = useNewCodeSandboxAllowance(resolvedBurningRate);
|
|
115
|
-
useEffect(() => {
|
|
116
|
-
const maxMinutes = selectedRuntimeDesc?.location === 'remote'
|
|
117
|
-
? allowance.maxFromCredits
|
|
118
|
-
: undefined;
|
|
119
|
-
const effectiveTimeLimit = selectedRuntimeDesc?.location === 'remote'
|
|
120
|
-
? Math.max(1, Math.min(timeLimit, maxMinutes && maxMinutes > 0 ? maxMinutes : 10))
|
|
121
|
-
: timeLimit;
|
|
122
|
-
const creditsLimit = selectedRuntimeDesc?.location === 'remote' && resolvedBurningRate
|
|
123
|
-
? creditsLimitFor(effectiveTimeLimit, resolvedBurningRate)
|
|
124
|
-
: undefined;
|
|
125
|
-
const requiresRuntimeStart = !!selectedRuntimeDesc && !selectedRuntimeDesc.kernelId;
|
|
126
|
-
if (requiresRuntimeStart && selectedRuntimeDesc.location === 'remote') {
|
|
127
|
-
if (!resolvedBurningRate || !Number.isFinite(resolvedBurningRate)) {
|
|
128
|
-
setValue({ runtime: null, selectedVariables: toTransfer });
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (allowance.hasKnownCredits &&
|
|
132
|
-
allowance.hasKnownRunAllowance &&
|
|
133
|
-
!allowance.hasRemainingRuns &&
|
|
134
|
-
(!creditsLimit || creditsLimit <= 0)) {
|
|
135
|
-
setValue({ runtime: null, selectedVariables: toTransfer });
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
setValue({
|
|
140
|
-
runtime: selectedRuntimeDesc
|
|
141
|
-
? {
|
|
142
|
-
environmentName: ['browser', 'remote'].includes(selectedRuntimeDesc.location)
|
|
143
|
-
? `${selectedRuntimeDesc.location}-${selectedRuntimeDesc.name}`
|
|
144
|
-
: selectedRuntimeDesc.name,
|
|
145
|
-
id: selectedRuntimeDesc.kernelId,
|
|
146
|
-
creditsLimit,
|
|
147
|
-
capabilities: userStorage ? ['user_storage'] : undefined,
|
|
148
|
-
}
|
|
149
|
-
: null,
|
|
150
|
-
selectedVariables: toTransfer,
|
|
151
|
-
});
|
|
152
|
-
}, [
|
|
153
|
-
selectedRuntimeDesc,
|
|
154
|
-
userStorage,
|
|
155
|
-
toTransfer,
|
|
156
|
-
timeLimit,
|
|
157
|
-
multiServiceManager.remote,
|
|
158
|
-
resolvedBurningRate,
|
|
159
|
-
allowance,
|
|
160
|
-
]);
|
|
161
|
-
const { kernelPreference: { canStart }, } = sessionContext;
|
|
162
|
-
const effectiveMaxMinutes = selectedRuntimeDesc?.location === 'remote'
|
|
163
|
-
? allowance.effectiveMaxMinutes
|
|
164
|
-
: Math.max(1, allowance.maxFromCredits ?? -1);
|
|
165
|
-
const outOfCredits = allowance.hasKnownCredits &&
|
|
166
|
-
allowance.hasKnownRunAllowance &&
|
|
167
|
-
!allowance.hasRemainingRuns &&
|
|
168
|
-
(allowance.maxFromCredits ?? -1) < Number.EPSILON;
|
|
169
|
-
return (_jsxs(Box, { as: "form", className: "dla-Runtimes-picker", children: [_jsx(Box, { sx: { padding: 'var(--stack-padding-condensed) 0' }, children: _jsx(CodeSandboxPicker, { display: "radio", disabled: canStart === false, preference: {
|
|
170
|
-
id: sessionContext.session?.id,
|
|
171
|
-
kernelDisplayName: sessionContext.kernelPreference.shouldStart
|
|
172
|
-
? sessionContext.kernelDisplayName
|
|
173
|
-
: undefined,
|
|
174
|
-
}, sessionContext: sessionContext, multiServiceManager: multiServiceManager, translator: translator, runtimeDesc: selectedRuntimeDesc, setRuntimeDesc: setRuntimeDesc, postActions: token || !props.logIn ? (
|
|
175
|
-
/*
|
|
176
|
-
<Button
|
|
177
|
-
variant="default"
|
|
178
|
-
onClick={e => {
|
|
179
|
-
e.preventDefault();
|
|
180
|
-
commands.execute(CommandIDs.launchRemoteRuntime);
|
|
181
|
-
close();
|
|
182
|
-
}}
|
|
183
|
-
>
|
|
184
|
-
Launch a New Runtime
|
|
185
|
-
</Button>
|
|
186
|
-
*/
|
|
187
|
-
_jsx(_Fragment, {})) : (_jsx(ActionList.Item, { onSelect: props.logIn, title: 'Runtime Provider.', children: _jsx(ExternalTokenSilentLogin, { message: "Click to sign in." }) })) }) }), !selectedRuntimeDesc?.kernelId &&
|
|
188
|
-
selectedRuntimeDesc?.location === 'remote' && (
|
|
189
|
-
// The user asked for a NEW sandbox: the questions are the
|
|
190
|
-
// launcher's, asked through the launcher's own controls.
|
|
191
|
-
_jsx(NewCodeSandboxControls, { burningRate: selectedRuntimeDesc.burningRate, timeLimit: timeLimit, onTimeChange: setTimeLimit, max: effectiveMaxMinutes, disabled: outOfCredits, error: outOfCredits && (allowance.maxFromCredits ?? -1) >= 0
|
|
192
|
-
? 'You must add credits to your account.'
|
|
193
|
-
: timeLimit === 0
|
|
194
|
-
? 'You must set a time limit.'
|
|
195
|
-
: undefined, userStorage: userStorage, onUserStorageToggle: () => setUserStorage(current => !current) })), canTransferFrom && canTransferTo && (_jsx(RuntimeVariables, { selectedVariables: toTransfer, setSelectVariable: setSelectedVariables, transferVariables: transferVariables, setTransferVariable: setTransferVariable, kernelVariables: kernelVariables, translator: translator }))] }));
|
|
196
|
-
}
|
|
197
|
-
export default RuntimePickerNotebook;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Session } from '@jupyterlab/services';
|
|
2
|
-
import { IRuntimeModel, type IRuntimeDesc } from '../../models';
|
|
3
|
-
export interface IRuntimeAssignOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Runtime description.
|
|
6
|
-
*/
|
|
7
|
-
runtimeDesc?: IRuntimeDesc;
|
|
8
|
-
/**
|
|
9
|
-
* Runtime model to connect to.
|
|
10
|
-
*/
|
|
11
|
-
runtimeModel?: IRuntimeModel;
|
|
12
|
-
/**
|
|
13
|
-
* Whether to transfer the state to the runtime model.
|
|
14
|
-
*/
|
|
15
|
-
transferState?: boolean;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Runtime picker component properties.
|
|
19
|
-
*/
|
|
20
|
-
interface IRuntimeSimplePickerProps {
|
|
21
|
-
/**
|
|
22
|
-
* Runtime assignment callback.
|
|
23
|
-
*/
|
|
24
|
-
assignRuntime: (options: IRuntimeAssignOptions) => Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* Connection to the active runtime.
|
|
27
|
-
*/
|
|
28
|
-
sessionConnection?: Session.ISessionConnection;
|
|
29
|
-
/**
|
|
30
|
-
* Whether browser runtime is available.
|
|
31
|
-
*/
|
|
32
|
-
browserRuntimeAvailable?: boolean;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Runtime simple picker component.
|
|
36
|
-
*/
|
|
37
|
-
export declare function RuntimeSimplePicker(props: IRuntimeSimplePickerProps): JSX.Element;
|
|
38
|
-
export {};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
-
* Distributed under the terms of the Modified BSD License.
|
|
5
|
-
*/
|
|
6
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
7
|
-
import { KernelIndicator, useJupyterReactStore, } from '@datalayer/jupyter-react';
|
|
8
|
-
import { ISanitizer } from '@jupyterlab/apputils';
|
|
9
|
-
import { IMarkdownParser } from '@jupyterlab/rendermime';
|
|
10
|
-
import { ActionList, ActionMenu, Box, Button, Tooltip } from '@primer/react';
|
|
11
|
-
import { CloudIcon, EyeIcon, UnfoldIcon } from '@primer/octicons-react';
|
|
12
|
-
import { BrowserIcon, PlusIcon } from '@datalayer/icons-react';
|
|
13
|
-
import { ArtifactIcon } from '../../components/icons';
|
|
14
|
-
import { RuntimeLauncherDialog } from '.';
|
|
15
|
-
import { useRuntimesStore } from '../../state/substates';
|
|
16
|
-
/**
|
|
17
|
-
* Cause to open the new runtime dialog.
|
|
18
|
-
*/
|
|
19
|
-
var RuntimeDialogCause;
|
|
20
|
-
(function (RuntimeDialogCause) {
|
|
21
|
-
/**
|
|
22
|
-
* Don't open.
|
|
23
|
-
*/
|
|
24
|
-
RuntimeDialogCause[RuntimeDialogCause["None"] = 0] = "None";
|
|
25
|
-
/**
|
|
26
|
-
* Launch a new runtime.
|
|
27
|
-
*/
|
|
28
|
-
RuntimeDialogCause[RuntimeDialogCause["New"] = 1] = "New";
|
|
29
|
-
/**
|
|
30
|
-
* Transfer the state from the current runtime to a new runtime.
|
|
31
|
-
*/
|
|
32
|
-
RuntimeDialogCause[RuntimeDialogCause["Transfer"] = 2] = "Transfer";
|
|
33
|
-
})(RuntimeDialogCause || (RuntimeDialogCause = {}));
|
|
34
|
-
/**
|
|
35
|
-
* Runtime simple picker component.
|
|
36
|
-
*/
|
|
37
|
-
export function RuntimeSimplePicker(props) {
|
|
38
|
-
const { assignRuntime, sessionConnection, browserRuntimeAvailable = true, } = props;
|
|
39
|
-
const { runtimeModels, multiServiceManager } = useRuntimesStore();
|
|
40
|
-
const jupyterReactStore = useJupyterReactStore();
|
|
41
|
-
const jupyterLabAdapter = jupyterReactStore.jupyterLabAdapter;
|
|
42
|
-
const [runtimeLocation, setRuntimeLocation] = useState();
|
|
43
|
-
const [luminoServices, setLuminoServices] = useState({});
|
|
44
|
-
const [dialogCause, setDialogCause] = useState(RuntimeDialogCause.None);
|
|
45
|
-
const [status, setStatus] = useState('');
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (sessionConnection) {
|
|
48
|
-
function onStatusChanged(connection) {
|
|
49
|
-
setStatus(`Runtime ${connection.kernel?.connectionStatus} - Status: ${connection.kernel?.status}`);
|
|
50
|
-
}
|
|
51
|
-
onStatusChanged(sessionConnection);
|
|
52
|
-
sessionConnection?.statusChanged.connect(onStatusChanged);
|
|
53
|
-
sessionConnection?.connectionStatusChanged.connect(onStatusChanged);
|
|
54
|
-
return () => {
|
|
55
|
-
sessionConnection?.statusChanged.disconnect(onStatusChanged);
|
|
56
|
-
sessionConnection?.connectionStatusChanged.disconnect(onStatusChanged);
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
setStatus('No kernel');
|
|
61
|
-
}
|
|
62
|
-
}, [sessionConnection]);
|
|
63
|
-
const refreshRemoteKernels = useCallback(async () => {
|
|
64
|
-
if (multiServiceManager?.remote?.runtimesManager) {
|
|
65
|
-
await multiServiceManager.remote.runtimesManager.refresh();
|
|
66
|
-
}
|
|
67
|
-
}, [multiServiceManager?.remote?.runtimesManager]);
|
|
68
|
-
const handleLaunchRemoteKernel = useCallback(() => {
|
|
69
|
-
setDialogCause(RuntimeDialogCause.New);
|
|
70
|
-
}, []);
|
|
71
|
-
const handleCloseDialog = useCallback((runtimeDesc) => {
|
|
72
|
-
if (runtimeDesc) {
|
|
73
|
-
switch (dialogCause) {
|
|
74
|
-
case RuntimeDialogCause.New:
|
|
75
|
-
refreshRemoteKernels().then(() => {
|
|
76
|
-
setRuntimeLocation('remote');
|
|
77
|
-
assignRuntime({
|
|
78
|
-
runtimeDesc,
|
|
79
|
-
runtimeModel: multiServiceManager?.remote?.runtimesManager
|
|
80
|
-
.get()
|
|
81
|
-
.find(model => model.id === runtimeDesc.kernelId),
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
break;
|
|
85
|
-
case RuntimeDialogCause.Transfer:
|
|
86
|
-
setRuntimeLocation('remote');
|
|
87
|
-
assignRuntime({ runtimeDesc, transferState: true });
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
setDialogCause(RuntimeDialogCause.None);
|
|
92
|
-
}, [refreshRemoteKernels, multiServiceManager?.remote, dialogCause]);
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
if (jupyterLabAdapter) {
|
|
95
|
-
Promise.all([
|
|
96
|
-
jupyterLabAdapter.jupyterLab.resolveOptionalService(IMarkdownParser),
|
|
97
|
-
jupyterLabAdapter.jupyterLab.resolveOptionalService(ISanitizer),
|
|
98
|
-
]).then(services => {
|
|
99
|
-
setLuminoServices({
|
|
100
|
-
[IMarkdownParser.name]: services[0],
|
|
101
|
-
[ISanitizer.name]: services[1],
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
setLuminoServices({});
|
|
107
|
-
}
|
|
108
|
-
}, [jupyterLabAdapter]);
|
|
109
|
-
return (_jsxs(_Fragment, { children: [_jsxs(ActionMenu, { children: [_jsx(ActionMenu.Button, { leadingVisual: () => {
|
|
110
|
-
switch (runtimeLocation) {
|
|
111
|
-
case 'browser':
|
|
112
|
-
return _jsx(BrowserIcon, {});
|
|
113
|
-
case 'remote':
|
|
114
|
-
return _jsx(CloudIcon, {});
|
|
115
|
-
case undefined:
|
|
116
|
-
return _jsx(EyeIcon, {});
|
|
117
|
-
}
|
|
118
|
-
return _jsx(ArtifactIcon, { type: "runtime" });
|
|
119
|
-
}, trailingVisual: () => sessionConnection ? (_jsx(Box, { sx: { paddingTop: '5px' }, children: _jsx(KernelIndicator, { kernel: sessionConnection.kernel }) })) : (_jsx(_Fragment, {})), size: "small", variant: "invisible", children: _jsx(Tooltip, { text: status, direction: "s", children: _jsx(Button, { variant: "invisible", size: "small", children: sessionConnection?.kernel?.name ?? 'Runtimes' }) }) }), _jsx(ActionMenu.Overlay, { width: "medium", children: _jsxs(ActionList, { selectionVariant: "single", showDividers: true, children: [_jsxs(ActionList.Group, { children: [_jsxs(ActionList.Item, { selected: runtimeLocation === undefined &&
|
|
120
|
-
sessionConnection === undefined, onSelect: () => {
|
|
121
|
-
setRuntimeLocation(undefined);
|
|
122
|
-
assignRuntime({ runtimeDesc: undefined });
|
|
123
|
-
}, children: [_jsx(ActionList.LeadingVisual, { children: _jsx(EyeIcon, {}) }), "Viewer", _jsx(ActionList.Description, { variant: "block", children: "A simple Notebook Viewer without Runtime." })] }), browserRuntimeAvailable && (_jsxs(ActionList.Item, { selected: runtimeLocation === 'browser', onSelect: () => {
|
|
124
|
-
setRuntimeLocation('browser');
|
|
125
|
-
assignRuntime({
|
|
126
|
-
runtimeDesc: {
|
|
127
|
-
name: 'pyodide',
|
|
128
|
-
location: 'browser',
|
|
129
|
-
language: 'python',
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
}, children: [_jsx(ActionList.LeadingVisual, { children: _jsx(BrowserIcon, {}) }), "Browser Runtime", _jsx(ActionList.Description, { variant: "block", children: "A Browser Runtime based on Pyodide." })] }))] }), runtimeModels.length > 0 && (_jsxs(ActionList.Group, { children: [_jsx(ActionList.GroupHeading, { children: "Cloud Runtimes" }), runtimeModels.map(kernelModel => {
|
|
133
|
-
return (_jsxs(ActionList.Item, { selected: sessionConnection?.kernel?.id === kernelModel.id, onSelect: () => {
|
|
134
|
-
setRuntimeLocation('remote');
|
|
135
|
-
assignRuntime({
|
|
136
|
-
runtimeDesc: {
|
|
137
|
-
name: kernelModel.environment.name,
|
|
138
|
-
language: '',
|
|
139
|
-
location: 'remote',
|
|
140
|
-
displayName: kernelModel.given_name,
|
|
141
|
-
kernelId: kernelModel.id,
|
|
142
|
-
burningRate: kernelModel.burning_rate,
|
|
143
|
-
podName: kernelModel.pod_name,
|
|
144
|
-
},
|
|
145
|
-
runtimeModel: kernelModel,
|
|
146
|
-
});
|
|
147
|
-
}, children: [_jsx(ActionList.LeadingVisual, { children: _jsx(ArtifactIcon, { type: "runtime" }) }), kernelModel.given_name, _jsx(ActionList.Description, { variant: "block", children: kernelModel.environment.title ||
|
|
148
|
-
kernelModel.environment.name })] }, kernelModel.id));
|
|
149
|
-
})] })), _jsx(ActionList.Divider, {}), _jsxs(ActionList.Group, { children: [_jsxs(ActionList.Item, { selected: false, onSelect: handleLaunchRemoteKernel, children: [_jsx(ActionList.LeadingVisual, { children: _jsx(PlusIcon, {}) }), "Launch a new Code Sandbox\u2026"] }), _jsxs(ActionList.Item, { disabled: runtimeLocation !== 'browser', selected: false, onSelect: () => {
|
|
150
|
-
setDialogCause(RuntimeDialogCause.Transfer);
|
|
151
|
-
}, title: "Transfer the state of the current Runtime to a new Remote Runtime.", children: [_jsx(ActionList.LeadingVisual, { children: _jsx(UnfoldIcon, {}) }), "Transfer state to a new Runtime\u2026"] })] })] }) })] }), multiServiceManager?.remote && dialogCause > 0 && (_jsx(RuntimeLauncherDialog, { dialogTitle: dialogCause === RuntimeDialogCause.Transfer
|
|
152
|
-
? 'Switch to a new Cloud Runtime'
|
|
153
|
-
: undefined, manager: multiServiceManager.remote, onSubmit: handleCloseDialog, markdownParser: luminoServices[IMarkdownParser.name], sanitizer: luminoServices[ISanitizer.name], startRuntime: dialogCause === RuntimeDialogCause.Transfer
|
|
154
|
-
? 'defer'
|
|
155
|
-
: dialogCause === RuntimeDialogCause.New }))] }));
|
|
156
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { ITranslator } from '@jupyterlab/translation';
|
|
3
|
-
/**
|
|
4
|
-
* {@link RuntimeVariables} properties
|
|
5
|
-
*/
|
|
6
|
-
export interface IRuntimeVariablesProps {
|
|
7
|
-
/**
|
|
8
|
-
* Component class name
|
|
9
|
-
*/
|
|
10
|
-
className?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Available kernel variables
|
|
13
|
-
*
|
|
14
|
-
* Mapping (variable name, variable type)
|
|
15
|
-
*/
|
|
16
|
-
kernelVariables?: {
|
|
17
|
-
[name: string]: string;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Kernel variables to be transferred.
|
|
21
|
-
*/
|
|
22
|
-
selectedVariables: string[];
|
|
23
|
-
setSelectVariable: (l: string[]) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Whether to transfer the variable from the current
|
|
26
|
-
* to the selected kernel or not.
|
|
27
|
-
*/
|
|
28
|
-
transferVariables: boolean;
|
|
29
|
-
setTransferVariable: (v: boolean) => void;
|
|
30
|
-
/**
|
|
31
|
-
* Application translator
|
|
32
|
-
*/
|
|
33
|
-
translator?: ITranslator;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Runtime variables selector component.
|
|
37
|
-
*/
|
|
38
|
-
export declare function RuntimeVariables(props: IRuntimeVariablesProps): ReactElement;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from './RuntimeCellVariables';
|
|
2
|
-
export * from './RuntimeCellVariablesDialog';
|
|
3
|
-
export * from './RuntimeLauncherDialog';
|
|
4
|
-
export * from './RuntimePickerBase';
|
|
5
|
-
export * from './RuntimePickerCell';
|
|
6
|
-
export * from './RuntimePickerNotebook';
|
|
7
|
-
export * from './RuntimeReservationControl';
|
|
8
|
-
export * from './RuntimeSimplePicker';
|
|
9
|
-
export * from './RuntimeTransfer';
|
|
10
|
-
export * from './RuntimeUtils';
|
|
11
|
-
export * from './RuntimeVariables';
|
|
12
|
-
export * from '../code-sandboxes';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
export * from './RuntimeCellVariables';
|
|
6
|
-
export * from './RuntimeCellVariablesDialog';
|
|
7
|
-
export * from './RuntimeLauncherDialog';
|
|
8
|
-
export * from './RuntimePickerBase';
|
|
9
|
-
export * from './RuntimePickerCell';
|
|
10
|
-
export * from './RuntimePickerNotebook';
|
|
11
|
-
export * from './RuntimeReservationControl';
|
|
12
|
-
export * from './RuntimeSimplePicker';
|
|
13
|
-
export * from './RuntimeTransfer';
|
|
14
|
-
export * from './RuntimeUtils';
|
|
15
|
-
export * from './RuntimeVariables';
|
|
16
|
-
// The picker and the launcher moved in with the code sandboxes.
|
|
17
|
-
export * from '../code-sandboxes';
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { StudentResultCircle } from '@datalayer/core/lib/components/students/StudentResultCircle';
|
|
3
|
-
const getExerciseScore = (studentItem) => {
|
|
4
|
-
if (studentItem && studentItem.score) {
|
|
5
|
-
return studentItem.score;
|
|
6
|
-
}
|
|
7
|
-
return 0;
|
|
8
|
-
};
|
|
9
|
-
export const StudentItemStatus = (props) => {
|
|
10
|
-
const { studentItem } = props;
|
|
11
|
-
if (!studentItem) {
|
|
12
|
-
return _jsx(StudentResultCircle, { status: "none", label: "No result yet" });
|
|
13
|
-
}
|
|
14
|
-
switch (studentItem.itemType) {
|
|
15
|
-
case 'dataset': {
|
|
16
|
-
if (studentItem.completed === undefined) {
|
|
17
|
-
return (_jsx(StudentResultCircle, { status: "none", label: "Dataset not started" }));
|
|
18
|
-
}
|
|
19
|
-
const completed = Boolean(studentItem.completed);
|
|
20
|
-
return (_jsx(StudentResultCircle, { status: completed ? 'pass' : 'fail', label: completed ? 'Dataset completed' : 'Dataset not completed' }));
|
|
21
|
-
}
|
|
22
|
-
case 'lesson': {
|
|
23
|
-
if (studentItem.completed === undefined) {
|
|
24
|
-
return _jsx(StudentResultCircle, { status: "none", label: "Lesson not started" });
|
|
25
|
-
}
|
|
26
|
-
const completed = Boolean(studentItem.completed);
|
|
27
|
-
return (_jsx(StudentResultCircle, { status: completed ? 'pass' : 'fail', label: completed ? 'Lesson completed' : 'Lesson not completed' }));
|
|
28
|
-
}
|
|
29
|
-
case 'exercise': {
|
|
30
|
-
const hasResult = Boolean(studentItem.id) ||
|
|
31
|
-
Boolean(studentItem.codeStudent) ||
|
|
32
|
-
studentItem.score !== undefined;
|
|
33
|
-
if (!hasResult) {
|
|
34
|
-
return (_jsx(StudentResultCircle, { status: "none", label: "Exercise not started" }));
|
|
35
|
-
}
|
|
36
|
-
const passed = getExerciseScore(studentItem) > 0;
|
|
37
|
-
return (_jsx(StudentResultCircle, { status: passed ? 'pass' : 'fail', label: passed ? 'Exercise passed' : 'Exercise failed' }));
|
|
38
|
-
}
|
|
39
|
-
case 'assignment': {
|
|
40
|
-
const hasRecordedAttempt = Boolean(studentItem.id) ||
|
|
41
|
-
studentItem.nbgradesTotalScore !== undefined ||
|
|
42
|
-
studentItem.nbgradesTotalPoints !== undefined ||
|
|
43
|
-
Boolean(studentItem.nbgrades);
|
|
44
|
-
if (!hasRecordedAttempt) {
|
|
45
|
-
return (_jsx(StudentResultCircle, { status: "none", label: "Assignment not graded" }));
|
|
46
|
-
}
|
|
47
|
-
const totalScore = studentItem.nbgradesTotalScore ?? 0;
|
|
48
|
-
const totalPoints = studentItem.nbgradesTotalPoints ?? 0;
|
|
49
|
-
const nbgrades = Array.isArray(studentItem.nbgrades)
|
|
50
|
-
? studentItem.nbgrades
|
|
51
|
-
: [];
|
|
52
|
-
const status = totalPoints === 0
|
|
53
|
-
? 'pass'
|
|
54
|
-
: totalScore <= 0
|
|
55
|
-
? 'fail'
|
|
56
|
-
: totalScore >= totalPoints
|
|
57
|
-
? 'pass'
|
|
58
|
-
: 'partial';
|
|
59
|
-
const tooltip = nbgrades.length > 0
|
|
60
|
-
? `Assignment graded: ${totalScore} / ${totalPoints} (${nbgrades.length} checks)`
|
|
61
|
-
: `Assignment graded: ${totalScore} / ${totalPoints}`;
|
|
62
|
-
return _jsx(StudentResultCircle, { status: status, label: tooltip });
|
|
63
|
-
}
|
|
64
|
-
default:
|
|
65
|
-
return _jsx(StudentResultCircle, { status: "none", label: "No result yet" });
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
export default StudentItemStatus;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './StudentItemStatus';
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/lib/components/{runtimes/RuntimeTransfer.js → code-sandboxes/CodeSandboxTransfer.js}
RENAMED
|
File without changes
|