fieldtrial 0.1.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 (142) hide show
  1. fieldtrial-0.1.0/.gitignore +39 -0
  2. fieldtrial-0.1.0/CHANGELOG.md +86 -0
  3. fieldtrial-0.1.0/LICENSE +202 -0
  4. fieldtrial-0.1.0/PKG-INFO +182 -0
  5. fieldtrial-0.1.0/README.md +123 -0
  6. fieldtrial-0.1.0/pyproject.toml +345 -0
  7. fieldtrial-0.1.0/src/fieldtrial/__init__.py +13 -0
  8. fieldtrial-0.1.0/src/fieldtrial/analysis/__init__.py +1 -0
  9. fieldtrial-0.1.0/src/fieldtrial/analysis/engine.py +817 -0
  10. fieldtrial-0.1.0/src/fieldtrial/analysis/records.py +53 -0
  11. fieldtrial-0.1.0/src/fieldtrial/analysis/results.py +273 -0
  12. fieldtrial-0.1.0/src/fieldtrial/analysis/wording.py +274 -0
  13. fieldtrial-0.1.0/src/fieldtrial/api/__init__.py +1 -0
  14. fieldtrial-0.1.0/src/fieldtrial/api/schemas.py +190 -0
  15. fieldtrial-0.1.0/src/fieldtrial/api/v1.py +432 -0
  16. fieldtrial-0.1.0/src/fieldtrial/cli/__init__.py +1 -0
  17. fieldtrial-0.1.0/src/fieldtrial/cli/calc.py +299 -0
  18. fieldtrial-0.1.0/src/fieldtrial/cli/main.py +42 -0
  19. fieldtrial-0.1.0/src/fieldtrial/cli/serve.py +112 -0
  20. fieldtrial-0.1.0/src/fieldtrial/cli/study.py +376 -0
  21. fieldtrial-0.1.0/src/fieldtrial/client.py +272 -0
  22. fieldtrial-0.1.0/src/fieldtrial/design/__init__.py +32 -0
  23. fieldtrial-0.1.0/src/fieldtrial/design/blinding.py +26 -0
  24. fieldtrial-0.1.0/src/fieldtrial/design/hashing.py +31 -0
  25. fieldtrial-0.1.0/src/fieldtrial/design/loader.py +135 -0
  26. fieldtrial-0.1.0/src/fieldtrial/design/models.py +231 -0
  27. fieldtrial-0.1.0/src/fieldtrial/design/schedule.py +122 -0
  28. fieldtrial-0.1.0/src/fieldtrial/io/__init__.py +1 -0
  29. fieldtrial-0.1.0/src/fieldtrial/io/csv.py +219 -0
  30. fieldtrial-0.1.0/src/fieldtrial/io/jsonl.py +17 -0
  31. fieldtrial-0.1.0/src/fieldtrial/py.typed +0 -0
  32. fieldtrial-0.1.0/src/fieldtrial/report/__init__.py +6 -0
  33. fieldtrial-0.1.0/src/fieldtrial/report/charts.py +361 -0
  34. fieldtrial-0.1.0/src/fieldtrial/report/html.py +66 -0
  35. fieldtrial-0.1.0/src/fieldtrial/report/markdown.py +314 -0
  36. fieldtrial-0.1.0/src/fieldtrial/report/templates/report.css +25 -0
  37. fieldtrial-0.1.0/src/fieldtrial/report/templates/report.html +203 -0
  38. fieldtrial-0.1.0/src/fieldtrial/runners/__init__.py +1 -0
  39. fieldtrial-0.1.0/src/fieldtrial/runners/base.py +89 -0
  40. fieldtrial-0.1.0/src/fieldtrial/runners/manual.py +55 -0
  41. fieldtrial-0.1.0/src/fieldtrial/runners/sim.py +133 -0
  42. fieldtrial-0.1.0/src/fieldtrial/services/__init__.py +14 -0
  43. fieldtrial-0.1.0/src/fieldtrial/services/_context.py +61 -0
  44. fieldtrial-0.1.0/src/fieldtrial/services/analysis.py +33 -0
  45. fieldtrial-0.1.0/src/fieldtrial/services/events.py +110 -0
  46. fieldtrial-0.1.0/src/fieldtrial/services/registry.py +95 -0
  47. fieldtrial-0.1.0/src/fieldtrial/services/session.py +206 -0
  48. fieldtrial-0.1.0/src/fieldtrial/services/simulate.py +176 -0
  49. fieldtrial-0.1.0/src/fieldtrial/services/study.py +500 -0
  50. fieldtrial-0.1.0/src/fieldtrial/services/transfer.py +136 -0
  51. fieldtrial-0.1.0/src/fieldtrial/services/trial.py +897 -0
  52. fieldtrial-0.1.0/src/fieldtrial/stats/__init__.py +72 -0
  53. fieldtrial-0.1.0/src/fieldtrial/stats/_rng.py +72 -0
  54. fieldtrial-0.1.0/src/fieldtrial/stats/_types.py +237 -0
  55. fieldtrial-0.1.0/src/fieldtrial/stats/_validation.py +48 -0
  56. fieldtrial-0.1.0/src/fieldtrial/stats/bayes.py +82 -0
  57. fieldtrial-0.1.0/src/fieldtrial/stats/compare.py +206 -0
  58. fieldtrial-0.1.0/src/fieldtrial/stats/drift.py +80 -0
  59. fieldtrial-0.1.0/src/fieldtrial/stats/multiplicity.py +96 -0
  60. fieldtrial-0.1.0/src/fieldtrial/stats/ordinal.py +139 -0
  61. fieldtrial-0.1.0/src/fieldtrial/stats/paired.py +244 -0
  62. fieldtrial-0.1.0/src/fieldtrial/stats/power.py +501 -0
  63. fieldtrial-0.1.0/src/fieldtrial/stats/proportions.py +160 -0
  64. fieldtrial-0.1.0/src/fieldtrial/stats/stratified.py +127 -0
  65. fieldtrial-0.1.0/src/fieldtrial/stats/timing.py +103 -0
  66. fieldtrial-0.1.0/src/fieldtrial/store/__init__.py +1 -0
  67. fieldtrial-0.1.0/src/fieldtrial/store/db.py +46 -0
  68. fieldtrial-0.1.0/src/fieldtrial/store/ids.py +17 -0
  69. fieldtrial-0.1.0/src/fieldtrial/store/migrations/__init__.py +0 -0
  70. fieldtrial-0.1.0/src/fieldtrial/store/migrations/env.py +14 -0
  71. fieldtrial-0.1.0/src/fieldtrial/store/migrations/script.py.mako +21 -0
  72. fieldtrial-0.1.0/src/fieldtrial/store/migrations/versions/0001_baseline.py +182 -0
  73. fieldtrial-0.1.0/src/fieldtrial/store/migrations/versions/0002_idempotency.py +24 -0
  74. fieldtrial-0.1.0/src/fieldtrial/store/migrations/versions/__init__.py +0 -0
  75. fieldtrial-0.1.0/src/fieldtrial/store/models.py +188 -0
  76. fieldtrial-0.1.0/src/fieldtrial/templates/__init__.py +15 -0
  77. fieldtrial-0.1.0/src/fieldtrial/templates/basic.yaml +58 -0
  78. fieldtrial-0.1.0/src/fieldtrial/templates/checkpoint-ladder.yaml +41 -0
  79. fieldtrial-0.1.0/src/fieldtrial/templates/demo.yaml +59 -0
  80. fieldtrial-0.1.0/src/fieldtrial/templates/serving-sweep.yaml +41 -0
  81. fieldtrial-0.1.0/src/fieldtrial/web/__init__.py +1 -0
  82. fieldtrial-0.1.0/src/fieldtrial/web/app.py +87 -0
  83. fieldtrial-0.1.0/src/fieldtrial/web/console.py +547 -0
  84. fieldtrial-0.1.0/src/fieldtrial/web/security.py +169 -0
  85. fieldtrial-0.1.0/src/fieldtrial/web/static/app.css +169 -0
  86. fieldtrial-0.1.0/src/fieldtrial/web/static/app.js +216 -0
  87. fieldtrial-0.1.0/src/fieldtrial/web/static/vendor/README.md +11 -0
  88. fieldtrial-0.1.0/src/fieldtrial/web/static/vendor/htmx-2.0.11.min.js +1 -0
  89. fieldtrial-0.1.0/src/fieldtrial/web/static/vendor/htmx-LICENSE.txt +13 -0
  90. fieldtrial-0.1.0/src/fieldtrial/web/templates/_edit_row.html +38 -0
  91. fieldtrial-0.1.0/src/fieldtrial/web/templates/_flash.html +1 -0
  92. fieldtrial-0.1.0/src/fieldtrial/web/templates/_panel.html +105 -0
  93. fieldtrial-0.1.0/src/fieldtrial/web/templates/_slot_header.html +9 -0
  94. fieldtrial-0.1.0/src/fieldtrial/web/templates/_trial_header.html +2 -0
  95. fieldtrial-0.1.0/src/fieldtrial/web/templates/_trial_row.html +12 -0
  96. fieldtrial-0.1.0/src/fieldtrial/web/templates/base.html +24 -0
  97. fieldtrial-0.1.0/src/fieldtrial/web/templates/console.html +27 -0
  98. fieldtrial-0.1.0/src/fieldtrial/web/templates/draft.html +13 -0
  99. fieldtrial-0.1.0/src/fieldtrial/web/templates/error.html +6 -0
  100. fieldtrial-0.1.0/src/fieldtrial/web/templates/history.html +20 -0
  101. fieldtrial-0.1.0/src/fieldtrial/web/templates/report.html +54 -0
  102. fieldtrial-0.1.0/src/fieldtrial/web/templates/studies.html +19 -0
  103. fieldtrial-0.1.0/src/fieldtrial/web/templates/study.html +81 -0
  104. fieldtrial-0.1.0/tests/analysis/test_engine.py +361 -0
  105. fieldtrial-0.1.0/tests/analysis/test_report.py +72 -0
  106. fieldtrial-0.1.0/tests/analysis/test_schema.py +19 -0
  107. fieldtrial-0.1.0/tests/analysis/test_wording.py +171 -0
  108. fieldtrial-0.1.0/tests/conftest.py +50 -0
  109. fieldtrial-0.1.0/tests/design/snapshots/schedules.json +2036 -0
  110. fieldtrial-0.1.0/tests/design/test_models.py +165 -0
  111. fieldtrial-0.1.0/tests/design/test_schedule.py +160 -0
  112. fieldtrial-0.1.0/tests/fixtures/golden/study.yaml +30 -0
  113. fieldtrial-0.1.0/tests/fixtures/golden/trials.csv +201 -0
  114. fieldtrial-0.1.0/tests/report/test_html.py +166 -0
  115. fieldtrial-0.1.0/tests/services/conftest.py +31 -0
  116. fieldtrial-0.1.0/tests/services/test_console_services.py +272 -0
  117. fieldtrial-0.1.0/tests/services/test_registry.py +41 -0
  118. fieldtrial-0.1.0/tests/services/test_simulate.py +153 -0
  119. fieldtrial-0.1.0/tests/services/test_store.py +80 -0
  120. fieldtrial-0.1.0/tests/services/test_study_services.py +164 -0
  121. fieldtrial-0.1.0/tests/services/test_transfer.py +119 -0
  122. fieldtrial-0.1.0/tests/services/test_trial_services.py +194 -0
  123. fieldtrial-0.1.0/tests/stats/test_bayes.py +71 -0
  124. fieldtrial-0.1.0/tests/stats/test_compare.py +159 -0
  125. fieldtrial-0.1.0/tests/stats/test_m2_stats.py +214 -0
  126. fieldtrial-0.1.0/tests/stats/test_multiplicity.py +91 -0
  127. fieldtrial-0.1.0/tests/stats/test_paired.py +191 -0
  128. fieldtrial-0.1.0/tests/stats/test_power.py +252 -0
  129. fieldtrial-0.1.0/tests/stats/test_proportions.py +166 -0
  130. fieldtrial-0.1.0/tests/stats/test_slow_properties.py +73 -0
  131. fieldtrial-0.1.0/tests/test_architecture.py +110 -0
  132. fieldtrial-0.1.0/tests/test_calc_cli.py +150 -0
  133. fieldtrial-0.1.0/tests/test_cli.py +48 -0
  134. fieldtrial-0.1.0/tests/test_examples.py +66 -0
  135. fieldtrial-0.1.0/tests/test_network_guard.py +27 -0
  136. fieldtrial-0.1.0/tests/test_release_tools.py +55 -0
  137. fieldtrial-0.1.0/tests/test_study_cli.py +146 -0
  138. fieldtrial-0.1.0/tests/web/conftest.py +33 -0
  139. fieldtrial-0.1.0/tests/web/test_api.py +272 -0
  140. fieldtrial-0.1.0/tests/web/test_client.py +85 -0
  141. fieldtrial-0.1.0/tests/web/test_console.py +450 -0
  142. fieldtrial-0.1.0/tests/web/test_serve.py +117 -0
@@ -0,0 +1,39 @@
1
+ # Secrets: tokens and credentials stay local
2
+ .env
3
+ .env.*
4
+ !.env.example
5
+ .pypirc
6
+
7
+ # Python bytecode
8
+ __pycache__/
9
+ *.py[cod]
10
+
11
+ # Virtual environments (uv)
12
+ .venv/
13
+ venv/
14
+
15
+ # Build artifacts (uv build / hatchling)
16
+ build/
17
+ dist/
18
+ *.egg-info/
19
+ *.whl
20
+
21
+ # Test, lint and type-check caches
22
+ .pytest_cache/
23
+ .hypothesis/
24
+ .mypy_cache/
25
+ .ruff_cache/
26
+ .import_linter_cache/
27
+ .coverage
28
+ .coverage.*
29
+ htmlcov/
30
+ coverage.xml
31
+
32
+ # Docs build (mkdocs)
33
+ /site/
34
+
35
+ # Editors and OS clutter
36
+ .idea/
37
+ .vscode/
38
+ .DS_Store
39
+ Thumbs.db
@@ -0,0 +1,86 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this
6
+ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Before 1.0,
7
+ minor releases may contain breaking changes.
8
+
9
+ ## [Unreleased]
10
+
11
+ ## [0.1.0] - 2026-10-02
12
+
13
+ First release. Studies: design, lock, fill and analyze end to end, run them from a
14
+ phone-friendly operator console or your own runtime, and share a self-contained report.
15
+
16
+ ### Added
17
+
18
+ - `study.yaml` schema with line-numbered validation errors, and three templates (`basic`,
19
+ `checkpoint-ladder`, `serving-sweep`).
20
+ - Randomized complete block schedules with Williams-balanced arm order and blind codes.
21
+ The schedule is identical on every platform and numpy version for a given seed.
22
+ - Locking and amendments: the design, its hash and the schedule are stored in a SQLite
23
+ database in the study folder; every change is one transaction plus one event-log row.
24
+ - Invalid trials are kept and rescheduled at the end of their block.
25
+ - A simulated runner and auto-operator, and CSV import (all or nothing, `--map`) and
26
+ CSV/JSONL export.
27
+ - The analysis engine: the primary analysis follows the locked design (McNemar with a Tango
28
+ interval, CMH, or Cochran's Q with Holm; a threshold test for single-arm studies), with
29
+ an independent Boschloo/Newcombe sensitivity analysis, stage funnels, time to success,
30
+ per-condition and per-session tables, drift and invalid-trial checks, deviations and
31
+ provenance. The `Results` model is versioned, and its JSON schema is published.
32
+ - Report wording from one tested template per situation, and a Markdown report.
33
+ - New statistics: stage distribution and funnel, Brunner–Munzel on stages, success-time
34
+ curve and bootstrap median time, CMH test, and homogeneity tests for drift.
35
+ - Commands `init`, `validate`, `plan`, `lock`, `amend`, `simulate`, `import`, `export`,
36
+ `status`, `unblind`, `analyze` and `report`.
37
+ - Documentation: "Running a study" and "Analysis and reports".
38
+ - The operator console (`fieldtrial serve`): start a session with the rig checklist, run
39
+ trials by blind code with a timer, label the furthest stage, termination and failure tags,
40
+ undo within 10 seconds, mark invalid trials, correct labels with a logged reason, a live
41
+ mirror screen, keyboard and foot-pedal keys, light and dark themes. `--lan` serves phones
42
+ on the local network behind an access token with a QR code.
43
+ - `fieldtrial demo`: a half-run simulated study in the console.
44
+ - REST API v1 with an OpenAPI document, Server-Sent Events, idempotency keys and optimistic
45
+ concurrency, and `fieldtrial.client`, a dependency-free Python client.
46
+ - Reports list label corrections made after unblinding as deviations.
47
+ - Documentation: "Operator console", "REST API and client" and a phone test checklist.
48
+ - A self-contained HTML report with seven charts (`fieldtrial report`, now the default
49
+ format, and in the console): no scripts and nothing loaded from other hosts.
50
+ - An example re-analysis of Dream Machines' published pi0.5 fine-tuning results.
51
+ - Documentation: quickstart, concepts, guides (planning, comparing checkpoints, ladders,
52
+ serving sweeps, LeRobot, openpi, custom runtimes), and screenshots.
53
+ - `CITATION.cff`.
54
+
55
+ ## [0.1.0rc1] - 2026-10-02
56
+
57
+ Release candidate of 0.1.0, published to PyPI for testing. Its changes are listed under
58
+ 0.1.0; the release is identical apart from this changelog.
59
+
60
+ ## [0.1.0a1] - 2026-10-01
61
+
62
+ First alpha: the statistics core and the calculator commands.
63
+
64
+ ### Added
65
+
66
+ - `fieldtrial.stats`, the statistics core (numpy and scipy only):
67
+ - one-arm intervals: Wilson (default), Clopper–Pearson, Jeffreys, Agresti–Coull, and an
68
+ exact binomial test against a threshold
69
+ - two independent arms: Newcombe difference CI, Boschloo exact test (primary), Fisher's
70
+ exact test and the conditional odds ratio
71
+ - paired designs: exact McNemar, Tango score CI, Cochran's Q with pairwise McNemar
72
+ - multiplicity adjustments: Holm, Bonferroni, Benjamini–Hochberg
73
+ - planning: sample size, power and minimum detectable effect (pooled-z, Fleiss
74
+ continuity-corrected, arcsine; unequal allocation), exact power for Boschloo and
75
+ McNemar, and a seeded simulation cross-check
76
+ - Bayesian summaries (descriptive only): P(p_B > p_A) and credible intervals
77
+ - Calculator commands `fieldtrial ci`, `compare`, `paired`, `power`, `mde` and `adjust`,
78
+ each with `--json` output.
79
+ - Documentation: a statistics reference page per method, a command-line page and the API
80
+ reference.
81
+ - Project skeleton: packaging, `fieldtrial --version`, CI and the documentation site.
82
+
83
+ [Unreleased]: https://github.com/rokbenko/fieldtrial/compare/v0.1.0...HEAD
84
+ [0.1.0]: https://github.com/rokbenko/fieldtrial/compare/v0.1.0a1...v0.1.0
85
+ [0.1.0rc1]: https://github.com/rokbenko/fieldtrial/compare/v0.1.0a1...v0.1.0rc1
86
+ [0.1.0a1]: https://github.com/rokbenko/fieldtrial/releases/tag/v0.1.0a1
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,182 @@
1
+ Metadata-Version: 2.5
2
+ Name: fieldtrial
3
+ Version: 0.1.0
4
+ Summary: Find out whether your robot policy actually got better: statistically rigorous real-world evaluation of robot policies.
5
+ Project-URL: Homepage, https://github.com/rokbenko/fieldtrial
6
+ Project-URL: Repository, https://github.com/rokbenko/fieldtrial
7
+ Project-URL: Issues, https://github.com/rokbenko/fieldtrial/issues
8
+ Project-URL: Changelog, https://github.com/rokbenko/fieldtrial/blob/main/CHANGELOG.md
9
+ Author: Rok Benko
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: confidence intervals,hypothesis testing,lerobot,policy evaluation,robot learning,robotics,statistics,vla
13
+ Classifier: Development Status :: 2 - Pre-Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Scientific/Engineering
23
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.11
27
+ Requires-Dist: alembic>=1.13
28
+ Requires-Dist: fastapi>=0.115
29
+ Requires-Dist: jinja2>=3.1
30
+ Requires-Dist: matplotlib>=3.8
31
+ Requires-Dist: numpy>=1.26
32
+ Requires-Dist: pydantic>=2.7
33
+ Requires-Dist: python-multipart>=0.0.9
34
+ Requires-Dist: pyyaml>=6.0
35
+ Requires-Dist: qrcode>=7.4
36
+ Requires-Dist: rich>=13.8
37
+ Requires-Dist: scipy>=1.13
38
+ Requires-Dist: sqlalchemy>=2.0.30
39
+ Requires-Dist: sse-starlette>=2.1
40
+ Requires-Dist: typer>=0.15
41
+ Requires-Dist: uvicorn[standard]>=0.30
42
+ Provides-Extra: dev
43
+ Requires-Dist: httpx>=0.28; extra == 'dev'
44
+ Requires-Dist: hypothesis>=6.130; extra == 'dev'
45
+ Requires-Dist: import-linter>=2.1; extra == 'dev'
46
+ Requires-Dist: mypy>=2.0; extra == 'dev'
47
+ Requires-Dist: pre-commit>=4.0; extra == 'dev'
48
+ Requires-Dist: pytest-cov>=6.0; extra == 'dev'
49
+ Requires-Dist: pytest>=8.3; extra == 'dev'
50
+ Requires-Dist: ruff>=0.16; extra == 'dev'
51
+ Requires-Dist: scipy-stubs>=1.15; extra == 'dev'
52
+ Requires-Dist: statsmodels>=0.14.4; extra == 'dev'
53
+ Requires-Dist: types-pyyaml>=6.0; extra == 'dev'
54
+ Provides-Extra: docs
55
+ Requires-Dist: mkdocs-material>=9.6; extra == 'docs'
56
+ Requires-Dist: mkdocs<2,>=1.6; extra == 'docs'
57
+ Requires-Dist: mkdocstrings[python]>=0.29; extra == 'docs'
58
+ Description-Content-Type: text/markdown
59
+
60
+ # fieldtrial
61
+
62
+ **Find out whether your robot policy actually got better.**
63
+
64
+ [![CI](https://github.com/rokbenko/fieldtrial/actions/workflows/ci.yml/badge.svg)](https://github.com/rokbenko/fieldtrial/actions/workflows/ci.yml)
65
+ [![PyPI](https://img.shields.io/pypi/v/fieldtrial.svg)](https://pypi.org/project/fieldtrial/)
66
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://github.com/rokbenko/fieldtrial/blob/main/LICENSE)
67
+
68
+ fieldtrial is an open-source Python framework for statistically rigorous, real-world
69
+ evaluation of robot policies. LeRobot trains the policy; fieldtrial tells you whether it
70
+ actually got better.
71
+
72
+ ## Why
73
+
74
+ Real-world evaluation is slow, noisy and ad hoc. With 40 rollouts, the 95% confidence
75
+ interval for a success rate is 12 to 15 percentage points wide on each side, so many apparent
76
+ improvements from a fine-tuning run are just noise. fieldtrial helps at every stage:
77
+
78
+ - **Before:** how many rollouts do I need? What is the smallest difference this
79
+ evaluation can detect?
80
+ - **During:** a randomized, blinded schedule, and a phone-friendly operator console that
81
+ records the outcome, the furthest stage reached and the failure mode of each rollout.
82
+ - **After:** the right statistics for the design (exact tests, paired analyses,
83
+ multiplicity control), honest wording, and a self-contained report.
84
+
85
+ ## 30-second demo
86
+
87
+ ```console
88
+ $ uvx fieldtrial compare 74/80 91/120
89
+ Arm 1: 74/80 = 92.5% (95% CI 84.6%–96.5%)
90
+ Arm 2: 91/120 = 75.8% (95% CI 67.4%–82.6%)
91
+ Difference +16.7 pp, Newcombe 95% CI [+6.2 pp, +26.0 pp]
92
+ Boschloo p = 0.0020 (two-sided); rejects H0 at α = 0.05
93
+ Fisher p = 0.0022
94
+
95
+ $ uvx fieldtrial power --p1 0.76 --p2 0.90 # rollouts needed to detect 76% → 90%
96
+ 112 per arm (pooled-z)
97
+
98
+ $ uvx fieldtrial demo # a simulated study in the console
99
+ ```
100
+
101
+ `fieldtrial demo` opens a half-run, blinded study with a simulated robot. Run the rest
102
+ from the keyboard (Space, Space, Enter), unblind, and read the report.
103
+
104
+ <p>
105
+ <img src="https://raw.githubusercontent.com/rokbenko/fieldtrial/main/docs/assets/console-running.png" alt="The operator console on a phone: a trial in progress with its blind code, timer and a large Stop button" width="260">
106
+ <img src="https://raw.githubusercontent.com/rokbenko/fieldtrial/main/docs/assets/console-label.png" alt="Labelling a trial: furthest stage reached, why it ended, failure tags" width="260">
107
+ </p>
108
+ <p>
109
+ <img src="https://raw.githubusercontent.com/rokbenko/fieldtrial/main/docs/assets/report.png" alt="The HTML report: summary, success rate per arm with confidence intervals, primary analysis and a forest plot" width="560">
110
+ </p>
111
+
112
+ <!-- A short GIF of a trial run in the console goes here. -->
113
+
114
+ ## Quickstart
115
+
116
+ ```console
117
+ $ uv tool install fieldtrial # or: pip install fieldtrial
118
+ $ fieldtrial init my-study # writes my-study/study.yaml
119
+ $ fieldtrial plan my-study --baseline 0.75
120
+ $ fieldtrial lock my-study # freezes the design and randomizes the schedule
121
+ $ fieldtrial serve my-study --lan # scan the QR code with a phone at the robot
122
+ $ fieldtrial unblind my-study
123
+ $ fieldtrial report my-study # my-study/reports/report.html
124
+ ```
125
+
126
+ A study is one folder: `study.yaml` (the design) and a SQLite database. Everything is
127
+ local and works offline; fieldtrial sends no telemetry.
128
+
129
+ - [Documentation](https://rokbenko.github.io/fieldtrial/): quickstart, concepts, guides
130
+ and a statistics reference.
131
+ - [Re-analysis of Dream Machines' published pi0.5 results](https://github.com/rokbenko/fieldtrial/tree/main/examples/dream-machines-pi05):
132
+ which of 30 published comparisons the data actually resolve.
133
+
134
+ ## What you get
135
+
136
+ - **Design:** randomized complete blocks with balanced arm order, blind codes, a design
137
+ hash, locking and logged amendments.
138
+ - **Console:** sessions with a rig checklist, a timer, stage and failure-tag labels,
139
+ 10-second undo, invalid trials with automatic rescheduling, a live mirror screen,
140
+ keyboard and foot-pedal keys, LAN access with a QR code.
141
+ - **Analysis:** the primary test follows from the locked design (exact McNemar with a
142
+ Tango interval, Cochran–Mantel–Haenszel, or Cochran's Q with Holm), plus an
143
+ independent-samples sensitivity analysis, stage funnels, time to success, drift checks
144
+ and a list of every deviation from the plan.
145
+ - **Reports:** self-contained HTML with charts, Markdown for pull requests, and a
146
+ versioned JSON results model.
147
+ - **Integration:** a REST API with a dependency-free Python client for custom runtimes,
148
+ CSV import and export, and `fieldtrial.stats` as a library.
149
+
150
+ Every statistical function is tested against an independent reference implementation.
151
+ Reports only describe a difference when the pre-registered test rejects; otherwise they
152
+ say what the study could have detected.
153
+
154
+ ## How it fits with LeRobot and openpi
155
+
156
+ fieldtrial complements LeRobot and openpi and never forks them. It is not a training
157
+ framework, a simulation benchmark, a robot driver, a labeling platform or a cloud
158
+ service. In manual mode, fieldtrial schedules and records the trials and you run the
159
+ robot however you like. Runners that launch LeRobot rollouts and route openpi traffic for
160
+ real blinding are planned for v0.2; see the
161
+ [roadmap](https://github.com/rokbenko/fieldtrial/blob/main/docs/ROADMAP.md).
162
+
163
+ ## How to cite
164
+
165
+ If fieldtrial helps your research, please cite it (see
166
+ [CITATION.cff](https://github.com/rokbenko/fieldtrial/blob/main/CITATION.cff)):
167
+
168
+ ```bibtex
169
+ @software{benko_fieldtrial,
170
+ author = {Benko, Rok},
171
+ title = {fieldtrial: statistically rigorous real-world evaluation for robot policies},
172
+ url = {https://github.com/rokbenko/fieldtrial},
173
+ license = {Apache-2.0}
174
+ }
175
+ ```
176
+
177
+ For evaluation practice in general, see Kress-Gazit et al. (2024), *Robot Learning as an
178
+ Empirical Science: Best Practices for Policy Evaluation*, arXiv:2409.09491.
179
+
180
+ ## Development
181
+
182
+ See [CONTRIBUTING.md](https://github.com/rokbenko/fieldtrial/blob/main/CONTRIBUTING.md).
@@ -0,0 +1,123 @@
1
+ # fieldtrial
2
+
3
+ **Find out whether your robot policy actually got better.**
4
+
5
+ [![CI](https://github.com/rokbenko/fieldtrial/actions/workflows/ci.yml/badge.svg)](https://github.com/rokbenko/fieldtrial/actions/workflows/ci.yml)
6
+ [![PyPI](https://img.shields.io/pypi/v/fieldtrial.svg)](https://pypi.org/project/fieldtrial/)
7
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://github.com/rokbenko/fieldtrial/blob/main/LICENSE)
8
+
9
+ fieldtrial is an open-source Python framework for statistically rigorous, real-world
10
+ evaluation of robot policies. LeRobot trains the policy; fieldtrial tells you whether it
11
+ actually got better.
12
+
13
+ ## Why
14
+
15
+ Real-world evaluation is slow, noisy and ad hoc. With 40 rollouts, the 95% confidence
16
+ interval for a success rate is 12 to 15 percentage points wide on each side, so many apparent
17
+ improvements from a fine-tuning run are just noise. fieldtrial helps at every stage:
18
+
19
+ - **Before:** how many rollouts do I need? What is the smallest difference this
20
+ evaluation can detect?
21
+ - **During:** a randomized, blinded schedule, and a phone-friendly operator console that
22
+ records the outcome, the furthest stage reached and the failure mode of each rollout.
23
+ - **After:** the right statistics for the design (exact tests, paired analyses,
24
+ multiplicity control), honest wording, and a self-contained report.
25
+
26
+ ## 30-second demo
27
+
28
+ ```console
29
+ $ uvx fieldtrial compare 74/80 91/120
30
+ Arm 1: 74/80 = 92.5% (95% CI 84.6%–96.5%)
31
+ Arm 2: 91/120 = 75.8% (95% CI 67.4%–82.6%)
32
+ Difference +16.7 pp, Newcombe 95% CI [+6.2 pp, +26.0 pp]
33
+ Boschloo p = 0.0020 (two-sided); rejects H0 at α = 0.05
34
+ Fisher p = 0.0022
35
+
36
+ $ uvx fieldtrial power --p1 0.76 --p2 0.90 # rollouts needed to detect 76% → 90%
37
+ 112 per arm (pooled-z)
38
+
39
+ $ uvx fieldtrial demo # a simulated study in the console
40
+ ```
41
+
42
+ `fieldtrial demo` opens a half-run, blinded study with a simulated robot. Run the rest
43
+ from the keyboard (Space, Space, Enter), unblind, and read the report.
44
+
45
+ <p>
46
+ <img src="https://raw.githubusercontent.com/rokbenko/fieldtrial/main/docs/assets/console-running.png" alt="The operator console on a phone: a trial in progress with its blind code, timer and a large Stop button" width="260">
47
+ <img src="https://raw.githubusercontent.com/rokbenko/fieldtrial/main/docs/assets/console-label.png" alt="Labelling a trial: furthest stage reached, why it ended, failure tags" width="260">
48
+ </p>
49
+ <p>
50
+ <img src="https://raw.githubusercontent.com/rokbenko/fieldtrial/main/docs/assets/report.png" alt="The HTML report: summary, success rate per arm with confidence intervals, primary analysis and a forest plot" width="560">
51
+ </p>
52
+
53
+ <!-- A short GIF of a trial run in the console goes here. -->
54
+
55
+ ## Quickstart
56
+
57
+ ```console
58
+ $ uv tool install fieldtrial # or: pip install fieldtrial
59
+ $ fieldtrial init my-study # writes my-study/study.yaml
60
+ $ fieldtrial plan my-study --baseline 0.75
61
+ $ fieldtrial lock my-study # freezes the design and randomizes the schedule
62
+ $ fieldtrial serve my-study --lan # scan the QR code with a phone at the robot
63
+ $ fieldtrial unblind my-study
64
+ $ fieldtrial report my-study # my-study/reports/report.html
65
+ ```
66
+
67
+ A study is one folder: `study.yaml` (the design) and a SQLite database. Everything is
68
+ local and works offline; fieldtrial sends no telemetry.
69
+
70
+ - [Documentation](https://rokbenko.github.io/fieldtrial/): quickstart, concepts, guides
71
+ and a statistics reference.
72
+ - [Re-analysis of Dream Machines' published pi0.5 results](https://github.com/rokbenko/fieldtrial/tree/main/examples/dream-machines-pi05):
73
+ which of 30 published comparisons the data actually resolve.
74
+
75
+ ## What you get
76
+
77
+ - **Design:** randomized complete blocks with balanced arm order, blind codes, a design
78
+ hash, locking and logged amendments.
79
+ - **Console:** sessions with a rig checklist, a timer, stage and failure-tag labels,
80
+ 10-second undo, invalid trials with automatic rescheduling, a live mirror screen,
81
+ keyboard and foot-pedal keys, LAN access with a QR code.
82
+ - **Analysis:** the primary test follows from the locked design (exact McNemar with a
83
+ Tango interval, Cochran–Mantel–Haenszel, or Cochran's Q with Holm), plus an
84
+ independent-samples sensitivity analysis, stage funnels, time to success, drift checks
85
+ and a list of every deviation from the plan.
86
+ - **Reports:** self-contained HTML with charts, Markdown for pull requests, and a
87
+ versioned JSON results model.
88
+ - **Integration:** a REST API with a dependency-free Python client for custom runtimes,
89
+ CSV import and export, and `fieldtrial.stats` as a library.
90
+
91
+ Every statistical function is tested against an independent reference implementation.
92
+ Reports only describe a difference when the pre-registered test rejects; otherwise they
93
+ say what the study could have detected.
94
+
95
+ ## How it fits with LeRobot and openpi
96
+
97
+ fieldtrial complements LeRobot and openpi and never forks them. It is not a training
98
+ framework, a simulation benchmark, a robot driver, a labeling platform or a cloud
99
+ service. In manual mode, fieldtrial schedules and records the trials and you run the
100
+ robot however you like. Runners that launch LeRobot rollouts and route openpi traffic for
101
+ real blinding are planned for v0.2; see the
102
+ [roadmap](https://github.com/rokbenko/fieldtrial/blob/main/docs/ROADMAP.md).
103
+
104
+ ## How to cite
105
+
106
+ If fieldtrial helps your research, please cite it (see
107
+ [CITATION.cff](https://github.com/rokbenko/fieldtrial/blob/main/CITATION.cff)):
108
+
109
+ ```bibtex
110
+ @software{benko_fieldtrial,
111
+ author = {Benko, Rok},
112
+ title = {fieldtrial: statistically rigorous real-world evaluation for robot policies},
113
+ url = {https://github.com/rokbenko/fieldtrial},
114
+ license = {Apache-2.0}
115
+ }
116
+ ```
117
+
118
+ For evaluation practice in general, see Kress-Gazit et al. (2024), *Robot Learning as an
119
+ Empirical Science: Best Practices for Policy Evaluation*, arXiv:2409.09491.
120
+
121
+ ## Development
122
+
123
+ See [CONTRIBUTING.md](https://github.com/rokbenko/fieldtrial/blob/main/CONTRIBUTING.md).