Skip to content

Cherry pick history bug for Azure ML CI && Make Jupyter server clickable #13712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,71 @@
# Changelog

## 2020.8.4 (2 September 2020)

### Enhancements

1. Make Jupyter Server name clickable to select Jupyter server.
([#13656](https://github.com/Microsoft/vscode-python/issues/13656))

### Fixes

1. Fixed connection to a Compute Instance from the quickpicks history options.
([#13387](https://github.com/Microsoft/vscode-python/issues/13387))

### Thanks

Thanks to the following projects which we fully rely on to provide some of
our features:

- [debugpy](https://pypi.org/project/debugpy/)
- [isort](https://pypi.org/project/isort/)
- [jedi](https://pypi.org/project/jedi/)
and [parso](https://pypi.org/project/parso/)
- [Microsoft Python Language Server](https://github.com/microsoft/python-language-server)
- [Pylance](https://github.com/microsoft/pylance-release)
- [exuberant ctags](http://ctags.sourceforge.net/) (user-installed)
- [rope](https://pypi.org/project/rope/) (user-installed)

Also thanks to the various projects we provide integrations with which help
make this extension useful:

- Debugging support:
[Django](https://pypi.org/project/Django/),
[Flask](https://pypi.org/project/Flask/),
[gevent](https://pypi.org/project/gevent/),
[Jinja](https://pypi.org/project/Jinja/),
[Pyramid](https://pypi.org/project/pyramid/),
[PySpark](https://pypi.org/project/pyspark/),
[Scrapy](https://pypi.org/project/Scrapy/),
[Watson](https://pypi.org/project/Watson/)
- Formatting:
[autopep8](https://pypi.org/project/autopep8/),
[black](https://pypi.org/project/black/),
[yapf](https://pypi.org/project/yapf/)
- Interpreter support:
[conda](https://conda.io/),
[direnv](https://direnv.net/),
[pipenv](https://pypi.org/project/pipenv/),
[pyenv](https://github.com/pyenv/pyenv),
[venv](https://docs.python.org/3/library/venv.html#module-venv),
[virtualenv](https://pypi.org/project/virtualenv/)
- Linting:
[bandit](https://pypi.org/project/bandit/),
[flake8](https://pypi.org/project/flake8/),
[mypy](https://pypi.org/project/mypy/),
[prospector](https://pypi.org/project/prospector/),
[pylint](https://pypi.org/project/pylint/),
[pydocstyle](https://pypi.org/project/pydocstyle/),
[pylama](https://pypi.org/project/pylama/)
- Testing:
[nose](https://pypi.org/project/nose/),
[pytest](https://pypi.org/project/pytest/),
[unittest](https://docs.python.org/3/library/unittest.html#module-unittest)

And finally thanks to the [Python](https://www.python.org/) development team and
community for creating a fantastic programming language and community to be a
part of!

## 2020.8.3 (31 August 2020)

### Enhancements
Expand Down
10 changes: 6 additions & 4 deletions src/client/datascience/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,23 @@ const AllowedKeys = {
['execute_result']: new Set(Object.keys(dummyExecuteResultObj))
};

export function getSavedUriList(globalState: Memento): { uri: string; time: number }[] {
const uriList = globalState.get<{ uri: string; time: number }[]>(Settings.JupyterServerUriList);
export function getSavedUriList(globalState: Memento): { uri: string; time: number; displayName?: string }[] {
const uriList = globalState.get<{ uri: string; time: number; displayName?: string }[]>(
Settings.JupyterServerUriList
);
return uriList
? uriList.sort((a, b) => {
return b.time - a.time;
})
: [];
}
export function addToUriList(globalState: Memento, uri: string, time: number) {
export function addToUriList(globalState: Memento, uri: string, time: number, displayName: string) {
const uriList = getSavedUriList(globalState);

const editList = uriList.filter((f, i) => {
return f.uri !== uri && i < Settings.JupyterServerUriListMax - 1;
});
editList.splice(0, 0, { uri, time });
editList.splice(0, 0, { uri, time, displayName });

globalState.update(Settings.JupyterServerUriList, editList).then(noop, noop);
}
Expand Down
10 changes: 7 additions & 3 deletions src/client/datascience/interactive-common/interactiveBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { EXTENSION_ROOT_DIR, isTestExecution, PYTHON_LANGUAGE } from '../../comm
import { RemoveKernelToolbarInInteractiveWindow, RunByLine } from '../../common/experiments/groups';
import { traceError, traceInfo, traceWarning } from '../../common/logger';

import { isNil } from 'lodash';
import {
IConfigurationService,
IDisposableRegistry,
Expand Down Expand Up @@ -1162,10 +1163,13 @@ export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp
if (serverConnection.localLaunch) {
localizedUri = localize.DataScience.localJupyterServer();
} else {
localizedUri = serverConnection.displayName;

// Log this remote URI into our MRU list
addToUriList(this.globalStorage, localizedUri, Date.now());
addToUriList(
this.globalStorage,
!isNil(serverConnection.url) ? serverConnection.url : serverConnection.displayName,
Date.now(),
serverConnection.displayName
);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/client/datascience/jupyter/jupyterUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function createRemoteConnectionInfo(
return { dispose: noop };
},
dispose: noop,
getAuthHeader: serverUri ? () => getJupyterServerUri(uri)?.authorizationHeader : undefined
getAuthHeader: serverUri ? () => getJupyterServerUri(uri)?.authorizationHeader : undefined,
url: uri
};
}
9 changes: 6 additions & 3 deletions src/client/datascience/jupyter/serverSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'use strict';

import { inject, injectable, named } from 'inversify';
import { isNil } from 'lodash';
import { ConfigurationTarget, Memento, QuickPickItem, Uri } from 'vscode';
import { IClipboard, ICommandManager } from '../../common/application/types';
import { GLOBAL_MEMENTO, IConfigurationService, IMemento } from '../../common/types';
Expand All @@ -26,6 +27,7 @@ const defaultUri = 'https://hostname:8080/?token=849d61a414abafab97bc4aab1f35477
interface ISelectUriQuickPickItem extends QuickPickItem {
newChoice: boolean;
provider?: IJupyterUriProvider;
url?: string;
}

@injectable()
Expand Down Expand Up @@ -66,7 +68,7 @@ export class JupyterServerSelector {
if (item.label === this.localLabel) {
await this.setJupyterURIToLocal();
} else if (!item.newChoice && !item.provider) {
await this.setJupyterURIToRemote(item.label);
await this.setJupyterURIToRemote(!isNil(item.url) ? item.url : item.label);
} else if (!item.provider) {
return this.selectRemoteURI.bind(this);
} else {
Expand Down Expand Up @@ -208,9 +210,10 @@ export class JupyterServerSelector {
if (uriItem.uri) {
const uriDate = new Date(uriItem.time);
items.push({
label: uriItem.uri,
label: !isNil(uriItem.displayName) ? uriItem.displayName : uriItem.uri,
detail: DataScience.jupyterSelectURIMRUDetail().format(uriDate.toLocaleString()),
newChoice: false
newChoice: false,
url: uriItem.uri
});
}
});
Expand Down
1 change: 1 addition & 0 deletions src/client/datascience/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface IJupyterConnection extends Disposable {
readonly token: string;
readonly hostName: string;
localProcExitCode: number | undefined;
readonly url?: string;
// tslint:disable-next-line: no-any
getAuthHeader?(): any; // Snould be a json object
}
Expand Down
16 changes: 14 additions & 2 deletions src/datascience-ui/interactive-common/jupyterInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class JupyterInfo extends React.Component<IJupyterInfoProps> {
constructor(prop: IJupyterInfoProps) {
super(prop);
this.selectKernel = this.selectKernel.bind(this);
this.selectServer = this.selectServer.bind(this);
}

public render() {
Expand All @@ -59,11 +60,18 @@ export class JupyterInfo extends React.Component<IJupyterInfoProps> {
maxWidth: getMaxWidth(displayNameTextSize)
};

const ariaDisabled = this.props.isNotebookTrusted === undefined ? false : this.props.isNotebookTrusted;
return (
<div className="kernel-status" style={dynamicFont}>
{this.renderTrustMessage()}
<div className="kernel-status-section kernel-status-server" style={serverTextWidth} role="button">
<div className="kernel-status-text" title={jupyterServerDisplayName}>
<div className="kernel-status-section kernel-status-server" style={serverTextWidth}>
<div
className="kernel-status-text kernel-status-section-hoverable"
style={serverTextWidth}
onClick={this.selectServer}
role="button"
aria-disabled={ariaDisabled}
>
{getLocString('DataScience.jupyterServer', 'Jupyter Server')}: {jupyterServerDisplayName}
</div>
<Image
Expand Down Expand Up @@ -153,4 +161,8 @@ export class JupyterInfo extends React.Component<IJupyterInfoProps> {

return res[1];
}

private selectServer(): void {
this.props.selectServer();
}
}
8 changes: 4 additions & 4 deletions src/test/datascience/jupyter/serverSelector.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,31 +103,31 @@ suite('DataScience - Jupyter Server URI Selector', () => {

// Add in a new server
const serverA1 = { uri: 'ServerA', time: 1, date: new Date(1) };
addToUriList(mockStorage, serverA1.uri, serverA1.time);
addToUriList(mockStorage, serverA1.uri, serverA1.time, serverA1.uri);

await ds.selectJupyterURI(true);
assert.equal(quickPick?.items.length, 3, 'Wrong number of items in the quick pick');
quickPickCheck(quickPick?.items[2], serverA1);

// Add in a second server, the newer server should be higher in the list due to newer time
const serverB1 = { uri: 'ServerB', time: 2, date: new Date(2) };
addToUriList(mockStorage, serverB1.uri, serverB1.time);
addToUriList(mockStorage, serverB1.uri, serverB1.time, serverB1.uri);
await ds.selectJupyterURI(true);
assert.equal(quickPick?.items.length, 4, 'Wrong number of items in the quick pick');
quickPickCheck(quickPick?.items[2], serverB1);
quickPickCheck(quickPick?.items[3], serverA1);

// Reconnect to server A with a new time, it should now be higher in the list
const serverA3 = { uri: 'ServerA', time: 3, date: new Date(3) };
addToUriList(mockStorage, serverA3.uri, serverA3.time);
addToUriList(mockStorage, serverA3.uri, serverA3.time, serverA3.uri);
await ds.selectJupyterURI(true);
assert.equal(quickPick?.items.length, 4, 'Wrong number of items in the quick pick');
quickPickCheck(quickPick?.items[3], serverB1);
quickPickCheck(quickPick?.items[2], serverA1);

// Verify that we stick to our settings limit
for (let i = 0; i < Settings.JupyterServerUriListMax + 10; i = i + 1) {
addToUriList(mockStorage, i.toString(), i);
addToUriList(mockStorage, i.toString(), i, i.toString());
}

await ds.selectJupyterURI(true);
Expand Down