murineshiftwork 2.15.0__tar.gz → 2.15.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/PKG-INFO +13 -15
- murineshiftwork-2.15.2/README.md +67 -0
- murineshiftwork-2.15.2/VERSION +1 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/pyproject.toml +7 -8
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_calibration_outliers.py +6 -1
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_calibration_tasks_sim.py +8 -2
- murineshiftwork-2.15.2/tests/test_cli_entrypoints.py +28 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_config_io.py +6 -6
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_config_models.py +6 -6
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_hardware_manager.py +4 -2
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_host_session.py +10 -4
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_integration_deps.py +67 -9
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_plot_spec.py +11 -1
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_post_and_action.py +3 -1
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_preflight_and_pipeline.py +4 -5
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_task_discovery.py +18 -14
- murineshiftwork-2.15.0/README.md +0 -67
- murineshiftwork-2.15.0/VERSION +0 -1
- murineshiftwork-2.15.0/tests/list_used_probe_serial_numbers.py +0 -25
- murineshiftwork-2.15.0/tests/test_manifest.py +0 -172
- murineshiftwork-2.15.0/tests/test_optotagging.py +0 -467
- murineshiftwork-2.15.0/tests/test_rce_barcode_cmd.sh +0 -25
- murineshiftwork-2.15.0/tests/test_sequence_task.py +0 -447
- murineshiftwork-2.15.0/tests/test_sequence_writeback.py +0 -126
- murineshiftwork-2.15.0/tests/test_stimulation_waveform.py +0 -612
- murineshiftwork-2.15.0/tests/tests_cli.py +0 -42
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/.gitignore +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/CITATION.cff +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/LICENSE +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/src/murineshiftwork/py.typed +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/conftest.py +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_fixedsubjects/_test_subject__20260518_121602_710824__probabilistic_switching_fixedsubjects.msw.csv +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_fixedsubjects/_test_subject__20260518_121602_710824__probabilistic_switching_fixedsubjects.msw.df.jsonl +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_fixedsubjects/_test_subject__20260518_121602_710824__probabilistic_switching_fixedsubjects.msw.session.yaml +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_jsonl/subject001__20260508_172956_258756__probabilistic_switching_fixedsubjects.msw.csv +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_jsonl/subject001__20260508_172956_258756__probabilistic_switching_fixedsubjects.msw.df.jsonl +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_jsonl/subject001__20260508_172956_258756__probabilistic_switching_fixedsubjects.msw.settings.process.json +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_jsonl/subject001__20260508_172956_258756__probabilistic_switching_fixedsubjects.msw.settings.task.json +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_legacy/subject003__20210426_183409__probabilistic_switching/subject003__20210426_183409__probabilistic_switching.pkl +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_legacy/subject003__20210426_183409__probabilistic_switching/subject003__20210426_183409__probabilistic_switching.task_settings.py +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_optotagging/_test_subject__20260527_133053_901389__optotagging/_test_subject__20260527_133053_901389__optotagging.msw.session.yaml +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_optotagging/_test_subject__20260527_133053_901389__optotagging/_test_subject__20260527_133053_901389__optotagging_power_ramp_1mw.msw.df.jsonl +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_optotagging/_test_subject__20260527_133053_901389__optotagging/_test_subject__20260527_133053_901389__optotagging_power_ramp_2mw.msw.csv +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_optotagging/_test_subject__20260527_133053_901389__optotagging/session_manifest.yaml +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_pkl/subject002__20260429_153653__probabilistic_switching_fixedsubjects.msw.csv +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_pkl/subject002__20260429_153653__probabilistic_switching_fixedsubjects.msw.df.pkl +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_pkl/subject002__20260429_153653__probabilistic_switching_fixedsubjects.msw.settings.process.json +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_pkl/subject002__20260429_153653__probabilistic_switching_fixedsubjects.msw.settings.task.json +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_sequence/_test_subject__20260520_114516_534465__sequence.msw.csv +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_sequence/_test_subject__20260520_114516_534465__sequence.msw.df.jsonl +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_sequence/_test_subject__20260520_114516_534465__sequence.msw.session.yaml +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_v2/_test_subject__20260516_130611_739182__probabilistic_switching_fixedsubjects.msw.csv +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_v2/_test_subject__20260516_130611_739182__probabilistic_switching_fixedsubjects.msw.df.jsonl +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/fixture_v2/_test_subject__20260516_130611_739182__probabilistic_switching_fixedsubjects.msw.session.yaml +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/namespace.v1.yaml +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/namespace.v2.yaml +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/data/namespace.v3.yaml +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_cli_evaluate.py +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_hooks.py +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_logagent.py +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_namespace_readiness.py +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_session_yaml_serialization.py +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_sim_hardware.py +0 -0
- {murineshiftwork-2.15.0 → murineshiftwork-2.15.2}/tests/test_taskrunner_paths.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: murineshiftwork
|
|
3
|
-
Version: 2.15.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 2.15.2
|
|
4
|
+
Summary: Behaviour acquisition framework for standardised, scalable experiments.
|
|
5
5
|
Project-URL: Homepage, https://github.com/MurineShiftWork/murineshiftwork
|
|
6
6
|
Project-URL: Documentation, https://MurineShiftWork.github.io/murineshiftwork/
|
|
7
7
|
Project-URL: Issue Tracker, https://github.com/MurineShiftWork/murineshiftwork/issues
|
|
@@ -40,8 +40,8 @@ License: Copyright (c) 2021-present Lars B. Rollik. All rights reserved.
|
|
|
40
40
|
License-File: LICENSE
|
|
41
41
|
Requires-Python: <3.14,>=3.12
|
|
42
42
|
Requires-Dist: ipython>=9.14.1
|
|
43
|
-
Requires-Dist: msw-core>=0.
|
|
44
|
-
Requires-Dist: msw-io>=1.
|
|
43
|
+
Requires-Dist: msw-core>=0.6.0
|
|
44
|
+
Requires-Dist: msw-io>=1.6.0
|
|
45
45
|
Requires-Dist: plotly>=5.0
|
|
46
46
|
Requires-Dist: pyarrow>=24.0.0
|
|
47
47
|
Requires-Dist: tqdm
|
|
@@ -68,7 +68,6 @@ Provides-Extra: full
|
|
|
68
68
|
Requires-Dist: msw-open-ephys>=3.0.0; extra == 'full'
|
|
69
69
|
Requires-Dist: msw-tasks-core>=0.2.0; extra == 'full'
|
|
70
70
|
Requires-Dist: myterial; extra == 'full'
|
|
71
|
-
Requires-Dist: opencv-python-headless; extra == 'full'
|
|
72
71
|
Requires-Dist: pyqt6; extra == 'full'
|
|
73
72
|
Requires-Dist: pyqtgraph; extra == 'full'
|
|
74
73
|
Requires-Dist: rpi-camera-ensemble[conductor]>=0.5.0; extra == 'full'
|
|
@@ -83,7 +82,6 @@ Provides-Extra: pulsepal
|
|
|
83
82
|
Requires-Dist: pypulsepal>=0.4.0; extra == 'pulsepal'
|
|
84
83
|
Provides-Extra: qt
|
|
85
84
|
Requires-Dist: myterial; extra == 'qt'
|
|
86
|
-
Requires-Dist: opencv-python-headless; extra == 'qt'
|
|
87
85
|
Requires-Dist: pyqt6; extra == 'qt'
|
|
88
86
|
Requires-Dist: pyqtgraph; extra == 'qt'
|
|
89
87
|
Provides-Extra: rce
|
|
@@ -94,7 +92,7 @@ Description-Content-Type: text/markdown
|
|
|
94
92
|
|
|
95
93
|
# Murine Shift Work
|
|
96
94
|
|
|
97
|
-
|
|
95
|
+
Behaviour acquisition framework for standardised, scalable experiments.
|
|
98
96
|
|
|
99
97
|
```bash
|
|
100
98
|
msw run --setup rig-a --subject mouse001 --task sequence
|
|
@@ -104,12 +102,12 @@ msw run --setup rig-a --subject mouse001 --task sequence
|
|
|
104
102
|
|
|
105
103
|
## What it does
|
|
106
104
|
|
|
107
|
-
- **Behavioural tasks
|
|
108
|
-
- **Hardware abstraction
|
|
109
|
-
- **Config system
|
|
110
|
-
- **Session files
|
|
111
|
-
- **Live plot
|
|
112
|
-
- **TTL barcodes
|
|
105
|
+
- **Behavioural tasks**: sequence learning, probabilistic switching, optotagging, calibration routines
|
|
106
|
+
- **Hardware abstraction**: interchangeable backends for behaviour controllers, cameras, stage, scale, stimulators
|
|
107
|
+
- **Config system**: layered YAML overrides (bundled defaults, rig overlay, task mode, subject, CLI)
|
|
108
|
+
- **Session files**: structured `.msw.session.yaml` + JSONL trial data; reader API for analysis
|
|
109
|
+
- **Live plot**: per-task online performance display during acquisition
|
|
110
|
+
- **TTL barcodes**: unique per-trial barcodes on BNC output for alignment with parallel recordings
|
|
113
111
|
|
|
114
112
|
---
|
|
115
113
|
|
|
@@ -134,7 +132,7 @@ msw subject add -s mouse001
|
|
|
134
132
|
## Development
|
|
135
133
|
|
|
136
134
|
```bash
|
|
137
|
-
git clone https://github.com/
|
|
135
|
+
git clone https://github.com/MurineShiftWork/murineshiftwork.git
|
|
138
136
|
cd murineshiftwork
|
|
139
137
|
uv sync --group dev
|
|
140
138
|
uv run pytest tests/
|
|
@@ -157,5 +155,5 @@ Key architecture decisions are in `docs/MASTER_PLAN.md`.
|
|
|
157
155
|
|
|
158
156
|
## License
|
|
159
157
|
|
|
160
|
-
Copyright © 2021
|
|
158
|
+
Copyright © 2021-2026 Lars B. Rollik.
|
|
161
159
|
See [LICENSE](LICENSE) for terms.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Murine Shift Work
|
|
2
|
+
|
|
3
|
+
Behaviour acquisition framework for standardised, scalable experiments.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
msw run --setup rig-a --subject mouse001 --task sequence
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## What it does
|
|
12
|
+
|
|
13
|
+
- **Behavioural tasks**: sequence learning, probabilistic switching, optotagging, calibration routines
|
|
14
|
+
- **Hardware abstraction**: interchangeable backends for behaviour controllers, cameras, stage, scale, stimulators
|
|
15
|
+
- **Config system**: layered YAML overrides (bundled defaults, rig overlay, task mode, subject, CLI)
|
|
16
|
+
- **Session files**: structured `.msw.session.yaml` + JSONL trial data; reader API for analysis
|
|
17
|
+
- **Live plot**: per-task online performance display during acquisition
|
|
18
|
+
- **TTL barcodes**: unique per-trial barcodes on BNC output for alignment with parallel recordings
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
Requires Python ≥ 3.12 and [uv](https://docs.astral.sh/uv/).
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install murineshiftwork
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### First-time setup
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
msw init --config-dir /path/to/msw_configs
|
|
34
|
+
msw setup create rig-a
|
|
35
|
+
msw subject add -s mouse001
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Development
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
git clone https://github.com/MurineShiftWork/murineshiftwork.git
|
|
44
|
+
cd murineshiftwork
|
|
45
|
+
uv sync --group dev
|
|
46
|
+
uv run pytest tests/
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Pre-commit hooks (ruff, mypy, secrets scan):
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pre-commit install
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Docs
|
|
58
|
+
|
|
59
|
+
See `docs/` for CLI reference, config system, session files, and task guides.
|
|
60
|
+
Key architecture decisions are in `docs/MASTER_PLAN.md`.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
Copyright © 2021-2026 Lars B. Rollik.
|
|
67
|
+
See [LICENSE](LICENSE) for terms.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.15.2
|
|
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "murineshiftwork"
|
|
7
7
|
dynamic = ["version"]
|
|
8
|
-
description = "
|
|
8
|
+
description = "Behaviour acquisition framework for standardised, scalable experiments."
|
|
9
9
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
10
10
|
license = { file = "LICENSE" }
|
|
11
11
|
authors = [
|
|
@@ -13,8 +13,8 @@ authors = [
|
|
|
13
13
|
]
|
|
14
14
|
requires-python = ">=3.12,<3.14"
|
|
15
15
|
dependencies = [
|
|
16
|
-
"msw-core>=0.
|
|
17
|
-
"msw-io>=1.
|
|
16
|
+
"msw-core>=0.6.0",
|
|
17
|
+
"msw-io>=1.6.0",
|
|
18
18
|
"tqdm",
|
|
19
19
|
"plotly>=5.0",
|
|
20
20
|
"pyarrow>=24.0.0",
|
|
@@ -66,7 +66,6 @@ qt = [
|
|
|
66
66
|
"PyQt6",
|
|
67
67
|
"pyqtgraph",
|
|
68
68
|
"myterial",
|
|
69
|
-
"opencv-python-headless",
|
|
70
69
|
]
|
|
71
70
|
rce = [
|
|
72
71
|
"rpi-camera-ensemble[conductor]>=0.5.0",
|
|
@@ -79,7 +78,7 @@ full = [
|
|
|
79
78
|
murineshiftwork = "murineshiftwork.cli:run_cli"
|
|
80
79
|
msw = "murineshiftwork.cli:run_cli"
|
|
81
80
|
|
|
82
|
-
# External task packages register here
|
|
81
|
+
# External task packages register here; bundled tasks need no entry-point.
|
|
83
82
|
# Example (in an external package's pyproject.toml):
|
|
84
83
|
# [project.entry-points."msw.tasks"]
|
|
85
84
|
# my_task = "my_package.tasks.my_task.my_task"
|
|
@@ -119,7 +118,7 @@ include = [
|
|
|
119
118
|
# creates "bump: ..." commit and annotated tag v{version}.
|
|
120
119
|
# git push && git push --tags → pushes bump commit + tag; triggers release CI.
|
|
121
120
|
#
|
|
122
|
-
# cz bump always produces a clean X.Y.Z tag
|
|
121
|
+
# cz bump always produces a clean X.Y.Z tag, never dev or rc unless you pass
|
|
123
122
|
# --prerelease explicitly. Do NOT pass --prerelease in normal releases.
|
|
124
123
|
# .devN versions in pip show / __version__ between tags are computed at install
|
|
125
124
|
# time by hatch-vcs from git tags and are NOT written as git tags.
|
|
@@ -135,7 +134,7 @@ include = [
|
|
|
135
134
|
[tool.commitizen]
|
|
136
135
|
name = "cz_conventional_commits"
|
|
137
136
|
version_provider = "commitizen"
|
|
138
|
-
version = "2.15.
|
|
137
|
+
version = "2.15.2"
|
|
139
138
|
tag_format = "v$version"
|
|
140
139
|
update_changelog_on_bump = false
|
|
141
140
|
version_files = ["VERSION"]
|
|
@@ -155,7 +154,7 @@ addopts = "--cov=murineshiftwork --durations=0"
|
|
|
155
154
|
[tool.ruff]
|
|
156
155
|
line-length = 88
|
|
157
156
|
indent-width = 4
|
|
158
|
-
exclude = ["
|
|
157
|
+
exclude = ["scripts"]
|
|
159
158
|
|
|
160
159
|
[tool.ruff.lint]
|
|
161
160
|
select = ["E", "W", "F", "I", "UP", "YTT", "SIM", "PTH", "TCH", "PYI"]
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"""Tests for flag_outlier_points: calibration data outlier detection."""
|
|
2
2
|
|
|
3
|
+
import pytest
|
|
3
4
|
from murineshiftwork.logic.calibration import flag_outlier_points
|
|
4
|
-
|
|
5
|
+
|
|
6
|
+
# Calibration task lives in msw-tasks-core; skip when that package is absent.
|
|
7
|
+
pytest.importorskip("murineshiftwork.tasks._calibration_liquid_dynamic")
|
|
8
|
+
|
|
9
|
+
from murineshiftwork.tasks._calibration_liquid_dynamic.task import ( # noqa: E402
|
|
5
10
|
_compute_n_pulses,
|
|
6
11
|
_estimate_ul,
|
|
7
12
|
_suggest_additional_times,
|
|
@@ -8,8 +8,14 @@ Tests run without hardware. They verify that:
|
|
|
8
8
|
|
|
9
9
|
from pathlib import Path
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
import pytest
|
|
12
|
+
|
|
13
|
+
# Calibration tasks live in msw-tasks-core; skip when that package is absent
|
|
14
|
+
# (the lean `test` job runs without --extra tasks).
|
|
15
|
+
pytest.importorskip("murineshiftwork.tasks._calibration_liquid_static")
|
|
16
|
+
|
|
17
|
+
from murineshiftwork.hardware.bpod.sim import SimBpod # noqa: E402
|
|
18
|
+
from murineshiftwork.hardware.scale import SimWeighingScale # noqa: E402
|
|
13
19
|
|
|
14
20
|
# ---------------------------------------------------------------------------
|
|
15
21
|
# Helpers
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""CLI entry-point registration and dispatch smoke tests."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import entry_points
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
from murineshiftwork.cli.parser import parse_args
|
|
7
|
+
from murineshiftwork.cli.tasks import run_tasks_list
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_console_scripts_registered():
|
|
11
|
+
names = {ep.name for ep in entry_points(group="console_scripts")}
|
|
12
|
+
assert "murineshiftwork" in names
|
|
13
|
+
assert "msw" in names
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_version_exits_cleanly():
|
|
17
|
+
with pytest.raises(SystemExit) as exc:
|
|
18
|
+
parse_args(["--version"])
|
|
19
|
+
assert exc.value.code == 0
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_tasks_list_runs(capsys):
|
|
23
|
+
run_tasks_list()
|
|
24
|
+
out = capsys.readouterr().out
|
|
25
|
+
assert isinstance(out, str)
|
|
26
|
+
assert len(out) > 0, (
|
|
27
|
+
"run_tasks_list() produced no output; expected at least one task listed"
|
|
28
|
+
)
|
|
@@ -133,7 +133,7 @@ def test_load_setup_config_with_calibration(tmp_path):
|
|
|
133
133
|
|
|
134
134
|
|
|
135
135
|
def test_load_subject_config_missing(tmp_path):
|
|
136
|
-
result = load_subject_config(tmp_path, "
|
|
136
|
+
result = load_subject_config(tmp_path, "s001_tabfixed_m0000001")
|
|
137
137
|
assert result is None
|
|
138
138
|
|
|
139
139
|
|
|
@@ -146,14 +146,14 @@ def test_load_subject_config_test_subject_skipped(tmp_path):
|
|
|
146
146
|
def test_load_subject_config_valid(tmp_path):
|
|
147
147
|
(tmp_path / "subjects").mkdir()
|
|
148
148
|
data = {
|
|
149
|
-
"name": "
|
|
150
|
-
"project": "
|
|
149
|
+
"name": "s001_tabfixed_m0000001",
|
|
150
|
+
"project": "example_project",
|
|
151
151
|
"task_overrides": {"_test_flush_valves": {"VALVE_OPENING_TIME_MS": 70}},
|
|
152
152
|
}
|
|
153
|
-
(tmp_path / "subjects" / "
|
|
154
|
-
cfg = load_subject_config(tmp_path, "
|
|
153
|
+
(tmp_path / "subjects" / "s001_tabfixed_m0000001.yaml").write_text(yaml.dump(data))
|
|
154
|
+
cfg = load_subject_config(tmp_path, "s001_tabfixed_m0000001")
|
|
155
155
|
assert cfg is not None
|
|
156
|
-
assert cfg.name == "
|
|
156
|
+
assert cfg.name == "s001_tabfixed_m0000001"
|
|
157
157
|
assert cfg.task_overrides["_test_flush_valves"]["VALVE_OPENING_TIME_MS"] == 70
|
|
158
158
|
|
|
159
159
|
|
|
@@ -30,20 +30,20 @@ POINTS_SETUP3_VALVE1 = [
|
|
|
30
30
|
]
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
def
|
|
33
|
+
def test_valve_calibration_check_quality_pass():
|
|
34
34
|
vc = ValveCalibration(points=POINTS_SETUP3_VALVE1)
|
|
35
|
-
ok, reason = vc.
|
|
35
|
+
ok, reason = vc.check_quality()
|
|
36
36
|
assert ok, reason
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
def
|
|
39
|
+
def test_valve_calibration_check_quality_too_few_points():
|
|
40
40
|
vc = ValveCalibration(points=[[10.0, 0.5], [20.0, 1.0]])
|
|
41
|
-
ok, reason = vc.
|
|
41
|
+
ok, reason = vc.check_quality()
|
|
42
42
|
assert not ok
|
|
43
43
|
assert "3" in reason
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
def
|
|
46
|
+
def test_valve_calibration_check_quality_non_monotonic():
|
|
47
47
|
vc = ValveCalibration(
|
|
48
48
|
points=[
|
|
49
49
|
[10.0, 1.0],
|
|
@@ -53,7 +53,7 @@ def test_valve_calibration_validate_non_monotonic():
|
|
|
53
53
|
[50.0, 2.5],
|
|
54
54
|
]
|
|
55
55
|
)
|
|
56
|
-
ok, reason = vc.
|
|
56
|
+
ok, reason = vc.check_quality()
|
|
57
57
|
assert not ok
|
|
58
58
|
assert "monoton" in reason.lower()
|
|
59
59
|
|
|
@@ -182,10 +182,12 @@ class TestBpodDevice:
|
|
|
182
182
|
|
|
183
183
|
assert BpodDevice(serial_port="/dev/ttyACM0").name == "bpod"
|
|
184
184
|
|
|
185
|
-
def test_preflight_raises_on_missing_port(self
|
|
185
|
+
def test_preflight_raises_on_missing_port(self):
|
|
186
186
|
from murineshiftwork.hardware.bpod.device import BpodDevice
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
# serial_port_present only filesystem-checks /dev/* paths; use a missing
|
|
189
|
+
# /dev node so preflight detects the absent device cross-platform.
|
|
190
|
+
dev = BpodDevice(serial_port="/dev/msw_nonexistent_bpod_xyz")
|
|
189
191
|
with pytest.raises(ValueError, match="not accessible"):
|
|
190
192
|
dev.preflight()
|
|
191
193
|
|
|
@@ -258,14 +258,17 @@ def test_attach_invalid_acq_segment_returns_none():
|
|
|
258
258
|
assert "not a valid MSW session name" in client.fail_reason
|
|
259
259
|
|
|
260
260
|
|
|
261
|
-
def
|
|
261
|
+
def test_attach_acquisition_and_session_levels_are_distinct_in_v42():
|
|
262
|
+
# v4.2 deliberately differentiates the two levels: the acquisition carries
|
|
263
|
+
# acq_type + optional version, the session container carries session_type.
|
|
262
264
|
from murineshiftwork.namespace.paths import get_msw_builder
|
|
263
265
|
|
|
264
266
|
b = get_msw_builder()
|
|
265
267
|
acq_spec = b.spec.levels["acquisition"]
|
|
266
268
|
ses_spec = b.spec.levels["session"]
|
|
267
|
-
assert acq_spec.template
|
|
268
|
-
assert
|
|
269
|
+
assert acq_spec.template != ses_spec.template
|
|
270
|
+
assert "acq_type" in acq_spec.template
|
|
271
|
+
assert "session_type" in ses_spec.template
|
|
269
272
|
|
|
270
273
|
|
|
271
274
|
# ---------------------------------------------------------------------------
|
|
@@ -287,6 +290,7 @@ def test_attach_feeds_generate_session_paths_correctly(tmp_path):
|
|
|
287
290
|
paths = generate_session_paths(
|
|
288
291
|
subject="m01",
|
|
289
292
|
task="sequence",
|
|
293
|
+
acq_type="sequence",
|
|
290
294
|
basepath=tmp_path,
|
|
291
295
|
linked_to=info.session_name,
|
|
292
296
|
printout=False,
|
|
@@ -296,6 +300,8 @@ def test_attach_feeds_generate_session_paths_correctly(tmp_path):
|
|
|
296
300
|
assert rel_parts[0] == "m01"
|
|
297
301
|
assert rel_parts[1] == "m01__20260524_143022__ephys" # host session dir
|
|
298
302
|
assert rel_parts[2].startswith("m01__") # MSW acquisition dir
|
|
299
|
-
|
|
303
|
+
# v4.2: acquisition dir carries acq_type + default version suffix.
|
|
304
|
+
assert "__sequence" in rel_parts[2]
|
|
305
|
+
assert rel_parts[2].endswith("__v1")
|
|
300
306
|
assert paths["host_session_name"] == "m01__20260524_143022__ephys"
|
|
301
307
|
assert paths["acquisition_name"] == paths["session_basename"]
|
|
@@ -96,22 +96,24 @@ def test_make_host_session_resolves_openephys_without_mock():
|
|
|
96
96
|
|
|
97
97
|
|
|
98
98
|
def test_all_namespace_contributors_have_no_root_init():
|
|
99
|
-
"""
|
|
100
|
-
|
|
101
|
-
With msw-io installed, murineshiftwork.__path__ contains entries from both
|
|
102
|
-
murineshiftwork main and msw-io. Neither may have a root __init__.py or
|
|
99
|
+
"""No murineshiftwork namespace contributor may have a root __init__.py, or
|
|
103
100
|
Python will not treat the directory as an implicit namespace package.
|
|
101
|
+
|
|
102
|
+
Contributor count is not asserted: when distributions are installed as
|
|
103
|
+
wheels into the same site-packages they share one __path__ entry, while
|
|
104
|
+
editable installs expose one entry each. Instead we (a) confirm msw-io's
|
|
105
|
+
contribution is importable and (b) check every __path__ entry for a root
|
|
106
|
+
__init__.py.
|
|
104
107
|
"""
|
|
108
|
+
import importlib.util
|
|
105
109
|
from pathlib import Path
|
|
106
110
|
|
|
107
111
|
import murineshiftwork
|
|
108
112
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
f"Expected >= 2 namespace contributors (murineshiftwork + msw-io), "
|
|
112
|
-
f"got {len(roots)}: {roots}. Is msw-io installed?"
|
|
113
|
+
assert importlib.util.find_spec("murineshiftwork.namespace") is not None, (
|
|
114
|
+
"murineshiftwork.namespace not importable - is msw-io installed?"
|
|
113
115
|
)
|
|
114
|
-
for root in
|
|
116
|
+
for root in murineshiftwork.__path__:
|
|
115
117
|
init = Path(root) / "__init__.py"
|
|
116
118
|
assert not init.exists(), (
|
|
117
119
|
f"{init} exists. Namespace contributor at {root!r} must not have "
|
|
@@ -127,3 +129,59 @@ def test_msw_io_subpackages_importable_with_oe_stack():
|
|
|
127
129
|
init_acquisition_manifest, # noqa: F401
|
|
128
130
|
)
|
|
129
131
|
from murineshiftwork.readers import MswSession # noqa: F401
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
# ---------------------------------------------------------------------------
|
|
135
|
+
# Version floor checks (pyproject.toml lower bounds)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def test_installed_dep_versions_meet_floors():
|
|
139
|
+
"""Installed versions of core deps must meet pyproject.toml lower bounds."""
|
|
140
|
+
from importlib.metadata import version
|
|
141
|
+
|
|
142
|
+
from packaging.version import Version
|
|
143
|
+
|
|
144
|
+
floors = {
|
|
145
|
+
"msw-core": "0.3.0",
|
|
146
|
+
"msw-io": "1.2.0",
|
|
147
|
+
"msw-plugin-api": "0.2.0",
|
|
148
|
+
}
|
|
149
|
+
for pkg, floor in floors.items():
|
|
150
|
+
installed = Version(version(pkg))
|
|
151
|
+
assert installed >= Version(floor), (
|
|
152
|
+
f"{pkg} {installed} is below required floor {floor}"
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
# ---------------------------------------------------------------------------
|
|
157
|
+
# Namespace contributor count: msw-core must be present
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def test_murineshiftwork_namespace_has_msw_core_contributor():
|
|
161
|
+
"""msw-core must be a namespace contributor (adds cli/, hardware/, etc.)."""
|
|
162
|
+
from pathlib import Path
|
|
163
|
+
|
|
164
|
+
import murineshiftwork
|
|
165
|
+
|
|
166
|
+
roots = [Path(p) for p in murineshiftwork.__path__]
|
|
167
|
+
has_cli = any((r / "cli").is_dir() for r in roots)
|
|
168
|
+
assert has_cli, (
|
|
169
|
+
f"cli/ not found in any namespace root: {roots}. "
|
|
170
|
+
"Is msw-core installed correctly?"
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
# ---------------------------------------------------------------------------
|
|
175
|
+
# Optional: msw-tasks-core entry points (if installed)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def test_msw_tasks_core_entry_points_if_installed():
|
|
179
|
+
"""When msw-tasks-core is installed, its tasks must appear in msw.tasks group."""
|
|
180
|
+
pytest.importorskip(
|
|
181
|
+
"murineshiftwork.tasks._calibration_liquid_static",
|
|
182
|
+
reason="msw-tasks-core not installed; skipping",
|
|
183
|
+
)
|
|
184
|
+
names = {ep.name for ep in entry_points(group="msw.tasks")}
|
|
185
|
+
assert "_calibration_liquid_static" in names, (
|
|
186
|
+
f"msw-tasks-core entry points not registered. Got: {names!r}"
|
|
187
|
+
)
|
|
@@ -18,7 +18,17 @@ TASKS_DIR = Path(__file__).parent.parent / "src/murineshiftwork/tasks"
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def _find_plot_specs() -> list[Path]:
|
|
21
|
-
|
|
21
|
+
specs = sorted(TASKS_DIR.glob("*/plot_spec.yaml"))
|
|
22
|
+
return specs
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_plot_spec_files_exist():
|
|
26
|
+
"""Ensure TASKS_DIR is reachable and contains at least one plot_spec.yaml."""
|
|
27
|
+
assert TASKS_DIR.exists(), (
|
|
28
|
+
f"tasks dir not found at {TASKS_DIR} (editable install required)"
|
|
29
|
+
)
|
|
30
|
+
specs = _find_plot_specs()
|
|
31
|
+
assert len(specs) > 0, f"No plot_spec.yaml found under {TASKS_DIR}"
|
|
22
32
|
|
|
23
33
|
|
|
24
34
|
# ---------------------------------------------------------------------------
|
|
@@ -185,7 +185,9 @@ def test_run_action_unsupported_device_type_raises(tmp_path, monkeypatch):
|
|
|
185
185
|
)
|
|
186
186
|
from murineshiftwork.cli.execute import run_action
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
# 'flir' is not a valid device type (DeviceUnion has no camera), so the
|
|
189
|
+
# SetupConfig is rejected at load with a union-tag validation error.
|
|
190
|
+
with pytest.raises(ValueError, match="does not match any of the expected tags"):
|
|
189
191
|
run_action(
|
|
190
192
|
setup="cam_setup",
|
|
191
193
|
device="camera",
|
|
@@ -55,20 +55,19 @@ def test_resolve_data_dir_machine_config(tmp_path, monkeypatch):
|
|
|
55
55
|
def test_list_available_tasks_nonempty():
|
|
56
56
|
from murineshiftwork.cli.tasks import list_available_tasks
|
|
57
57
|
|
|
58
|
+
# Public msw-tasks-core tasks (the `tasks` extra); lab tasks are tested in
|
|
59
|
+
# msw-tasks-lab.
|
|
58
60
|
tasks = list_available_tasks()
|
|
59
61
|
assert len(tasks) >= 5
|
|
60
62
|
assert "_test_flush_valves" in tasks
|
|
61
|
-
assert "
|
|
62
|
-
assert "probabilistic_switching" in tasks
|
|
63
|
+
assert "_calibration_liquid_dynamic" in tasks
|
|
63
64
|
|
|
64
65
|
|
|
65
66
|
def test_find_task_by_name():
|
|
66
67
|
from murineshiftwork.cli.tasks import find_task_by_name, list_available_tasks
|
|
67
68
|
|
|
68
69
|
assert find_task_by_name("flush") == "_test_flush_valves"
|
|
69
|
-
assert (
|
|
70
|
-
find_task_by_name("sequence") in list_available_tasks()
|
|
71
|
-
) # "sequence" substring also matches _test_ttl_sequences
|
|
70
|
+
assert find_task_by_name("_calibration_sound") in list_available_tasks()
|
|
72
71
|
assert find_task_by_name("nonexistent_xyz_task") is None
|
|
73
72
|
|
|
74
73
|
|
|
@@ -16,10 +16,12 @@ from murineshiftwork.cli.tasks import (
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def test_filesystem_returns_known_bundled_tasks():
|
|
19
|
+
# Use msw-tasks-core tasks (public, installed via the `tasks` extra) - lab
|
|
20
|
+
# tasks (sequence/airpuff/optotagging) are tested in msw-tasks-lab.
|
|
19
21
|
tasks = list_available_tasks()
|
|
20
|
-
assert "
|
|
21
|
-
assert "
|
|
22
|
-
assert "
|
|
22
|
+
assert "_calibration_liquid_dynamic" in tasks
|
|
23
|
+
assert "_calibration_liquid_static" in tasks
|
|
24
|
+
assert "_calibration_sound_latency" in tasks
|
|
23
25
|
|
|
24
26
|
|
|
25
27
|
def test_filesystem_result_is_sorted():
|
|
@@ -54,7 +56,7 @@ def test_filesystem_excludes_other_private_dirs():
|
|
|
54
56
|
def test_filesystem_task_dir_contains_expected_module():
|
|
55
57
|
tasks = list_available_tasks(detailed=True)
|
|
56
58
|
for name, path in tasks.items():
|
|
57
|
-
assert (path /
|
|
59
|
+
assert (path / "task.py").exists(), f"{name}: expected task.py in {path}"
|
|
58
60
|
|
|
59
61
|
|
|
60
62
|
# ---------------------------------------------------------------------------
|
|
@@ -84,8 +86,8 @@ def test_external_task_path_is_dir_of_ep_module():
|
|
|
84
86
|
|
|
85
87
|
|
|
86
88
|
def test_bundled_task_takes_precedence_over_entry_point():
|
|
87
|
-
# Register
|
|
88
|
-
ep = _make_ep("
|
|
89
|
+
# Register a clashing bundled name as an entry point - bundled must win.
|
|
90
|
+
ep = _make_ep("_calibration_liquid_dynamic", "murineshiftwork.cli.tasks")
|
|
89
91
|
with (
|
|
90
92
|
patch("murineshiftwork.cli.tasks.entry_points", return_value=[ep]),
|
|
91
93
|
patch("murineshiftwork.cli.tasks.importlib.import_module") as mock_import,
|
|
@@ -93,8 +95,8 @@ def test_bundled_task_takes_precedence_over_entry_point():
|
|
|
93
95
|
tasks = list_available_tasks(detailed=True)
|
|
94
96
|
# import_module must NOT be called for the clashing name.
|
|
95
97
|
mock_import.assert_not_called()
|
|
96
|
-
# The path from filesystem (a real dir with
|
|
97
|
-
assert (tasks["
|
|
98
|
+
# The path from filesystem (a real dir with task.py) is used.
|
|
99
|
+
assert (tasks["_calibration_liquid_dynamic"] / "task.py").exists()
|
|
98
100
|
|
|
99
101
|
|
|
100
102
|
def test_failed_entry_point_load_is_silently_skipped():
|
|
@@ -109,12 +111,14 @@ def test_failed_entry_point_load_is_silently_skipped():
|
|
|
109
111
|
|
|
110
112
|
|
|
111
113
|
def test_find_task_exact_match():
|
|
112
|
-
assert
|
|
114
|
+
assert (
|
|
115
|
+
find_task_by_name("_calibration_sound_latency") == "_calibration_sound_latency"
|
|
116
|
+
)
|
|
113
117
|
|
|
114
118
|
|
|
115
119
|
def test_find_task_partial_unique_match():
|
|
116
|
-
result = find_task_by_name("
|
|
117
|
-
assert result == "
|
|
120
|
+
result = find_task_by_name("_calibration_sound")
|
|
121
|
+
assert result == "_calibration_sound_latency"
|
|
118
122
|
|
|
119
123
|
|
|
120
124
|
def test_find_task_not_found_returns_none():
|
|
@@ -133,9 +137,9 @@ def test_find_task_ambiguous_returns_first_alphabetically():
|
|
|
133
137
|
|
|
134
138
|
|
|
135
139
|
def test_load_bundled_task_module():
|
|
136
|
-
mod = load_task_module("
|
|
140
|
+
mod = load_task_module("_calibration_liquid_dynamic")
|
|
137
141
|
assert mod.__file__ is not None
|
|
138
|
-
assert "
|
|
142
|
+
assert "_calibration_liquid_dynamic" in mod.__file__
|
|
139
143
|
|
|
140
144
|
|
|
141
145
|
def test_load_task_module_via_entry_point():
|
|
@@ -148,5 +152,5 @@ def test_load_task_module_via_entry_point():
|
|
|
148
152
|
def test_load_task_module_bundled_ignores_absent_entry_point():
|
|
149
153
|
# Even with no entry points registered, bundled tasks load by module path.
|
|
150
154
|
with patch("murineshiftwork.cli.tasks.entry_points", return_value=[]):
|
|
151
|
-
mod = load_task_module("
|
|
155
|
+
mod = load_task_module("_calibration_liquid_dynamic")
|
|
152
156
|
assert mod.__file__ is not None
|