daftar 0.3.0__tar.gz → 0.3.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.
Files changed (39) hide show
  1. {daftar-0.3.0 → daftar-0.3.2}/CHANGELOG.md +52 -0
  2. {daftar-0.3.0/src/daftar.egg-info → daftar-0.3.2}/PKG-INFO +2 -1
  3. {daftar-0.3.0 → daftar-0.3.2}/README.md +1 -0
  4. {daftar-0.3.0 → daftar-0.3.2}/TROUBLESHOOTING.md +133 -0
  5. {daftar-0.3.0 → daftar-0.3.2}/pyproject.toml +1 -1
  6. daftar-0.3.2/src/daftar/__version__.py +1 -0
  7. {daftar-0.3.0 → daftar-0.3.2}/src/daftar/adapters/__init__.py +23 -1
  8. {daftar-0.3.0 → daftar-0.3.2}/src/daftar/adapters/base.py +33 -0
  9. {daftar-0.3.0 → daftar-0.3.2}/src/daftar/adapters/brian2_adapter.py +7 -6
  10. {daftar-0.3.0 → daftar-0.3.2}/src/daftar/adapters/cpm_adapter.py +7 -6
  11. {daftar-0.3.0 → daftar-0.3.2}/src/daftar/adapters/jaxley_adapter.py +7 -6
  12. {daftar-0.3.0 → daftar-0.3.2}/src/daftar/adapters/meltingpot_adapter.py +7 -6
  13. {daftar-0.3.0 → daftar-0.3.2}/src/daftar/cli.py +50 -0
  14. {daftar-0.3.0 → daftar-0.3.2/src/daftar.egg-info}/PKG-INFO +2 -1
  15. {daftar-0.3.0 → daftar-0.3.2}/tests/test_adapters_live.py +93 -8
  16. daftar-0.3.0/src/daftar/__version__.py +0 -1
  17. {daftar-0.3.0 → daftar-0.3.2}/LICENSE +0 -0
  18. {daftar-0.3.0 → daftar-0.3.2}/MANIFEST.in +0 -0
  19. {daftar-0.3.0 → daftar-0.3.2}/PUBLISHING.md +0 -0
  20. {daftar-0.3.0 → daftar-0.3.2}/ROADMAP.md +0 -0
  21. {daftar-0.3.0 → daftar-0.3.2}/examples/adapter_usage.py +0 -0
  22. {daftar-0.3.0 → daftar-0.3.2}/examples/daftar_in_notebooks.ipynb +0 -0
  23. {daftar-0.3.0 → daftar-0.3.2}/examples/demo_end_to_end.py +0 -0
  24. {daftar-0.3.0 → daftar-0.3.2}/setup.cfg +0 -0
  25. {daftar-0.3.0 → daftar-0.3.2}/src/daftar/__init__.py +0 -0
  26. {daftar-0.3.0 → daftar-0.3.2}/src/daftar/capture.py +0 -0
  27. {daftar-0.3.0 → daftar-0.3.2}/src/daftar/diff.py +0 -0
  28. {daftar-0.3.0 → daftar-0.3.2}/src/daftar/manifest.py +0 -0
  29. {daftar-0.3.0 → daftar-0.3.2}/src/daftar/notebook.py +0 -0
  30. {daftar-0.3.0 → daftar-0.3.2}/src/daftar/run.py +0 -0
  31. {daftar-0.3.0 → daftar-0.3.2}/src/daftar/store.py +0 -0
  32. {daftar-0.3.0 → daftar-0.3.2}/src/daftar/sweep.py +0 -0
  33. {daftar-0.3.0 → daftar-0.3.2}/src/daftar.egg-info/SOURCES.txt +0 -0
  34. {daftar-0.3.0 → daftar-0.3.2}/src/daftar.egg-info/dependency_links.txt +0 -0
  35. {daftar-0.3.0 → daftar-0.3.2}/src/daftar.egg-info/entry_points.txt +0 -0
  36. {daftar-0.3.0 → daftar-0.3.2}/src/daftar.egg-info/requires.txt +0 -0
  37. {daftar-0.3.0 → daftar-0.3.2}/src/daftar.egg-info/top_level.txt +0 -0
  38. {daftar-0.3.0 → daftar-0.3.2}/tests/test_core.py +0 -0
  39. {daftar-0.3.0 → daftar-0.3.2}/tests/test_notebook.py +0 -0
@@ -1,5 +1,57 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.2
4
+
5
+ **cpm live tests now skip with an explanation instead of failing** when cpm and
6
+ SciPy disagree. cpm 0.25.6 passes `disp=` to `fmin_l_bfgs_b`, which SciPy
7
+ removed in 1.18.0, so cpm imports cleanly and raises the moment you fit
8
+ anything.
9
+
10
+ This is the third framework/dependency clash across four adapters — jaxley
11
+ against JAX, brian2 against NumPy, cpm against SciPy — so the preflight logic is
12
+ now a single `_require_working(name, probe)` helper rather than one bespoke
13
+ function per adapter. The rule it encodes: skip for a clash we recognise and can
14
+ explain, fail loudly for anything we do not, because an unrecognised error might
15
+ be our bug and a silent skip would hide it.
16
+
17
+ **Runtime checks are reported separately from import checks.** `daftar doctor`
18
+ answers "does it import", which is fast and usually enough. It is not the same
19
+ question as "does it work": cpm reports `ok` under SciPy 1.18 and then fails on
20
+ the first fit. The adapter status test now prints both.
21
+
22
+ ## 0.3.1
23
+
24
+ **A framework that is installed but broken is no longer reported as absent.**
25
+ Every adapter's `is_available()` was a bare `try: import x except: return False`,
26
+ so an import that failed for *any* reason looked exactly like a package that was
27
+ never installed. The live tests then skipped quietly and nothing said why.
28
+
29
+ This surfaced with Brian2: `pip install brian2` on Python 3.11 resolves to 2.9.0
30
+ (the newest supporting that interpreter), which calls `ndarray.ptp` — removed in
31
+ NumPy 2.0. It imports with an `AttributeError`, the tests skipped, and the output
32
+ was indistinguishable from Brian2 not being installed at all.
33
+
34
+ Adapters now expose `availability() -> (status, reason)` with three states:
35
+ `available`, `missing`, and **`broken`** carrying the exception. Live tests skip
36
+ with that reason attached rather than a generic "not installed".
37
+
38
+ **New: `daftar doctor`.** Reports the interpreter, the daftar version, and every
39
+ adapter's status with the reason for any failure. Exits 1 if anything is broken,
40
+ so it is usable in CI. It generalises the ad-hoc `diagnose_jaxley.py`.
41
+
42
+ ```
43
+ daftar 0.3.1
44
+ python 3.11.16 on Darwin arm64
45
+
46
+ brian2 BROKEN AttributeError: type object 'numpy.ndarray' has no attribute 'ptp'
47
+ cpm ok
48
+ jaxley ok
49
+ meltingpot ok
50
+ ```
51
+
52
+ `TROUBLESHOOTING.md` documents the Brian2 / NumPy 2 / Python 3.12 trap and why
53
+ downgrading NumPy is the wrong fix.
54
+
3
55
  ## 0.3.0 — Brian2
4
56
 
5
57
  Brian2 hides more of what determines the answer than any other framework daftar
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: daftar
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Record what produced each computational result: environment, code, parameters, seeds, inputs.
5
5
  Author: Aslan Satary Dizaji
6
6
  License-Expression: Apache-2.0
@@ -176,6 +176,7 @@ daftar diff r-4f21ab r-88c07e # what changed, and whether it mattered
176
176
  daftar vary -l my-sweep # which fields differ across many runs
177
177
  daftar replay r-4f21ab # what it would take to reproduce this
178
178
  daftar export r-4f21ab -o run.zip
179
+ daftar doctor # which adapters work here, and why not
179
180
  ```
180
181
 
181
182
  `diff` exits 0 if the second run reproduces the first and 1 otherwise, so it
@@ -138,6 +138,7 @@ daftar diff r-4f21ab r-88c07e # what changed, and whether it mattered
138
138
  daftar vary -l my-sweep # which fields differ across many runs
139
139
  daftar replay r-4f21ab # what it would take to reproduce this
140
140
  daftar export r-4f21ab -o run.zip
141
+ daftar doctor # which adapters work here, and why not
141
142
  ```
142
143
 
143
144
  `diff` exits 0 if the second run reproduces the first and 1 otherwise, so it
@@ -225,6 +225,99 @@ wrong".
225
225
 
226
226
  ---
227
227
 
228
+ ## cpm: `fmin_l_bfgs_b() got an unexpected keyword argument 'disp'`
229
+
230
+ cpm 0.25.6 calls:
231
+
232
+ ```python
233
+ result = fmin_l_bfgs_b(objective, x0=..., bounds=bounds,
234
+ args=(model, observed, loss, prior),
235
+ disp=self.display, **self.kwargs)
236
+ ```
237
+
238
+ SciPy deprecated `disp` and `iprint` for L-BFGS-B and **removed them in 1.18.0**.
239
+ So cpm imports cleanly and raises the moment you fit anything.
240
+
241
+ If you ran this on an older SciPy you were already warned:
242
+
243
+ ```
244
+ DeprecationWarning: scipy.optimize: The `disp` and `iprint` options of the
245
+ L-BFGS-B solver are deprecated and will be removed in SciPy 1.18.0
246
+ ```
247
+
248
+ **Fix:**
249
+
250
+ ```bash
251
+ pip install "scipy<1.18"
252
+ ```
253
+
254
+ Then report it upstream — this breaks cpm for every user who upgrades SciPy, and
255
+ the fix is a couple of lines. A template is in the announcement plan; the short
256
+ version is that `disp` should be dropped, or passed only when
257
+ `scipy.__version__ < 1.18`.
258
+
259
+ ### Note that `daftar doctor` reports cpm as `ok`
260
+
261
+ Correctly: `import cpm` succeeds. **Importing is not the same as working.**
262
+ `doctor` is a fast import check; the live adapter tests run a real fit and will
263
+ skip with the explanation above. If you want the runtime check on its own:
264
+
265
+ ```bash
266
+ pytest tests/test_adapters_live.py -rs -k at_least_report -s
267
+ ```
268
+
269
+ which prints both the import status and a runtime usability line per framework.
270
+
271
+ ---
272
+
273
+ ## Brian2: `type object 'numpy.ndarray' has no attribute 'ptp'`
274
+
275
+ Brian2 is installed and imports fail. The adapter tests skip, and older daftar
276
+ versions skipped *silently* because a broken import looked identical to an
277
+ absent package. Run `daftar doctor` to see the difference.
278
+
279
+ **The cause is a three-way version trap:**
280
+
281
+ | | |
282
+ |---|---|
283
+ | NumPy 2.0 removed `ndarray.ptp` | you have numpy 2.x |
284
+ | brian2 ≤ 2.9 still calls it | so it cannot import under numpy 2 |
285
+ | brian2 ≥ 2.10 fixed it, and **requires Python ≥ 3.12** | your env is Python 3.11 |
286
+
287
+ So `pip install brian2` on Python 3.11 correctly resolves to 2.9.0 — the newest
288
+ release that supports your interpreter — and that release cannot work with the
289
+ NumPy you have. **On Python 3.11 there is no brian2 version compatible with
290
+ NumPy 2.x.**
291
+
292
+ ### Fix: a Python 3.12 environment
293
+
294
+ ```bash
295
+ conda create --name daftar312 python=3.12
296
+ conda activate daftar312
297
+ pip install daftar brian2 jaxley cpm-toolbox pytest
298
+ python -c "import brian2; print(brian2.__version__)" # expect >= 2.10
299
+ daftar doctor
300
+ ```
301
+
302
+ ### Why not just downgrade NumPy instead
303
+
304
+ `pip install "numpy<2"` would fix Brian2 and break the rest of the environment:
305
+ jaxley, cpm-toolbox and pandas 3.x in your setup all expect NumPy 2. Pinning
306
+ NumPy back to satisfy one framework is how an environment becomes unreproducible
307
+ in the way this whole package exists to detect.
308
+
309
+ ### If you must stay on Python 3.11
310
+
311
+ Keep two environments: 3.11 for MeltingPot (whose `dmlab2d` wheel coverage is
312
+ narrow) and 3.12 for Brian2. The adapter tests skip cleanly in whichever
313
+ framework is absent, so both environments give a green suite.
314
+
315
+ Do not attempt to have every adapter live in one environment. Four research
316
+ frameworks with independent release schedules will eventually make that
317
+ impossible, and the honest answer is to test each where it works.
318
+
319
+ ---
320
+
228
321
  ## MeltingPot will not install
229
322
 
230
323
  `dm-meltingpot` depends on `dmlab2d`, whose wheel coverage is narrow and weakest
@@ -270,6 +363,46 @@ wrong, and re-running `daftar replay` on an old run now prints correctly.
270
363
 
271
364
  ---
272
365
 
366
+ ## Which adapters actually work here?
367
+
368
+ ```bash
369
+ daftar doctor
370
+ ```
371
+
372
+ Reports the daftar version, the interpreter, and every adapter as `ok`,
373
+ `not installed`, or **`BROKEN`** with the exception that caused it. Exit code is
374
+ 1 if anything is broken, so it works in CI.
375
+
376
+ `BROKEN` means the framework is installed and will not import — an incompatible
377
+ NumPy, a missing shared library, a clash with another package. That is fixable
378
+ and worth knowing about; "not installed" usually is not. Conflating the two is
379
+ how a broken environment goes unnoticed for weeks.
380
+
381
+ ---
382
+
383
+ ## Why does this keep happening?
384
+
385
+ Three of the four adapters have now hit the same shape of problem:
386
+
387
+ | Framework | Dependency | What broke |
388
+ |---|---|---|
389
+ | jaxley 0.13.0 | JAX ≥ 0.7 | `jnp.clip(a_max=...)` removed |
390
+ | brian2 ≤ 2.9 | NumPy ≥ 2.0 | `ndarray.ptp` removed |
391
+ | cpm 0.25.6 | SciPy ≥ 1.18 | `fmin_l_bfgs_b(disp=...)` removed |
392
+
393
+ Research packages pin loosely and their dependencies remove APIs on a schedule
394
+ the packages do not track. This is not unusual and it is not anyone's fault; it
395
+ is the normal condition of a scientific Python environment, and it is a large
396
+ part of why daftar records `env.*` at all. Each of these would appear in a diff
397
+ as an environment change with a matching result change — or, worse, as code that
398
+ simply stops running.
399
+
400
+ The test suite's rule: **skip for a clash we recognise and can explain, fail
401
+ loudly for anything we do not.** An unrecognised error might be our bug, and a
402
+ silent skip would hide it.
403
+
404
+ ---
405
+
273
406
  ## Adapter tests pass but a manifest field says `<unavailable>`
274
407
 
275
408
  Working as designed, and worth understanding. `adapters/base.py` wraps every
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "daftar"
7
- version = "0.3.0"
7
+ version = "0.3.2"
8
8
  description = "Record what produced each computational result: environment, code, parameters, seeds, inputs."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -0,0 +1 @@
1
+ __version__ = "0.3.2"
@@ -8,7 +8,10 @@ at module load.
8
8
  from __future__ import annotations
9
9
 
10
10
  from . import brian2_adapter, cpm_adapter, jaxley_adapter, meltingpot_adapter
11
- from .base import Adapter, AdapterRegistry, record_optional, safe
11
+ from .base import (
12
+ AVAILABLE, BROKEN, MISSING, Adapter, AdapterRegistry, probe_import,
13
+ record_optional, safe,
14
+ )
12
15
 
13
16
  registry = AdapterRegistry()
14
17
  registry.register("jaxley", jaxley_adapter)
@@ -27,6 +30,24 @@ def available() -> list[str]:
27
30
  return registry.available()
28
31
 
29
32
 
33
+ def status() -> dict[str, tuple[str, str]]:
34
+ """``{adapter: (status, reason)}`` for every registered adapter.
35
+
36
+ Distinguishes an absent framework from a broken one. A framework that is
37
+ installed but fails to import -- an incompatible NumPy, a missing shared
38
+ library -- is a situation the user can fix, and it must not be reported the
39
+ same way as one they simply have not installed.
40
+ """
41
+ out: dict[str, tuple[str, str]] = {}
42
+ for name in registry.all():
43
+ mod = registry.get(name)
44
+ try:
45
+ out[name] = mod.availability()
46
+ except Exception as exc: # pragma: no cover - defensive
47
+ out[name] = (BROKEN, f"{type(exc).__name__}: {exc}")
48
+ return out
49
+
50
+
30
51
  def get(name: str):
31
52
  return registry.get(name)
32
53
 
@@ -36,4 +57,5 @@ __all__ = [
36
57
  "jaxley", "cpm", "meltingpot", "brian2",
37
58
  "jaxley_adapter", "cpm_adapter", "meltingpot_adapter", "brian2_adapter",
38
59
  "Adapter", "AdapterRegistry", "safe", "record_optional",
60
+ "status", "probe_import", "AVAILABLE", "MISSING", "BROKEN",
39
61
  ]
@@ -80,6 +80,39 @@ def safe(fn, default=None):
80
80
  return default
81
81
 
82
82
 
83
+ #: An adapter's target framework is in one of three states, and conflating the
84
+ #: last two is how a broken environment gets mistaken for an absent one.
85
+ AVAILABLE = "available"
86
+ MISSING = "missing"
87
+ BROKEN = "broken"
88
+
89
+
90
+ def probe_import(module_name: str) -> tuple[str, str]:
91
+ """Try to import a framework. Returns ``(status, reason)``.
92
+
93
+ ``ImportError`` means the package is not installed, which is ordinary and
94
+ uninteresting. **Any other exception means it is installed and broken** --
95
+ an incompatible NumPy, a missing shared library, a version clash with
96
+ another package. Those two cases need different responses from the user and
97
+ must not look identical.
98
+
99
+ This distinction exists because a bare ``try: import x except: False``
100
+ reports a broken install as an absent one. The test suite then skips
101
+ quietly, the adapter is never exercised, and nothing anywhere says why.
102
+ """
103
+ try:
104
+ __import__(module_name)
105
+ return AVAILABLE, ""
106
+ except ImportError as exc:
107
+ # A broken C extension also raises ImportError, so check the message.
108
+ text = str(exc)
109
+ if "No module named" in text:
110
+ return MISSING, "not installed"
111
+ return BROKEN, f"{type(exc).__name__}: {text}"
112
+ except Exception as exc:
113
+ return BROKEN, f"{type(exc).__name__}: {exc}"
114
+
115
+
83
116
  def record_optional(run: Run, key: str, fn, *, kind: str = "param") -> None:
84
117
  """Record ``fn()`` under ``key``, or note that it could not be read."""
85
118
  value = safe(fn, default="<unavailable>")
@@ -35,7 +35,7 @@ import re
35
35
  from typing import Any
36
36
 
37
37
  from ..run import Run
38
- from .base import safe
38
+ from .base import AVAILABLE, probe_import, safe
39
39
 
40
40
  name = "brian2"
41
41
 
@@ -49,12 +49,13 @@ _METHOD_PATTERNS = (
49
49
  )
50
50
 
51
51
 
52
+ def availability() -> tuple[str, str]:
53
+ """``(status, reason)`` -- see ``adapters.base.probe_import``."""
54
+ return probe_import("brian2")
55
+
56
+
52
57
  def is_available() -> bool:
53
- try:
54
- import brian2 # noqa: F401
55
- return True
56
- except Exception:
57
- return False
58
+ return availability()[0] == AVAILABLE
58
59
 
59
60
 
60
61
  def _sha(text: str) -> str:
@@ -26,17 +26,18 @@ import hashlib
26
26
  from typing import Any
27
27
 
28
28
  from ..run import Run
29
- from .base import safe
29
+ from .base import AVAILABLE, probe_import, safe
30
30
 
31
31
  name = "cpm"
32
32
 
33
33
 
34
+ def availability() -> tuple[str, str]:
35
+ """``(status, reason)`` -- see ``adapters.base.probe_import``."""
36
+ return probe_import("cpm")
37
+
38
+
34
39
  def is_available() -> bool:
35
- try:
36
- import cpm # noqa: F401
37
- return True
38
- except Exception:
39
- return False
40
+ return availability()[0] == AVAILABLE
40
41
 
41
42
 
42
43
  # --------------------------------------------------------------------------
@@ -22,7 +22,7 @@ import sys
22
22
  from typing import Any
23
23
 
24
24
  from ..run import Run
25
- from .base import safe
25
+ from .base import AVAILABLE, probe_import, safe
26
26
 
27
27
  name = "jaxley"
28
28
 
@@ -38,12 +38,13 @@ INTEGRATE_DEFAULTS = {
38
38
  }
39
39
 
40
40
 
41
+ def availability() -> tuple[str, str]:
42
+ """``(status, reason)`` -- see ``adapters.base.probe_import``."""
43
+ return probe_import("jaxley")
44
+
45
+
41
46
  def is_available() -> bool:
42
- try:
43
- import jaxley # noqa: F401
44
- return True
45
- except Exception:
46
- return False
47
+ return availability()[0] == AVAILABLE
47
48
 
48
49
 
49
50
  def _jax_config(run: Run) -> None:
@@ -27,17 +27,18 @@ import hashlib
27
27
  from typing import Any, Callable, Sequence
28
28
 
29
29
  from ..run import Run
30
- from .base import safe
30
+ from .base import AVAILABLE, probe_import, safe
31
31
 
32
32
  name = "meltingpot"
33
33
 
34
34
 
35
+ def availability() -> tuple[str, str]:
36
+ """``(status, reason)`` -- see ``adapters.base.probe_import``."""
37
+ return probe_import("meltingpot")
38
+
39
+
35
40
  def is_available() -> bool:
36
- try:
37
- import meltingpot # noqa: F401
38
- return True
39
- except Exception:
40
- return False
41
+ return availability()[0] == AVAILABLE
41
42
 
42
43
 
43
44
  def _config_hash(config: Any) -> str:
@@ -101,6 +101,53 @@ def cmd_vary(args) -> int:
101
101
  return 0
102
102
 
103
103
 
104
+ def cmd_doctor(args) -> int:
105
+ """Report the environment and every adapter's status, with reasons."""
106
+ import platform
107
+
108
+ from . import adapters
109
+ from .__version__ import __version__
110
+ from .adapters.base import AVAILABLE, BROKEN
111
+
112
+ print(f"daftar {__version__}")
113
+ print(f"python {platform.python_version()} on {platform.system()} "
114
+ f"{platform.machine()}")
115
+ print()
116
+
117
+ table = adapters.status()
118
+ width = max(len(n) for n in table)
119
+ broken = []
120
+ for name in sorted(table):
121
+ state, reason = table[name]
122
+ mark = {AVAILABLE: "ok", BROKEN: "BROKEN"}.get(state, "-")
123
+ line = f" {name.ljust(width)} {mark:<7}"
124
+ if state != AVAILABLE and reason:
125
+ line += f" {reason}"
126
+ print(line)
127
+ if state == BROKEN:
128
+ broken.append((name, reason))
129
+
130
+ if broken:
131
+ print()
132
+ print("An adapter's framework is installed but will not import. That is")
133
+ print("not the same as it being absent, and it is usually fixable:")
134
+ for name, reason in broken:
135
+ print(f" - {name}: {reason}")
136
+ print()
137
+ print("See TROUBLESHOOTING.md. Common cause: the framework predates a")
138
+ print("major NumPy release, and the version that supports current NumPy")
139
+ print("needs a newer Python than this environment has.")
140
+
141
+ store = _store(args)
142
+ print()
143
+ print(f"run store: {store.dir}"
144
+ + ("" if store.runs_dir.exists() else " (not initialised)"))
145
+ if store.runs_dir.exists():
146
+ print(f"runs recorded: {len(store.list_ids())}")
147
+
148
+ return 1 if broken else 0
149
+
150
+
104
151
  def cmd_reindex(args) -> int:
105
152
  n = _store(args).reindex()
106
153
  print(f"Reindexed {n} run(s).")
@@ -152,6 +199,9 @@ def build_parser() -> argparse.ArgumentParser:
152
199
  s.add_argument("-l", "--label")
153
200
  s.set_defaults(func=cmd_vary)
154
201
 
202
+ s = sub.add_parser("doctor", help="report environment and adapter status")
203
+ s.set_defaults(func=cmd_doctor)
204
+
155
205
  s = sub.add_parser("reindex", help="rebuild the index from manifests")
156
206
  s.set_defaults(func=cmd_reindex)
157
207
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: daftar
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Record what produced each computational result: environment, code, parameters, seeds, inputs.
5
5
  Author: Aslan Satary Dizaji
6
6
  License-Expression: Apache-2.0
@@ -176,6 +176,7 @@ daftar diff r-4f21ab r-88c07e # what changed, and whether it mattered
176
176
  daftar vary -l my-sweep # which fields differ across many runs
177
177
  daftar replay r-4f21ab # what it would take to reproduce this
178
178
  daftar export r-4f21ab -o run.zip
179
+ daftar doctor # which adapters work here, and why not
179
180
  ```
180
181
 
181
182
  `diff` exits 0 if the second run reproduces the first and 1 otherwise, so it
@@ -34,10 +34,87 @@ def store(tmp_path, monkeypatch):
34
34
 
35
35
 
36
36
  def _require(name: str):
37
- return pytest.mark.skipif(
38
- not daftar.adapters.get(name).is_available(),
39
- reason=f"{name} not installed",
40
- )
37
+ """Skip with a reason that distinguishes absent from broken.
38
+
39
+ A framework that is installed but fails to import is a different situation
40
+ from one that was never installed, and the user can act on it. Reporting
41
+ both as "not installed" is how a broken environment goes unnoticed: the
42
+ suite skips quietly and nothing anywhere says why.
43
+ """
44
+ state, reason = daftar.adapters.get(name).availability()
45
+ if state == daftar.adapters.AVAILABLE:
46
+ return pytest.mark.skipif(False, reason="")
47
+ if state == daftar.adapters.BROKEN:
48
+ return pytest.mark.skipif(
49
+ True,
50
+ reason=(f"{name} is INSTALLED BUT BROKEN -- {reason}. "
51
+ f"Run `daftar doctor`; see TROUBLESHOOTING.md"),
52
+ )
53
+ return pytest.mark.skipif(True, reason=f"{name} not installed")
54
+
55
+
56
+ def _require_working(name: str, probe, clash_marker: str = "version clash"):
57
+ """Skip only for a *known* framework/dependency clash; fail on anything else.
58
+
59
+ This is the third instance of the same pattern -- jaxley against JAX,
60
+ brian2 against NumPy, cpm against SciPy -- so it is worth stating the rule
61
+ once. Research packages pin loosely and their dependencies remove APIs, so
62
+ a framework that imports cleanly can still be unusable.
63
+
64
+ The rule: skip when we recognise the clash and can explain it, because it is
65
+ not our bug and the user needs to be told what to do. Fail loudly for
66
+ anything else, because an unrecognised error may well be *our* bug and a
67
+ silent skip would hide it.
68
+ """
69
+ state, reason = daftar.adapters.get(name).availability()
70
+ if state != daftar.adapters.AVAILABLE:
71
+ return pytest.mark.skipif(True, reason=f"{name}: {reason}")
72
+ ok, why = probe()
73
+ return pytest.mark.skipif(not ok and clash_marker in why, reason=why)
74
+
75
+
76
+ def _cpm_is_usable() -> tuple[bool, str]:
77
+ """Check that cpm can actually fit before blaming the adapter.
78
+
79
+ cpm 0.25.6 calls ``fmin_l_bfgs_b(..., disp=self.display)``. SciPy deprecated
80
+ ``disp`` and ``iprint`` for L-BFGS-B and removed them in 1.18.0, so cpm
81
+ imports fine and then raises ``TypeError`` the moment you fit anything.
82
+ ``daftar doctor`` reports cpm as ``ok`` because the import succeeds --
83
+ importing is not the same as working.
84
+ """
85
+ try:
86
+ import numpy as np
87
+ import pandas as pd
88
+ from cpm.generators import Parameters, Value, Wrapper
89
+ from cpm.optimisation import FminBound, minimise
90
+
91
+ def model(parameters, trial):
92
+ return {"dependent": np.array([trial["stimulus"] * parameters.alpha])}
93
+
94
+ data = pd.DataFrame({
95
+ "ppt": [1, 1, 2, 2],
96
+ "stimulus": [1.0, 2.0, 1.0, 2.0],
97
+ "observed": [0.1, 0.2, 0.15, 0.25],
98
+ })
99
+ params = Parameters(alpha=Value(value=0.1, lower=0.0, upper=1.0,
100
+ prior="norm",
101
+ args={"mean": 0.5, "sd": 0.25}))
102
+ wrapper = Wrapper(model=model, data=data.iloc[:2], parameters=params)
103
+ FminBound(model=wrapper, data=data,
104
+ minimisation=minimise.LogLikelihood.continuous,
105
+ ppt_identifier="ppt", approx_grad=True).optimise()
106
+ return True, ""
107
+ except TypeError as exc:
108
+ if "disp" in str(exc) or "iprint" in str(exc):
109
+ import scipy
110
+ return False, (
111
+ f"cpm/SciPy version clash: this cpm release passes disp= to "
112
+ f"fmin_l_bfgs_b, which SciPy {scipy.__version__} removed in "
113
+ f"1.18.0. Not a daftar bug. Fix with: pip install 'scipy<1.18'"
114
+ )
115
+ return False, f"cpm unusable: {type(exc).__name__}: {exc}"
116
+ except Exception as exc: # pragma: no cover - environment dependent
117
+ return False, f"cpm unusable: {type(exc).__name__}: {exc}"
41
118
 
42
119
 
43
120
  def _jaxley_is_usable() -> tuple[bool, str]:
@@ -170,7 +247,7 @@ def test_jaxley_same_config_reproduces(store):
170
247
  # cpm
171
248
  # ==========================================================================
172
249
 
173
- @_require("cpm")
250
+ @_require_working("cpm", _cpm_is_usable)
174
251
  def test_cpm_records_bounds_priors_and_restarts(store):
175
252
  import numpy as np
176
253
  import pandas as pd
@@ -341,6 +418,11 @@ def test_at_least_report_what_is_installed():
341
418
  mark = "yes" if name in available else "no"
342
419
  print(f" {name:<12} {mark}")
343
420
 
421
+ print("\nadapter status:")
422
+ for name, (state, reason) in sorted(daftar.adapters.status().items()):
423
+ detail = f" {reason}" if reason else ""
424
+ print(f" {name:<12} {state}{detail}")
425
+
344
426
  print("\nframework versions:")
345
427
  for dist in ("jaxley", "jax", "jaxlib", "cpm-toolbox", "dm-meltingpot",
346
428
  "dmlab2d", "numpy", "scipy"):
@@ -349,9 +431,12 @@ def test_at_least_report_what_is_installed():
349
431
  except Exception:
350
432
  pass
351
433
 
352
- ok, why = _jaxley_is_usable()
353
- if daftar.adapters.get("jaxley").is_available() and not ok:
354
- print(f"\nNOTE: {why}")
434
+ print("\nruntime checks (importing is not the same as working):")
435
+ for name, probe in (("jaxley", _jaxley_is_usable), ("cpm", _cpm_is_usable)):
436
+ if not daftar.adapters.get(name).is_available():
437
+ continue
438
+ ok, why = probe()
439
+ print(f" {name:<12} {'usable' if ok else 'UNUSABLE -- ' + why}")
355
440
 
356
441
 
357
442
  # ==========================================================================
@@ -1 +0,0 @@
1
- __version__ = "0.3.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes