Skip to content
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

Add performance and caching tests for stdout/stderr #138

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions .github/workflows/galata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
python_version: "3.11"

- name: Set up browser cache
uses: actions/cache@v4
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/linuxjs-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ jobs:
name: JS
strategy:
matrix:
# Fix for https://github.com/jupyterlab/jupyterlab/issues/13903
include:
- group: js-debugger
python-version: '3.11'
python-version: ["3.13"]
group:
[
js-application,
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/linuxtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,35 @@ jobs:
matrix:
group: [integrity, integrity2, integrity3, release_test, docs, usage, usage2, splice_source, python, examples, interop, nonode, lint]
# This will be used by the base setup action
python-version: ["3.8", "3.12"]
python-version: ["3.9", "3.13"]
include:
- group: examples
upload-output: true
- group: release_test
upload-output: true
exclude:
- group: integrity
python-version: "3.8"
python-version: "3.9"
- group: integrity2
python-version: "3.8"
python-version: "3.9"
- group: integrity3
python-version: "3.8"
python-version: "3.9"
- group: release_test
python-version: "3.8"
python-version: "3.9"
- group: docs
python-version: "3.8"
python-version: "3.9"
- group: usage
python-version: "3.8"
python-version: "3.9"
- group: usage2
python-version: "3.8"
python-version: "3.9"
- group: nonode
python-version: "3.8"
python-version: "3.9"
- group: lint
python-version: "3.8"
python-version: "3.9"
- group: examples
python-version: "3.8"
python-version: "3.9"
- group: splice_source
python-version: "3.8"
python-version: "3.9"
fail-fast: false
timeout-minutes: 45
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
python_version: "3.8"
python_version: "3.9"
dependency_type: minimum
- name: Install dependencies
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/macostests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
strategy:
matrix:
group: [integrity, python, usage, usage2]
python-version: [3.11]
python-version: [3.12]
include:
- group: python
python-version: 3.12
python-version: 3.13
fail-fast: false
timeout-minutes: 45
runs-on: macos-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windowstests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
strategy:
matrix:
group: [integrity, python]
python-version: ["3.13"]
fail-fast: false
runs-on: windows-latest
timeout-minutes: 40
Expand Down
1 change: 1 addition & 0 deletions docs/source/extension/extension_points.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Here is a sample block of code that adds a command to the application (given by
execute: () => {
console.log(`Executed ${commandID}`);
toggled = !toggled;
}
});

This example adds a new command, which, when triggered, calls the ``execute`` function.
Expand Down
6 changes: 3 additions & 3 deletions jupyterlab/extensions/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def make_connection(self, host):
proxy_host, _, proxy_port = http_proxy.netloc.partition(":")

proxies = {
"http://": http_proxy_url,
"https://": https_proxy_url,
"http://": httpx.HTTPTransport(proxy=http_proxy_url),
"https://": httpx.HTTPTransport(proxy=https_proxy_url),
}

xmlrpc_transport_override = ProxiedTransport()
Expand Down Expand Up @@ -131,7 +131,7 @@ def __init__(
parent: Optional[config.Configurable] = None,
) -> None:
super().__init__(app_options, ext_options, parent)
self._httpx_client = httpx.AsyncClient(proxies=proxies)
self._httpx_client = httpx.AsyncClient(mounts=proxies)
# Set configurable cache size to fetch function
self._fetch_package_metadata = partial(_fetch_package_metadata, self._httpx_client)
self._observe_package_metadata_cache_size({"new": self.package_metadata_cache_size})
Expand Down
9 changes: 7 additions & 2 deletions packages/filebrowser/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,15 @@ export class FileBrowserModel implements IDisposable {
const path = this._model.path;
const { sessions } = this.manager.services;
const { oldValue, newValue } = change;
const prefix = this.driveName.length > 0 ? this.driveName + ':' : '';
const value =
oldValue && oldValue.path && PathExt.dirname(oldValue.path) === path
oldValue &&
oldValue.path &&
prefix + PathExt.dirname(oldValue.path) === path
? oldValue
: newValue && newValue.path && PathExt.dirname(newValue.path) === path
: newValue &&
newValue.path &&
prefix + PathExt.dirname(newValue.path) === path
? newValue
: undefined;

Expand Down
22 changes: 22 additions & 0 deletions packages/filebrowser/test/model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,28 @@ describe('filebrowser/model', () => {
expect(called).toBe(true);
});

it('should be emitted when a file is created in a drive with a name', async () => {
await state.clear();
const driveName = 'RTC';
const modelWithName = new FileBrowserModel({
manager,
state,
driveName
});

let called = false;
modelWithName.fileChanged.connect((sender, args) => {
expect(sender).toBe(modelWithName);
expect(args.type).toBe('new');
expect(args.oldValue).toBeNull();
expect(args.newValue!.type).toBe('file');
called = true;
});
await manager.newUntitled({ type: 'file' });
expect(called).toBe(true);
modelWithName.dispose();
});

it('should be emitted when a file is renamed', async () => {
let called = false;
model.fileChanged.connect((sender, args) => {
Expand Down
9 changes: 8 additions & 1 deletion packages/notebook/style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
flex: 0 0 auto;
min-width: 36px;
color: var(--jp-cell-inprompt-font-color);
opacity: 0.5;
padding: var(--jp-code-padding);
padding-left: 12px;
font-family: var(--jp-cell-prompt-font-family);
Expand All @@ -221,7 +222,13 @@
top: 8px;
left: 8px;
background: var(--jp-layout-color2);
border: var(--jp-border-width) solid var(--jp-input-border-color);
border-width: var(--jp-border-width);
border-style: solid;
border-color: color-mix(
in srgb,
var(--jp-input-border-color) 20%,
transparent
);
box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.12);
}

Expand Down
33 changes: 25 additions & 8 deletions packages/outputarea/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,20 @@ export class OutputAreaModel implements IOutputAreaModel {
const curText = prev.streamText!;
const newText =
typeof value.text === 'string' ? value.text : value.text.join('');
Private.addText(curText, newText);
this._streamIndex = Private.addText(this._streamIndex, curText, newText);
return this.length;
}

if (nbformat.isStream(value)) {
if (typeof value.text !== 'string') {
value.text = value.text.join('');
}
value.text = Private.processText(value.text);
const { text, index } = Private.processText(
this._streamIndex,
value.text
);
this._streamIndex = index;
value.text = text;
}

// Create the new item.
Expand Down Expand Up @@ -480,6 +485,7 @@ export class OutputAreaModel implements IOutputAreaModel {
private _changed = new Signal<OutputAreaModel, IOutputAreaModel.ChangedArgs>(
this
);
private _streamIndex = 0;
}

/**
Expand Down Expand Up @@ -530,14 +536,20 @@ namespace Private {
/*
* Handle backspaces in `newText` and concatenates to `text`, if any.
*/
export function processText(newText: string, text?: string): string {
export function processText(
index: number,
newText: string,
text?: string
): { text: string; index: number } {
if (text === undefined) {
text = '';
}
if (!(newText.includes('\b') || newText.includes('\r'))) {
return text + newText;
text =
text.slice(0, index) + newText + text.slice(index + newText.length);
return { text, index: index + newText.length };
}
let idx0 = text.length;
let idx0 = index;
let idx1: number = -1;
let lastEnd: number = 0;
const regex = /[\n\b\r]/;
Expand Down Expand Up @@ -587,14 +599,18 @@ namespace Private {
throw Error(`This should not happen`);
}
}
return text;
return { text, index: idx0 };
}

/*
* Concatenate a string to an observable string, handling backspaces.
*/
export function addText(curText: IObservableString, newText: string): void {
const text = processText(newText, curText.text);
export function addText(
prevIndex: number,
curText: IObservableString,
newText: string
): number {
const { text, index } = processText(prevIndex, newText, curText.text);
// Compute the difference between current text and new text.
let done = false;
let idx = 0;
Expand All @@ -619,5 +635,6 @@ namespace Private {
idx++;
}
}
return index;
}
}
Loading
Loading