Skip to content

Commit 42ee0ec

Browse files
authored
Documentation updates and minor fixes (#28)
* Update panel version, add watchfiles and use Viewer for app * Rename immutable_id to predefined * Add license * Update dev docs to describe admin panel and dev mode * Remove obsolete configuration value width_policy * Add example to docstring * Fix github actions syntax * Comment out failing github actions line * Remove Python 3.13 * Recomment failing actions line * Fix ignn formatting * Make rye fmt ignore _version.py
1 parent 1f3b02d commit 42ee0ec

File tree

12 files changed

+85
-48
lines changed

12 files changed

+85
-48
lines changed

.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
py: ["3.12", "3.13"]
10+
py: ["3.12"]
1111
steps:
1212
- uses: actions/checkout@v4
1313
- uses: eifinger/setup-rye@v3
14-
- run: rye pin $
14+
- run: rye pin ${{ matrix.py }}
1515
- run: |
1616
rye sync
17-
[[ -n $(git diff --stat requirements.lock) ]] && exit 1
18-
- run: rye fmt --check
17+
# [[ -n $(git diff --stat requirements.lock) ]] && exit 1
18+
- run: rye fmt --check $( find src/tseda -name "*.py" | grep -v _version.py )
1919
- run: rye lint src
2020
- run: rye run check
2121
- run: rye run test

CONTRIBUTING.md

+35-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Contributor guide
1+
# Contributor guide
22

33
Thank you for your interest in improving this project. This project is
44
open-source under the [MIT license] and welcomes contributions in the
@@ -21,16 +21,16 @@ introduction to rye, see the [postmodern python] blog post.
2121
Use rye to add and remove dependencies from `pyproject.toml`.
2222
Development packages are added by applying the `--dev` flag:
2323

24-
rye add package
25-
rye add dev-package --dev
26-
rye remove package
27-
rye remove dev-package --dev
24+
rye add package
25+
rye add dev-package --dev
26+
rye remove package
27+
rye remove dev-package --dev
2828

2929
After modifying dependencies, make sure to run `rye sync` to update
3030
the virtual environment.
3131

3232
[rye]: https://rye.astral.sh/
33-
[postmodern python]: https://rdrn.me/postmodern-python/
33+
[postmodern python]: https://rdrn.me/postmodern-python/
3434

3535
## Virtual environment
3636

@@ -40,7 +40,7 @@ you have `pyenv` installed you may run into the issue that nothing
4040
seems to load. This is a known issue (see [pyenv issue]). You can
4141
always run programs in the virtual environment with `rye run`, e.g.,
4242

43-
rye run pytest -v -s
43+
rye run pytest -v -s
4444

4545
[pyenv issue]: https://github.com/astral-sh/rye/issues/317
4646

@@ -49,25 +49,44 @@ always run programs in the virtual environment with `rye run`, e.g.,
4949
rye provides support for Python code formatting, linting, and more.
5050
The steps can be run separately
5151

52-
rye fmt
53-
rye lint --fix
54-
rye run check
55-
rye test
56-
57-
Alternativel, you can run the entire toolchain with
52+
rye fmt
53+
rye lint --fix
54+
rye run check
55+
rye test
5856

59-
rye run all
57+
Alternatively, you can run the entire toolchain with
58+
59+
rye run all
6060

6161
## Development with small test data set
6262

6363
Development is facilitated by loading the small data set that is
6464
provided and reloading upon code changes:
6565

66-
rye run python -m tseda tests/data/test.trees
67-
66+
rye run python -m tseda tests/data/test.trees
67+
6868
The test data is a modified simulation of the [out of Africa]
6969
demographic model (stdpopsim model `OutOfAfrica_3G09`), amended with
7070
three outgroup species. The geolocations are dummy locations meant to
7171
reflect typical metadata.
7272

7373
[out of africa]: https://github.com/popsim-consortium/stdpopsim/blob/main/stdpopsim/catalog/HomSap/demographic_models.py
74+
75+
## Monitoring resource usage and user behaviour
76+
77+
The `--admin` option will activate the `/admin` panel:
78+
79+
rye run python -m tseda tests/data/test.trees --admin
80+
81+
If the project is served locally on port 5006, the `/admin` endpoint
82+
would be available at `http://localhost:5006/admin. See [admin] for
83+
more information.
84+
85+
[admin]: https://panel.holoviz.org/how_to/profiling/admin.html
86+
87+
## Serving the application in development mode
88+
89+
For interactive development, you can serve the app in development mode
90+
with `panel serve`:
91+
92+
rye run panel serve src/tseda --dev --show --args tests/data/test.trees

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Tskit developers
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

pyproject.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = [
55
{ name = "Per Unneberg", email = "[email protected]" }
66
]
77
dependencies = [
8-
"panel~=1.5.2",
8+
"panel~=1.5.3",
99
"tskit~=0.5.8",
1010
"tszip~=0.2.5",
1111
"click~=8.1.7",
@@ -46,12 +46,13 @@ packages = ["src/tseda"]
4646
managed = true
4747
dev-dependencies = [
4848
"jupyter~=1.0.0",
49-
"pyright~=1.1.386",
49+
"pyright~=1.1.388",
5050
"pytest~=8.3.2",
5151
"stdpopsim~=0.2.0",
5252
"geodatasets~=2024.7.0",
5353
"pip~=24.2",
5454
"hatch-vcs~=0.4.0",
55+
"watchfiles~=0.24.0",
5556
]
5657

5758
[project.scripts]
@@ -96,4 +97,4 @@ test = "rye test"
9697
all = { chain = ["fmt", "lint", "check", "test"] }
9798

9899
[tool.pytest.ini_options]
99-
addopts = "--doctest-modules"
100+
addopts = "--doctest-modules --ignore src/tseda/main.py"

requirements-dev.lock

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
anyio==4.4.0
1414
# via httpx
1515
# via jupyter-server
16+
# via watchfiles
1617
appdirs==1.4.4
1718
# via stdpopsim
1819
# via tseda
@@ -334,7 +335,7 @@ pandas==2.2.2
334335
# via xarray
335336
pandocfilters==1.5.1
336337
# via nbconvert
337-
panel==1.5.2
338+
panel==1.5.3
338339
# via geoviews
339340
# via holoviews
340341
# via hvplot
@@ -400,7 +401,7 @@ pyproj==3.6.1
400401
# via cartopy
401402
# via geopandas
402403
# via geoviews
403-
pyright==1.1.386
404+
pyright==1.1.388
404405
pyshp==2.3.1
405406
# via cartopy
406407
pyslim==1.0.4
@@ -544,6 +545,7 @@ uri-template==1.3.0
544545
# via jsonschema
545546
urllib3==2.2.2
546547
# via requests
548+
watchfiles==0.24.0
547549
wcwidth==0.2.13
548550
# via prompt-toolkit
549551
webcolors==24.8.0

requirements.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ pandas==2.2.2
162162
# via hvplot
163163
# via panel
164164
# via xarray
165-
panel==1.5.2
165+
panel==1.5.3
166166
# via geoviews
167167
# via holoviews
168168
# via hvplot

src/tseda/__main__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,17 @@ def preprocess(tszip_path, output):
9797
default=True,
9898
help="Launch a web-browser showing the app",
9999
)
100+
@click.option(
101+
"--admin", default=False, is_flag=True, help="Add bokeh admin panel"
102+
)
100103
@click.option("--log-level", default="INFO", help="Logging level")
101104
@click.option(
102105
"--no-log-filter",
103106
default=False,
104107
is_flag=True,
105108
help="Do not filter the output log (advanced debugging only)",
106109
)
107-
def serve(path, port, show, log_level, no_log_filter):
110+
def serve(path, port, show, log_level, no_log_filter, admin):
108111
"""
109112
Run the tseda datastore server, version based on View base class.
110113
"""
@@ -123,7 +126,7 @@ def serve(path, port, show, log_level, no_log_filter):
123126
title="TSEda Datastore App",
124127
views=[IndividualsTable],
125128
)
126-
pn.serve(app_.view(), port=port, show=show, verbose=False)
129+
pn.serve(app_.view(), port=port, show=show, verbose=False, admin=admin)
127130

128131

129132
if __name__ == "__main__":

src/tseda/app.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import panel as pn
66
import param
77
from holoviews import opts
8+
from panel.viewable import Viewer
89

910
from tseda import config, datastore, pages, vpages
1011

@@ -84,8 +85,7 @@ def get_sidebar(selected_page):
8485
return template
8586

8687

87-
# class DataStoreApp(Viewer):
88-
class DataStoreApp(param.Parameterized):
88+
class DataStoreApp(Viewer):
8989
datastore = param.ClassSelector(class_=datastore.DataStore)
9090

9191
title = param.String()
@@ -114,14 +114,6 @@ def __init__(self, **params):
114114
else pn.state.curdoc.unhold()
115115
)
116116

117-
def servable(self):
118-
if pn.state.served:
119-
return self._template.servable()
120-
return self
121-
122-
def show(self, selected_page):
123-
yield self.pages[selected_page]
124-
125117
@param.depends("views")
126118
def view(self):
127119
page_titles = list(self.pages.keys())

src/tseda/datastore.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def make_individuals_table(tsm):
2424
def make_sample_sets_table(tsm):
2525
result = []
2626
for ts_pop in tsm.ts.populations():
27-
ss = SampleSet(id=ts_pop.id, population=ts_pop, immutable_id=True)
27+
ss = SampleSet(id=ts_pop.id, population=ts_pop, predefined=True)
2828
result.append(ss)
2929
return SampleSetsTable(table=pd.DataFrame(result))
3030

@@ -197,17 +197,17 @@ def sidebar(self):
197197

198198

199199
class SampleSetsTable(Viewer):
200-
default_columns = ["name", "color", "immutable_id"]
200+
default_columns = ["name", "color", "predefined"]
201201
editors = {k: None for k in default_columns}
202202
editors["color"] = {
203203
"type": "list",
204204
"values": config.COLORS,
205205
"valueLookup": True,
206206
}
207-
editors["name"] = {"type": "input"}
207+
editors["name"] = {"type": "input", "validator": "unique", "search": True}
208208
formatters = {
209209
"color": {"type": "color"},
210-
"immutable_id": {"type": "tickCross"},
210+
"predefined": {"type": "tickCross"},
211211
}
212212

213213
create_sample_set_textinput = param.String(
@@ -247,7 +247,7 @@ def __panel__(self):
247247
self.create_sample_set_textinput = None
248248
table = pn.widgets.Tabulator(
249249
self.data,
250-
layout="fit_columns",
250+
layout="fit_data_table",
251251
selectable=True,
252252
page_size=100,
253253
pagination="remote",
@@ -260,14 +260,14 @@ def __panel__(self):
260260
def sidebar_table(self):
261261
table = pn.widgets.Tabulator(
262262
self.data,
263-
layout="fit_columns",
263+
layout="fit_data_table",
264264
selectable=True,
265265
page_size=100,
266266
pagination="remote",
267267
margin=10,
268268
formatters=self.formatters,
269269
editors=self.editors,
270-
hidden_columns=["id", "immutable_id"],
270+
hidden_columns=["id"],
271271
)
272272
return pn.Card(
273273
pn.Column(self.tooltip, table),

src/tseda/model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class SampleSet:
9393
name: str = None
9494
color: str = None
9595
population: dataclasses.InitVar[tskit.Population | None] = None
96-
immutable_id: bool = False
96+
predefined: bool = False
9797

9898
colormap = config.COLORS
9999

src/tseda/pages/gnnhaplotype.py

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import param
2222

2323
hv.extension("bokeh")
24-
pn.extension(width_policy="max")
2524

2625

2726
def make_windows(window_size, sequence_length):

src/tseda/vpages/ignn.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class VBar(View):
143143
doc=(
144144
"Change sort order within sample sets. Default is "
145145
"to sort by sample index. Provide a list of strings "
146-
"where items correspond to sample set names."
146+
'where items correspond to sample set names, e.g. `["sampleset"]`.'
147147
),
148148
)
149149

0 commit comments

Comments
 (0)