Skip to content

Commit

Permalink
Merge pull request #188 from scipp/use-multi-file-widget
Browse files Browse the repository at this point in the history
Use multi-file widget in workflow widget
  • Loading branch information
nvaytet authored Jan 24, 2025
2 parents 9689af1 + a214d63 commit 37fd8c3
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 42 deletions.
6 changes: 3 additions & 3 deletions docs/user-guide/loki/workflow-widget-loki.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@
"pbox = wfw.parameter_box\n",
"pbox.parameter_refresh_button.click()\n",
"# Enable DirectBeam input\n",
"pbox._input_widgets[DirectBeam].children[0].enabled = True\n",
"pbox._input_widgets[DirectBeam].children[0].wrapped._option_box.value = None\n",
"pbox._input_widgets[DirectBeam].children[0].value = True\n",
"pbox._input_widgets[DirectBeam].children[1].children[1]._option_box.value = None\n",
"# Adjust Q range\n",
"pbox._input_widgets[QBins].children[0].fields[\"start\"].value = 0.01\n",
"pbox._input_widgets[QBins].fields[\"start\"].value = 0.01\n",
"# Run the workflow\n",
"rbox = wfw.result_box\n",
"rbox.run_button.click()"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ requires-python = ">=3.10"
dependencies = [
"dask",
"graphviz",
"essreduce>=24.10.2, <24.11.0",
"essreduce>=24.11.3",
"numpy",
"pandas",
"plopp",
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!
dask
graphviz
essreduce>=24.10.2, <24.11.0
essreduce>=24.11.3
numpy
pandas
plopp
Expand Down
14 changes: 8 additions & 6 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SHA1:01b4e247f3980e3f21b6b9ad70d3e5e49610d9c4
# SHA1:71fbc763453db59fbe23acb0df92531c0434f7ef
#
# This file is autogenerated by pip-compile-multi
# To update, run:
Expand All @@ -23,13 +23,13 @@ dask==2025.1.0
# via -r base.in
decorator==5.1.1
# via ipython
essreduce==24.10.3
essreduce==24.12.0
# via -r base.in
exceptiongroup==1.2.2
# via ipython
executing==2.1.0
executing==2.2.0
# via stack-data
fonttools==4.55.3
fonttools==4.55.5
# via matplotlib
fsspec==2024.12.0
# via dask
Expand Down Expand Up @@ -130,7 +130,9 @@ scipp==25.1.0
# scippneutron
# scippnexus
scippneutron==25.1.0
# via -r base.in
# via
# -r base.in
# essreduce
scippnexus==24.11.1
# via
# -r base.in
Expand Down Expand Up @@ -160,7 +162,7 @@ traittypes==0.2.1
# via ipydatawidgets
typing-extensions==4.12.2
# via ipython
tzdata==2024.2
tzdata==2025.1
# via pandas
wcwidth==0.2.13
# via prompt-toolkit
Expand Down
8 changes: 4 additions & 4 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# pip-compile-multi
#
cachetools==5.5.0
cachetools==5.5.1
# via tox
certifi==2024.12.14
# via requests
Expand All @@ -17,7 +17,7 @@ colorama==0.4.6
# via tox
distlib==0.3.9
# via virtualenv
filelock==3.16.1
filelock==3.17.0
# via
# tox
# virtualenv
Expand All @@ -38,7 +38,7 @@ platformdirs==4.3.6
# virtualenv
pluggy==1.5.0
# via tox
pyproject-api==1.8.0
pyproject-api==1.9.0
# via tox
requests==2.32.3
# via -r ci.in
Expand All @@ -48,7 +48,7 @@ tomli==2.2.1
# via
# pyproject-api
# tox
tox==4.23.2
tox==4.24.1
# via -r ci.in
typing-extensions==4.12.2
# via tox
Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ prometheus-client==0.21.1
# via jupyter-server
pycparser==2.22
# via cffi
pydantic==2.10.5
pydantic==2.10.6
# via copier
pydantic-core==2.27.2
# via pydantic
Expand Down
6 changes: 3 additions & 3 deletions requirements/nightly.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ decorator==5.1.1
# via ipython
essreduce @ git+https://github.com/scipp/essreduce@main
# via -r nightly.in
executing==2.1.0
executing==2.2.0
# via stack-data
fonttools==4.55.3
fonttools==4.55.5
# via matplotlib
fsspec==2024.12.0
# via dask
Expand Down Expand Up @@ -140,7 +140,7 @@ traittypes==0.2.1
# via ipydatawidgets
typing-extensions==4.12.2
# via ipython
tzdata==2024.2
tzdata==2025.1
# via pandas
wcwidth==0.2.13
# via prompt-toolkit
Expand Down
2 changes: 1 addition & 1 deletion requirements/static.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cfgv==3.4.0
# via pre-commit
distlib==0.3.9
# via virtualenv
filelock==3.16.1
filelock==3.17.0
# via virtualenv
identify==2.6.6
# via pre-commit
Expand Down
35 changes: 16 additions & 19 deletions src/ess/loki/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,31 @@
from ess.sans.parameters import typical_outputs

from ..sans.types import (
BackgroundRun,
BeamCenter,
DetectorBankSizes,
DetectorData,
DetectorPixelShape,
DirectBeam,
DirectBeamFilename,
EmptyBeamRun,
Filename,
Incident,
MonitorData,
MonitorType,
NeXusComponent,
NeXusDetectorName,
NeXusMonitorName,
NonBackgroundWavelengthRange,
PixelMaskFilename,
PixelShapePath,
RunType,
SampleRun,
ScatteringRunType,
TofData,
TofMonitor,
Transmission,
TransmissionRun,
)

DETECTOR_BANK_SIZES = {
Expand Down Expand Up @@ -105,7 +113,7 @@ def LokiAtLarmorWorkflow() -> sciline.Pipeline:
for key, param in default_parameters().items():
workflow[key] = param
workflow.insert(read_xml_detector_masking)
workflow[sans.types.NeXusDetectorName] = 'larmor_detector'
workflow[NeXusDetectorName] = 'larmor_detector'
workflow.typical_outputs = typical_outputs
return workflow

Expand All @@ -115,25 +123,14 @@ def LokiAtLarmorTutorialWorkflow() -> sciline.Pipeline:
from ess.loki import data

workflow = LokiAtLarmorWorkflow()
# TODO This does not work with multiple
workflow[sans.types.PixelMaskFilename] = data.loki_tutorial_mask_filenames()[0]

workflow[sans.types.Filename[sans.types.SampleRun]] = (
data.loki_tutorial_sample_run_60339()
)
workflow[sans.types.Filename[sans.types.BackgroundRun]] = (
data.loki_tutorial_background_run_60393()
)
workflow[sans.types.Filename[sans.types.TransmissionRun[sans.types.SampleRun]]] = (
workflow[PixelMaskFilename] = data.loki_tutorial_mask_filenames()
workflow[Filename[SampleRun]] = data.loki_tutorial_sample_run_60339()
workflow[Filename[BackgroundRun]] = data.loki_tutorial_background_run_60393()
workflow[Filename[TransmissionRun[SampleRun]]] = (
data.loki_tutorial_sample_transmission_run()
)
workflow[
sans.types.Filename[sans.types.TransmissionRun[sans.types.BackgroundRun]]
] = data.loki_tutorial_run_60392()
workflow[sans.types.Filename[sans.types.EmptyBeamRun]] = (
data.loki_tutorial_run_60392()
)
workflow[sans.types.BeamCenter] = sc.vector(
value=[-0.02914868, -0.01816138, 0.0], unit='m'
)
workflow[Filename[TransmissionRun[BackgroundRun]]] = data.loki_tutorial_run_60392()
workflow[Filename[EmptyBeamRun]] = data.loki_tutorial_run_60392()
workflow[BeamCenter] = sc.vector(value=[-0.02914868, -0.01816138, 0.0], unit='m')
return workflow
6 changes: 4 additions & 2 deletions src/ess/sans/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
CorrectForGravity, default=False
)
parameter_registry[NeXusDetectorName] = StringParameter.from_type(NeXusDetectorName)

parameter_registry[NeXusMonitorName[Incident]] = StringParameter.from_type(
NeXusMonitorName[Incident], default=''
)
Expand All @@ -76,10 +77,10 @@
parameter_registry[UncertaintyBroadcastMode] = ParamWithOptions.from_enum(
UncertaintyBroadcastMode, default=UncertaintyBroadcastMode.upper_bound
)
parameter_registry[Filename[SampleRun]] = FilenameParameter.from_type(
parameter_registry[Filename[SampleRun]] = MultiFilenameParameter.from_type(
Filename[SampleRun]
)
parameter_registry[Filename[BackgroundRun]] = FilenameParameter.from_type(
parameter_registry[Filename[BackgroundRun]] = MultiFilenameParameter.from_type(
Filename[BackgroundRun]
)
parameter_registry[Filename[TransmissionRun[SampleRun]]] = FilenameParameter.from_type(
Expand All @@ -91,6 +92,7 @@
parameter_registry[Filename[EmptyBeamRun]] = FilenameParameter.from_type(
Filename[EmptyBeamRun]
)

parameter_registry[WavelengthBins] = BinEdgesParameter(
WavelengthBins, dim='wavelength', start=2, stop=12.0, nbins=300, log=False
)
Expand Down
5 changes: 4 additions & 1 deletion src/ess/sans/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ def with_background_runs(


parameter_mappers[PixelMaskFilename] = with_pixel_mask_filenames
parameter_mappers[NeXusDetectorName] = with_banks
# TODO: for now, we leave the mapping over detector banks out, because we do not have a
# method to merge the I(Q) of different banks, and we thus cannot compute a single
# result from the workflow. So only a single detector bank can be processed at a time.
# parameter_mappers[NeXusDetectorName] = with_banks
parameter_mappers[Filename[SampleRun]] = with_sample_runs
parameter_mappers[Filename[BackgroundRun]] = with_background_runs

Expand Down

0 comments on commit 37fd8c3

Please sign in to comment.