evalsuite-python 1.3.5__tar.gz → 1.4.0__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 (169) hide show
  1. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/CHANGELOG.md +35 -0
  2. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/PKG-INFO +20 -3
  3. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/README.md +19 -2
  4. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/pyproject.toml +5 -0
  5. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/Cargo.lock +6 -6
  6. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/Cargo.toml +1 -1
  7. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/__init__.py +16 -0
  8. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/_update.py +40 -10
  9. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/agreement.py +2 -1
  10. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/bayes.py +3 -2
  11. evalsuite_python-1.4.0/src/evalsuite/cache.py +258 -0
  12. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/cards.py +1 -1
  13. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/cli/main.py +37 -0
  14. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/core/registry.py +4 -0
  15. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/core/validation.py +21 -1
  16. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/llm_benchmarks.py +8 -1
  17. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/llmsys/longcontext.py +4 -3
  18. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/llmsys/multilingual.py +2 -1
  19. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/llmsys/robustness.py +4 -6
  20. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/llmsys/safety.py +2 -1
  21. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/monitor.py +5 -4
  22. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/multilabel.py +4 -0
  23. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/recalibration.py +4 -3
  24. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/stats/compare.py +10 -3
  25. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/stats/effect.py +5 -5
  26. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/stats/hypothesis.py +3 -3
  27. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/stats/intervals.py +2 -2
  28. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/stats/planning.py +9 -2
  29. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/survival.py +2 -1
  30. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/text/factuality.py +4 -3
  31. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/text/generation.py +2 -1
  32. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/text/judge.py +3 -2
  33. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/text/qa.py +2 -0
  34. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/text/rag.py +2 -1
  35. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/text/semantic.py +3 -2
  36. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/text/structured.py +3 -1
  37. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/version.py +1 -1
  38. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/vision/detection.py +3 -2
  39. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/integration/test_readme_examples.py +1 -0
  40. evalsuite_python-1.4.0/tests/test_cache.py +97 -0
  41. evalsuite_python-1.4.0/tests/test_v140.py +101 -0
  42. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/CONTRIBUTING.md +0 -0
  43. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/LICENSE +0 -0
  44. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/LICENSE-APACHE +0 -0
  45. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/Cargo.toml +0 -0
  46. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/README.md +0 -0
  47. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/src/agreement.rs +0 -0
  48. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/src/coco.rs +0 -0
  49. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/src/curve.rs +0 -0
  50. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/src/groups.rs +0 -0
  51. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/src/hash.rs +0 -0
  52. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/src/lib.rs +0 -0
  53. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/src/meteor.rs +0 -0
  54. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/src/permutation.rs +0 -0
  55. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/src/qa.rs +0 -0
  56. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/src/ranks.rs +0 -0
  57. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/src/resample.rs +0 -0
  58. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/src/surface.rs +0 -0
  59. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/src/survival.rs +0 -0
  60. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/src/ter.rs +0 -0
  61. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-core/src/text.rs +0 -0
  62. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-py/Cargo.toml +0 -0
  63. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/rust/evalsuite-py/src/lib.rs +0 -0
  64. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/__main__.py +0 -0
  65. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/_bench_metrics.py +0 -0
  66. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/_evalci.py +0 -0
  67. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/_lazy.py +0 -0
  68. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/_native.py +0 -0
  69. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/api.py +0 -0
  70. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/benchmarks.py +0 -0
  71. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/calibration.py +0 -0
  72. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/classification/__init__.py +0 -0
  73. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/classification/_common.py +0 -0
  74. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/classification/metrics.py +0 -0
  75. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/cli/__init__.py +0 -0
  76. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/clinical/__init__.py +0 -0
  77. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/clinical/metrics.py +0 -0
  78. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/clinical/report.py +0 -0
  79. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/core/__init__.py +0 -0
  80. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/core/context.py +0 -0
  81. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/core/exceptions.py +0 -0
  82. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/core/export.py +0 -0
  83. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/core/result.py +0 -0
  84. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/core/types.py +0 -0
  85. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/drift.py +0 -0
  86. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/fairness.py +0 -0
  87. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/forecasting.py +0 -0
  88. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/harness.py +0 -0
  89. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/html_report.py +0 -0
  90. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/integrations.py +0 -0
  91. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/judging.py +0 -0
  92. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/llmsys/__init__.py +0 -0
  93. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/llmsys/_common.py +0 -0
  94. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/llmsys/agents.py +0 -0
  95. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/llmsys/code.py +0 -0
  96. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/llmsys/efficiency.py +0 -0
  97. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/llmsys/uncertainty.py +0 -0
  98. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/plot.py +0 -0
  99. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/py.typed +0 -0
  100. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/rag_report.py +0 -0
  101. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/regression/__init__.py +0 -0
  102. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/regression/metrics.py +0 -0
  103. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/reporting.py +0 -0
  104. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/stats/__init__.py +0 -0
  105. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/stats/_resolve.py +0 -0
  106. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/stats/paired.py +0 -0
  107. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/stats/results.py +0 -0
  108. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/text/__init__.py +0 -0
  109. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/text/_common.py +0 -0
  110. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/text/reasoning.py +0 -0
  111. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/text/report.py +0 -0
  112. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/text/retrieval.py +0 -0
  113. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/text/spice.py +0 -0
  114. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/vision/__init__.py +0 -0
  115. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/src/evalsuite/vision/segmentation.py +0 -0
  116. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/__init__.py +0 -0
  117. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/classification/__init__.py +0 -0
  118. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/classification/test_against_sklearn.py +0 -0
  119. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/clinical/__init__.py +0 -0
  120. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/clinical/test_outputs.py +0 -0
  121. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/clinical/test_v020.py +0 -0
  122. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/conftest.py +0 -0
  123. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/integration/__init__.py +0 -0
  124. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/integration/test_qa.py +0 -0
  125. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/integration/test_repo_hygiene.py +0 -0
  126. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/llmsys/__init__.py +0 -0
  127. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/llmsys/test_code_longcontext_efficiency.py +0 -0
  128. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/llmsys/test_edges.py +0 -0
  129. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/llmsys/test_fast_text.py +0 -0
  130. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/llmsys/test_hardening.py +0 -0
  131. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/llmsys/test_safety_robustness.py +0 -0
  132. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/llmsys/test_uncertainty_agents_multilingual.py +0 -0
  133. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/output/__init__.py +0 -0
  134. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/output/test_benchmarks.py +0 -0
  135. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/output/test_cli.py +0 -0
  136. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/output/test_plot.py +0 -0
  137. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/output/test_reporting.py +0 -0
  138. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/regression/__init__.py +0 -0
  139. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/regression/test_against_sklearn.py +0 -0
  140. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/stats/__init__.py +0 -0
  141. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/stats/test_branches.py +0 -0
  142. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/stats/test_compare.py +0 -0
  143. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/stats/test_fast_paths.py +0 -0
  144. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/stats/test_reference.py +0 -0
  145. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/test_cards.py +0 -0
  146. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/test_harness.py +0 -0
  147. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/test_integrations.py +0 -0
  148. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/test_monitor.py +0 -0
  149. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/test_native.py +0 -0
  150. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/test_update.py +0 -0
  151. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/test_v111_fixes.py +0 -0
  152. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/test_v12.py +0 -0
  153. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/test_v121.py +0 -0
  154. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/test_v121_coverage.py +0 -0
  155. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/test_v13.py +0 -0
  156. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/test_v135.py +0 -0
  157. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/test_v13_edges.py +0 -0
  158. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/text/__init__.py +0 -0
  159. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/text/test_against_references.py +0 -0
  160. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/text/test_text_edges.py +0 -0
  161. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/text/test_v040.py +0 -0
  162. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/unit/__init__.py +0 -0
  163. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/unit/test_core.py +0 -0
  164. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/unit/test_edges.py +0 -0
  165. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/vision/__init__.py +0 -0
  166. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/vision/test_detection.py +0 -0
  167. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/vision/test_edges.py +0 -0
  168. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/vision/test_outputs.py +0 -0
  169. {evalsuite_python-1.3.5 → evalsuite_python-1.4.0}/tests/vision/test_segmentation.py +0 -0
@@ -6,6 +6,41 @@ All notable changes to this project are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.4.0] - 2026-11-28
10
+
11
+ Smoother, cleaner and easier to keep tidy. Results are unchanged.
12
+
13
+ ### Added
14
+
15
+ - **Cache management.** One cache folder (`EVALSUITE_CACHE`, else the platform cache directory) for downloaded
16
+ benchmark data (`load_benchmark` now downloads there by default) and the update-check record.
17
+ `es.cache_info()` / `es.clear_cache(older_than=, max_size=, dry_run=)` and `evalsuite cache info|clear`.
18
+ - **Automatic cache clearing**, at most once a day in a background thread after import: entries unused for 90
19
+ days, then the least recently used until the cache is below 2 GB (`EVALSUITE_CACHE_MAX_AGE`,
20
+ `EVALSUITE_CACHE_MAX_SIZE`, `EVALSUITE_CACHE_AUTO_CLEAN=0`). Whole entries only, renamed out of the way before
21
+ deletion so an interrupted run never leaves half a download; folders without EvalSuite's marker file are
22
+ never touched.
23
+
24
+ ### Fixed
25
+
26
+ - Package-wide fuzz of every public function: non-numeric values (strings, None) in numeric arguments raised a
27
+ raw `ValueError("could not convert string to float")` in about 30 functions; they now raise
28
+ `InputValidationError` naming the argument and the offending value.
29
+ - Clear errors for wrong argument types: `compare` given an array instead of a dict of models, `ranking_report`
30
+ given arrays, sample-size functions given arrays, `list_metrics` given a non-string, `normalize_answer`,
31
+ `extract_json` and `format_multiple_choice` given non-strings, tool-call metrics given numeric matrices.
32
+ - `evaluate` with infinite or NaN labels no longer emits a NumPy `RuntimeWarning` before its error.
33
+ - The type checker reports no issues.
34
+
35
+ ### Changed
36
+
37
+ - Wheels exclude `__pycache__`, `.pyc` files and any stray local build of the compiled core. Wheel sizes are
38
+ unchanged (about 0.75–1.06 MB per platform, 0.41 MB pure Python): the package already shipped no tests,
39
+ notebooks, benchmark data or duplicate files.
40
+ - A test checks that each feature area (text, LLM systems, vision, clinical, survival, forecasting, drift,
41
+ judging, RAG, fairness, multi-label, agreement, Bayesian, recalibration, calibration, reports, cache, CLI)
42
+ imports without SciPy, pandas, Matplotlib, scikit-learn or PyTorch.
43
+
9
44
  ## [1.3.5] - 2026-11-28
10
45
 
11
46
  A deep clean of the 1.3 modules and bounded-memory resampling. Results are unchanged except where a bug is
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: evalsuite-python
3
- Version: 1.3.5
3
+ Version: 1.4.0
4
4
  Classifier: Development Status :: 5 - Production/Stable
5
5
  Classifier: Intended Audience :: Science/Research
6
6
  Classifier: Intended Audience :: Healthcare Industry
@@ -104,11 +104,15 @@ evaluation into one consistent, validated, documented framework.
104
104
  > **On an older version? Upgrade once:** `pip install -U evalsuite-python`. From 1.1.2 on, EvalSuite tells you
105
105
  > when a newer release is out (`evalsuite upgrade`).
106
106
 
107
- > **Status: stable (1.3.5).** [Example notebooks](notebooks/README.md) (Colab) ·
107
+ > **Status: stable (1.4.0).** [Example notebooks](notebooks/README.md) (Colab) ·
108
108
  > [in-browser tools](https://evalsuite-nine.vercel.app/tools) · [changelog](CHANGELOG.md)
109
109
 
110
110
  **What's new**
111
111
 
112
+ - **1.4** — a cache you can see and clear (`evalsuite cache info` / `clear`), cleared automatically (unused for
113
+ 90 days or beyond 2 GB); a package-wide fuzz: non-numeric input now raises a clear `InputValidationError`
114
+ naming the argument in every function, and wrong argument types are explained; every feature area loads
115
+ without SciPy, pandas or Matplotlib until used.
112
116
  - **1.3.5** — a deep clean of the 1.3 modules (ranking counts a document once and rejects NaN scores, temperature
113
117
  scaling maps string labels to the right columns, clearer errors on degenerate data, `to_html` on every report)
114
118
  and bounded memory: bootstrap intervals on 100,000 rows peak at about 90 MB instead of 1.6 GB, with identical
@@ -614,7 +618,7 @@ scripts, no external requests).
614
618
  ## Evaluation in pull requests
615
619
 
616
620
  ```yaml
617
- - uses: mkcs28/evalsuite-python@v1.3.5
621
+ - uses: mkcs28/evalsuite-python@v1.4.0
618
622
  with:
619
623
  predictions: predictions.csv
620
624
  y-true: label
@@ -659,6 +663,19 @@ Every result (`evaluate`, `classification_report`, `compare`, single metrics) ex
659
663
  `to_json()`, `to_csv()`, `to_dataframe()`, `to_markdown()`, `to_latex()` and `to_html()`, and `save(path)` picks
660
664
  the format from the extension. HTML pages are standalone (inline CSS, no scripts) and escape all text.
661
665
 
666
+ ## Cache
667
+
668
+ ```python
669
+ es.cache_info() # where EvalSuite keeps downloaded benchmark data, and how much
670
+ es.clear_cache(older_than="30d") # or es.clear_cache() for everything
671
+ ```
672
+
673
+ `evalsuite cache info` and `evalsuite cache clear [--older-than 30d] [--max-size 1GB] [--dry-run]` do the same
674
+ from the shell. The cache is also cleared automatically, at most once a day in the background: entries unused
675
+ for 90 days go, then the least recently used until it is under 2 GB. Change this with `EVALSUITE_CACHE_MAX_AGE`
676
+ and `EVALSUITE_CACHE_MAX_SIZE`, turn it off with `EVALSUITE_CACHE_AUTO_CLEAN=0`, and move the folder with
677
+ `EVALSUITE_CACHE`. Only folders EvalSuite created are ever touched.
678
+
662
679
  ## Command line
663
680
 
664
681
  ```bash
@@ -13,11 +13,15 @@ evaluation into one consistent, validated, documented framework.
13
13
  > **On an older version? Upgrade once:** `pip install -U evalsuite-python`. From 1.1.2 on, EvalSuite tells you
14
14
  > when a newer release is out (`evalsuite upgrade`).
15
15
 
16
- > **Status: stable (1.3.5).** [Example notebooks](notebooks/README.md) (Colab) ·
16
+ > **Status: stable (1.4.0).** [Example notebooks](notebooks/README.md) (Colab) ·
17
17
  > [in-browser tools](https://evalsuite-nine.vercel.app/tools) · [changelog](CHANGELOG.md)
18
18
 
19
19
  **What's new**
20
20
 
21
+ - **1.4** — a cache you can see and clear (`evalsuite cache info` / `clear`), cleared automatically (unused for
22
+ 90 days or beyond 2 GB); a package-wide fuzz: non-numeric input now raises a clear `InputValidationError`
23
+ naming the argument in every function, and wrong argument types are explained; every feature area loads
24
+ without SciPy, pandas or Matplotlib until used.
21
25
  - **1.3.5** — a deep clean of the 1.3 modules (ranking counts a document once and rejects NaN scores, temperature
22
26
  scaling maps string labels to the right columns, clearer errors on degenerate data, `to_html` on every report)
23
27
  and bounded memory: bootstrap intervals on 100,000 rows peak at about 90 MB instead of 1.6 GB, with identical
@@ -523,7 +527,7 @@ scripts, no external requests).
523
527
  ## Evaluation in pull requests
524
528
 
525
529
  ```yaml
526
- - uses: mkcs28/evalsuite-python@v1.3.5
530
+ - uses: mkcs28/evalsuite-python@v1.4.0
527
531
  with:
528
532
  predictions: predictions.csv
529
533
  y-true: label
@@ -568,6 +572,19 @@ Every result (`evaluate`, `classification_report`, `compare`, single metrics) ex
568
572
  `to_json()`, `to_csv()`, `to_dataframe()`, `to_markdown()`, `to_latex()` and `to_html()`, and `save(path)` picks
569
573
  the format from the extension. HTML pages are standalone (inline CSS, no scripts) and escape all text.
570
574
 
575
+ ## Cache
576
+
577
+ ```python
578
+ es.cache_info() # where EvalSuite keeps downloaded benchmark data, and how much
579
+ es.clear_cache(older_than="30d") # or es.clear_cache() for everything
580
+ ```
581
+
582
+ `evalsuite cache info` and `evalsuite cache clear [--older-than 30d] [--max-size 1GB] [--dry-run]` do the same
583
+ from the shell. The cache is also cleared automatically, at most once a day in the background: entries unused
584
+ for 90 days go, then the least recently used until it is under 2 GB. Change this with `EVALSUITE_CACHE_MAX_AGE`
585
+ and `EVALSUITE_CACHE_MAX_SIZE`, turn it off with `EVALSUITE_CACHE_AUTO_CLEAN=0`, and move the folder with
586
+ `EVALSUITE_CACHE`. Only folders EvalSuite created are ever touched.
587
+
571
588
  ## Command line
572
589
 
573
590
  ```bash
@@ -111,6 +111,11 @@ exclude = [
111
111
  { path = "**/__pycache__/**", format = "sdist" },
112
112
  { path = "**/*.pyc", format = "sdist" },
113
113
  { path = "rust/target/**", format = "sdist" },
114
+ # wheels carry only the package: never caches or a stray local build of the compiled core
115
+ { path = "**/__pycache__/**", format = "wheel" },
116
+ { path = "**/*.pyc", format = "wheel" },
117
+ { path = "src/evalsuite/_core*.so", format = "wheel" },
118
+ { path = "src/evalsuite/_core*.pyd", format = "wheel" },
114
119
  ]
115
120
 
116
121
  [tool.hatch.build.targets.sdist]
@@ -319,7 +319,7 @@ checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
319
319
 
320
320
  [[package]]
321
321
  name = "evalsuite"
322
- version = "1.3.5"
322
+ version = "1.4.0"
323
323
  dependencies = [
324
324
  "criterion",
325
325
  "evalsuite-core",
@@ -334,14 +334,14 @@ dependencies = [
334
334
 
335
335
  [[package]]
336
336
  name = "evalsuite-capi"
337
- version = "1.3.5"
337
+ version = "1.4.0"
338
338
  dependencies = [
339
339
  "evalsuite",
340
340
  ]
341
341
 
342
342
  [[package]]
343
343
  name = "evalsuite-cli"
344
- version = "1.3.5"
344
+ version = "1.4.0"
345
345
  dependencies = [
346
346
  "clap",
347
347
  "csv",
@@ -351,14 +351,14 @@ dependencies = [
351
351
 
352
352
  [[package]]
353
353
  name = "evalsuite-core"
354
- version = "1.3.5"
354
+ version = "1.4.0"
355
355
  dependencies = [
356
356
  "rayon",
357
357
  ]
358
358
 
359
359
  [[package]]
360
360
  name = "evalsuite-py"
361
- version = "1.3.5"
361
+ version = "1.4.0"
362
362
  dependencies = [
363
363
  "evalsuite-core",
364
364
  "pyo3",
@@ -367,7 +367,7 @@ dependencies = [
367
367
 
368
368
  [[package]]
369
369
  name = "evalsuite-wasm"
370
- version = "1.3.5"
370
+ version = "1.4.0"
371
371
  dependencies = [
372
372
  "evalsuite",
373
373
  "js-sys",
@@ -3,7 +3,7 @@ members = ["evalsuite-core", "evalsuite-py"]
3
3
  resolver = "2"
4
4
 
5
5
  [workspace.package]
6
- version = "1.3.5"
6
+ version = "1.4.0"
7
7
  edition = "2021"
8
8
  rust-version = "1.82"
9
9
  license = "MIT OR Apache-2.0"
@@ -46,6 +46,12 @@ if TYPE_CHECKING: # static analysers and IDEs see the full eager API
46
46
  bayes_compare,
47
47
  bayes_correlated_ttest,
48
48
  )
49
+ from .cache import (
50
+ CacheInfo,
51
+ cache_dir,
52
+ cache_info,
53
+ clear_cache,
54
+ )
49
55
  from .calibration import (
50
56
  CalibrationReport,
51
57
  calibration_intercept,
@@ -384,6 +390,12 @@ _EXPORTS: dict[str, tuple[str, ...]] = {
384
390
  "Calibrator",
385
391
  "recalibrate",
386
392
  ),
393
+ ".cache": (
394
+ "CacheInfo",
395
+ "cache_dir",
396
+ "cache_info",
397
+ "clear_cache",
398
+ ),
387
399
  ".fairness": (
388
400
  "FairnessReport",
389
401
  "fairness_report",
@@ -674,6 +686,7 @@ __all__ = [
674
686
  "BENCHMARKS",
675
687
  "BayesComparison",
676
688
  "BlandAltman",
689
+ "CacheInfo",
677
690
  "CalibrationReport",
678
691
  "Calibrator",
679
692
  "ClassificationReport",
@@ -745,6 +758,8 @@ __all__ = [
745
758
  "bradley_terry",
746
759
  "brier_score",
747
760
  "brier_score_survival",
761
+ "cache_dir",
762
+ "cache_info",
748
763
  "calibration",
749
764
  "calibration_curve",
750
765
  "calibration_intercept",
@@ -760,6 +775,7 @@ __all__ = [
760
775
  "claim_verification_accuracy",
761
776
  "classification",
762
777
  "classification_report",
778
+ "clear_cache",
763
779
  "cliffs_delta",
764
780
  "clinical",
765
781
  "code_complexity",
@@ -68,13 +68,20 @@ def _installed() -> str:
68
68
  return __version__
69
69
 
70
70
 
71
+ def _cache_root() -> Path:
72
+ """EvalSuite's cache folder (documented in :mod:`evalsuite.cache`); kept here so importing stays light."""
73
+ env = os.environ.get("EVALSUITE_CACHE")
74
+ if env:
75
+ return Path(env).expanduser()
76
+ if os.environ.get("XDG_CACHE_HOME"):
77
+ return Path(os.environ["XDG_CACHE_HOME"]) / "evalsuite"
78
+ if sys.platform == "win32" and os.environ.get("LOCALAPPDATA"):
79
+ return Path(os.environ["LOCALAPPDATA"]) / "evalsuite"
80
+ return Path.home() / ".cache" / "evalsuite"
81
+
82
+
71
83
  def _cache_file() -> Path:
72
- base = os.environ.get("XDG_CACHE_HOME") or (
73
- os.path.join(os.environ.get("LOCALAPPDATA", ""), "evalsuite")
74
- if sys.platform == "win32" and os.environ.get("LOCALAPPDATA")
75
- else os.path.join(os.path.expanduser("~"), ".cache")
76
- )
77
- return Path(base) / "evalsuite" / "update-check.json"
84
+ return _cache_root() / "update-check.json"
78
85
 
79
86
 
80
87
  def _read_cache() -> dict[str, Any]:
@@ -87,9 +94,10 @@ def _read_cache() -> dict[str, Any]:
87
94
 
88
95
  def _write_cache(data: dict[str, Any]) -> None:
89
96
  try:
90
- path = _cache_file()
91
- path.parent.mkdir(parents=True, exist_ok=True)
92
- path.write_text(json.dumps(data))
97
+ from .cache import cache_dir
98
+
99
+ cache_dir(create=True)
100
+ _cache_file().write_text(json.dumps(data))
93
101
  except OSError:
94
102
  pass
95
103
 
@@ -148,8 +156,30 @@ def _background_refresh() -> None:
148
156
  _write_cache(data)
149
157
 
150
158
 
159
+ def _clean_in_background() -> None:
160
+ """Start the automatic cache clearing (evalsuite.cache) in a background thread when it is due (daily)."""
161
+ try:
162
+ root = _cache_root()
163
+ stamp = root / ".last-clean"
164
+ if not (root / ".evalsuite-cache").is_file():
165
+ return
166
+ if stamp.exists() and time.time() - stamp.stat().st_mtime < DAY:
167
+ return
168
+ except OSError:
169
+ return
170
+
171
+ def run() -> None:
172
+ from .cache import auto_clean
173
+
174
+ auto_clean()
175
+
176
+ threading.Thread(target=run, name="evalsuite-cache-clean", daemon=True).start()
177
+
178
+
151
179
  def notify_on_import() -> None:
152
- """Print the cached notice (at most once a day) and refresh the cache in the background when stale."""
180
+ """Print the cached notice (at most once a day) and refresh the cache in the background when stale; also
181
+ start the daily automatic cache clearing when due."""
182
+ _clean_in_background()
153
183
  if _disabled():
154
184
  return
155
185
  data = _read_cache()
@@ -21,6 +21,7 @@ from typing import Any, Optional
21
21
  import numpy as np
22
22
 
23
23
  from .core.exceptions import InputValidationError
24
+ from .core.validation import numeric
24
25
 
25
26
  __all__ = ["ICCResult", "ICCForm", "BlandAltman", "icc", "bland_altman", "lins_ccc"]
26
27
 
@@ -136,7 +137,7 @@ def _table(ratings: Any, subjects: Any, raters: Any) -> np.ndarray:
136
137
  return x
137
138
  if subjects is None or raters is None:
138
139
  raise InputValidationError("Long format needs both subjects= and raters=.")
139
- vals = np.asarray(ratings, dtype=np.float64).ravel()
140
+ vals = numeric(ratings, "ratings").ravel()
140
141
  s = np.asarray(subjects).ravel()
141
142
  r = np.asarray(raters).ravel()
142
143
  if not (vals.size == s.size == r.size):
@@ -23,6 +23,7 @@ from typing import Any, Callable, Optional, Union
23
23
  import numpy as np
24
24
 
25
25
  from .core.exceptions import EvalSuiteError, InputValidationError
26
+ from .core.validation import numeric
26
27
 
27
28
  __all__ = ["BayesComparison", "bayes_compare", "bayes_correlated_ttest"]
28
29
 
@@ -277,8 +278,8 @@ def bayes_correlated_ttest(
277
278
  Student t with n − 1 degrees of freedom; probabilities are exact and the draws only feed ``samples``."""
278
279
  from scipy import stats
279
280
 
280
- sa = np.asarray(scores_a, dtype=np.float64).ravel()
281
- sb = np.asarray(scores_b, dtype=np.float64).ravel()
281
+ sa = numeric(scores_a, "scores_a").ravel()
282
+ sb = numeric(scores_b, "scores_b").ravel()
282
283
  if sa.size != sb.size:
283
284
  raise InputValidationError(f"Both models need a score per fold; got {sa.size} and {sb.size}.")
284
285
  if sa.size < 2 or not (np.all(np.isfinite(sa)) and np.all(np.isfinite(sb))):
@@ -0,0 +1,258 @@
1
+ """EvalSuite's cache folder: where downloaded benchmark data and the update-check record live.
2
+
3
+ >>> import evalsuite as es
4
+ >>> es.cache_info() # location, size, entries
5
+ >>> es.clear_cache(older_than="30d") # or clear_cache() for everything
6
+
7
+ The folder is ``$EVALSUITE_CACHE`` if set, else ``$XDG_CACHE_HOME/evalsuite``, ``%LOCALAPPDATA%\\evalsuite`` on
8
+ Windows, or ``~/.cache/evalsuite``. From the command line: ``evalsuite cache info`` and ``evalsuite cache clear``.
9
+
10
+ Automatic clearing: at most once a day, in the background after import, entries not used for
11
+ ``EVALSUITE_CACHE_MAX_AGE`` (default 90 days) are removed, then the least recently used entries until the cache is
12
+ below ``EVALSUITE_CACHE_MAX_SIZE`` (default 2 GB). Set ``EVALSUITE_CACHE_AUTO_CLEAN=0`` to turn it off. Only
13
+ folders EvalSuite created (they carry a marker file) are ever touched, and only whole entries (one data set
14
+ download, one record) are removed, never part of one.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import contextlib
20
+ import os
21
+ import re
22
+ import shutil
23
+ import time
24
+ from dataclasses import dataclass
25
+ from pathlib import Path
26
+ from typing import Any, Optional, Union
27
+
28
+ from .core.exceptions import InputValidationError
29
+
30
+ __all__ = ["CacheInfo", "cache_dir", "cache_info", "clear_cache"]
31
+
32
+ MARKER = ".evalsuite-cache"
33
+ _STAMP = ".last-clean"
34
+ _KEEP = {MARKER, _STAMP}
35
+ _DEFAULT_MAX_AGE = 90 * 86400.0
36
+ _DEFAULT_MAX_SIZE = 2 * 1024**3
37
+
38
+
39
+ def cache_dir(*, create: bool = False) -> Path:
40
+ """The cache folder (see the module docstring); ``create=True`` makes it, with its marker file."""
41
+ from ._update import _cache_root
42
+
43
+ path = _cache_root()
44
+ if create:
45
+ path.mkdir(parents=True, exist_ok=True)
46
+ marker = path / MARKER
47
+ if not marker.exists():
48
+ marker.write_text("Created by EvalSuite. Everything in this folder can be deleted safely.\n")
49
+ return path
50
+
51
+
52
+ def _parse_age(value: Union[str, float, int, None]) -> Optional[float]:
53
+ """Seconds from 3600, "30d", "12h", "45m", "90s", "2w" (None stays None)."""
54
+ if value is None:
55
+ return None
56
+ if isinstance(value, (int, float)):
57
+ if value < 0:
58
+ raise InputValidationError("Ages must be non-negative.")
59
+ return float(value)
60
+ m = re.fullmatch(r"\s*(\d+(?:\.\d+)?)\s*([smhdw]?)\s*", str(value).lower())
61
+ if not m:
62
+ raise InputValidationError(f"Cannot read the age {value!r}; use e.g. '30d', '12h', '2w' or seconds.")
63
+ unit = {"": 1, "s": 1, "m": 60, "h": 3600, "d": 86400, "w": 7 * 86400}[m.group(2)]
64
+ return float(m.group(1)) * unit
65
+
66
+
67
+ def _parse_size(value: Union[str, int, None]) -> Optional[int]:
68
+ """Bytes from 1048576, "500MB", "2GB", "1.5G" (None stays None)."""
69
+ if value is None:
70
+ return None
71
+ if isinstance(value, int):
72
+ return value
73
+ m = re.fullmatch(r"\s*(\d+(?:\.\d+)?)\s*([kmgt]?)i?b?\s*", str(value).lower())
74
+ if not m:
75
+ raise InputValidationError(f"Cannot read the size {value!r}; use e.g. '500MB' or '2GB'.")
76
+ return int(float(m.group(1)) * 1024 ** "_kmgt".index(m.group(2) or "_"))
77
+
78
+
79
+ def _entries(root: Path) -> list[tuple[Path, int, float]]:
80
+ """Whole entries — a top-level file, or one item inside a top-level folder (one data set download) — with
81
+ their size and last use (newest access or modification time of anything in them)."""
82
+ out: list[tuple[Path, int, float]] = []
83
+ if not root.is_dir():
84
+ return out
85
+ for top in root.iterdir():
86
+ if top.name in _KEEP or top.name.startswith(".trash-"):
87
+ continue
88
+ units = list(top.iterdir()) if top.is_dir() and not top.is_symlink() else [top]
89
+ for unit in units:
90
+ size, last = 0, 0.0
91
+ files = [unit] if not unit.is_dir() or unit.is_symlink() else [p for p in unit.rglob("*")]
92
+ for f in files:
93
+ if f.is_dir() and not f.is_symlink():
94
+ continue # listing a folder updates its access time, so only files say when it was used
95
+ try:
96
+ st = f.lstat()
97
+ except OSError:
98
+ continue
99
+ size += st.st_size
100
+ last = max(last, st.st_atime, st.st_mtime)
101
+ if last == 0.0:
102
+ with contextlib.suppress(OSError):
103
+ last = unit.lstat().st_mtime
104
+ out.append((unit, size, last))
105
+ return out
106
+
107
+
108
+ @dataclass(frozen=True)
109
+ class CacheInfo:
110
+ """What the cache holds."""
111
+
112
+ path: str
113
+ exists: bool
114
+ size_bytes: int
115
+ entries: tuple[dict[str, Any], ...]
116
+ auto_clean: bool
117
+ max_age_days: float
118
+ max_size_bytes: int
119
+
120
+ def summary(self) -> str:
121
+ if not self.exists:
122
+ return f"EvalSuite cache: {self.path} (empty; nothing downloaded yet)"
123
+ lines = [
124
+ f"EvalSuite cache: {self.path}",
125
+ f" {_human(self.size_bytes)} in {len(self.entries)} entr{'y' if len(self.entries) == 1 else 'ies'}",
126
+ " Automatic clearing: "
127
+ + (
128
+ f"on (unused for {self.max_age_days:g} days, or beyond {_human(self.max_size_bytes)})"
129
+ if self.auto_clean
130
+ else "off"
131
+ ),
132
+ ]
133
+ for e in sorted(self.entries, key=lambda e: -e["size_bytes"])[:15]:
134
+ lines.append(f" {_human(e['size_bytes']):>9} {e['days_unused']:6.1f} days unused {e['name']}")
135
+ return "\n".join(lines)
136
+
137
+ def __repr__(self) -> str:
138
+ return self.summary()
139
+
140
+
141
+ def _human(n: float) -> str:
142
+ for unit in ("B", "KB", "MB", "GB"):
143
+ if n < 1024 or unit == "GB":
144
+ return f"{n:.0f} {unit}" if unit == "B" else f"{n:.1f} {unit}"
145
+ n /= 1024
146
+ return f"{n:.1f} GB" # pragma: no cover
147
+
148
+
149
+ def _settings() -> tuple[bool, float, int]:
150
+ auto = os.environ.get("EVALSUITE_CACHE_AUTO_CLEAN", "1").strip().lower() not in ("0", "false", "no", "off")
151
+ try:
152
+ age = _parse_age(os.environ.get("EVALSUITE_CACHE_MAX_AGE")) or _DEFAULT_MAX_AGE
153
+ size = _parse_size(os.environ.get("EVALSUITE_CACHE_MAX_SIZE")) or _DEFAULT_MAX_SIZE
154
+ except InputValidationError:
155
+ age, size = _DEFAULT_MAX_AGE, _DEFAULT_MAX_SIZE
156
+ return auto, age, size
157
+
158
+
159
+ def cache_info() -> CacheInfo:
160
+ """Location, size and entries of the cache, and the automatic-clearing settings."""
161
+ root = cache_dir()
162
+ auto, age, size = _settings()
163
+ now = time.time()
164
+ entries: tuple[dict[str, Any], ...] = tuple(
165
+ {"name": p.relative_to(root).as_posix(), "size_bytes": s, "days_unused": max(0.0, (now - last) / 86400)}
166
+ for p, s, last in _entries(root)
167
+ )
168
+ return CacheInfo(
169
+ str(root), root.is_dir(), sum(int(e["size_bytes"]) for e in entries), entries, auto, age / 86400, size
170
+ )
171
+
172
+
173
+ def _remove(path: Path, root: Path) -> None:
174
+ """Delete one entry: rename it into the cache's trash first (atomic), so an interrupted deletion never leaves
175
+ half an entry where a reader would find it; the trash is emptied now and on later runs."""
176
+ import uuid
177
+
178
+ trash = root / f".trash-{uuid.uuid4().hex}"
179
+ try:
180
+ path.rename(trash)
181
+ except OSError:
182
+ trash = path
183
+ if trash.is_dir() and not trash.is_symlink():
184
+ shutil.rmtree(trash, ignore_errors=True)
185
+ else:
186
+ with contextlib.suppress(OSError):
187
+ trash.unlink()
188
+
189
+
190
+ def _owned(root: Path) -> bool:
191
+ return (root / MARKER).is_file()
192
+
193
+
194
+ def clear_cache(
195
+ *,
196
+ older_than: Union[str, float, None] = None,
197
+ max_size: Union[str, int, None] = None,
198
+ dry_run: bool = False,
199
+ ) -> dict[str, Any]:
200
+ """Delete cache entries: everything, or those unused for ``older_than`` (e.g. ``"30d"``), then the least
201
+ recently used until the cache is below ``max_size`` (e.g. ``"1GB"``). Returns what was (or with
202
+ ``dry_run=True`` would be) removed. Only a folder EvalSuite created is touched."""
203
+ root = cache_dir()
204
+ if not root.is_dir():
205
+ return {"path": str(root), "removed": [], "freed_bytes": 0, "dry_run": dry_run}
206
+ if not _owned(root):
207
+ raise InputValidationError(
208
+ f"{root} was not created by EvalSuite (no {MARKER} file); refusing to delete anything in it."
209
+ )
210
+ age = _parse_age(older_than)
211
+ limit = _parse_size(max_size)
212
+ now = time.time()
213
+ entries = sorted(_entries(root), key=lambda e: e[2]) # least recently used first
214
+ doomed: list[tuple[Path, int]] = []
215
+ if age is None and limit is None:
216
+ doomed = [(p, s) for p, s, _ in entries]
217
+ else:
218
+ keep = []
219
+ for p, s, last in entries:
220
+ (doomed.append((p, s)) if age is not None and now - last > age else keep.append((p, s)))
221
+ if limit is not None:
222
+ total = sum(s for _, s in keep)
223
+ for p, s in keep:
224
+ if total <= limit:
225
+ break
226
+ doomed.append((p, s))
227
+ total -= s
228
+ if not dry_run:
229
+ for p, _ in doomed:
230
+ _remove(p, root)
231
+ for leftover in root.glob(".trash-*"): # from an interrupted earlier run
232
+ _remove(leftover, root)
233
+ for top in root.iterdir(): # drop section folders left empty
234
+ if top.is_dir() and top.name not in _KEEP and not top.name.startswith(".") and not any(top.iterdir()):
235
+ top.rmdir()
236
+ return {
237
+ "path": str(root),
238
+ "removed": [p.relative_to(root).as_posix() for p, _ in doomed],
239
+ "freed_bytes": sum(s for _, s in doomed),
240
+ "dry_run": dry_run,
241
+ }
242
+
243
+
244
+ def auto_clean(*, force: bool = False) -> Optional[dict[str, Any]]:
245
+ """The automatic clearing (see the module docstring): runs at most once a day unless ``force``; never
246
+ raises."""
247
+ try:
248
+ auto, age, size = _settings()
249
+ root = cache_dir()
250
+ if not (auto or force) or not root.is_dir() or not _owned(root):
251
+ return None
252
+ stamp = root / _STAMP
253
+ if not force and stamp.exists() and time.time() - stamp.stat().st_mtime < 86400:
254
+ return None
255
+ stamp.write_text(str(time.time()))
256
+ return clear_cache(older_than=age, max_size=size)
257
+ except Exception:
258
+ return None
@@ -228,7 +228,7 @@ class ReportCard:
228
228
  def to_docx(self, path: str, *, digits: int = 3) -> None:
229
229
  """Write a Word document with the paragraph, the table and (model card) the narrative sections."""
230
230
  try:
231
- import docx # type: ignore[import-not-found]
231
+ import docx # type: ignore[import-not-found, unused-ignore]
232
232
  except ImportError as exc:
233
233
  raise OptionalDependencyError("python-docx", "docx", "ReportCard.to_docx") from exc
234
234
  doc = docx.Document()