Skip to content

Commit c6833e1

Browse files
committedAug 5, 2022
Update tests, use Preact for rendering
1 parent 3e946c4 commit c6833e1

File tree

11 files changed

+404
-83
lines changed

11 files changed

+404
-83
lines changed
 

‎css/widget.css

+24-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
.content {
22
padding: 20px;
3-
line-height: 2;
4-
font-size: 20px;
3+
line-height: 1.7;
4+
font-size: 18px;
55
font-family: "Lato", "Trebuchet MS", Roboto, Helvetica, Arial, sans-serif;
6+
7+
max-width: 720px;
68
}
79
.label {
810
margin: 5px 10px 5px 0;
@@ -12,27 +14,41 @@
1214
padding: 1px 10px;
1315
position: relative;
1416
border-radius: 4px;
17+
font-size: 16px;
1518
}
1619
.selected {
1720
background: white;
1821
color: rgb(31, 41, 55);
1922
}
2023
.labelContainer {
2124
display: flex;
25+
flex-grow: 1;
2226
color: #fff;
23-
width: 100%;
24-
padding: 12px;
25-
font-size: 20px;
26-
background: rgb(31, 41, 55);
27-
text-align: center;
28-
box-sizing: border-box;
2927
font-weight: bold;
3028
font-family: "Roboto Condensed", "Arial Narrow", sans-serif;
3129
text-transform: uppercase;
3230
border-top-left-radius: 0;
3331
border-top-right-radius: 0;
3432
}
3533

34+
.topBar {
35+
display: flex;
36+
color: #fff;
37+
width: 100%;
38+
padding: 12px;
39+
background: rgb(31, 41, 55);
40+
box-sizing: border-box;
41+
font-size: 20px;
42+
}
43+
44+
.nav {
45+
display: flex;
46+
}
47+
48+
.navLink {
49+
cursor: pointer;
50+
}
51+
3652
.span {
3753
font-size: 18px;
3854
padding: 0.25em 0.4em;

‎examples/introduction.ipynb

+65-7
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818
},
1919
{
2020
"cell_type": "code",
21-
"execution_count": 6,
21+
"execution_count": 2,
2222
"metadata": {},
2323
"outputs": [
2424
{
2525
"data": {
2626
"application/vnd.jupyter.widget-view+json": {
27-
"model_id": "b9d65f4968cd49c29b1377a964688549",
27+
"model_id": "02d172394132421a994a671c9ebea9ec",
2828
"version_major": 2,
2929
"version_minor": 0
3030
},
3131
"text/plain": [
32-
"ExampleWidget(value=None, labels=['person', 'date', 'org'], spans=[{'start': 6, 'end': 16, 'text': 'March 2014"
32+
"AnnotateWidget(value=None, labels=['person', 'date', 'org'], spans=[{'start': 6, 'end': 16, 'text': 'March 201"
3333
]
3434
},
3535
"metadata": {},
@@ -40,7 +40,7 @@
4040
"abstract = \"\"\"\n",
4141
"In a March 2014 interview, Apple designer Jonathan Ive used the iPhone as an example of Apple's ethos of creating high - quality, life - changing products. \n",
4242
"\"\"\"\n",
43-
"w = jupyterannotate.ExampleWidget(\n",
43+
"w = jupyterannotate.AnnotateWidget(\n",
4444
" text=abstract,\n",
4545
" labels=[\"person\", \"date\", \"org\"],\n",
4646
" spans=[{'start': 6, 'end': 16, 'text': 'March 2014', 'label': 'date'}, {'start': 43, 'end': 55, 'text': 'Jonathan Ive', 'label': 'person'}]\n",
@@ -50,23 +50,81 @@
5050
},
5151
{
5252
"cell_type": "code",
53-
"execution_count": 8,
53+
"execution_count": 3,
5454
"metadata": {},
5555
"outputs": [
5656
{
5757
"data": {
5858
"text/plain": [
59-
"[{'start': 6, 'end': 16, 'text': 'March 2014', 'label': 'date'}]"
59+
"[{'start': 6, 'end': 16, 'text': 'March 2014', 'label': 'date'},\n",
60+
" {'start': 43, 'end': 55, 'text': 'Jonathan Ive', 'label': 'person'}]"
6061
]
6162
},
62-
"execution_count": 8,
63+
"execution_count": 3,
6364
"metadata": {},
6465
"output_type": "execute_result"
6566
}
6667
],
6768
"source": [
6869
"w.spans"
6970
]
71+
},
72+
{
73+
"cell_type": "code",
74+
"execution_count": null,
75+
"metadata": {},
76+
"outputs": [],
77+
"source": []
78+
},
79+
{
80+
"cell_type": "code",
81+
"execution_count": 4,
82+
"metadata": {},
83+
"outputs": [
84+
{
85+
"data": {
86+
"application/vnd.jupyter.widget-view+json": {
87+
"model_id": "83936e8edc8047638f3f7645ed238180",
88+
"version_major": 2,
89+
"version_minor": 0
90+
},
91+
"text/plain": [
92+
"AnnotateWidget(value=None, labels=['condition', 'intervention', 'outcome'], text='\\nBackground: Despite advanc…"
93+
]
94+
},
95+
"metadata": {},
96+
"output_type": "display_data"
97+
}
98+
],
99+
"source": [
100+
"abstract = \"\"\"\n",
101+
"Background: Despite advances in targeted therapy, treatment options for metastatic NSCLC progressing after initial therapy remains limited. HSP90 is an ATP-dependent molecular chaperone that plays a vital role in protein stabilization. Some HSP90 client proteins are key regulators in cell proliferation and survival. Many mutant oncoproteins are more dependent on HSP90 for proper folding and stability compared to their wildtype counterparts. AUY922 potently inhibits HSP90, showing preclinical activity in a wide range of cancer cell lines, including NSCLC (1). Phase I clinical trials established 70 mg/m2 as the dose for further development (2). A single agent phase II trial demonstrated clinical activity of AUY922 in NSCLC, particularly molecular subsets with driver mutations in the known HSP90 client proteins, epidermal growth factor receptor (EGFR) and anaplastic lymphoma kinase (ALK) (3). Pemetrexed is a folate antimetabolite chemotherapeutic approved for use in advanced non-squamous, NSCLC. In pre-clinical models, mRNA for dihydrofolate reductase (DHFR), a target of pemetrexed, reliably decreased in response to AUY922 exposure (1). These findings suggest that the combination of AUY922 and premetrexed in NSCLC is worthy of investigation. Methods: Adult patients with previously treated stage IV non-squamous, NSCLC, measureable disease per RECIST 1.1, ECOG performance status < 2, and life expectancy > 3 months are eligible for this open label phase Ib clinical trial (NCT01784640). A standard 3 x 3 design will evaluate 3 cohorts, all with pemetrexed at the standard 500 mg/m2 dose, plus: AUY922 40 mg/m2, 55 mg/ m2, and 70 mg/m2 qwk. Enrollment of the 70 mg/m2 qwk cohort has been open since November 2014 and is currently ongoing. After the optimal dose for further evaluation is determined, an additional 20 patients will be enrolled at that dose. This expansion phase will focus on patients with EGFR mutations and ALK gene rearrangements. The primary endpoint is safety and tolerability of AUY922 combined with pemetrexed in patients with previously treated non-squamous NSCLC.\"\"\"\n",
102+
"other = jupyterannotate.AnnotateWidget(\n",
103+
" text=abstract,\n",
104+
" labels=[\"condition\", \"intervention\", \"outcome\"],\n",
105+
")\n",
106+
"other"
107+
]
108+
},
109+
{
110+
"cell_type": "code",
111+
"execution_count": 5,
112+
"metadata": {},
113+
"outputs": [
114+
{
115+
"data": {
116+
"text/plain": [
117+
"[]"
118+
]
119+
},
120+
"execution_count": 5,
121+
"metadata": {},
122+
"output_type": "execute_result"
123+
}
124+
],
125+
"source": [
126+
"other.spans"
127+
]
70128
}
71129
],
72130
"metadata": {

‎jupyterannotate/__init__.py

+16-11
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
# Copyright (c) Stuart Quin.
55
# Distributed under the terms of the Modified BSD License.
66

7-
from .example import ExampleWidget
7+
from .annotate import AnnotateWidget
88
from ._version import __version__, version_info
99

10+
1011
def _jupyter_labextension_paths():
1112
"""Called by Jupyter Lab Server to detect if it is a valid labextension and
1213
to install the widget
@@ -19,10 +20,12 @@ def _jupyter_labextension_paths():
1920
from `src` directory into <jupyter path>/labextensions/<dest> directory
2021
during widget installation
2122
"""
22-
return [{
23-
'src': 'labextension',
24-
'dest': 'jupyterannotate',
25-
}]
23+
return [
24+
{
25+
"src": "labextension",
26+
"dest": "jupyterannotate",
27+
}
28+
]
2629

2730

2831
def _jupyter_nbextension_paths():
@@ -41,9 +44,11 @@ def _jupyter_nbextension_paths():
4144
require: Path to importable AMD Javascript module inside the
4245
<jupyter path>/nbextensions/<dest> directory
4346
"""
44-
return [{
45-
'section': 'notebook',
46-
'src': 'nbextension',
47-
'dest': 'jupyterannotate',
48-
'require': 'jupyterannotate/extension'
49-
}]
47+
return [
48+
{
49+
"section": "notebook",
50+
"src": "nbextension",
51+
"dest": "jupyterannotate",
52+
"require": "jupyterannotate/extension",
53+
}
54+
]

‎jupyterannotate/example.py ‎jupyterannotate/annotate.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
from ._frontend import module_name, module_version
1414

1515

16-
class ExampleWidget(DOMWidget, ValueWidget):
16+
class AnnotateWidget(DOMWidget, ValueWidget):
1717
"""TODO: Add docstring here"""
1818

19-
_model_name = Unicode("ExampleModel").tag(sync=True)
19+
_model_name = Unicode("AnnotateModel").tag(sync=True)
2020
_model_module = Unicode(module_name).tag(sync=True)
2121
_model_module_version = Unicode(module_version).tag(sync=True)
22-
_view_name = Unicode("ExampleView").tag(sync=True)
22+
_view_name = Unicode("AnnotateView").tag(sync=True)
2323
_view_module = Unicode(module_name).tag(sync=True)
2424
_view_module_version = Unicode(module_version).tag(sync=True)
2525

‎jupyterannotate/tests/test_example.py ‎jupyterannotate/tests/test_annotate.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
import pytest
88

9-
from ..example import ExampleWidget
9+
from jupyterannotate.annotate import AnnotateWidget
1010

1111

12-
def test_example_creation_blank():
13-
w = ExampleWidget()
14-
assert w.value == 'Hello World'
12+
def test_annotate_widget():
13+
w = AnnotateWidget()
14+
assert w.spans == []

‎package-lock.json

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"jest": "^26.0.0",
7272
"mkdirp": "^0.5.1",
7373
"npm-run-all": "^4.1.3",
74+
"preact": "^10.10.1",
7475
"prettier": "^2.0.5",
7576
"rimraf": "^2.6.2",
7677
"source-map-loader": "^1.1.3",

‎src/__tests__/index.spec.ts

+12-15
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@
44
// Add any needed widget imports here (or from controls)
55
// import {} from '@jupyter-widgets/base';
66

7-
import { createTestModel } from './utils';
7+
import { createTestModel } from "./utils";
88

9-
import { ExampleModel } from '..';
9+
import { AnnotateModel } from "..";
1010

11-
describe('Example', () => {
12-
describe('ExampleModel', () => {
13-
it('should be createable', () => {
14-
const model = createTestModel(ExampleModel);
15-
expect(model).toBeInstanceOf(ExampleModel);
16-
expect(model.get('value')).toEqual('Hello World');
17-
});
11+
describe("AnnotateModel", () => {
12+
it("should be createable", () => {
13+
const model = createTestModel(AnnotateModel);
14+
expect(model).toBeInstanceOf(AnnotateModel);
15+
});
1816

19-
it('should be createable with a value', () => {
20-
const state = { value: 'Foo Bar!' };
21-
const model = createTestModel(ExampleModel, state);
22-
expect(model).toBeInstanceOf(ExampleModel);
23-
expect(model.get('value')).toEqual('Foo Bar!');
24-
});
17+
it("should be createable with a value", () => {
18+
const state = { text: "Foo Bar!" };
19+
const model = createTestModel(AnnotateModel, state);
20+
expect(model).toBeInstanceOf(AnnotateModel);
21+
expect(model.get("text")).toEqual("Foo Bar!");
2522
});
2623
});

0 commit comments

Comments
 (0)