@datalayer/core 0.0.3 → 0.0.5
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/README.md +114 -3
- package/lib/App.css +2 -2
- package/lib/App.d.ts +1 -1
- package/lib/App.js +9 -9
- package/lib/__tests__/index.test.js +5 -5
- package/lib/api/DatalayerApi.d.ts +1 -1
- package/lib/api/DatalayerApi.js +3 -3
- package/lib/api/index.d.ts +3 -3
- package/lib/api/index.js +3 -3
- package/lib/api/runtimes/actions.js +22 -23
- package/lib/api/runtimes/settings.js +3 -3
- package/lib/api/runtimes/snapshots.d.ts +1 -1
- package/lib/api/runtimes/snapshots.js +8 -8
- package/lib/api/runtimes/utils.js +1 -4
- package/lib/collaboration/DatalayerCollaboration.d.ts +9 -0
- package/lib/collaboration/DatalayerCollaboration.js +28 -0
- package/lib/collaboration/DatalayerCollaborationProvider.d.ts +54 -0
- package/lib/collaboration/DatalayerCollaborationProvider.js +162 -0
- package/lib/collaboration/index.d.ts +2 -0
- package/lib/collaboration/index.js +6 -0
- package/lib/components/avatars/BoringAvatar.d.ts +1 -1
- package/lib/components/avatars/BoringAvatar.js +2 -2
- package/lib/components/avatars/UserProfileAvatar.js +2 -9
- package/lib/components/banners/NoAutomationBanner.js +4 -4
- package/lib/components/buttons/DownloadCSVButton.js +1 -1
- package/lib/components/buttons/UploadButton.js +1 -1
- package/lib/components/checkout/StripeCheckout.d.ts +1 -1
- package/lib/components/checkout/StripeCheckout.js +6 -6
- package/lib/components/confetti/ConfettiSuccess.js +1 -1
- package/lib/components/context/OrganizationSelect.js +5 -5
- package/lib/components/context/SpaceSelect.js +7 -7
- package/lib/components/display/AvatarSkeleton.js +1 -1
- package/lib/components/display/CenteredSpinner.js +4 -4
- package/lib/components/display/CodePreview.js +4 -4
- package/lib/components/display/DatalayerBox.js +13 -14
- package/lib/components/display/HorizontalCenter.d.ts +1 -1
- package/lib/components/display/HorizontalCenter.js +1 -1
- package/lib/components/display/JupyterDialog.js +17 -15
- package/lib/components/display/NavLink.d.ts +4 -2
- package/lib/components/display/NavLink.js +6 -4
- package/lib/components/display/NotebookSkeleton.js +2 -2
- package/lib/components/display/Placeholder.js +1 -1
- package/lib/components/display/ToTopBranded.js +1 -1
- package/lib/components/echarts/EChartsReact.d.ts +1 -1
- package/lib/components/echarts/EChartsReact.js +1 -1
- package/lib/components/flashes/FlashClosable.js +11 -11
- package/lib/components/flashes/FlashDisclaimer.js +2 -3
- package/lib/components/flashes/FlashGuest.js +3 -4
- package/lib/components/flashes/FlashSurveys.js +3 -4
- package/lib/components/flashes/FlashUnauthorized.js +2 -2
- package/lib/components/flashes/surveys/Survey2025_1.d.ts +1 -1
- package/lib/components/flashes/surveys/Survey2025_1.js +62 -85
- package/lib/components/iam/ExternalTokenSilentLogin.js +6 -4
- package/lib/components/icons/ArtifactIcon.d.ts +2 -2
- package/lib/components/icons/ArtifactIcon.js +39 -39
- package/lib/components/labels/VisibilityLabel.js +2 -5
- package/lib/components/landings/StepBlock.d.ts +1 -1
- package/lib/components/landings/StepBlock.js +1 -1
- package/lib/components/navbar/NavigationVisbilityObserver.js +2 -2
- package/lib/components/navbar/SubdomainNavBar.js +45 -23
- package/lib/components/navbar/SubdomainNavBar.module.css +33 -14
- package/lib/components/nbgrader/NbGradesDetails.d.ts +1 -1
- package/lib/components/nbgrader/NbGradesDetails.js +5 -8
- package/lib/components/notebooks/JupyterNotebook.js +5 -5
- package/lib/components/notebooks/JupyterNotebookToolbar.js +3 -3
- package/lib/components/primer/Helper.d.ts +1 -1
- package/lib/components/primer/Helper.js +5 -3
- package/lib/components/primer/Portals.d.ts +1 -1
- package/lib/components/primer/Portals.js +2 -2
- package/lib/components/primer/Styles.js +1 -1
- package/lib/components/progress/ConsumptionBar.js +2 -2
- package/lib/components/progress/CreditsIndicator.d.ts +1 -1
- package/lib/components/progress/CreditsIndicator.js +4 -7
- package/lib/components/progress/ProgressRing.js +2 -2
- package/lib/components/runtimes/RuntimeCellVariables.js +9 -9
- package/lib/components/runtimes/RuntimeCellVariablesDialog.js +3 -3
- package/lib/components/runtimes/RuntimeLauncherDialog.js +30 -34
- package/lib/components/runtimes/RuntimePickerBase.js +42 -31
- package/lib/components/runtimes/RuntimePickerCell.js +9 -12
- package/lib/components/runtimes/RuntimePickerNotebook.js +44 -44
- package/lib/components/runtimes/RuntimeReservationControl.js +10 -15
- package/lib/components/runtimes/RuntimeSimplePicker.js +9 -12
- package/lib/components/runtimes/RuntimeUtils.js +22 -12
- package/lib/components/runtimes/RuntimeVariables.js +7 -7
- package/lib/components/screenshot/ScreenCapture.js +9 -13
- package/lib/components/screenshot/ScreenCaptureButton.d.ts +1 -1
- package/lib/components/screenshot/ScreenCaptureButton.js +14 -8
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +19 -17
- package/lib/components/snippets/SnippetDialog.js +5 -5
- package/lib/components/storage/ContentsBrowser.js +63 -56
- package/lib/components/storage/ContentsItems.js +10 -8
- package/lib/components/students/StudentItemStatus.d.ts +1 -1
- package/lib/components/students/StudentItemStatus.js +35 -16
- package/lib/components/subnav/SubNav.d.ts +1 -1
- package/lib/components/subnav/SubNav.js +30 -15
- package/lib/components/subnav/SubNav.module.css +55 -21
- package/lib/components/tables/DataTable.js +1 -4
- package/lib/components/text-reveal/TextRevealAnimation.js +7 -2
- package/lib/components/text-reveal/TextRevealAnimation.module.css +4 -2
- package/lib/components/tokens/SpaceVariantToken.d.ts +1 -1
- package/lib/components/tokens/SpaceVariantToken.js +5 -5
- package/lib/components/toolbars/AssignmentEditorToolbar.js +1 -3
- package/lib/components/users/PeerIndicator.d.ts +1 -1
- package/lib/components/users/PeerIndicator.js +5 -5
- package/lib/config/Configuration.d.ts +48 -0
- package/lib/config/Configuration.js +42 -0
- package/lib/config/integrations/Loom.js +3 -3
- package/lib/examples/CellExample.d.ts +2 -2
- package/lib/examples/CellExample.js +34 -3
- package/lib/examples/DatalayerNotebookExample.d.ts +16 -0
- package/lib/examples/DatalayerNotebookExample.js +75 -0
- package/lib/examples/NativeNavigationExample.d.ts +8 -0
- package/lib/examples/NativeNavigationExample.js +97 -0
- package/lib/examples/NotebookExample.d.ts +1 -3
- package/lib/examples/NotebookExample.js +9 -7
- package/lib/examples/NotebookMutationsKernel.d.ts +2 -0
- package/lib/examples/NotebookMutationsKernel.js +115 -0
- package/lib/examples/NotebookMutationsServiceManager.d.ts +2 -0
- package/lib/examples/NotebookMutationsServiceManager.js +107 -0
- package/lib/examples/ReactRouterExample.d.ts +6 -0
- package/lib/examples/ReactRouterExample.js +175 -0
- package/lib/examples/example-selector.d.ts +22 -0
- package/lib/examples/example-selector.js +45 -0
- package/lib/examples/index.d.ts +2 -0
- package/lib/examples/index.js +6 -0
- package/lib/examples/main.js +153 -0
- package/lib/examples/notebooks/IPyWidgetsExample.ipynb.json +101 -0
- package/lib/examples/notebooks/IPyWidgetsExampleWithState.ipynb.json +112 -0
- package/lib/examples/{NotebookExample1.ipynb.json → notebooks/Lite.ipynb.json} +45 -53
- package/lib/examples/notebooks/Matplotlib.ipynb.json +137 -0
- package/lib/examples/notebooks/NotebookExample1.ipynb.json +126 -0
- package/lib/examples/notebooks/NotebookExample2.ipynb.json +48 -0
- package/lib/examples/notebooks/NotebookOutputs.ipynb.json +49 -0
- package/lib/examples/notebooks/NotebookToCExample.ipynb.json +102 -0
- package/lib/examples/notebooks/OutputIPyWidgetsExample.d.ts +145 -0
- package/lib/examples/notebooks/OutputIPyWidgetsExample.js +153 -0
- package/lib/examples/notebooks/PyGWalker.ipynb.json +55 -0
- package/lib/hooks/assets/OutputshotPlaceholders.d.ts +10 -10
- package/lib/hooks/assets/OutputshotPlaceholders.js +10 -10
- package/lib/hooks/index.d.ts +29 -28
- package/lib/hooks/index.js +29 -28
- package/lib/hooks/layouts/LayoutBackdrop.js +3 -6
- package/lib/hooks/layouts/LayoutScreenshot.css +1 -1
- package/lib/hooks/layouts/LayoutScreenshot.js +6 -6
- package/lib/hooks/useAIAgents.d.ts +1 -1
- package/lib/hooks/useAIAgents.js +6 -6
- package/lib/hooks/useAuthorization.js +4 -4
- package/lib/hooks/useBackdrop.js +7 -7
- package/lib/hooks/useBackdropJupyterLab.d.ts +1 -1
- package/lib/hooks/useBackdropJupyterLab.js +4 -4
- package/lib/hooks/useCache.d.ts +6 -2
- package/lib/hooks/useCache.js +233 -179
- package/lib/hooks/useCellOutputshot.js +3 -6
- package/lib/hooks/useContainsFocus.js +2 -1
- package/lib/hooks/useDatalayer.js +5 -3
- package/lib/hooks/useError.d.ts +1 -1
- package/lib/hooks/useError.js +2 -2
- package/lib/hooks/useExternalScript.js +4 -4
- package/lib/hooks/useFocusTrap.js +2 -1
- package/lib/hooks/useIAM.js +4 -5
- package/lib/hooks/useId.js +3 -3
- package/lib/hooks/useJupyterLabTheme.js +3 -1
- package/lib/hooks/useLocation.d.ts +22 -0
- package/lib/hooks/useLocation.js +149 -0
- package/lib/hooks/useLocationHandles.d.ts +2 -2
- package/lib/hooks/useLocationHandles.js +6 -4
- package/lib/hooks/useNavigate.d.ts +5 -1
- package/lib/hooks/useNavigate.js +62 -7
- package/lib/hooks/useNotebookAIAgent.js +3 -1
- package/lib/hooks/useParams.d.ts +5 -0
- package/lib/hooks/useParams.js +112 -0
- package/lib/hooks/useRuntimes.js +2 -2
- package/lib/hooks/useScreenshot.js +5 -5
- package/lib/hooks/useToast.js +15 -13
- package/lib/hooks/useUpload.js +9 -9
- package/lib/hooks/useUser.js +1 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +6 -3
- package/lib/index.js +7 -3
- package/lib/mocks/components/FlashMock.js +4 -4
- package/lib/mocks/hooks/rests/rests.js +15 -18
- package/lib/mocks/hooks/useDatalayerMock.d.ts +2 -2
- package/lib/mocks/hooks/useDatalayerMock.js +7 -7
- package/lib/mocks/models/CodeBlockMock.js +1 -1
- package/lib/mocks/models/CodelineMock.js +1 -1
- package/lib/mocks/models/CourseMock.d.ts +1 -1
- package/lib/mocks/models/CourseMock.js +10 -10
- package/lib/mocks/models/InviteMock.d.ts +1 -1
- package/lib/mocks/models/InviteMock.js +21 -6
- package/lib/mocks/models/JupyterLabUserMock.js +2 -2
- package/lib/mocks/models/OrganisationMock.d.ts +1 -1
- package/lib/mocks/models/OrganisationMock.js +11 -7
- package/lib/mocks/models/SchoolMock.d.ts +1 -1
- package/lib/mocks/models/SchoolMock.js +6 -6
- package/lib/mocks/models/SpaceMock.d.ts +1 -1
- package/lib/mocks/models/SpaceMock.js +9 -9
- package/lib/mocks/models/TeamMock.d.ts +1 -1
- package/lib/mocks/models/TeamMock.js +6 -6
- package/lib/mocks/models/UserMock.d.ts +1 -1
- package/lib/mocks/models/UserMock.js +4 -6
- package/lib/mocks/views/ActionMenuMock.js +1 -1
- package/lib/mocks/views/ChartMock.js +3 -3
- package/lib/mocks/views/ChartMockOptions.js +24 -24
- package/lib/mocks/views/DashboardMock.js +74 -74
- package/lib/mocks/views/FormMock.js +1 -1
- package/lib/mocks/views/TableMock.js +1 -1
- package/lib/models/Account.d.ts +2 -2
- package/lib/models/Assignment.d.ts +2 -2
- package/lib/models/Cell.d.ts +1 -1
- package/lib/models/CodeBlock.d.ts +1 -1
- package/lib/models/CodefeedBlocks.d.ts +2 -2
- package/lib/models/Contact.d.ts +1 -1
- package/lib/models/Contact.js +14 -14
- package/lib/models/ContactIAMProvider.js +2 -2
- package/lib/models/Course.d.ts +7 -7
- package/lib/models/Dataset.d.ts +1 -1
- package/lib/models/Dean.d.ts +1 -1
- package/lib/models/Document.d.ts +1 -1
- package/lib/models/Environment.d.ts +2 -2
- package/lib/models/Exercise.d.ts +1 -1
- package/lib/models/IAMProviderLinked.js +1 -1
- package/lib/models/Instructor.d.ts +1 -1
- package/lib/models/Invite.d.ts +2 -2
- package/lib/models/Invite.js +1 -1
- package/lib/models/Item.d.ts +5 -5
- package/lib/models/LandingRoles.js +18 -18
- package/lib/models/Lesson.d.ts +1 -1
- package/lib/models/Member.d.ts +1 -1
- package/lib/models/Notebook.d.ts +1 -1
- package/lib/models/Organization.d.ts +4 -4
- package/lib/models/Organization.js +2 -2
- package/lib/models/OrganizationMember.d.ts +2 -2
- package/lib/models/Page.js +4 -2
- package/lib/models/PageTag.d.ts +1 -1
- package/lib/models/PageTag.js +56 -9
- package/lib/models/Profile.d.ts +1 -1
- package/lib/models/RolesOrganization.d.ts +1 -1
- package/lib/models/RolesOrganization.js +4 -12
- package/lib/models/RolesPlatform.d.ts +1 -1
- package/lib/models/RolesPlatform.js +12 -34
- package/lib/models/RolesTeam.d.ts +1 -1
- package/lib/models/RolesTeam.js +3 -10
- package/lib/models/Runtime.js +4 -4
- package/lib/models/RuntimeSnapshot.js +1 -1
- package/lib/models/School.d.ts +4 -4
- package/lib/models/Space.d.ts +5 -5
- package/lib/models/Space.js +3 -3
- package/lib/models/SpaceItem.d.ts +8 -8
- package/lib/models/SpaceMember.d.ts +2 -2
- package/lib/models/Student.d.ts +2 -2
- package/lib/models/StudentItem.d.ts +3 -3
- package/lib/models/Team.d.ts +3 -3
- package/lib/models/Team.js +2 -2
- package/lib/models/TeamMember.d.ts +2 -2
- package/lib/models/URN.js +1 -1
- package/lib/models/User.d.ts +2 -2
- package/lib/models/User.js +5 -3
- package/lib/models/UserOnboarding.d.ts +1 -1
- package/lib/models/UserOnboarding.js +7 -7
- package/lib/models/UserSettings.js +2 -2
- package/lib/models/index.d.ts +2 -2
- package/lib/models/index.js +2 -2
- package/lib/navigation/adapters/native.d.ts +11 -0
- package/lib/navigation/adapters/native.js +48 -0
- package/lib/navigation/adapters/nextjs.d.ts +9 -0
- package/lib/navigation/adapters/nextjs.js +35 -0
- package/lib/navigation/adapters/react-router.d.ts +4 -0
- package/lib/navigation/adapters/react-router.js +12 -0
- package/lib/navigation/components.d.ts +20 -0
- package/lib/navigation/components.js +36 -0
- package/lib/navigation/index.d.ts +4 -0
- package/lib/navigation/index.js +12 -0
- package/lib/routes/index.d.ts +1 -1
- package/lib/routes/index.js +1 -1
- package/lib/services/DatalayerServiceManager.d.ts +22 -0
- package/lib/services/DatalayerServiceManager.js +69 -0
- package/lib/services/index.d.ts +4 -0
- package/lib/services/index.js +7 -0
- package/lib/services/reconnectToRuntime.d.ts +32 -0
- package/lib/services/reconnectToRuntime.js +59 -0
- package/lib/state/State.d.ts +1 -1
- package/lib/state/State.js +1 -1
- package/lib/state/index.d.ts +1 -1
- package/lib/state/index.js +1 -1
- package/lib/state/storage/IAMStorage.js +14 -2
- package/lib/state/storage/index.d.ts +1 -1
- package/lib/state/storage/index.js +1 -1
- package/lib/state/substates/AIAgentState.js +4 -2
- package/lib/state/substates/CellState.js +6 -5
- package/lib/state/substates/CoreState.d.ts +1 -1
- package/lib/state/substates/CoreState.js +26 -17
- package/lib/state/substates/DatasourceState.js +1 -1
- package/lib/state/substates/IAMState.d.ts +4 -0
- package/lib/state/substates/IAMState.js +39 -23
- package/lib/state/substates/JupyterLabState.js +1 -1
- package/lib/state/substates/LayoutState.d.ts +2 -2
- package/lib/state/substates/LayoutState.js +41 -28
- package/lib/state/substates/OrganizationState.js +1 -1
- package/lib/state/substates/RuntimesState.js +11 -6
- package/lib/state/substates/SpaceState.js +1 -1
- package/lib/state/substates/SurveysState.js +4 -4
- package/lib/state/substates/TeamState.js +1 -1
- package/lib/test-setup.js +25 -3
- package/lib/theme/DatalayerTheme.js +1 -1
- package/lib/theme/DatalayerThemeProvider.js +17 -14
- package/lib/theme/Palette.js +1 -1
- package/lib/utils/Avatar.js +2 -2
- package/lib/utils/Browser.js +6 -6
- package/lib/utils/Cells.d.ts +1 -1
- package/lib/utils/Cookie.js +1 -1
- package/lib/utils/Date.js +2 -2
- package/lib/utils/Download.js +5 -3
- package/lib/utils/DownloadFile.js +4 -2
- package/lib/utils/Env.js +2 -1
- package/lib/utils/Lazy.d.ts +1 -1
- package/lib/utils/Lazy.js +2 -2
- package/lib/utils/Name.js +10 -8
- package/lib/utils/Notebook.d.ts +1 -1
- package/lib/utils/Notebook.js +3 -3
- package/lib/utils/Number.js +13 -9
- package/lib/utils/Plots.js +4 -4
- package/lib/utils/Screenshot.js +1 -1
- package/lib/utils/Sleep.js +1 -1
- package/lib/utils/Snapshot.js +2 -2
- package/lib/utils/String.js +2 -2
- package/lib/utils/Uri.js +1 -1
- package/lib/utils/WithSuspense.js +3 -6
- package/lib/utils/logger.d.ts +16 -0
- package/lib/utils/logger.js +52 -0
- package/package.json +49 -5
- package/lib/__tests__/App.test.js +0 -17
- /package/lib/{__tests__/App.test.d.ts → examples/main.d.ts} +0 -0
|
@@ -5,19 +5,19 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
5
5
|
*/
|
|
6
6
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
7
7
|
import { useIsMounted } from 'usehooks-ts';
|
|
8
|
-
import { Button, FormControl, Select, Spinner, Text, TextInput, ToggleSwitch, Tooltip, IconButton } from '@primer/react';
|
|
8
|
+
import { Button, FormControl, Select, Spinner, Text, TextInput, ToggleSwitch, Tooltip, IconButton, } from '@primer/react';
|
|
9
9
|
import { Dialog } from '@primer/react/experimental';
|
|
10
10
|
import { AlertIcon } from '@primer/octicons-react';
|
|
11
|
-
import { Box } from
|
|
11
|
+
import { Box } from '@datalayer/primer-addons';
|
|
12
12
|
import { USAGE_ROUTE } from '../../routes';
|
|
13
13
|
import { useNavigate } from '../../hooks';
|
|
14
14
|
import { NO_RUNTIME_AVAILABLE_LABEL } from '../../i18n';
|
|
15
|
-
import { iamStore, useCoreStore, useIAMStore, useRuntimesStore } from '../../state';
|
|
15
|
+
import { iamStore, useCoreStore, useIAMStore, useRuntimesStore, } from '../../state';
|
|
16
16
|
import { createNotebook, sleep } from '../../utils';
|
|
17
17
|
import { Markdown } from '../display';
|
|
18
18
|
import { Timer } from '../progress';
|
|
19
19
|
import { FlashClosable } from '../flashes';
|
|
20
|
-
import { RuntimeReservationControl, MAXIMAL_RUNTIME_TIME_RESERVATION_MINUTES } from './RuntimeReservationControl';
|
|
20
|
+
import { RuntimeReservationControl, MAXIMAL_RUNTIME_TIME_RESERVATION_MINUTES, } from './RuntimeReservationControl';
|
|
21
21
|
/**
|
|
22
22
|
* Initial time in milliseconds before retrying in case no kernels are available
|
|
23
23
|
*/
|
|
@@ -30,7 +30,7 @@ const NOT_AVAILABLE_RETRIES = 5;
|
|
|
30
30
|
* Start Remote Runtime Dialog.
|
|
31
31
|
*/
|
|
32
32
|
export function KernelLauncherDialog(props) {
|
|
33
|
-
const { dialogTitle, kernelSnapshot, manager, onSubmit, markdownParser, sanitizer, upgradeSubscription, startKernel = true } = props;
|
|
33
|
+
const { dialogTitle, kernelSnapshot, manager, onSubmit, markdownParser, sanitizer, upgradeSubscription, startKernel = true, } = props;
|
|
34
34
|
const hasExample = startKernel === 'with-example';
|
|
35
35
|
const user = iamStore.getState().user;
|
|
36
36
|
const environments = manager.environments.get();
|
|
@@ -87,7 +87,8 @@ export function KernelLauncherDialog(props) {
|
|
|
87
87
|
location: 'remote',
|
|
88
88
|
displayName: runtimeName ?? spec?.title,
|
|
89
89
|
};
|
|
90
|
-
const creditsLimit = Math.min(timeLimit, MAXIMAL_RUNTIME_TIME_RESERVATION_MINUTES) /
|
|
90
|
+
const creditsLimit = Math.min(timeLimit, MAXIMAL_RUNTIME_TIME_RESERVATION_MINUTES) /
|
|
91
|
+
creditsToMinutes;
|
|
91
92
|
desc.params = {};
|
|
92
93
|
if (startKernel === 'defer') {
|
|
93
94
|
desc.params['creditsLimit'] = creditsLimit;
|
|
@@ -108,13 +109,11 @@ export function KernelLauncherDialog(props) {
|
|
|
108
109
|
type: 'notebook',
|
|
109
110
|
givenName: runtimeName,
|
|
110
111
|
creditsLimit: creditsLimit,
|
|
111
|
-
capabilities: userStorage
|
|
112
|
-
|
|
113
|
-
: undefined,
|
|
114
|
-
snapshot: kernelSnapshot?.id
|
|
112
|
+
capabilities: userStorage ? ['user_storage'] : undefined,
|
|
113
|
+
snapshot: kernelSnapshot?.id,
|
|
115
114
|
}, {
|
|
116
115
|
username: user?.handle,
|
|
117
|
-
handleComms: true
|
|
116
|
+
handleComms: true,
|
|
118
117
|
});
|
|
119
118
|
desc.kernelId = connection.id;
|
|
120
119
|
if (jupyterLabAdapter?.jupyterLab && hasExample && openExample) {
|
|
@@ -122,13 +121,13 @@ export function KernelLauncherDialog(props) {
|
|
|
122
121
|
if (example) {
|
|
123
122
|
const options = {
|
|
124
123
|
kernelId: connection.id,
|
|
125
|
-
kernelName: connection.name
|
|
124
|
+
kernelName: connection.name,
|
|
126
125
|
};
|
|
127
126
|
createNotebook({
|
|
128
127
|
app: jupyterLabAdapter.jupyterLab,
|
|
129
128
|
name: selection,
|
|
130
129
|
url: example,
|
|
131
|
-
options
|
|
130
|
+
options,
|
|
132
131
|
});
|
|
133
132
|
}
|
|
134
133
|
}
|
|
@@ -190,7 +189,7 @@ export function KernelLauncherDialog(props) {
|
|
|
190
189
|
openExample,
|
|
191
190
|
jupyterLabAdapter,
|
|
192
191
|
timeLimit,
|
|
193
|
-
isMounted
|
|
192
|
+
isMounted,
|
|
194
193
|
]);
|
|
195
194
|
const handleUserStorageChange = useCallback((e) => {
|
|
196
195
|
e.preventDefault();
|
|
@@ -211,23 +210,24 @@ export function KernelLauncherDialog(props) {
|
|
|
211
210
|
setHasCustomRuntimeName(true);
|
|
212
211
|
}
|
|
213
212
|
}, []);
|
|
214
|
-
return (_jsx(Dialog, { title: dialogTitle || 'Launch a new Runtime', onClose: () => {
|
|
213
|
+
return (_jsx(Dialog, { title: dialogTitle || 'Launch a new Runtime', onClose: () => {
|
|
214
|
+
onSubmit(undefined);
|
|
215
|
+
}, footerButtons: [
|
|
215
216
|
{
|
|
216
217
|
buttonType: 'default',
|
|
217
|
-
onClick: () => {
|
|
218
|
+
onClick: () => {
|
|
219
|
+
onSubmit(undefined);
|
|
220
|
+
},
|
|
218
221
|
content: 'Cancel',
|
|
219
|
-
disabled: waitingForRuntime
|
|
222
|
+
disabled: waitingForRuntime,
|
|
220
223
|
},
|
|
221
224
|
{
|
|
222
225
|
buttonType: 'primary',
|
|
223
226
|
onClick: handleSubmitKernel,
|
|
224
|
-
content: waitingForRuntime ?
|
|
225
|
-
_jsx(Spinner, { size: "small" })
|
|
226
|
-
:
|
|
227
|
-
startKernel ?? true ? 'Launch' : 'Assign from the Environment',
|
|
227
|
+
content: waitingForRuntime ? (_jsx(Spinner, { size: "small" })) : (startKernel ?? true) ? ('Launch') : ('Assign from the Environment'),
|
|
228
228
|
disabled: waitingForRuntime || outOfCredits || timeLimit < Number.EPSILON,
|
|
229
|
-
autoFocus: true
|
|
230
|
-
}
|
|
229
|
+
autoFocus: true,
|
|
230
|
+
},
|
|
231
231
|
], children: _jsxs(Box, { as: "form", onKeyDown: event => {
|
|
232
232
|
if (event.defaultPrevented) {
|
|
233
233
|
return;
|
|
@@ -236,15 +236,11 @@ export function KernelLauncherDialog(props) {
|
|
|
236
236
|
event.preventDefault();
|
|
237
237
|
handleSubmitKernel();
|
|
238
238
|
}
|
|
239
|
-
}, children: [_jsxs(FormControl, { disabled: !!kernelSnapshot?.environment || environments.length === 0, children: [_jsx(FormControl.Label, { children: "Environment" }), _jsx(Select, { name: "environment", disabled: !!kernelSnapshot?.environment || environments.length === 0, value: selection, onChange: handleSelectionChange, block: true, children: environments.map(spec => (_jsxs(Select.Option, { value: spec.name, children: [spec.name, spec.title && (_jsxs(_Fragment, { children: [' - ', spec.title] }))] }, spec.name))) }), _jsx(FormControl.Caption, { children: _jsx(_Fragment, { children: markdownParser ? (_jsx(Box, { sx: { img: { maxWidth: '100%' } }, children: _jsx(Markdown, { text: description, markdownParser: markdownParser, sanitizer: sanitizer }) })) : (description) }) })] }), startKernel &&
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
_jsxs(FormControl, { sx: { paddingTop: '10px' }, children: [_jsx(FormControl.Label, { children: "Open example notebook" }), _jsx(ToggleSwitch, { disabled: !environments.find(spec => spec.name === selection)?.example, checked: openExample, size: "small", onClick: handleSwitchClick })] }), error &&
|
|
246
|
-
_jsx(FlashClosable, { variant: flashLevel, actions: navigate && upgradeSubscription && flashLevel === 'warning' ?
|
|
247
|
-
_jsx(Button, { onClick: handleUpgrade, title: 'Upgrade your subscription.', children: "Upgrade" })
|
|
248
|
-
:
|
|
249
|
-
undefined, children: error })] }) }));
|
|
239
|
+
}, children: [_jsxs(FormControl, { disabled: !!kernelSnapshot?.environment || environments.length === 0, children: [_jsx(FormControl.Label, { children: "Environment" }), _jsx(Select, { name: "environment", disabled: !!kernelSnapshot?.environment || environments.length === 0, value: selection, onChange: handleSelectionChange, block: true, children: environments.map(spec => (_jsxs(Select.Option, { value: spec.name, children: [spec.name, spec.title && (_jsxs(_Fragment, { children: [' - ', spec.title] }))] }, spec.name))) }), _jsx(FormControl.Caption, { children: _jsx(_Fragment, { children: markdownParser ? (_jsx(Box, { sx: { img: { maxWidth: '100%' } }, children: _jsx(Markdown, { text: description, markdownParser: markdownParser, sanitizer: sanitizer }) })) : (description) }) })] }), startKernel && (_jsx(RuntimeReservationControl, { addCredits: navigate
|
|
240
|
+
? () => {
|
|
241
|
+
navigate(USAGE_ROUTE);
|
|
242
|
+
}
|
|
243
|
+
: undefined, disabled: outOfCredits, label: 'Time reservation', max: max, time: timeLimit, burningRate: burningRate, onTimeChange: setTimeLimit, error: outOfCredits ? 'You must add credits to your account.' : undefined })), !configuration.whiteLabel && (_jsxs(FormControl, { layout: "horizontal", children: [_jsxs(FormControl.Label, { id: "user-storage-label", children: ["User storage", _jsx(Tooltip, { text: 'The runtime will be slower to start.', direction: "e", style: { marginLeft: 3 }, children: _jsx(IconButton, { icon: AlertIcon, "aria-label": "", variant: "invisible" }) })] }), _jsx(ToggleSwitch, { checked: userStorage, size: "small", onClick: handleUserStorageChange, "aria-labelledby": "user-storage-label" })] })), _jsxs(FormControl, { sx: { paddingTop: '10px' }, children: [_jsx(FormControl.Label, { children: "Runtime name" }), _jsx(TextInput, { name: "name", value: runtimeName, onChange: handleKernelNameChange, block: true })] }), hasExample &&
|
|
244
|
+
jupyterLabAdapter?.jupyterLab &&
|
|
245
|
+
!configuration.whiteLabel && (_jsxs(FormControl, { sx: { paddingTop: '10px' }, children: [_jsx(FormControl.Label, { id: "open-example-label", children: "Open example notebook" }), _jsx(ToggleSwitch, { disabled: !environments.find(spec => spec.name === selection)?.example, checked: openExample, size: "small", onClick: handleSwitchClick, "aria-labelledby": "open-example-label" })] })), error && (_jsx(FlashClosable, { variant: flashLevel, actions: navigate && upgradeSubscription && flashLevel === 'warning' ? (_jsx(Button, { onClick: handleUpgrade, title: 'Upgrade your subscription.', children: "Upgrade" })) : undefined, children: error }))] }) }));
|
|
250
246
|
}
|
|
@@ -6,9 +6,9 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
6
6
|
import { useEffect, useMemo, useState } from 'react';
|
|
7
7
|
import { nullTranslator } from '@jupyterlab/translation';
|
|
8
8
|
//import { kernelIcon } from '@jupyterlab/ui-components';
|
|
9
|
-
import { ActionList, ActionMenu, IconButton, Text, RadioGroup, Radio, FormControl, LabelGroup, Label } from '@primer/react';
|
|
9
|
+
import { ActionList, ActionMenu, IconButton, Text, RadioGroup, Radio, FormControl, LabelGroup, Label, } from '@primer/react';
|
|
10
10
|
import CloudUploadIcon from '@datalayer/icons-react/data1/CloudUploadIcon';
|
|
11
|
-
import { Box } from
|
|
11
|
+
import { Box } from '@datalayer/primer-addons';
|
|
12
12
|
import { CpuIcon } from '@primer/octicons-react';
|
|
13
13
|
import { BrowserIcon, LaptopSimpleIcon } from '@datalayer/icons-react';
|
|
14
14
|
import { CreditsIndicator } from '../../components/progress';
|
|
@@ -29,7 +29,7 @@ export function RuntimePickerBase(props) {
|
|
|
29
29
|
// Trick because overflow is an unknown prop of ActionMenu.Overlay.
|
|
30
30
|
const overlayProps = {
|
|
31
31
|
maxHeight: 'large',
|
|
32
|
-
width: (variant === 'cell' ? 'small' : 'auto')
|
|
32
|
+
width: (variant === 'cell' ? 'small' : 'auto'),
|
|
33
33
|
};
|
|
34
34
|
/*
|
|
35
35
|
// TODO this effect generates refresh of the react components which discards any change in the selection.
|
|
@@ -77,33 +77,44 @@ export function RuntimePickerBase(props) {
|
|
|
77
77
|
// For cell using submenu instead of group would be nice unfortunately the feature
|
|
78
78
|
// is not yet implemented in the component there has been a not-great demo story.
|
|
79
79
|
// https://github.com/primer/react/pull/3585
|
|
80
|
-
return (_jsx(_Fragment, { children: display === 'menu' ?
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
80
|
+
return (_jsx(_Fragment, { children: display === 'menu' ? (
|
|
81
|
+
/*
|
|
82
|
+
* Section for Menu display.
|
|
83
|
+
*/
|
|
84
|
+
_jsxs(ActionMenu, { children: [variant === 'cell' ? (_jsx(ActionMenu.Anchor, { children: _jsx(IconButton, { disabled: disabled || groupedKernelDescs === null,
|
|
85
|
+
// icon={() => <kernelIcon.react className="dla-Cell-runtime-icon" tag={'span'} />}
|
|
86
|
+
icon: () => (_jsx("span", { className: "dla-Cell-runtime-icon", children: _jsx(CpuIcon, {}) })), "aria-label": trans.__('Assign a Runtime to the Cell.'), title: trans.__('Assign a Runtime to the Cell.'), size: "small", variant: "invisible" }) })) : (_jsxs(ActionMenu.Button, { variant: "default", disabled: disabled || groupedKernelDescs === null, children: [_jsx(Text, { fontWeight: 'bold', children: trans.__('Runtime:') }), ' ' + (runtimeDesc?.displayName ?? trans.__('No Runtime'))] })), _jsx(ActionMenu.Overlay, { ...overlayProps, width: "medium", sx: { overflowY: 'auto' }, side: variant === 'cell' ? 'outside-left' : 'outside-right', children: _jsxs(ActionList, { selectionVariant: "single", children: [variant === 'cell' && (_jsxs(ActionList.Item, { selected: runtimeDesc === undefined, onSelect: () => {
|
|
87
|
+
setRuntimeDesc(undefined);
|
|
88
|
+
}, children: [preference?.location && (_jsx(ActionList.LeadingVisual, { children: preference.location === 'local' ? (_jsx(LaptopSimpleIcon, {})) : preference.location === 'browser' ? (_jsx(BrowserIcon, {})) : (_jsx(CloudUploadIcon, {})) })), trans.__('Assign the Notebook Runtime')] }, 'null')), !!preActions && preActions, Object.entries(groupedKernelDescs ?? {}).map(([group, runtimeDescs]) => (_jsxs(ActionList.Group, { children: [_jsx(ActionList.GroupHeading, { children: group }), runtimeDescs.map(runtimeDesc => {
|
|
89
|
+
const annotation = runtimeDesc.podName
|
|
90
|
+
? ` - ${runtimeDesc.podName.split('-', 2).reverse()[0]}`
|
|
91
|
+
: runtimeDesc.kernelId
|
|
92
|
+
? ` - ${runtimeDesc.kernelId}`
|
|
93
|
+
: '';
|
|
94
|
+
const fullDisplayName = (runtimeDesc.displayName ?? '') + annotation;
|
|
95
|
+
const displayName = (runtimeDesc.displayName?.length ?? 0) >
|
|
96
|
+
RUNTIME_DISPLAY_NAME_MAX_LENGTH
|
|
97
|
+
? runtimeDesc.displayName.slice(0, RUNTIME_DISPLAY_NAME_MAX_LENGTH) + '…'
|
|
98
|
+
: (runtimeDesc.displayName ?? '');
|
|
99
|
+
return (_jsxs(ActionList.Item, { title: fullDisplayName, selected: (runtimeDesc.location === runtimeDesc?.location ||
|
|
100
|
+
(isRuntimeRemote(runtimeDesc.location) &&
|
|
101
|
+
isRuntimeRemote(runtimeDesc?.location ?? 'local'))) &&
|
|
102
|
+
(runtimeDesc.kernelId ?? runtimeDesc.name) ===
|
|
103
|
+
(runtimeDesc?.kernelId ?? runtimeDesc?.name), onSelect: () => {
|
|
104
|
+
setRuntimeDesc(runtimeDesc);
|
|
105
|
+
}, children: [_jsx(ActionList.LeadingVisual, { children: runtimeDesc.location === 'local' ? (_jsx(LaptopSimpleIcon, {})) : runtimeDesc.location === 'browser' ? (_jsx(BrowserIcon, {})) : (_jsx(CloudUploadIcon, {})) }), displayName + annotation.slice(0, 10)] }, runtimeDesc.name));
|
|
106
|
+
})] }, group))), !!postActions && (_jsxs(_Fragment, { children: [_jsx(ActionList.Divider, {}), postActions] }))] }) })] })) : (
|
|
107
|
+
/*
|
|
108
|
+
* Section for Radio display.
|
|
109
|
+
*/
|
|
110
|
+
_jsxs(_Fragment, { children: [defaultSet && (_jsx(RadioGroup, { name: "kernel-options", "aria-labelledby": "kernel-options", children: Object.entries(groupedKernelDescs ?? {}).map(([group, runtimeDescs]) => (_jsxs(Box, { children: [_jsx(Box, { as: "h4", style: { marginTop: 0 }, children: group }), runtimeDescs.map(k => {
|
|
111
|
+
return (_jsxs(Box, { title: k.name, children: [_jsxs(FormControl, { children: [_jsx(Radio, { value: k.kernelId, onChange: () => {
|
|
112
|
+
setRuntimeDesc(k);
|
|
113
|
+
}, checked: (k.location === k?.location ||
|
|
114
|
+
(isRuntimeRemote(k.location) &&
|
|
115
|
+
isRuntimeRemote(k?.location ?? 'local'))) &&
|
|
116
|
+
(k.kernelId ?? k.name) ===
|
|
117
|
+
(runtimeDesc?.kernelId ?? runtimeDesc?.name) }), _jsx(FormControl.Label, { children: _jsxs(Box, { display: "flex", children: [_jsx(Box, { children: k.displayName }), k.kernelId && k.location === 'remote' && (_jsx(Box, { ml: 3, mt: 1, children: _jsx(CreditsIndicator, { kernelId: k.kernelId, serviceManager: multiServiceManager.remote }, "credits-indicator") }))] }) }), _jsx(FormControl.Caption, { children: _jsxs(LabelGroup, { sx: { marginTop: 1 }, children: [_jsx(Label, { variant: "secondary", children: k.name }), _jsx(Label, { variant: "secondary", sx: { marginLeft: 1 }, children: k.location }), k.burningRate && (_jsxs(Label, { variant: "sponsors", sx: { marginLeft: 1 }, children: [k.burningRate, " credits/second"] })), k.gpu && (_jsx(Label, { variant: "success", sx: { marginLeft: 1 }, children: "GPU" }))] }) })] }), _jsx(ActionList.Divider, {})] }, k.kernelId));
|
|
118
|
+
})] }, group))) })), !!postActions && _jsx(_Fragment, { children: postActions })] })) }));
|
|
108
119
|
}
|
|
109
120
|
export default RuntimePickerBase;
|
|
@@ -18,7 +18,7 @@ import { RuntimeCellVariablesDialog } from './RuntimeCellVariablesDialog';
|
|
|
18
18
|
* Kernel picker component for a cell.
|
|
19
19
|
*/
|
|
20
20
|
export function RuntimePickerCell(props) {
|
|
21
|
-
const { logIn, markdownParser, model, preference, sanitizer, multiServiceManager, sessionContext, translator } = props;
|
|
21
|
+
const { logIn, markdownParser, model, preference, sanitizer, multiServiceManager, sessionContext, translator, } = props;
|
|
22
22
|
const { token } = useIAMStore();
|
|
23
23
|
const { configuration } = useCoreStore();
|
|
24
24
|
const [isForeign, setIsForeign] = useState(false);
|
|
@@ -37,7 +37,9 @@ export function RuntimePickerCell(props) {
|
|
|
37
37
|
setHasCellKernel(kernel?.params?.notebook === false);
|
|
38
38
|
const newSnippets = new Array();
|
|
39
39
|
if (kernel) {
|
|
40
|
-
const spec = multiServiceManager.remote?.environments
|
|
40
|
+
const spec = multiServiceManager.remote?.environments
|
|
41
|
+
.get()
|
|
42
|
+
.find(env => env.name === kernel.name);
|
|
41
43
|
setLanguage(spec?.language ?? '');
|
|
42
44
|
if (spec?.snippets) {
|
|
43
45
|
newSnippets.push(...spec.snippets);
|
|
@@ -57,7 +59,9 @@ export function RuntimePickerCell(props) {
|
|
|
57
59
|
(!preference?.language || desc.language === preference?.language));
|
|
58
60
|
}, [preference]);
|
|
59
61
|
const setSelectedKernelDesc = useCallback((kernel) => {
|
|
60
|
-
const datalayerMeta = model.getMetadata('datalayer') ?? {
|
|
62
|
+
const datalayerMeta = model.getMetadata('datalayer') ?? {
|
|
63
|
+
kernel: undefined,
|
|
64
|
+
};
|
|
61
65
|
if (!kernel) {
|
|
62
66
|
delete datalayerMeta.kernel;
|
|
63
67
|
model.setMetadata('datalayer', datalayerMeta);
|
|
@@ -85,7 +89,7 @@ export function RuntimePickerCell(props) {
|
|
|
85
89
|
if (desc) {
|
|
86
90
|
desc.params = {
|
|
87
91
|
...desc.params,
|
|
88
|
-
notebook: false
|
|
92
|
+
notebook: false,
|
|
89
93
|
};
|
|
90
94
|
setSelectedKernelDesc(desc);
|
|
91
95
|
}
|
|
@@ -94,13 +98,6 @@ export function RuntimePickerCell(props) {
|
|
|
94
98
|
const datalayerMeta = model.getMetadata('datalayer') ?? {};
|
|
95
99
|
return (_jsxs(_Fragment, { children: [_jsx(RuntimePickerBase, { display: "menu", filterKernel: filterKernel, preference: preference, multiServiceManager: multiServiceManager, runtimeDesc: datalayerMeta.kernel ? datalayerMeta.kernel : undefined, setRuntimeDesc: setSelectedKernelDesc, variant: 'cell', preActions: _jsxs(ActionList.Item, { disabled: !multiServiceManager.remote, onSelect: setCell, selected: hasCellKernel, title: !multiServiceManager.remote
|
|
96
100
|
? 'You are not connected with Datalayer.'
|
|
97
|
-
: 'Assign a new temporary Runtime on each Cell execution.', children: [_jsx(ActionList.LeadingVisual, { children: _jsx(CloudUploadIcon, {}) }), trans.__('Assign a Cell Runtime')] }), postActions: token || !logIn ?
|
|
98
|
-
_jsxs(_Fragment, { children: [RuntimeSnippetsFacade.supports(preference?.language ?? '') && (_jsx(ActionList.Item, { onSelect: openVariableDialog, disabled: !isForeign, title: trans.__('Define variables to transfer between the document kernel and the cell kernel.'), children: trans.__('Define Cell Variables Transfer') })), !configuration.whiteLabel &&
|
|
99
|
-
_jsx(ActionList.Item, { onSelect: openSnippetDialog, disabled: snippets.length === 0, title: trans.__('Inject a code snippet at the end of the cell.'), children: trans.__('Inject Code Snippet') })] })
|
|
100
|
-
:
|
|
101
|
-
_jsx(ActionList.Item, { onSelect: props.logIn, title: 'Connect to the Runtime provider.', children: _jsx(ExternalTokenSilentLogin, { message: "Connect to the Runtime provider" }) }), translator: translator }), isVariableDialogOpen &&
|
|
102
|
-
_jsx(RuntimeCellVariablesDialog, { model: model, onClose: closeVariableDialog, preference: preference, sessionContext: sessionContext, translator: translator }), isSnippetDialogOpen &&
|
|
103
|
-
_jsx(SnippetDialog, { language: language, model: model, snippets: snippets, onClose: closeSnippetDialog, markdownParser: markdownParser, sanitizer: sanitizer }), isKernelDialogOpen &&
|
|
104
|
-
_jsx(KernelLauncherDialog, { manager: multiServiceManager.remote, onSubmit: onStartRemote, startKernel: false, markdownParser: markdownParser, sanitizer: sanitizer })] }));
|
|
101
|
+
: 'Assign a new temporary Runtime on each Cell execution.', children: [_jsx(ActionList.LeadingVisual, { children: _jsx(CloudUploadIcon, {}) }), trans.__('Assign a Cell Runtime')] }), postActions: token || !logIn ? (_jsxs(_Fragment, { children: [RuntimeSnippetsFacade.supports(preference?.language ?? '') && (_jsx(ActionList.Item, { onSelect: openVariableDialog, disabled: !isForeign, title: trans.__('Define variables to transfer between the document kernel and the cell kernel.'), children: trans.__('Define Cell Variables Transfer') })), !configuration.whiteLabel && (_jsx(ActionList.Item, { onSelect: openSnippetDialog, disabled: snippets.length === 0, title: trans.__('Inject a code snippet at the end of the cell.'), children: trans.__('Inject Code Snippet') }))] })) : (_jsx(ActionList.Item, { onSelect: props.logIn, title: 'Connect to the Runtime provider.', children: _jsx(ExternalTokenSilentLogin, { message: "Connect to the Runtime provider" }) })), translator: translator }), isVariableDialogOpen && (_jsx(RuntimeCellVariablesDialog, { model: model, onClose: closeVariableDialog, preference: preference, sessionContext: sessionContext, translator: translator })), isSnippetDialogOpen && (_jsx(SnippetDialog, { language: language, model: model, snippets: snippets, onClose: closeSnippetDialog, markdownParser: markdownParser, sanitizer: sanitizer })), isKernelDialogOpen && (_jsx(KernelLauncherDialog, { manager: multiServiceManager.remote, onSubmit: onStartRemote, startKernel: false, markdownParser: markdownParser, sanitizer: sanitizer }))] }));
|
|
105
102
|
}
|
|
106
103
|
export default RuntimePickerCell;
|
|
@@ -4,8 +4,8 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
6
|
import { useCallback, useEffect, useState } from 'react';
|
|
7
|
-
import { ActionList, FormControl, ToggleSwitch, Tooltip, IconButton } from '@primer/react';
|
|
8
|
-
import { Box } from
|
|
7
|
+
import { ActionList, FormControl, ToggleSwitch, Tooltip, IconButton, } from '@primer/react';
|
|
8
|
+
import { Box } from '@datalayer/primer-addons';
|
|
9
9
|
import { AlertIcon } from '@primer/octicons-react';
|
|
10
10
|
import { JSONExt } from '@lumino/coreutils';
|
|
11
11
|
import { KernelExecutor } from '@datalayer/jupyter-react';
|
|
@@ -13,7 +13,7 @@ import { DatalayerThemeProvider } from '../../theme';
|
|
|
13
13
|
import { RuntimeSnippetsFacade } from '../../api';
|
|
14
14
|
import { ExternalTokenSilentLogin } from '../../components/iam';
|
|
15
15
|
import { useCoreStore, useIAMStore } from '../../state';
|
|
16
|
-
import { RuntimeReservationControl, MAXIMAL_RUNTIME_TIME_RESERVATION_MINUTES } from './RuntimeReservationControl';
|
|
16
|
+
import { RuntimeReservationControl, MAXIMAL_RUNTIME_TIME_RESERVATION_MINUTES, } from './RuntimeReservationControl';
|
|
17
17
|
import { RuntimeVariables } from './RuntimeVariables';
|
|
18
18
|
import { RuntimePickerBase } from './RuntimePickerBase';
|
|
19
19
|
/**
|
|
@@ -45,7 +45,7 @@ export function RuntimePickerNotebook(props) {
|
|
|
45
45
|
kernelId: sessionContext.session.kernel.id,
|
|
46
46
|
location: sessionContext.location,
|
|
47
47
|
language: spec.language,
|
|
48
|
-
displayName: sessionContext.kernelDisplayName
|
|
48
|
+
displayName: sessionContext.kernelDisplayName,
|
|
49
49
|
});
|
|
50
50
|
setTransferFrom(RuntimeSnippetsFacade.supports(spec.language));
|
|
51
51
|
}
|
|
@@ -102,7 +102,8 @@ export function RuntimePickerNotebook(props) {
|
|
|
102
102
|
}
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
|
-
if (selectedRuntimeDesc?.displayName !== runtimeDesc.displayName ||
|
|
105
|
+
if (selectedRuntimeDesc?.displayName !== runtimeDesc.displayName ||
|
|
106
|
+
selectedRuntimeDesc?.kernelId !== runtimeDesc.kernelId) {
|
|
106
107
|
setSelectedRuntimeDesc({ ...runtimeDesc });
|
|
107
108
|
setTransferTo(RuntimeSnippetsFacade.supports(runtimeDesc.language));
|
|
108
109
|
}
|
|
@@ -112,57 +113,56 @@ export function RuntimePickerNotebook(props) {
|
|
|
112
113
|
setUserStorage(!userStorage);
|
|
113
114
|
}, [userStorage]);
|
|
114
115
|
useEffect(() => {
|
|
115
|
-
const creditsLimit = selectedRuntimeDesc?.location === 'remote' &&
|
|
116
|
+
const creditsLimit = selectedRuntimeDesc?.location === 'remote' &&
|
|
117
|
+
selectedRuntimeDesc.burningRate
|
|
116
118
|
? Math.min(timeLimit, MAXIMAL_RUNTIME_TIME_RESERVATION_MINUTES) *
|
|
117
119
|
selectedRuntimeDesc.burningRate *
|
|
118
120
|
60
|
|
119
121
|
: undefined;
|
|
120
|
-
setValue(creditsLimit !== 0
|
|
121
|
-
{
|
|
122
|
+
setValue(creditsLimit !== 0
|
|
123
|
+
? {
|
|
122
124
|
kernel: selectedRuntimeDesc
|
|
123
|
-
?
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
:
|
|
133
|
-
null,
|
|
125
|
+
? {
|
|
126
|
+
environmentName: ['browser', 'remote'].includes(selectedRuntimeDesc.location)
|
|
127
|
+
? `${selectedRuntimeDesc.location}-${selectedRuntimeDesc.name}`
|
|
128
|
+
: selectedRuntimeDesc.name,
|
|
129
|
+
id: selectedRuntimeDesc.kernelId,
|
|
130
|
+
creditsLimit,
|
|
131
|
+
capabilities: userStorage ? ['user_storage'] : undefined,
|
|
132
|
+
}
|
|
133
|
+
: null,
|
|
134
134
|
selectedVariables: toTransfer,
|
|
135
135
|
}
|
|
136
136
|
: new Error('Credits limit must be strictly positive.'));
|
|
137
137
|
}, [selectedRuntimeDesc, userStorage, toTransfer, timeLimit]);
|
|
138
|
-
const { kernelPreference: { canStart } } = sessionContext;
|
|
138
|
+
const { kernelPreference: { canStart }, } = sessionContext;
|
|
139
139
|
const max = Math.floor((credits?.available ?? 0) / (selectedRuntimeDesc?.burningRate ?? -1) / 60.0);
|
|
140
140
|
const outOfCredits = !credits?.available || max < Number.EPSILON;
|
|
141
141
|
return (_jsx(DatalayerThemeProvider, { children: _jsxs(Box, { as: "form", className: "dla-Runtimes-picker", children: [_jsx(Box, { sx: { padding: 'var(--stack-padding-condensed) 0' }, children: _jsx(RuntimePickerBase, { display: "radio", disabled: canStart === false, preference: {
|
|
142
142
|
id: sessionContext.session?.id,
|
|
143
|
-
kernelDisplayName: sessionContext.kernelPreference.shouldStart
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
_jsxs(_Fragment, { children: [_jsx(RuntimeReservationControl, { disabled: outOfCredits || selectedRuntimeDesc?.location !== 'remote', label: 'Time reservation', max: max < 0 ? 1 : max, time: timeLimit, onTimeChange: setTimeLimit, error: outOfCredits && max >= 0
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
143
|
+
kernelDisplayName: sessionContext.kernelPreference.shouldStart
|
|
144
|
+
? sessionContext.kernelDisplayName
|
|
145
|
+
: undefined,
|
|
146
|
+
}, sessionContext: sessionContext, multiServiceManager: multiServiceManager, translator: translator, runtimeDesc: selectedRuntimeDesc, setRuntimeDesc: setRuntimeDesc, postActions: token || !props.logIn ? (
|
|
147
|
+
/*
|
|
148
|
+
<Button
|
|
149
|
+
variant="default"
|
|
150
|
+
onClick={e => {
|
|
151
|
+
e.preventDefault();
|
|
152
|
+
commands.execute(CommandIDs.launchRemoteRuntime);
|
|
153
|
+
close();
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
Launch a New Runtime
|
|
157
|
+
</Button>
|
|
158
|
+
*/
|
|
159
|
+
_jsx(_Fragment, {})) : (_jsx(ActionList.Item, { onSelect: props.logIn, title: 'Connect to Runtime provider.', children: _jsx(ExternalTokenSilentLogin, { message: "Connect to the Runtime provider" }) })) }) }), !selectedRuntimeDesc?.kernelId &&
|
|
160
|
+
selectedRuntimeDesc?.location === 'remote' && (_jsxs(_Fragment, { children: [_jsx(RuntimeReservationControl, { disabled: outOfCredits || selectedRuntimeDesc?.location !== 'remote', label: 'Time reservation', max: max < 0 ? 1 : max, time: timeLimit, onTimeChange: setTimeLimit, error: outOfCredits && max >= 0
|
|
161
|
+
? 'You must add credits to your account.'
|
|
162
|
+
: timeLimit === 0
|
|
163
|
+
? 'You must set a time limit.'
|
|
164
|
+
: undefined, burningRate: selectedRuntimeDesc.burningRate }), !configuration.whiteLabel && (_jsxs(FormControl, { disabled: !!selectedRuntimeDesc?.kernelId ||
|
|
165
|
+
selectedRuntimeDesc?.location !== 'remote', layout: "horizontal", children: [_jsxs(FormControl.Label, { id: "user-storage-picker-label", children: ["User storage", _jsx(Tooltip, { text: "The runtime will be slower to start.", direction: "e", style: { marginLeft: 3 }, children: _jsx(IconButton, { icon: AlertIcon, "aria-label": "", variant: "invisible" }) })] }), _jsx(ToggleSwitch, { disabled: !!selectedRuntimeDesc?.kernelId ||
|
|
166
|
+
selectedRuntimeDesc?.location !== 'remote', checked: userStorage, size: "small", onClick: handleUserStorageChange, "aria-labelledby": "user-storage-picker-label" })] }))] })), canTransferFrom && canTransferTo && (_jsx(RuntimeVariables, { selectedVariables: toTransfer, setSelectVariable: setSelectedVariables, transferVariables: transferVariables, setTransferVariable: setTransferVariable, kernelVariables: kernelVariables, translator: translator }))] }) }));
|
|
167
167
|
}
|
|
168
168
|
export default RuntimePickerNotebook;
|
|
@@ -4,7 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
6
|
import { FormControl, IconButton, Text, TextInput } from '@primer/react';
|
|
7
|
-
import { Box } from
|
|
7
|
+
import { Box } from '@datalayer/primer-addons';
|
|
8
8
|
import { PlusIcon } from '@primer/octicons-react';
|
|
9
9
|
import { Slider } from '@datalayer/primer-addons';
|
|
10
10
|
/**
|
|
@@ -21,18 +21,13 @@ export function RuntimeReservationControl(props) {
|
|
|
21
21
|
const max = Math.min(maxProps, MAXIMAL_RUNTIME_TIME_RESERVATION_MINUTES);
|
|
22
22
|
// Temporary workaround to not show disabled components.
|
|
23
23
|
const hidden = disabled;
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} }), (max === 0 || max > Number.EPSILON) && (_jsxs(_Fragment, { children: [_jsxs(Text, { children: ["out of ", maxProps, " available minutes"] }), addCredits &&
|
|
34
|
-
_jsx(IconButton, { icon: PlusIcon, "aria-label": "Add credits", onClick: () => addCredits() })] }))] }), _jsxs(FormControl.Caption, { children: ["Maximum execution time that can be consumed by the runtime. It must be less than ", (MAXIMAL_RUNTIME_TIME_RESERVATION_MINUTES / 60).toFixed(0), ' ', " hours.", burningRate &&
|
|
35
|
-
_jsxs(_Fragment, { children: [_jsx("br", {}), `With the current value, the runtime execution will consume at most ${(time * burningRate * 60).toFixed(2)} credits.`] })] }), error && _jsx(FormControl.Validation, { variant: "error", children: error })] })
|
|
36
|
-
:
|
|
37
|
-
_jsx(_Fragment, {}));
|
|
24
|
+
return !hidden ? (_jsxs(FormControl, { disabled: disabled, sx: { paddingBottom: 'var(--stack-padding-condensed)' }, children: [_jsx(FormControl.Label, { children: label }), _jsxs(Box, { style: {
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
display: 'grid',
|
|
27
|
+
gridTemplateColumns: 'max-content 1fr max-content max-content',
|
|
28
|
+
gridGap: 'var(--stack-gap-condensed)',
|
|
29
|
+
width: '100%',
|
|
30
|
+
}, children: [_jsx(Slider, { step: 1, min: 1, max: max, value: time, onChange: onTimeChange, disabled: disabled, label: "", displayValue: false }), _jsx(TextInput, { type: "number", step: "1", min: "1", max: max, disabled: disabled, value: Math.min(max, time).toFixed(2), onChange: event => {
|
|
31
|
+
onTimeChange(parseFloat(event.target.value));
|
|
32
|
+
} }), (max === 0 || max > Number.EPSILON) && (_jsxs(_Fragment, { children: [_jsxs(Text, { children: ["out of ", maxProps, " available minutes"] }), addCredits && (_jsx(IconButton, { icon: PlusIcon, "aria-label": "Add credits", onClick: () => addCredits() }))] }))] }), _jsxs(FormControl.Caption, { children: ["Maximum execution time that can be consumed by the runtime. It must be less than ", (MAXIMAL_RUNTIME_TIME_RESERVATION_MINUTES / 60).toFixed(0), ' ', "hours.", burningRate && (_jsxs(_Fragment, { children: [_jsx("br", {}), `With the current value, the runtime execution will consume at most ${(time * burningRate * 60).toFixed(2)} credits.`] }))] }), error && (_jsx(FormControl.Validation, { variant: "error", children: error }))] })) : (_jsx(_Fragment, {}));
|
|
38
33
|
}
|
|
@@ -76,7 +76,7 @@ export function RuntimeSimplePicker(props) {
|
|
|
76
76
|
runtimeDesc,
|
|
77
77
|
runtimeModel: multiServiceManager?.remote?.runtimesManager
|
|
78
78
|
.get()
|
|
79
|
-
.find(model => model.id === runtimeDesc.kernelId)
|
|
79
|
+
.find(model => model.id === runtimeDesc.kernelId),
|
|
80
80
|
});
|
|
81
81
|
});
|
|
82
82
|
break;
|
|
@@ -92,11 +92,11 @@ export function RuntimeSimplePicker(props) {
|
|
|
92
92
|
if (jupyterLabAdapter) {
|
|
93
93
|
Promise.all([
|
|
94
94
|
jupyterLabAdapter.jupyterLab.resolveOptionalService(IMarkdownParser),
|
|
95
|
-
jupyterLabAdapter.jupyterLab.resolveOptionalService(ISanitizer)
|
|
95
|
+
jupyterLabAdapter.jupyterLab.resolveOptionalService(ISanitizer),
|
|
96
96
|
]).then(services => {
|
|
97
97
|
setLuminoServices({
|
|
98
98
|
[IMarkdownParser.name]: services[0],
|
|
99
|
-
[ISanitizer.name]: services[1]
|
|
99
|
+
[ISanitizer.name]: services[1],
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
102
|
}
|
|
@@ -114,11 +114,8 @@ export function RuntimeSimplePicker(props) {
|
|
|
114
114
|
return _jsx(EyeIcon, {});
|
|
115
115
|
}
|
|
116
116
|
return _jsx(ArtifactIcon, { type: "runtime" });
|
|
117
|
-
}, trailingVisual: () => sessionConnection
|
|
118
|
-
|
|
119
|
-
_jsx(Box, { sx: { paddingTop: '5px' }, children: _jsx(KernelIndicator, { kernel: sessionConnection.kernel }) })
|
|
120
|
-
:
|
|
121
|
-
_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 && sessionConnection === undefined, onSelect: () => {
|
|
117
|
+
}, 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 &&
|
|
118
|
+
sessionConnection === undefined, onSelect: () => {
|
|
122
119
|
setRuntimeLocation(undefined);
|
|
123
120
|
assignRuntime({ runtimeDesc: undefined });
|
|
124
121
|
}, children: [_jsx(ActionList.LeadingVisual, { children: _jsx(EyeIcon, {}) }), "Viewer", _jsx(ActionList.Description, { variant: "block", children: "A simple Notebook Viewer without Runtime." })] }), _jsxs(ActionList.Item, { selected: runtimeLocation === 'browser', onSelect: () => {
|
|
@@ -127,8 +124,8 @@ export function RuntimeSimplePicker(props) {
|
|
|
127
124
|
runtimeDesc: {
|
|
128
125
|
name: 'pyodide',
|
|
129
126
|
location: 'browser',
|
|
130
|
-
language: 'python'
|
|
131
|
-
}
|
|
127
|
+
language: 'python',
|
|
128
|
+
},
|
|
132
129
|
});
|
|
133
130
|
}, 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 => {
|
|
134
131
|
return (_jsxs(ActionList.Item, { selected: sessionConnection?.kernel?.id === kernelModel.id, onSelect: () => {
|
|
@@ -141,9 +138,9 @@ export function RuntimeSimplePicker(props) {
|
|
|
141
138
|
displayName: kernelModel.given_name,
|
|
142
139
|
kernelId: kernelModel.id,
|
|
143
140
|
burningRate: kernelModel.burning_rate,
|
|
144
|
-
podName: kernelModel.pod_name
|
|
141
|
+
podName: kernelModel.pod_name,
|
|
145
142
|
},
|
|
146
|
-
runtimeModel: kernelModel
|
|
143
|
+
runtimeModel: kernelModel,
|
|
147
144
|
});
|
|
148
145
|
}, children: [_jsx(ActionList.LeadingVisual, { children: _jsx(ArtifactIcon, { type: "runtime" }) }), kernelModel.given_name, _jsx(ActionList.Description, { variant: "block", children: kernelModel.environment_name })] }, kernelModel.id));
|
|
149
146
|
})] })), _jsx(ActionList.Divider, {}), _jsxs(ActionList.Group, { children: [_jsxs(ActionList.Item, { selected: false, onSelect: handleLaunchRemoteKernel, children: [_jsx(ActionList.LeadingVisual, { children: _jsx(PlusIcon, {}) }), "Launch a new Runtime\u2026"] }), _jsxs(ActionList.Item, { disabled: runtimeLocation !== 'browser', selected: false, onSelect: () => {
|