Skip to content

Commit ba9b1d5

Browse files
authored
Merge pull request #96 from scipp/workflow-interface
Workflow widget interface
2 parents 522f00f + fedbf6b commit ba9b1d5

15 files changed

+321
-30
lines changed

docs/user-guide/dream/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ maxdepth: 1
77
88
dream-data-reduction
99
dream-instrument-view
10+
workflow-widget-dream
1011
dream-detector-diagnostics
1112
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "0",
6+
"metadata": {},
7+
"source": [
8+
"# Workflow widgets example\n",
9+
"\n",
10+
"This notebook illustrates how we can use ESSreduce’s [workflow widgets](https://scipp.github.io/essreduce/user-guide/widget.html) to generate a graphical interface for running the LoKI tutorial workflow.\n",
11+
"\n",
12+
"## Initializing the GUI\n",
13+
"\n",
14+
"It is as simple as importing the dream submodule and generating a GUI using `workflow_widget` (the workflow automatically registers itself to a library of workflows when imported)."
15+
]
16+
},
17+
{
18+
"cell_type": "code",
19+
"execution_count": null,
20+
"id": "1",
21+
"metadata": {},
22+
"outputs": [],
23+
"source": [
24+
"# Import dream submodule to register workflow\n",
25+
"from ess import dream\n",
26+
"from ess.reduce import ui\n",
27+
"\n",
28+
"# Prepare a container for accessing the results computed by the GUI\n",
29+
"results = {}\n",
30+
"\n",
31+
"# Initialize the GUI widget\n",
32+
"widget = ui.workflow_widget(result_registry=results)\n",
33+
"widget"
34+
]
35+
},
36+
{
37+
"cell_type": "code",
38+
"execution_count": null,
39+
"id": "2",
40+
"metadata": {
41+
"editable": true,
42+
"slideshow": {
43+
"slide_type": ""
44+
},
45+
"tags": []
46+
},
47+
"outputs": [],
48+
"source": [
49+
"from ess.powder.types import DspacingBins, Filename, SampleRun, VanadiumRun\n",
50+
"import ess.dream.data # noqa: F401\n",
51+
"\n",
52+
"select = widget.children[0].children[0]\n",
53+
"keys, values = zip(*select.options, strict=True)\n",
54+
"ind = keys.index(\"DreamGeant4ProtonChargeWorkflow\")\n",
55+
"select.value = values[ind]\n",
56+
"# Select IofDspacing output\n",
57+
"wfw = widget.children[1].children[0]\n",
58+
"outputs = wfw.output_selection_box.typical_outputs_widget\n",
59+
"keys, values = zip(*outputs.options, strict=True)\n",
60+
"ind = keys.index(\"IofTof\")\n",
61+
"outputs.value = (values[ind],)\n",
62+
"# Refresh parameters\n",
63+
"pbox = wfw.parameter_box\n",
64+
"pbox.parameter_refresh_button.click()\n",
65+
"# Set parameters\n",
66+
"pbox._input_widgets[Filename[SampleRun]].children[0].value = dream.data.simulated_diamond_sample()\n",
67+
"pbox._input_widgets[Filename[VanadiumRun]].children[0].value = dream.data.simulated_vanadium_sample()\n",
68+
"pbox._input_widgets[DspacingBins].children[0].fields[\"stop\"].value = 2.3434\n",
69+
"# Run the workflow\n",
70+
"rbox = wfw.result_box\n",
71+
"rbox.run_button.click()"
72+
]
73+
},
74+
{
75+
"cell_type": "markdown",
76+
"id": "3",
77+
"metadata": {
78+
"editable": true,
79+
"slideshow": {
80+
"slide_type": ""
81+
},
82+
"tags": []
83+
},
84+
"source": [
85+
"## Accessing the results\n",
86+
"\n",
87+
"We can now access the computed result in the `results` dictionary:"
88+
]
89+
},
90+
{
91+
"cell_type": "code",
92+
"execution_count": null,
93+
"id": "4",
94+
"metadata": {},
95+
"outputs": [],
96+
"source": [
97+
"results"
98+
]
99+
},
100+
{
101+
"cell_type": "markdown",
102+
"id": "5",
103+
"metadata": {},
104+
"source": [
105+
"The result can be plotted using"
106+
]
107+
},
108+
{
109+
"cell_type": "code",
110+
"execution_count": null,
111+
"id": "6",
112+
"metadata": {},
113+
"outputs": [],
114+
"source": [
115+
"(da,) = results.values()\n",
116+
"da.hist(tof=200).plot()"
117+
]
118+
}
119+
],
120+
"metadata": {
121+
"kernelspec": {
122+
"display_name": "Python 3 (ipykernel)",
123+
"language": "python",
124+
"name": "python3"
125+
},
126+
"language_info": {
127+
"codemirror_mode": {
128+
"name": "ipython",
129+
"version": 3
130+
},
131+
"file_extension": ".py",
132+
"mimetype": "text/x-python",
133+
"name": "python",
134+
"nbconvert_exporter": "python",
135+
"pygments_lexer": "ipython3"
136+
}
137+
},
138+
"nbformat": 4,
139+
"nbformat_minor": 5
140+
}

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ requires-python = ">=3.10"
3131
# Make sure to list one dependency per line.
3232
dependencies = [
3333
"dask",
34-
"essreduce>=24.10.2",
34+
"essreduce>=24.11.3",
3535
"graphviz",
3636
"numpy",
3737
"plopp",

requirements/base.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# --- END OF CUSTOM SECTION ---
44
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!
55
dask
6-
essreduce>=24.10.2
6+
essreduce>=24.11.3
77
graphviz
88
numpy
99
plopp
1010
pythreejs
1111
sciline>=24.06.0
1212
scipp>=24.09.1
13-
scippneutron>=24.9.0
13+
scippneutron>=24.11.0
1414
scippnexus>=23.12.0

requirements/base.txt

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SHA1:86f9288f7221f3a8506d1cc40db8a4584011b0e0
1+
# SHA1:6b89155439eb051cb7a3ca3e31678c9fa96a6f5a
22
#
33
# This file is autogenerated by pip-compile-multi
44
# To update, run:
@@ -23,13 +23,13 @@ dask==2024.11.2
2323
# via -r base.in
2424
decorator==5.1.1
2525
# via ipython
26-
essreduce==24.11.1
26+
essreduce==24.11.3
2727
# via -r base.in
2828
exceptiongroup==1.2.2
2929
# via ipython
3030
executing==2.1.0
3131
# via stack-data
32-
fonttools==4.54.1
32+
fonttools==4.55.0
3333
# via matplotlib
3434
fsspec==2024.10.0
3535
# via dask
@@ -124,8 +124,10 @@ scipp==24.11.1
124124
# scippneutron
125125
# scippnexus
126126
scippneutron==24.11.0
127-
# via -r base.in
128-
scippnexus==24.11.0
127+
# via
128+
# -r base.in
129+
# essreduce
130+
scippnexus==24.11.1
129131
# via
130132
# -r base.in
131133
# essreduce

requirements/basetest.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ requests==2.32.3
3939
# via pooch
4040
six==1.16.0
4141
# via python-dateutil
42-
tomli==2.1.0
42+
tomli==2.2.1
4343
# via pytest
4444
tzdata==2024.2
4545
# via pandas

requirements/ci.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ requests==2.32.3
4444
# via -r ci.in
4545
smmap==5.0.1
4646
# via gitdb
47-
tomli==2.1.0
47+
tomli==2.2.1
4848
# via
4949
# pyproject-api
5050
# tox
@@ -54,5 +54,5 @@ typing-extensions==4.12.2
5454
# via tox
5555
urllib3==2.2.3
5656
# via requests
57-
virtualenv==20.27.1
57+
virtualenv==20.28.0
5858
# via tox

requirements/dev.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ cffi==1.17.1
3030
# via argon2-cffi-bindings
3131
copier==9.4.1
3232
# via -r dev.in
33-
dunamai==1.22.0
33+
dunamai==1.23.0
3434
# via copier
3535
fqdn==1.5.1
3636
# via jsonschema
3737
funcy==2.0
3838
# via copier
3939
h11==0.14.0
4040
# via httpcore
41-
httpcore==1.0.6
41+
httpcore==1.0.7
4242
# via httpx
4343
httpx==0.27.2
4444
# via jupyterlab
4545
isoduration==20.11.0
4646
# via jsonschema
4747
jinja2-ansible-filters==1.3.2
4848
# via copier
49-
json5==0.9.28
49+
json5==0.10.0
5050
# via jupyterlab-server
5151
jsonpointer==3.0.0
5252
# via jsonschema
@@ -67,7 +67,7 @@ jupyter-server==2.14.2
6767
# notebook-shim
6868
jupyter-server-terminals==0.5.3
6969
# via jupyter-server
70-
jupyterlab==4.3.0
70+
jupyterlab==4.3.1
7171
# via -r dev.in
7272
jupyterlab-server==2.27.3
7373
# via jupyterlab
@@ -77,7 +77,7 @@ overrides==7.7.0
7777
# via jupyter-server
7878
pathspec==0.12.1
7979
# via copier
80-
pip-compile-multi==2.6.4
80+
pip-compile-multi==2.7.1
8181
# via -r dev.in
8282
pip-tools==7.4.1
8383
# via pip-compile-multi
@@ -87,9 +87,9 @@ prometheus-client==0.21.0
8787
# via jupyter-server
8888
pycparser==2.22
8989
# via cffi
90-
pydantic==2.9.2
90+
pydantic==2.10.2
9191
# via copier
92-
pydantic-core==2.23.4
92+
pydantic-core==2.27.1
9393
# via pydantic
9494
python-json-logger==2.0.7
9595
# via jupyter-events
@@ -123,7 +123,7 @@ webcolors==24.11.1
123123
# via jsonschema
124124
websocket-client==1.8.0
125125
# via jupyter-server
126-
wheel==0.45.0
126+
wheel==0.45.1
127127
# via pip-tools
128128

129129
# The following packages are considered to be unsafe in a requirements file:

requirements/docs.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ certifi==2024.8.30
2828
# via requests
2929
charset-normalizer==3.4.0
3030
# via requests
31-
debugpy==1.8.8
31+
debugpy==1.8.9
3232
# via ipykernel
3333
defusedxml==0.7.1
3434
# via nbconvert
@@ -40,7 +40,7 @@ docutils==0.21.2
4040
# pydata-sphinx-theme
4141
# sphinx
4242
# sphinxcontrib-bibtex
43-
fastjsonschema==2.20.0
43+
fastjsonschema==2.21.0
4444
# via nbformat
4545
idna==3.10
4646
# via requests
@@ -118,7 +118,7 @@ pooch==1.8.2
118118
# via -r docs.in
119119
psutil==6.1.0
120120
# via ipykernel
121-
pyarrow==18.0.0
121+
pyarrow==18.1.0
122122
# via -r docs.in
123123
pybtex==0.24.0
124124
# via
@@ -182,9 +182,9 @@ sphinxcontrib-serializinghtml==2.0.0
182182
# via sphinx
183183
tinycss2==1.4.0
184184
# via nbconvert
185-
tomli==2.1.0
185+
tomli==2.2.1
186186
# via sphinx
187-
tornado==6.4.1
187+
tornado==6.4.2
188188
# via
189189
# ipykernel
190190
# jupyter-client

requirements/nightly.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ essreduce @ git+https://github.com/scipp/essreduce@main
2828
# via -r nightly.in
2929
executing==2.1.0
3030
# via stack-data
31-
fonttools==4.54.1
31+
fonttools==4.55.0
3232
# via matplotlib
3333
fsspec==2024.10.0
3434
# via dask
@@ -103,7 +103,9 @@ scipp @ https://github.com/scipp/scipp/releases/download/nightly/scipp-nightly-c
103103
# scippneutron
104104
# scippnexus
105105
scippneutron @ git+https://github.com/scipp/scippneutron@main
106-
# via -r nightly.in
106+
# via
107+
# -r nightly.in
108+
# essreduce
107109
scippnexus @ git+https://github.com/scipp/scippnexus@main
108110
# via
109111
# -r nightly.in

requirements/static.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ distlib==0.3.9
1111
# via virtualenv
1212
filelock==3.16.1
1313
# via virtualenv
14-
identify==2.6.2
14+
identify==2.6.3
1515
# via pre-commit
1616
nodeenv==1.9.1
1717
# via pre-commit
@@ -21,5 +21,5 @@ pre-commit==4.0.1
2121
# via -r static.in
2222
pyyaml==6.0.2
2323
# via pre-commit
24-
virtualenv==20.27.1
24+
virtualenv==20.28.0
2525
# via pre-commit

requirements/wheels.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ packaging==24.2
1111
# via build
1212
pyproject-hooks==1.2.0
1313
# via build
14-
tomli==2.1.0
14+
tomli==2.2.1
1515
# via build

0 commit comments

Comments
 (0)