mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Wait for python installs to complete before starting a python notebook. (#7729)
This commit is contained in:
@@ -32,9 +32,8 @@ const msgTaskName = localize('msgTaskName', "Installing Notebook dependencies");
|
|||||||
const msgInstallPkgStart = localize('msgInstallPkgStart', "Installing Notebook dependencies, see Tasks view for more information");
|
const msgInstallPkgStart = localize('msgInstallPkgStart', "Installing Notebook dependencies, see Tasks view for more information");
|
||||||
const msgInstallPkgFinish = localize('msgInstallPkgFinish', "Notebook dependencies installation is complete");
|
const msgInstallPkgFinish = localize('msgInstallPkgFinish', "Notebook dependencies installation is complete");
|
||||||
const msgPythonRunningError = localize('msgPythonRunningError', "Cannot overwrite an existing Python installation while python is running. Please close any active notebooks before proceeding.");
|
const msgPythonRunningError = localize('msgPythonRunningError', "Cannot overwrite an existing Python installation while python is running. Please close any active notebooks before proceeding.");
|
||||||
const msgPendingInstallError = localize('msgPendingInstallError', "Another Python installation is currently in progress.");
|
|
||||||
const msgSkipPythonInstall = localize('msgSkipPythonInstall', "Python already exists at the specific location. Skipping install.");
|
const msgSkipPythonInstall = localize('msgSkipPythonInstall', "Python already exists at the specific location. Skipping install.");
|
||||||
const msgSkippedPackageUpgrade = localize('msgSkippedPackageUpgrade', "Skipping notebook package upgrade since another Python install is currently in progress.");
|
const msgWaitingForInstall = localize('msgWaitingForInstall', "Another Python installation is currently in progress. Waiting for it to complete.");
|
||||||
function msgDependenciesInstallationFailed(errorMessage: string): string { return localize('msgDependenciesInstallationFailed', "Installing Notebook dependencies failed with error: {0}", errorMessage); }
|
function msgDependenciesInstallationFailed(errorMessage: string): string { return localize('msgDependenciesInstallationFailed', "Installing Notebook dependencies failed with error: {0}", errorMessage); }
|
||||||
function msgDownloadPython(platform: string, pythonDownloadUrl: string): string { return localize('msgDownloadPython', "Downloading local python for platform: {0} to {1}", platform, pythonDownloadUrl); }
|
function msgDownloadPython(platform: string, pythonDownloadUrl: string): string { return localize('msgDownloadPython', "Downloading local python for platform: {0} to {1}", platform, pythonDownloadUrl); }
|
||||||
|
|
||||||
@@ -53,6 +52,7 @@ export class JupyterServerInstallation {
|
|||||||
private _usingConda: boolean;
|
private _usingConda: boolean;
|
||||||
|
|
||||||
private _installInProgress: boolean;
|
private _installInProgress: boolean;
|
||||||
|
private _installCompletion: Deferred<void>;
|
||||||
|
|
||||||
public static readonly DefaultPythonLocation = path.join(utils.getUserHome(), 'azuredatastudio-python');
|
public static readonly DefaultPythonLocation = path.join(utils.getUserHome(), 'azuredatastudio-python');
|
||||||
|
|
||||||
@@ -328,9 +328,12 @@ export class JupyterServerInstallation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this._installInProgress) {
|
if (this._installInProgress) {
|
||||||
return Promise.reject(msgPendingInstallError);
|
this.apiWrapper.showInfoMessage(msgWaitingForInstall);
|
||||||
|
return this._installCompletion.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._installInProgress = true;
|
this._installInProgress = true;
|
||||||
|
this._installCompletion = new Deferred<void>();
|
||||||
|
|
||||||
if (installSettings) {
|
if (installSettings) {
|
||||||
this._pythonInstallationPath = installSettings.installPath;
|
this._pythonInstallationPath = installSettings.installPath;
|
||||||
@@ -344,7 +347,7 @@ export class JupyterServerInstallation {
|
|||||||
await notebookConfig.update(constants.existingPythonConfigKey, this._usingExistingPython, ConfigurationTarget.Global);
|
await notebookConfig.update(constants.existingPythonConfigKey, this._usingExistingPython, ConfigurationTarget.Global);
|
||||||
await this.configurePackagePaths();
|
await this.configurePackagePaths();
|
||||||
};
|
};
|
||||||
let installReady = new Deferred<void>();
|
|
||||||
if (!(await utils.exists(this._pythonExecutable)) || forceInstall || this._usingExistingPython) {
|
if (!(await utils.exists(this._pythonExecutable)) || forceInstall || this._usingExistingPython) {
|
||||||
this.apiWrapper.startBackgroundOperation({
|
this.apiWrapper.startBackgroundOperation({
|
||||||
displayName: msgTaskName,
|
displayName: msgTaskName,
|
||||||
@@ -354,13 +357,13 @@ export class JupyterServerInstallation {
|
|||||||
this.installDependencies(op, forceInstall)
|
this.installDependencies(op, forceInstall)
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
await updateConfig();
|
await updateConfig();
|
||||||
installReady.resolve();
|
this._installCompletion.resolve();
|
||||||
this._installInProgress = false;
|
this._installInProgress = false;
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
let errorMsg = msgDependenciesInstallationFailed(utils.getErrorMessage(err));
|
let errorMsg = msgDependenciesInstallationFailed(utils.getErrorMessage(err));
|
||||||
op.updateStatus(azdata.TaskStatus.Failed, errorMsg);
|
op.updateStatus(azdata.TaskStatus.Failed, errorMsg);
|
||||||
installReady.reject(errorMsg);
|
this._installCompletion.reject(errorMsg);
|
||||||
this._installInProgress = false;
|
this._installInProgress = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -369,11 +372,11 @@ export class JupyterServerInstallation {
|
|||||||
// Python executable already exists, but the path setting wasn't defined,
|
// Python executable already exists, but the path setting wasn't defined,
|
||||||
// so update it here
|
// so update it here
|
||||||
await updateConfig();
|
await updateConfig();
|
||||||
installReady.resolve();
|
this._installCompletion.resolve();
|
||||||
this._installInProgress = false;
|
this._installInProgress = false;
|
||||||
this.apiWrapper.showInfoMessage(msgSkipPythonInstall);
|
this.apiWrapper.showInfoMessage(msgSkipPythonInstall);
|
||||||
}
|
}
|
||||||
return installReady.promise;
|
return this._installCompletion.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -391,16 +394,23 @@ export class JupyterServerInstallation {
|
|||||||
*/
|
*/
|
||||||
public async promptForPackageUpgrade(): Promise<void> {
|
public async promptForPackageUpgrade(): Promise<void> {
|
||||||
if (this._installInProgress) {
|
if (this._installInProgress) {
|
||||||
this.apiWrapper.showInfoMessage(msgSkippedPackageUpgrade);
|
this.apiWrapper.showInfoMessage(msgWaitingForInstall);
|
||||||
return;
|
return this._installCompletion.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._installInProgress = true;
|
this._installInProgress = true;
|
||||||
try {
|
this._installCompletion = new Deferred<void>();
|
||||||
await this.upgradePythonPackages(true, false);
|
this.upgradePythonPackages(true, false)
|
||||||
} finally {
|
.then(() => {
|
||||||
this._installInProgress = false;
|
this._installCompletion.resolve();
|
||||||
}
|
this._installInProgress = false;
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
let errorMsg = msgDependenciesInstallationFailed(utils.getErrorMessage(err));
|
||||||
|
this._installCompletion.reject(errorMsg);
|
||||||
|
this._installInProgress = false;
|
||||||
|
});
|
||||||
|
return this._installCompletion.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async upgradePythonPackages(promptForUpgrade: boolean, forceInstall: boolean): Promise<void> {
|
private async upgradePythonPackages(promptForUpgrade: boolean, forceInstall: boolean): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user