mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 17:30:46 +00:00
Merge branch 'master' into users/srnara/containerPooling
This commit is contained in:
@@ -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";
|
||||
@@ -24,12 +25,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";
|
||||
@@ -69,6 +64,8 @@ import StoredProcedure from "./Tree/StoredProcedure";
|
||||
import { useDatabases } from "./useDatabases";
|
||||
import { useSelectedNode } from "./useSelectedNode";
|
||||
|
||||
|
||||
|
||||
BindingHandlersRegisterer.registerBindingHandlers();
|
||||
// Hold a reference to ComponentRegisterer to prevent transpiler to ignore import
|
||||
var tmp = ComponentRegisterer;
|
||||
@@ -458,16 +455,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();
|
||||
@@ -501,6 +514,7 @@ export default class Explorer {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
try {
|
||||
const { value: workspaces } = await listByDatabaseAccount(
|
||||
userContext.subscriptionId,
|
||||
@@ -512,6 +526,8 @@ export default class Explorer {
|
||||
Logger.logError(getErrorMessage(error), "Explorer/_containsDefaultNotebookWorkspace");
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
return true
|
||||
}
|
||||
|
||||
private async ensureNotebookWorkspaceRunning() {
|
||||
@@ -519,6 +535,7 @@ export default class Explorer {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
let clearMessage;
|
||||
try {
|
||||
const notebookWorkspace = await getWorkspace(
|
||||
@@ -541,6 +558,7 @@ export default class Explorer {
|
||||
} finally {
|
||||
clearMessage && clearMessage();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private _resetNotebookWorkspace = async () => {
|
||||
|
||||
@@ -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");
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<void> {
|
||||
@@ -242,9 +255,7 @@ export class NotebookContentClient {
|
||||
|
||||
private fetchNotebookFiles(path: string): Promise<NotebookContentItem[]> {
|
||||
return this.contentProvider
|
||||
.get(this.getServerConfig(), path, {
|
||||
type: "directory",
|
||||
})
|
||||
.get(this.getServerConfig(), path + "/directory", {})
|
||||
.toPromise()
|
||||
.then((xhr) => {
|
||||
if (xhr.status !== 200) {
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user