diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index bb7ca660c..ee7a1d399 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -6,6 +6,7 @@ import _ from "underscore"; import { AuthType } from "../AuthType"; import { BindingHandlersRegisterer } from "../Bindings/BindingHandlersRegisterer"; import * as Constants from "../Common/Constants"; +import { HttpHeaders } from "../Common/Constants"; import { readCollection } from "../Common/dataAccess/readCollection"; import { readDatabases } from "../Common/dataAccess/readDatabases"; import { isPublicInternetAccessAllowed } from "../Common/DatabaseAccountUtility"; @@ -25,12 +26,6 @@ import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor"; import { userContext } from "../UserContext"; import { getCollectionName, getDatabaseName, getUploadName } from "../Utils/APITypeUtils"; import { update } from "../Utils/arm/generatedClients/cosmos/databaseAccounts"; -import { - get as getWorkspace, - listByDatabaseAccount, - listConnectionInfo, - start, -} from "../Utils/arm/generatedClients/cosmosNotebooks/notebookWorkspaces"; import { getAuthorizationHeader } from "../Utils/AuthorizationUtils"; import { stringToBlob } from "../Utils/BlobUtils"; import { isCapabilityEnabled } from "../Utils/CapabilityUtils"; @@ -71,6 +66,8 @@ import { ResourceTreeAdapterForResourceToken } from "./Tree/ResourceTreeAdapterF import StoredProcedure from "./Tree/StoredProcedure"; import { useDatabases } from "./useDatabases"; + + BindingHandlersRegisterer.registerBindingHandlers(); // Hold a reference to ComponentRegisterer to prevent transpiler to ignore import var tmp = ComponentRegisterer; @@ -511,16 +508,32 @@ export default class Explorer { this._isInitializingNotebooks = true; await this.ensureNotebookWorkspaceRunning(); + /* const connectionInfo = await listConnectionInfo( userContext.subscriptionId, userContext.resourceGroup, databaseAccount.name, "default" ); + */ + + const provisionData = { + cosmosKey: userContext.masterKey, + cosmosEndpoint: userContext.databaseAccount.properties.documentEndpoint, + resourceId: userContext.databaseAccount.id, + dbAcountName: userContext.databaseAccount.name + } + const response = await window.fetch("http://localhost:443/api/containerpooling/provision", { + method: "POST", + headers: { + [HttpHeaders.contentType]: "application/json", + }, + body: JSON.stringify(provisionData) + }) this.notebookServerInfo({ - notebookServerEndpoint: userContext.features.notebookServerUrl || connectionInfo.notebookServerEndpoint, - authToken: userContext.features.notebookServerToken || connectionInfo.authToken, + notebookServerEndpoint: userContext.features.notebookServerUrl || `http://localhost:443/api/containerpooling/resid${userContext.databaseAccount.id}/forward/`, + authToken: userContext.features.notebookServerToken || "token", }); this.notebookServerInfo.valueHasMutated(); this.refreshNotebookList(); @@ -554,6 +567,7 @@ export default class Explorer { return false; } + /* try { const { value: workspaces } = await listByDatabaseAccount( userContext.subscriptionId, @@ -565,6 +579,8 @@ export default class Explorer { Logger.logError(getErrorMessage(error), "Explorer/_containsDefaultNotebookWorkspace"); return false; } + */ + return true } private async ensureNotebookWorkspaceRunning() { @@ -572,6 +588,7 @@ export default class Explorer { return; } + /* let clearMessage; try { const notebookWorkspace = await getWorkspace( @@ -594,6 +611,7 @@ export default class Explorer { } finally { clearMessage && clearMessage(); } + */ } private _resetNotebookWorkspace = async () => { diff --git a/src/Explorer/Notebook/NotebookComponent/epics.ts b/src/Explorer/Notebook/NotebookComponent/epics.ts index 33eac5fac..64cf42a98 100644 --- a/src/Explorer/Notebook/NotebookComponent/epics.ts +++ b/src/Explorer/Notebook/NotebookComponent/epics.ts @@ -9,7 +9,7 @@ import { KernelRef, RemoteKernelProps, selectors, - ServerConfig as JupyterServerConfig, + ServerConfig as JupyterServerConfig } from "@nteract/core"; import { Channels, childOf, createMessage, JupyterMessage, message, ofMessageType } from "@nteract/messaging"; import { RecordOf } from "immutable"; @@ -29,7 +29,7 @@ import { switchMap, take, tap, - timeout, + timeout } from "rxjs/operators"; import { webSocket } from "rxjs/webSocket"; import * as Constants from "../../../Common/Constants"; @@ -107,7 +107,7 @@ const formWebSocketURL = (serverConfig: NotebookServiceConfig, kernelId: string, const q = params.toString(); const suffix = q !== "" ? `?${q}` : ""; - const url = (serverConfig.endpoint || "") + `api/kernels/${kernelId}/channels${suffix}`; + const url = (serverConfig.endpoint.slice(0, -1) || "") + `api/kernels/${kernelId}/channels${suffix}`; return url.replace(/^http(s)?/, "ws$1"); }; diff --git a/src/Explorer/Notebook/NotebookContainerClient.ts b/src/Explorer/Notebook/NotebookContainerClient.ts index 3764360ef..b63142cc5 100644 --- a/src/Explorer/Notebook/NotebookContainerClient.ts +++ b/src/Explorer/Notebook/NotebookContainerClient.ts @@ -6,7 +6,6 @@ import { getErrorMessage } from "../../Common/ErrorHandlingUtils"; import * as Logger from "../../Common/Logger"; import * as DataModels from "../../Contracts/DataModels"; import { userContext } from "../../UserContext"; -import { createOrUpdate, destroy } from "../../Utils/arm/generatedClients/cosmosNotebooks/notebookWorkspaces"; import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils"; export class NotebookContainerClient { @@ -54,7 +53,7 @@ export class NotebookContainerClient { const { notebookServerEndpoint, authToken } = this.getNotebookServerConfig(); try { - const response = await fetch(`${notebookServerEndpoint}/api/metrics/memory`, { + const response = await fetch(`${notebookServerEndpoint}api/metrics/memory`, { method: "GET", headers: { Authorization: authToken, @@ -135,6 +134,7 @@ export class NotebookContainerClient { if (!databaseAccount?.id) { throw new Error("DataExplorer not initialized"); } + /* try { await destroy(userContext.subscriptionId, userContext.resourceGroup, userContext.databaseAccount.name, "default"); await createOrUpdate( @@ -147,5 +147,6 @@ export class NotebookContainerClient { Logger.logError(getErrorMessage(error), "NotebookContainerClient/recreateNotebookWorkspaceAsync"); return Promise.reject(error); } + */ } } diff --git a/src/Explorer/Notebook/NotebookContentClient.ts b/src/Explorer/Notebook/NotebookContentClient.ts index e7f14b112..6ebe8f45e 100644 --- a/src/Explorer/Notebook/NotebookContentClient.ts +++ b/src/Explorer/Notebook/NotebookContentClient.ts @@ -25,6 +25,9 @@ export class NotebookContentClient { }); } + private sleep = (milliseconds: number) => { + return new Promise(resolve => setTimeout(resolve, milliseconds)) + } /** * * @param parent parent folder @@ -35,6 +38,15 @@ export class NotebookContentClient { } const type = "notebook"; + const item = NotebookUtil.createNotebookContentItem("Sample.ipynb", "notebooks/Sample.ipynb", "notebook"); + if (parent.children) { + item.parent = parent; + parent.children.push(item); + } + return this.sleep(1000).then(() => item); + + /* + return this.contentProvider .create<"notebook">(this.getServerConfig(), parent.path, { type }) .toPromise() @@ -57,6 +69,7 @@ export class NotebookContentClient { return item; }); + */ } public deleteContentItem(item: NotebookContentItem): Promise { @@ -242,9 +255,7 @@ export class NotebookContentClient { private fetchNotebookFiles(path: string): Promise { return this.contentProvider - .get(this.getServerConfig(), path, { - type: "directory", - }) + .get(this.getServerConfig(), path + "/directory", {}) .toPromise() .then((xhr) => { if (xhr.status !== 200) { diff --git a/src/Explorer/Tabs/NotebookV2Tab.ts b/src/Explorer/Tabs/NotebookV2Tab.ts index 96adcab86..86ec54fc6 100644 --- a/src/Explorer/Tabs/NotebookV2Tab.ts +++ b/src/Explorer/Tabs/NotebookV2Tab.ts @@ -14,7 +14,6 @@ import SaveIcon from "../../../images/save-cosmos.svg"; import { useNotebookSnapshotStore } from "../../hooks/useNotebookSnapshotStore"; import { Action, ActionModifiers, Source } from "../../Shared/Telemetry/TelemetryConstants"; import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; -import * as NotebookConfigurationUtils from "../../Utils/NotebookConfigurationUtils"; import { logConsoleInfo } from "../../Utils/NotificationConsoleUtils"; import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent"; import * as CommandBarComponentButtonFactory from "../Menus/CommandBar/CommandBarComponentButtonFactory"; @@ -361,12 +360,14 @@ export default class NotebookTabV2 extends NotebookTabBase { private async configureServiceEndpoints(kernelName: string) { const notebookConnectionInfo = this.container && this.container.notebookServerInfo(); const sparkClusterConnectionInfo = this.container && this.container.sparkClusterConnectionInfo(); + /* await NotebookConfigurationUtils.configureServiceEndpoints( this.notebookPath(), notebookConnectionInfo, kernelName, sparkClusterConnectionInfo ); + */ } private publishToGallery = async () => {