ab-analysis-kit 0.0.1.dev0__py3-none-any.whl
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.
- ab_analysis_kit-0.0.1.dev0.dist-info/METADATA +126 -0
- ab_analysis_kit-0.0.1.dev0.dist-info/RECORD +122 -0
- ab_analysis_kit-0.0.1.dev0.dist-info/WHEEL +5 -0
- ab_analysis_kit-0.0.1.dev0.dist-info/entry_points.txt +2 -0
- ab_analysis_kit-0.0.1.dev0.dist-info/licenses/LICENSE +21 -0
- ab_analysis_kit-0.0.1.dev0.dist-info/top_level.txt +1 -0
- abkit/__init__.py +40 -0
- abkit/cli/__init__.py +1 -0
- abkit/cli/_output.py +111 -0
- abkit/cli/commands/__init__.py +1 -0
- abkit/cli/commands/_context.py +83 -0
- abkit/cli/commands/clean.py +133 -0
- abkit/cli/commands/explore.py +208 -0
- abkit/cli/commands/init.py +427 -0
- abkit/cli/commands/run.py +282 -0
- abkit/cli/commands/unlock.py +59 -0
- abkit/cli/commands/validate.py +264 -0
- abkit/cli/main.py +279 -0
- abkit/compute/__init__.py +5 -0
- abkit/compute/recompute_backend.py +140 -0
- abkit/config/__init__.py +51 -0
- abkit/config/discovery.py +168 -0
- abkit/config/experiment_config.py +511 -0
- abkit/config/method_config.py +80 -0
- abkit/config/metric_config.py +214 -0
- abkit/config/profile.py +301 -0
- abkit/config/project_config.py +244 -0
- abkit/config/validator.py +393 -0
- abkit/core/__init__.py +26 -0
- abkit/core/interval.py +148 -0
- abkit/core/models.py +121 -0
- abkit/core/period_planner.py +206 -0
- abkit/database/__init__.py +51 -0
- abkit/database/_sql_manager.py +432 -0
- abkit/database/clickhouse_manager.py +495 -0
- abkit/database/internal_tables/__init__.py +6 -0
- abkit/database/internal_tables/_aa_runs.py +53 -0
- abkit/database/internal_tables/_base.py +71 -0
- abkit/database/internal_tables/_experiments.py +82 -0
- abkit/database/internal_tables/_exposures.py +163 -0
- abkit/database/internal_tables/_maintenance.py +72 -0
- abkit/database/internal_tables/_results.py +231 -0
- abkit/database/internal_tables/_schema.py +23 -0
- abkit/database/internal_tables/_tasks.py +237 -0
- abkit/database/internal_tables/_unit_state.py +148 -0
- abkit/database/internal_tables/manager.py +30 -0
- abkit/database/manager.py +450 -0
- abkit/database/mysql_manager.py +175 -0
- abkit/database/postgres_manager.py +145 -0
- abkit/database/tables.py +326 -0
- abkit/loaders/__init__.py +28 -0
- abkit/loaders/exposure_loader.py +121 -0
- abkit/loaders/metric_loader.py +251 -0
- abkit/loaders/query_template.py +167 -0
- abkit/loaders/templates/abkit_assignment.jinja +62 -0
- abkit/pipeline/__init__.py +37 -0
- abkit/pipeline/_types.py +52 -0
- abkit/pipeline/analyze.py +223 -0
- abkit/pipeline/driver.py +477 -0
- abkit/pipeline/enrich.py +137 -0
- abkit/pipeline/readout.py +779 -0
- abkit/reporting/__init__.py +19 -0
- abkit/reporting/assets/report.js +138 -0
- abkit/reporting/builder.py +484 -0
- abkit/reporting/calibration.py +182 -0
- abkit/reporting/html_report.py +109 -0
- abkit/stats/__init__.py +94 -0
- abkit/stats/accumulate.py +82 -0
- abkit/stats/base.py +347 -0
- abkit/stats/bootstrap/__init__.py +69 -0
- abkit/stats/bootstrap/applier.py +81 -0
- abkit/stats/bootstrap/bootstrap.py +311 -0
- abkit/stats/bootstrap/ci.py +72 -0
- abkit/stats/bootstrap/engine.py +383 -0
- abkit/stats/bootstrap/paired_bootstrap.py +57 -0
- abkit/stats/bootstrap/paired_post_normed_bootstrap.py +81 -0
- abkit/stats/bootstrap/poisson_bootstrap.py +112 -0
- abkit/stats/bootstrap/post_normed_bootstrap.py +102 -0
- abkit/stats/correction.py +88 -0
- abkit/stats/effects.py +141 -0
- abkit/stats/exceptions.py +31 -0
- abkit/stats/factory.py +26 -0
- abkit/stats/parametric/__init__.py +10 -0
- abkit/stats/parametric/cuped_ttest.py +183 -0
- abkit/stats/parametric/paired_cuped_ttest.py +125 -0
- abkit/stats/parametric/paired_ttest.py +136 -0
- abkit/stats/parametric/ratio_delta.py +113 -0
- abkit/stats/parametric/ttest.py +105 -0
- abkit/stats/parametric/ztest.py +134 -0
- abkit/stats/power.py +278 -0
- abkit/stats/registry.py +111 -0
- abkit/stats/result.py +84 -0
- abkit/stats/rng.py +39 -0
- abkit/stats/samples.py +531 -0
- abkit/stats/sequential/__init__.py +18 -0
- abkit/stats/sequential/apply.py +37 -0
- abkit/stats/sequential/confidence_sequence.py +96 -0
- abkit/stats/sequential/mixture.py +70 -0
- abkit/stats/srm.py +221 -0
- abkit/tuning/__init__.py +59 -0
- abkit/tuning/assets/explore.js +173 -0
- abkit/tuning/config_writer.py +409 -0
- abkit/tuning/html.py +88 -0
- abkit/tuning/payload.py +122 -0
- abkit/tuning/recompute.py +1039 -0
- abkit/tuning/server.py +882 -0
- abkit/tuning/session.py +233 -0
- abkit/utils/__init__.py +27 -0
- abkit/utils/datetime_utils.py +97 -0
- abkit/utils/env_interpolation.py +50 -0
- abkit/utils/json_utils.py +38 -0
- abkit/validate/__init__.py +36 -0
- abkit/validate/_types.py +35 -0
- abkit/validate/inject.py +75 -0
- abkit/validate/load.py +160 -0
- abkit/validate/panel.py +59 -0
- abkit/validate/persistence.py +59 -0
- abkit/validate/resample.py +94 -0
- abkit/validate/result.py +60 -0
- abkit/validate/run_id.py +45 -0
- abkit/validate/runner.py +389 -0
- abkit/validate/scoring.py +544 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ab-analysis-kit
|
|
3
|
+
Version: 0.0.1.dev0
|
|
4
|
+
Summary: A/B experiment analysis as declarative YAML + SQL
|
|
5
|
+
Author: ab-analysis-kit authors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://abkit.pipelab.dev
|
|
8
|
+
Project-URL: Documentation, https://abkit.pipelab.dev
|
|
9
|
+
Project-URL: Repository, https://github.com/alexeiveselov92/ab-analysis-kit
|
|
10
|
+
Project-URL: Changelog, https://github.com/alexeiveselov92/ab-analysis-kit/blob/main/CHANGELOG.md
|
|
11
|
+
Project-URL: Issues, https://github.com/alexeiveselov92/ab-analysis-kit/issues
|
|
12
|
+
Keywords: ab-testing,experimentation,statistics,cuped,bootstrap,causal-inference,clickhouse
|
|
13
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: numpy>=1.24.0
|
|
27
|
+
Requires-Dist: scipy>=1.10.0
|
|
28
|
+
Requires-Dist: statsmodels>=0.14.0
|
|
29
|
+
Requires-Dist: pydantic>=2.0.0
|
|
30
|
+
Requires-Dist: pyyaml>=6.0
|
|
31
|
+
Requires-Dist: click>=8.0
|
|
32
|
+
Requires-Dist: jinja2>=3.0
|
|
33
|
+
Requires-Dist: orjson>=3.0
|
|
34
|
+
Requires-Dist: requests>=2.25.0
|
|
35
|
+
Provides-Extra: clickhouse
|
|
36
|
+
Requires-Dist: clickhouse-driver>=0.2.0; extra == "clickhouse"
|
|
37
|
+
Provides-Extra: postgres
|
|
38
|
+
Requires-Dist: psycopg2-binary>=2.9.0; extra == "postgres"
|
|
39
|
+
Provides-Extra: mysql
|
|
40
|
+
Requires-Dist: pymysql>=1.0.0; extra == "mysql"
|
|
41
|
+
Provides-Extra: all-db
|
|
42
|
+
Requires-Dist: clickhouse-driver>=0.2.0; extra == "all-db"
|
|
43
|
+
Requires-Dist: psycopg2-binary>=2.9.0; extra == "all-db"
|
|
44
|
+
Requires-Dist: pymysql>=1.0.0; extra == "all-db"
|
|
45
|
+
Provides-Extra: orchestration
|
|
46
|
+
Requires-Dist: prefect>=2.0; extra == "orchestration"
|
|
47
|
+
Provides-Extra: all
|
|
48
|
+
Requires-Dist: clickhouse-driver>=0.2.0; extra == "all"
|
|
49
|
+
Requires-Dist: psycopg2-binary>=2.9.0; extra == "all"
|
|
50
|
+
Requires-Dist: pymysql>=1.0.0; extra == "all"
|
|
51
|
+
Requires-Dist: prefect>=2.0; extra == "all"
|
|
52
|
+
Provides-Extra: dev
|
|
53
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
54
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
55
|
+
Requires-Dist: pytest-mock>=3.0; extra == "dev"
|
|
56
|
+
Requires-Dist: requests-mock>=1.12; extra == "dev"
|
|
57
|
+
Requires-Dist: black>=23.0; extra == "dev"
|
|
58
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
59
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
60
|
+
Provides-Extra: integration
|
|
61
|
+
Requires-Dist: testcontainers[clickhouse,mysql,postgres]>=4.0; extra == "integration"
|
|
62
|
+
Requires-Dist: psycopg2-binary>=2.9.0; extra == "integration"
|
|
63
|
+
Requires-Dist: pymysql>=1.0.0; extra == "integration"
|
|
64
|
+
Dynamic: license-file
|
|
65
|
+
|
|
66
|
+
# ab-analysis-kit
|
|
67
|
+
|
|
68
|
+
**A/B experiment analysis as declarative YAML + SQL — with a chart-first cockpit.**
|
|
69
|
+
|
|
70
|
+
`ab-analysis-kit` (CLI `abk`) is an open-source, declarative
|
|
71
|
+
(dbt / [detectkit](https://dtk.pipelab.dev)-style), database-agnostic, numpy-first
|
|
72
|
+
Python library for analyzing A/B experiments. You define an **experiment** and its
|
|
73
|
+
**metrics** in YAML + SQL; abkit computes per-method effect + confidence interval +
|
|
74
|
+
p-value + MDE/power **cumulatively over the experiment's lifetime** (the
|
|
75
|
+
stabilization chart), writes them to a clean warehouse table any BI can read, and
|
|
76
|
+
gives you a local cockpit to tune the analysis and a harness to prove your method is
|
|
77
|
+
actually calibrated.
|
|
78
|
+
|
|
79
|
+
> **Status: pre-development.** This repo currently holds the **project-initiation
|
|
80
|
+
> specs** (the development contract). Start with the master plan (RU):
|
|
81
|
+
> [docs/ru/project-initiation-spec.md](docs/ru/project-initiation-spec.md), then the
|
|
82
|
+
> [specs index](docs/specs/00-overview.md).
|
|
83
|
+
|
|
84
|
+
## What it will do
|
|
85
|
+
|
|
86
|
+
- **Declarative experiments** — `experiments/*.yml` (assignment + variants +
|
|
87
|
+
comparisons) referencing a reusable `metrics/*.yml` library (YAML + SQL).
|
|
88
|
+
- **A rigorous statistical engine** — t-test, two-proportion z-test, CUPED, ratio
|
|
89
|
+
(delta-method), and a vectorised bootstrap family (plain/paired/Poisson/
|
|
90
|
+
post-normed), with relative & absolute effects, MDE/power, and multiple-testing
|
|
91
|
+
correction. Ported from a battle-tested legacy engine and improved deliberately.
|
|
92
|
+
- **The cumulative stabilization chart** — effect + CI per day from experiment
|
|
93
|
+
start, so you see the estimate converge and call a winner only once it stabilizes.
|
|
94
|
+
- **`abk explore`** — a local, chart-first cockpit to turn method knobs (CUPED,
|
|
95
|
+
stratification, alpha…) and watch the result recompute live, with A/A calibration
|
|
96
|
+
always in view. *The priority interface.*
|
|
97
|
+
- **`abk validate`** — an A/A false-positive + power matrix that measures your
|
|
98
|
+
method's **real** α (including the honest cumulative-peeking FPR), not the nominal.
|
|
99
|
+
- **BI-agnostic** — results land in one clean table; connect Grafana, Lightdash,
|
|
100
|
+
Metabase, or Superset. Orchestrate with **Prefect**.
|
|
101
|
+
- **AI-native** — `abk init-claude` sets up assistant context + skills so an
|
|
102
|
+
assistant can scaffold and tune experiments with (or for) you.
|
|
103
|
+
|
|
104
|
+
## Design at a glance
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
experiment (YAML) ──▶ load exposures ──▶ SRM gate ──▶ compute (t/z/CUPED/bootstrap) ──▶ readout
|
|
108
|
+
└ references reusable metrics (YAML + SQL) └ _ab_results → your BI
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
abkit is the sibling of detectkit: same DNA (CLI-first, db-agnostic, numpy-first,
|
|
112
|
+
self-contained reports, a chart-first cockpit, `init-claude`), with the anomaly
|
|
113
|
+
`detect` stage replaced by a statistical `compute` stage and the primary entity
|
|
114
|
+
flipped from *metric* to *experiment*.
|
|
115
|
+
|
|
116
|
+
## Documentation
|
|
117
|
+
|
|
118
|
+
- **Master plan (RU):** [docs/ru/project-initiation-spec.md](docs/ru/project-initiation-spec.md)
|
|
119
|
+
- **Specs index:** [docs/specs/00-overview.md](docs/specs/00-overview.md)
|
|
120
|
+
- **Architecture:** [docs/specs/architecture.md](docs/specs/architecture.md)
|
|
121
|
+
- **Roadmap:** [ROADMAP.md](ROADMAP.md) · **Principles:** [PRINCIPLES.md](PRINCIPLES.md)
|
|
122
|
+
- **Contributor guide:** [CLAUDE.md](CLAUDE.md)
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
MIT (planned).
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
ab_analysis_kit-0.0.1.dev0.dist-info/licenses/LICENSE,sha256=MoPfZOFu6PotcYusTt652uJwlDMgq-D9yqJN7xPfxK4,1080
|
|
2
|
+
abkit/__init__.py,sha256=afxqZQNjMRlmyTWozazHEmdGPPxVALXhFj2NwhQDyV8,1126
|
|
3
|
+
abkit/cli/__init__.py,sha256=_K0Na1paxbN05BFmcU9ftwJSYAE_asTuiQ9V1wcp748,50
|
|
4
|
+
abkit/cli/_output.py,sha256=h1aONnXxH9mpRByOr3Qvyc7AevjX9CZTGO784jYIxy4,4070
|
|
5
|
+
abkit/cli/main.py,sha256=4eii4fJTHyOLA8V4aNkpkwbzihuFkcZ_2Bb6Os8gj3k,8748
|
|
6
|
+
abkit/cli/commands/__init__.py,sha256=5e8U7C3LOIOw6IiDiuk2pppA8TYb2aKnjs1UO_ztV0E,79
|
|
7
|
+
abkit/cli/commands/_context.py,sha256=ulAr5kk1JMwLUjsYQPJbyWuCSZx3PtxyAOuVxpngzt4,2536
|
|
8
|
+
abkit/cli/commands/clean.py,sha256=A-G2R-pK8jK4oDA41nrjtp3SBqPvtaNfrl_AH70fYvA,4859
|
|
9
|
+
abkit/cli/commands/explore.py,sha256=gPpCBqC7NzwuDaaF-SibnHABf9JsER5McNKrWMeWGi8,8077
|
|
10
|
+
abkit/cli/commands/init.py,sha256=m1t3hw56ffwyXBtfcLO6LObqkuIX8ptS-cUdLhIlUH8,14523
|
|
11
|
+
abkit/cli/commands/run.py,sha256=nVXTozTgUlUZiyR74X97bnkQVFnloauWc0UQSJvDxNg,11056
|
|
12
|
+
abkit/cli/commands/unlock.py,sha256=TuX8ur4bAdty5lrFs6g-W3AsWxCz9TnZKX2wJ6l5au4,2180
|
|
13
|
+
abkit/cli/commands/validate.py,sha256=FHH9VvcZjRWi648vrm7jrPA1Pj0VwxnDmHwUFM6w5h0,10321
|
|
14
|
+
abkit/compute/__init__.py,sha256=6MDCX8iANl8_n53kwJjJchYVUOE9lUL6txFjaXgQSDo,202
|
|
15
|
+
abkit/compute/recompute_backend.py,sha256=XdgJOfRM4esyPvxCuzkkgdhGh7cJcpLUMZpEap72nSM,5516
|
|
16
|
+
abkit/config/__init__.py,sha256=OYq1du3I-ayKjQbb8vakkvYaMsEyJURTIm0JELZICxU,1358
|
|
17
|
+
abkit/config/discovery.py,sha256=XFlJyYctiqAlsjn5V9ysiJUdH-I_3ANpYeHM5a8ktSE,5599
|
|
18
|
+
abkit/config/experiment_config.py,sha256=bYblQTVbkrfpcHIVWYkhjWc9ynw3THelJdKPerUleGU,21412
|
|
19
|
+
abkit/config/method_config.py,sha256=K6uj2R4tDCPcIWD-ShbL4FaBrHSeZRw5QJROOxN-vGc,3285
|
|
20
|
+
abkit/config/metric_config.py,sha256=Qs-iZjYaSMAJcQi--T1N6ab1QznjruWCLj-GjiOQW9A,8463
|
|
21
|
+
abkit/config/profile.py,sha256=2eYjQaHIYtIQlT7VRN9jfECFZ-fZvXTGxBdxgvxbmwA,10374
|
|
22
|
+
abkit/config/project_config.py,sha256=CLJdit6723cHgfpTJAoy1egcvBp2-0Hxxxps8U5LT0g,8252
|
|
23
|
+
abkit/config/validator.py,sha256=3cMuqbKeB8bpmuMMfHC_nnUqAsxsdhdtV-maVppLh4Q,16376
|
|
24
|
+
abkit/core/__init__.py,sha256=VH5D2-9Hx4nVU8flyUOWkRwgdpJOQpTH77s7Uc8AlSg,569
|
|
25
|
+
abkit/core/interval.py,sha256=RXMZxJdKvOyCd4wllHw12K-xYOIc4HUooMnA0QDOOgo,4259
|
|
26
|
+
abkit/core/models.py,sha256=Wbrw0yWqzFziNmBMTAHtP5_witpd7TzEYsKJ09WtZUs,4218
|
|
27
|
+
abkit/core/period_planner.py,sha256=nACY2lhYieEzOMmFKNwl4sI8nmAmwC1dFxS2kpae1Do,8381
|
|
28
|
+
abkit/database/__init__.py,sha256=j_91HIo9yxzN_TeEPnHT74_wYqKR_G9oUxkXLoSaIdU,1554
|
|
29
|
+
abkit/database/_sql_manager.py,sha256=6_S-PKpltCxImIQDT8K4vjeRM0k_Wy8XipdgWRZcz4o,17689
|
|
30
|
+
abkit/database/clickhouse_manager.py,sha256=qJuG0orVTcvdiN2naTOFZqyJpr7bkNjeXonkSsUV41U,17719
|
|
31
|
+
abkit/database/manager.py,sha256=jFGSpxPBiAcespZFu5eUJiZ5df_DHbBTOBH2m-kIeRc,15921
|
|
32
|
+
abkit/database/mysql_manager.py,sha256=pR21-s8OJd1WxaRsv_vE4_2EXrNhCShTfPrnKcymzi0,6920
|
|
33
|
+
abkit/database/postgres_manager.py,sha256=J8QE0kiU4HYNFvO9on-kWF1MweVIvGy-NuY3LouIrEE,5248
|
|
34
|
+
abkit/database/tables.py,sha256=-nh2n87g3zpOMCeCcto4RbMFivBqioYqBPJq_4IbDAc,17586
|
|
35
|
+
abkit/database/internal_tables/__init__.py,sha256=PgHxlS_sdAya77YZRKLjvyBe3NR79ZGspgF9i1Rkj20,267
|
|
36
|
+
abkit/database/internal_tables/_aa_runs.py,sha256=a5xOQMAGQxpdNe1YEladv_mjve-AHZk4caHew76nN6Q,2304
|
|
37
|
+
abkit/database/internal_tables/_base.py,sha256=qmTm3To44jTI5mqlVqTWRokpHfk6Y1WW9AmxChBQ-H4,3076
|
|
38
|
+
abkit/database/internal_tables/_experiments.py,sha256=E_V8bclN3RI-jyetE_azK5WwDXErpGmfrY9cjsVBWtY,3157
|
|
39
|
+
abkit/database/internal_tables/_exposures.py,sha256=NLBSZCyB2DtGks_SsNSIvMfVindPpFxIiDEWqFGZsi0,7482
|
|
40
|
+
abkit/database/internal_tables/_maintenance.py,sha256=vqh7QiDX0V4iQ4XLIqd1Tvl-8zyEQp1YvvbrzvMZP2k,3102
|
|
41
|
+
abkit/database/internal_tables/_results.py,sha256=0xZXZQ9KZif_Z8De83pDR1wN0QUhJfFGjTrfrUePlDQ,9902
|
|
42
|
+
abkit/database/internal_tables/_schema.py,sha256=WwvYy4Rj2T9qL338a3XqR3cQmg9-8yJ5J8HxINGmJYQ,1155
|
|
43
|
+
abkit/database/internal_tables/_tasks.py,sha256=XTgD2VpEPdGT6A2Z3rjn3rd6DhXL0D0nmROn7-TTmjY,9220
|
|
44
|
+
abkit/database/internal_tables/_unit_state.py,sha256=VgSS8ruouADK4UUNTnmsJJeYM9Groh8o-paKw_nyACQ,6230
|
|
45
|
+
abkit/database/internal_tables/manager.py,sha256=0gh8A3inqAeVTsQMmC6Zll5g0ufxp-soD75YVR6ZwnY,1148
|
|
46
|
+
abkit/loaders/__init__.py,sha256=bX6nSfLMtbvKL3T_5va2XuUYcSRbdMENgjts51-8ihM,678
|
|
47
|
+
abkit/loaders/exposure_loader.py,sha256=o5Hh4fDCScKOyEKCT_InRKYQLhMR7xe5ECpViPXWW-8,4879
|
|
48
|
+
abkit/loaders/metric_loader.py,sha256=5m24vp6sBqpLeXTl3_-CjcBNmwc5jlLi_r4F-m9Qjaw,10051
|
|
49
|
+
abkit/loaders/query_template.py,sha256=3EAMFiolWXleNqIpLXwrj6IQyWttZzXz02168ROAHoc,5941
|
|
50
|
+
abkit/loaders/templates/abkit_assignment.jinja,sha256=BDZouY1j1x-I3TQu6i2ldv6PizqbCfxlQ50q0Q6Pt44,2743
|
|
51
|
+
abkit/pipeline/__init__.py,sha256=TD0erKcAbjMFVBNnn7l9rGAK1Dq-u02mJ_5qJr1xK3U,908
|
|
52
|
+
abkit/pipeline/_types.py,sha256=yL4VNYQZpFeF1QGX29Wwm2HrUqbpKv7dapoHiG7xS3k,1488
|
|
53
|
+
abkit/pipeline/analyze.py,sha256=xFRdYcQzF6Twe3p7ELQ-7oLeu2rUqyzC0-7-rSmq1Ko,8372
|
|
54
|
+
abkit/pipeline/driver.py,sha256=5CSQayTwgGYG0LQRPj_2Ut0VLvgVmYWKfrrgQmDF1ns,21574
|
|
55
|
+
abkit/pipeline/enrich.py,sha256=MVjz8Cty1aheIDgPYB9Qt4fUhd1dv7M_4O75hWcYAyQ,5976
|
|
56
|
+
abkit/pipeline/readout.py,sha256=5jxbmHAvuHiU8Qv1Uernd2x12m_YqtzU_Sp4iUrG-Mc,33391
|
|
57
|
+
abkit/reporting/__init__.py,sha256=HkALbNQKP3yInc-HQd6kCoO6oPfQGy6XF32sUboRsk8,529
|
|
58
|
+
abkit/reporting/builder.py,sha256=_N1AC8xBX4XSSreTaLFIR0ZUCgtxwOmSYeq5da3ogpg,21011
|
|
59
|
+
abkit/reporting/calibration.py,sha256=GIsVpEzcLDrNmLTlKyaBCDGpSzNIWyi2rtWeGh0Qveg,7542
|
|
60
|
+
abkit/reporting/html_report.py,sha256=9qetelNF1UbuvVFXlDafjoryhthqFuufwHiklkwHMQI,4544
|
|
61
|
+
abkit/reporting/assets/report.js,sha256=wAceGgtmZD0XkZ03EVvyCZzenBYmukjqmb6NI-41hZE,35476
|
|
62
|
+
abkit/stats/__init__.py,sha256=Y0yqzdqbC0ycCccui1DpvkRPfUk-ckQCfveC_xBI7IY,2548
|
|
63
|
+
abkit/stats/accumulate.py,sha256=o-tmaH7LtyjEa1LWCkXjJg4DR3NV2CKzQPB0Ps8s25o,3281
|
|
64
|
+
abkit/stats/base.py,sha256=wJ4nol4E5F1Ljc-oB2SgPlrlb1WQprU1XO36qR__A2M,14279
|
|
65
|
+
abkit/stats/correction.py,sha256=qqpfIUpdyZv3S395uWYklbALK5_zAwEziy4TQAR79MQ,3453
|
|
66
|
+
abkit/stats/effects.py,sha256=F5OnArC3q7ddjV_yK74bZRQTwaPjW0_3RkeHJYTH824,5173
|
|
67
|
+
abkit/stats/exceptions.py,sha256=fSVjZU6Pij-kDHEks0F-fB_YLsxjGaiVgAg0BMeRvzw,924
|
|
68
|
+
abkit/stats/factory.py,sha256=5-4i1SjIED9eqGh7SQh7FGTQnSR3QBTRq-XZN9AKKic,924
|
|
69
|
+
abkit/stats/power.py,sha256=WnGG6u52oL9ZCCY1dZHlrLD6o-yvj8qAY41YdpQfp1I,8578
|
|
70
|
+
abkit/stats/registry.py,sha256=jXvJw5L_znL4OJjAgxg67yTiAEI1CHOgYmHLt3DILwg,4617
|
|
71
|
+
abkit/stats/result.py,sha256=6Xg_F7X9iRzqQoUEFRlhYezr2s0kQP8boQ5VC_uNFB8,3132
|
|
72
|
+
abkit/stats/rng.py,sha256=57rOWal0BfUid7GSfPZR3AmK0Lzqgjm0qlYdlWev6cw,1634
|
|
73
|
+
abkit/stats/samples.py,sha256=AVvd15f_39ZLIFeC38Ixj97AJFDC6ogeiC6gXuAxOic,21284
|
|
74
|
+
abkit/stats/srm.py,sha256=m2NhzahNZPMZV-dNHly1CwE95tk_D2eRX-6PKxdXcZM,10081
|
|
75
|
+
abkit/stats/bootstrap/__init__.py,sha256=XBn1VZgjRs9IaP5M_HxSx_c37i9J9-63k6GZweGTvs4,1902
|
|
76
|
+
abkit/stats/bootstrap/applier.py,sha256=4KqT3rzku7bAIOdFSgbunoFyll5-Cr52NmWuX8pO5FU,3472
|
|
77
|
+
abkit/stats/bootstrap/bootstrap.py,sha256=4Tc4ZKUyCuaUkGNBa7bPFnUQUg3wykdX5eu4wH6LoNM,13427
|
|
78
|
+
abkit/stats/bootstrap/ci.py,sha256=hhIkHWy7IfILLwbNLjKD50YP8U0qIQaKrtM7W3YMmRA,3157
|
|
79
|
+
abkit/stats/bootstrap/engine.py,sha256=eP6WDGyhlkKnZ3H422sJv5vAKSoD6LP2Mfo6JSp9cWw,17677
|
|
80
|
+
abkit/stats/bootstrap/paired_bootstrap.py,sha256=je8bRUlhSQVsBEOm-dMWTpWCDab259TzxaqWYmDYkUA,2319
|
|
81
|
+
abkit/stats/bootstrap/paired_post_normed_bootstrap.py,sha256=aRjTNm33rcCuNLIqjxkAYkBk9alwG0K6Ab0Qd_B35Xk,3744
|
|
82
|
+
abkit/stats/bootstrap/poisson_bootstrap.py,sha256=8bt8Ul-toMyRtLGD5f-50vWEMAxyqk9bSpuF4udvNv0,4812
|
|
83
|
+
abkit/stats/bootstrap/post_normed_bootstrap.py,sha256=w-yA150ydd6E_EqoAsP6XRbIrUwnpdTyH5ole6Is93o,4508
|
|
84
|
+
abkit/stats/parametric/__init__.py,sha256=c6MUoyILMPqlqw0_DIwQkqUbvtOkAxBHzYGu6D9qn6g,511
|
|
85
|
+
abkit/stats/parametric/cuped_ttest.py,sha256=mt0Z7EQ5vA6mzmGiEY88OMb98GeJqHTMcpReURnDtno,7544
|
|
86
|
+
abkit/stats/parametric/paired_cuped_ttest.py,sha256=xAScR5lz_mME2RLj-JNg4h0eALtVJhQBvd41GdwRYqo,5615
|
|
87
|
+
abkit/stats/parametric/paired_ttest.py,sha256=FkOhiB-KKW_2Fhhd1G0qMq1oXuehu7EF0mHH22UcHrA,6158
|
|
88
|
+
abkit/stats/parametric/ratio_delta.py,sha256=w9RIx-HZ_wDCzlyRieQMsStWm0VnJxb_HZ59ebxyuOc,4675
|
|
89
|
+
abkit/stats/parametric/ttest.py,sha256=8WZnK25elUwgKxQcjkpUp33diwmzvCvLkWzmGAnCcIo,3866
|
|
90
|
+
abkit/stats/parametric/ztest.py,sha256=KYpbLs-zNW-C5rIJh5GwlQXtjZoANk0tR0qi8NPt4QM,5139
|
|
91
|
+
abkit/stats/sequential/__init__.py,sha256=vvbCZD2pCFHwCVoB1e4eWl1tXbUSPEvBMR_9giN6tGg,848
|
|
92
|
+
abkit/stats/sequential/apply.py,sha256=rpK5pAt3HKXrwfJXo5N2NBq_iwSGTU0XmAo75Ed8X5k,1609
|
|
93
|
+
abkit/stats/sequential/confidence_sequence.py,sha256=MurMVK1ba3yfjbXj7cHa4OOdookcGNvyKCU_YJ_HlPA,4721
|
|
94
|
+
abkit/stats/sequential/mixture.py,sha256=kiCnpByW9elR5u5FY_d3oxyM3UolFwJJ6NQLRl7ZURM,3773
|
|
95
|
+
abkit/tuning/__init__.py,sha256=vyYKNa9_lTGXGsacId2FKE8kmFHxuW67BypL0CwWs1w,1570
|
|
96
|
+
abkit/tuning/config_writer.py,sha256=y_1XO_p2vTwJUTMZ3w-5Gekii52P_MNPjot5A0ei4uM,16514
|
|
97
|
+
abkit/tuning/html.py,sha256=If_yTGJzIVAj1L758y1arTw1gcRU-gMtSGeeyzh0QLc,3329
|
|
98
|
+
abkit/tuning/payload.py,sha256=6FbcTRsdvkqvJj22FPfS8ip2Y5UsIbHSk04mZb6j5u8,4936
|
|
99
|
+
abkit/tuning/recompute.py,sha256=PdxogyLzR8IxRB2UEU0zH04JBN_TdkVXxFinGzPn8pM,43470
|
|
100
|
+
abkit/tuning/server.py,sha256=JM7Y5DLMBocvtMrDMarXMGqT_lRCWhXpRdenwwDg3ec,38094
|
|
101
|
+
abkit/tuning/session.py,sha256=84OrTKBmI-5BJwRh6n8dgf1Ckyz0za_18sRtgUYbhXs,9813
|
|
102
|
+
abkit/tuning/assets/explore.js,sha256=xYvKL2nRT648XEzbaVYYAxcKXVNDKMYPlD4ucaqMnVM,56268
|
|
103
|
+
abkit/utils/__init__.py,sha256=kP1JYtKIqmH3XfiR380q_UgAPQBqFt5AqBnXmuJY-C8,703
|
|
104
|
+
abkit/utils/datetime_utils.py,sha256=8y0u51538LF3bYbNWdZqLvF1MZKTcxrNY28ss5I-IbA,3100
|
|
105
|
+
abkit/utils/env_interpolation.py,sha256=uIj7bKBA4dK1L02qw1fZxeWE636-JJsC9bvBj7WXuqI,1537
|
|
106
|
+
abkit/utils/json_utils.py,sha256=I9C1RG-fqao1w3BEeG_6WonsjgwiLVjLDLaeKjEBDWY,1368
|
|
107
|
+
abkit/validate/__init__.py,sha256=D-VEd-VJ51VQx2vfvWGssct32AnhnYnkZhOK3fD5sBI,1408
|
|
108
|
+
abkit/validate/_types.py,sha256=vWQ7OzRAADhkO6hh8Lz80QlsN51J0gk6hb93GNNBwDI,1184
|
|
109
|
+
abkit/validate/inject.py,sha256=CTftjEUEfatLpUCD4tPTJPeyLzBrTlLpInSFF7ouk7Y,3223
|
|
110
|
+
abkit/validate/load.py,sha256=dnbwP_sXxOZq7QOCM3CHYlysvugzNHkuuI0zX4basy4,6662
|
|
111
|
+
abkit/validate/panel.py,sha256=Jn2b52UbUG4W1EjsxCthzuLTVbC3Q9vBLwWOZG8wD6o,2367
|
|
112
|
+
abkit/validate/persistence.py,sha256=hcnuoqtV5IGD5SWQT-yfajYFllckFMQVGwTDBwvdPgY,2536
|
|
113
|
+
abkit/validate/resample.py,sha256=TZm3DpgRXUICfsxywonPmCGFk0A5_NNzg6QDzBdwdT8,3957
|
|
114
|
+
abkit/validate/result.py,sha256=V5wPJOym7Fms_xrIean8QoFfqiblaRhrY0kIXT9b6yY,2165
|
|
115
|
+
abkit/validate/run_id.py,sha256=YI3MvlkK0Ydn5dwVlO3LcTVD9_UTJm5nwrHMckGwxMg,1880
|
|
116
|
+
abkit/validate/runner.py,sha256=5Xh_sBSlbRwgGmAyIoABL6MBaYdtVrxp7cl0rrkY5v4,15257
|
|
117
|
+
abkit/validate/scoring.py,sha256=IiAWZpV7vjoPLDllO9g3ruRZelh3b9WRh63HxEghW0Y,26178
|
|
118
|
+
ab_analysis_kit-0.0.1.dev0.dist-info/METADATA,sha256=s38S5KCCOnMjjVcmWUsyWWjHRpJ9OIgYSLmbbVzJE0c,6069
|
|
119
|
+
ab_analysis_kit-0.0.1.dev0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
120
|
+
ab_analysis_kit-0.0.1.dev0.dist-info/entry_points.txt,sha256=JtKWYsIRANc6zL9L_BTJDoQDUS0VlOuff6mxgtaGQAk,43
|
|
121
|
+
ab_analysis_kit-0.0.1.dev0.dist-info/top_level.txt,sha256=QvYmg3WsNmBbqGs35CKlrs9lNLcmLK2XC2vtli1lypI,6
|
|
122
|
+
ab_analysis_kit-0.0.1.dev0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ab-analysis-kit authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
abkit
|
abkit/__init__.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""ab-analysis-kit — A/B experiment analysis as declarative YAML + SQL.
|
|
2
|
+
|
|
3
|
+
``abkit.stats`` (the pure numpy-first statistical core) is available and
|
|
4
|
+
re-exported lazily below; the declarative config, DB layer, pipeline and the
|
|
5
|
+
full CLI arrive per ``ROADMAP.md``. ``__version__`` is the single source of
|
|
6
|
+
truth for the CLI and the ``abk init-claude`` version stamp.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
__version__ = "0.0.1.dev0"
|
|
14
|
+
|
|
15
|
+
#: Symbols re-exported lazily from ``abkit.stats`` (PEP 562) so importing
|
|
16
|
+
#: ``abkit`` for ``__version__`` (the CLI path) stays numpy-free and fast.
|
|
17
|
+
_STATS_EXPORTS = frozenset(
|
|
18
|
+
{
|
|
19
|
+
"BaseMethod",
|
|
20
|
+
"Fraction",
|
|
21
|
+
"RatioSample",
|
|
22
|
+
"Sample",
|
|
23
|
+
"SufficientStats",
|
|
24
|
+
"TestResult",
|
|
25
|
+
"available_methods",
|
|
26
|
+
"create_method",
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def __getattr__(name: str) -> Any:
|
|
32
|
+
if name in _STATS_EXPORTS:
|
|
33
|
+
import abkit.stats
|
|
34
|
+
|
|
35
|
+
return getattr(abkit.stats, name)
|
|
36
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def __dir__() -> list[str]:
|
|
40
|
+
return sorted(set(globals()) | _STATS_EXPORTS)
|
abkit/cli/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""The ``abk`` command-line interface package."""
|
abkit/cli/_output.py
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""Shared CLI output helpers so every command renders in one house style.
|
|
2
|
+
|
|
3
|
+
Mirrors the validate → plan → load → srm → compute → result pipeline's tree
|
|
4
|
+
look (``┌─ / │ / └─``) used by ``abk run`` so the maintenance commands
|
|
5
|
+
(``abk clean``, ``abk unlock``) match it instead of each inventing its own
|
|
6
|
+
formatting.
|
|
7
|
+
|
|
8
|
+
House conventions:
|
|
9
|
+
- An experiment *with* something to report is a tree: a cyan-bold ``┌─ <name>``
|
|
10
|
+
header followed by one child line per item (``│ `` for all but the last,
|
|
11
|
+
``└─ `` for the last).
|
|
12
|
+
- An experiment with *nothing* to do is a single ``•`` line.
|
|
13
|
+
- A per-experiment error is a red ``✗`` line (to stderr).
|
|
14
|
+
- The final summary is a cyan-bold ``Done. …`` line.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from collections.abc import Callable
|
|
20
|
+
|
|
21
|
+
import click
|
|
22
|
+
|
|
23
|
+
# Pipeline stage name → display title for the streamed run-log tree
|
|
24
|
+
# (architecture.md §5 stage order).
|
|
25
|
+
RUN_STAGE_TITLES = {
|
|
26
|
+
"validate": "VALIDATE",
|
|
27
|
+
"plan": "PLAN",
|
|
28
|
+
"load": "LOAD",
|
|
29
|
+
"srm": "SRM",
|
|
30
|
+
"compute": "COMPUTE",
|
|
31
|
+
"result": "RESULT",
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def echo_block(
|
|
36
|
+
title: str,
|
|
37
|
+
children: list[str],
|
|
38
|
+
*,
|
|
39
|
+
warnings: list[str] | None = None,
|
|
40
|
+
echo: Callable[[str], None] = click.echo,
|
|
41
|
+
) -> None:
|
|
42
|
+
"""Print a cyan-bold ``┌─ title`` header with ``│``/``└─`` child lines.
|
|
43
|
+
|
|
44
|
+
The injectable core of the house tree style: ``warnings`` render as yellow
|
|
45
|
+
``│`` continuation lines above the children, the last child gets the
|
|
46
|
+
``└─`` elbow. ``echo`` defaults to ``click.echo`` but can be any line sink
|
|
47
|
+
(the explore server reuses these blocks in M3). ``children`` must be
|
|
48
|
+
non-empty.
|
|
49
|
+
"""
|
|
50
|
+
echo(click.style(f" ┌─ {title}", fg="cyan", bold=True))
|
|
51
|
+
for warning in warnings or []:
|
|
52
|
+
echo(click.style(f" │ ⚠ {warning}", fg="yellow", bold=True))
|
|
53
|
+
last = len(children) - 1
|
|
54
|
+
for i, child in enumerate(children):
|
|
55
|
+
prefix = " └─ " if i == last else " │ "
|
|
56
|
+
echo(f"{prefix}{child}")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def echo_tree(name: str, children: list[str], *, warnings: list[str] | None = None) -> None:
|
|
60
|
+
"""Print a ``┌─ name`` header with ``│``/``└─`` child lines."""
|
|
61
|
+
echo_block(name, children, warnings=warnings)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class StageLogRenderer:
|
|
65
|
+
"""Stream ``(stage, line)`` pipeline progress as the run-log tree.
|
|
66
|
+
|
|
67
|
+
Opens a cyan-bold ``┌─ TITLE`` header the first time each stage appears and
|
|
68
|
+
prints every subsequent line for that stage as a ``│ `` child. ``titles``
|
|
69
|
+
maps a stage name to its display title (unmapped names fall back to
|
|
70
|
+
``upper()``); ``echo`` is injectable so one renderer drives both the CLI
|
|
71
|
+
and the M3 explore server. Build a fresh renderer per run so the first
|
|
72
|
+
stage re-opens its header.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
def __init__(
|
|
76
|
+
self,
|
|
77
|
+
*,
|
|
78
|
+
titles: dict[str, str] | None = None,
|
|
79
|
+
echo: Callable[[str], None] = click.echo,
|
|
80
|
+
) -> None:
|
|
81
|
+
self._open: str | None = None
|
|
82
|
+
self._titles = titles or RUN_STAGE_TITLES
|
|
83
|
+
self._echo = echo
|
|
84
|
+
|
|
85
|
+
def __call__(self, stage: str, line: str) -> None:
|
|
86
|
+
if self._open != stage:
|
|
87
|
+
title = self._titles.get(stage, stage.upper())
|
|
88
|
+
self._echo(click.style(f" ┌─ {title}", fg="cyan", bold=True))
|
|
89
|
+
self._open = stage
|
|
90
|
+
self._echo(f" │ {line}")
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def echo_noop(name: str, reason: str) -> None:
|
|
94
|
+
"""An experiment with nothing to do — a single ``•`` line."""
|
|
95
|
+
click.echo(f" • {name}: {reason}")
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def echo_error(name: str, message: str) -> None:
|
|
99
|
+
"""A per-experiment failure — a red ``✗`` line on stderr."""
|
|
100
|
+
click.echo(click.style(f" ✗ {name}: {message}", fg="red"), err=True)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def echo_srm(message: str) -> None:
|
|
104
|
+
"""The loud red SRM gate line (data-contract-and-reporting.md §6)."""
|
|
105
|
+
click.echo(click.style(f" ✗ {message}", fg="red", bold=True), err=True)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def echo_done(summary: str) -> None:
|
|
109
|
+
"""The closing ``Done. …`` summary (cyan, bold), preceded by a blank line."""
|
|
110
|
+
click.echo()
|
|
111
|
+
click.echo(click.style(f"Done. {summary}", fg="cyan", bold=True))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""``abk`` command implementations (lazily imported by ``abkit.cli.main``)."""
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""Shared command bootstrap: project root, configs, profiles, manager.
|
|
2
|
+
|
|
3
|
+
Every failure raises :class:`click.ClickException` so commands exit NON-ZERO —
|
|
4
|
+
a documented deviation from the detectkit donor (which echoed and returned 0):
|
|
5
|
+
the CLI is the Prefect unit of automation (cli-and-dx.md §3), and a scheduler
|
|
6
|
+
must see failures.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
import click
|
|
15
|
+
|
|
16
|
+
from abkit.config import (
|
|
17
|
+
ExperimentConfig,
|
|
18
|
+
MetricConfig,
|
|
19
|
+
ProfilesConfig,
|
|
20
|
+
ProjectConfig,
|
|
21
|
+
find_project_root,
|
|
22
|
+
validate_project_configs,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass
|
|
27
|
+
class ProjectContext:
|
|
28
|
+
root: Path
|
|
29
|
+
project: ProjectConfig
|
|
30
|
+
profiles: ProfilesConfig
|
|
31
|
+
experiments: list[tuple[Path, ExperimentConfig]]
|
|
32
|
+
metrics: list[tuple[Path, MetricConfig]]
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def metrics_by_name(self) -> dict[str, MetricConfig]:
|
|
36
|
+
return {config.name: config for _, config in self.metrics}
|
|
37
|
+
|
|
38
|
+
def manager_factory(self, profile: str | None):
|
|
39
|
+
"""One manager per call (worker threads need their own connections)."""
|
|
40
|
+
profiles = self.profiles
|
|
41
|
+
|
|
42
|
+
def factory():
|
|
43
|
+
return profiles.create_manager(profile)
|
|
44
|
+
|
|
45
|
+
return factory
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def load_project_context(require_profiles: bool = True) -> ProjectContext:
|
|
49
|
+
"""Resolve the project root and parse every config (level-1 fail-fast)."""
|
|
50
|
+
root = find_project_root()
|
|
51
|
+
if root is None:
|
|
52
|
+
raise click.ClickException(
|
|
53
|
+
"not inside an abkit project (no abkit_project.yml found up the tree). "
|
|
54
|
+
"Run `abk init <name>` to create one."
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
project = ProjectConfig.from_yaml_file(root / "abkit_project.yml")
|
|
59
|
+
except Exception as exc:
|
|
60
|
+
raise click.ClickException(f"abkit_project.yml: {exc}") from exc
|
|
61
|
+
|
|
62
|
+
profiles = None
|
|
63
|
+
profiles_path = root / "profiles.yml"
|
|
64
|
+
if profiles_path.exists():
|
|
65
|
+
try:
|
|
66
|
+
profiles = ProfilesConfig.from_yaml(profiles_path)
|
|
67
|
+
except Exception as exc:
|
|
68
|
+
raise click.ClickException(f"profiles.yml: {exc}") from exc
|
|
69
|
+
elif require_profiles:
|
|
70
|
+
raise click.ClickException(f"profiles.yml not found (expected at {profiles_path})")
|
|
71
|
+
|
|
72
|
+
try:
|
|
73
|
+
experiments, metrics = validate_project_configs(root, project)
|
|
74
|
+
except (ValueError, FileNotFoundError) as exc:
|
|
75
|
+
raise click.ClickException(str(exc)) from exc
|
|
76
|
+
|
|
77
|
+
return ProjectContext(
|
|
78
|
+
root=root,
|
|
79
|
+
project=project,
|
|
80
|
+
profiles=profiles,
|
|
81
|
+
experiments=experiments,
|
|
82
|
+
metrics=metrics,
|
|
83
|
+
)
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""Implementation of ``abk clean`` — config-hash drift GC.
|
|
2
|
+
|
|
3
|
+
Editing identity-bearing method params orphans the prior ``_ab_results``
|
|
4
|
+
series (a new ``method_config_id``); the BI chart would show duplicate
|
|
5
|
+
stabilization lines. This command diffs what is STORED against what the
|
|
6
|
+
current YAML produces — computed through the SAME ``MethodConfig`` path the
|
|
7
|
+
pipeline stamps rows with, so the valid set can never drift — and prunes the
|
|
8
|
+
orphans. ``--orphaned-experiments`` purges experiments whose YAML no longer
|
|
9
|
+
exists. DRY-RUN by default; ``--execute`` (+ ``--yes`` to skip the prompt)
|
|
10
|
+
applies.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import click
|
|
16
|
+
|
|
17
|
+
from abkit.cli._output import echo_done, echo_error, echo_noop, echo_tree
|
|
18
|
+
from abkit.cli.commands._context import ProjectContext, load_project_context
|
|
19
|
+
from abkit.config import select_experiments
|
|
20
|
+
from abkit.database.internal_tables import InternalTablesManager
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _clean_drift(
|
|
24
|
+
context: ProjectContext,
|
|
25
|
+
tables: InternalTablesManager,
|
|
26
|
+
select: tuple[str, ...],
|
|
27
|
+
execute: bool,
|
|
28
|
+
) -> tuple[int, int]:
|
|
29
|
+
"""Prune stored series whose method_config_id the YAML no longer produces."""
|
|
30
|
+
selected, warnings = select_experiments(context.root, select)
|
|
31
|
+
for warning in warnings:
|
|
32
|
+
click.echo(click.style(f" ⚠ {warning}", fg="yellow"))
|
|
33
|
+
|
|
34
|
+
pruned = 0
|
|
35
|
+
experiments_touched = 0
|
|
36
|
+
for _, experiment in selected:
|
|
37
|
+
valid_ids: dict[str, set[str]] = {}
|
|
38
|
+
for comparison in experiment.comparisons:
|
|
39
|
+
valid_ids.setdefault(comparison.metric, set()).add(comparison.method.method_config_id)
|
|
40
|
+
|
|
41
|
+
stored = tables.list_method_config_ids(experiment.name)
|
|
42
|
+
orphans = [
|
|
43
|
+
(metric, config_id, count)
|
|
44
|
+
for (metric, config_id), count in sorted(stored.items())
|
|
45
|
+
if config_id not in valid_ids.get(metric, set())
|
|
46
|
+
]
|
|
47
|
+
if not orphans:
|
|
48
|
+
echo_noop(experiment.name, "no orphaned series")
|
|
49
|
+
continue
|
|
50
|
+
|
|
51
|
+
experiments_touched += 1
|
|
52
|
+
children = []
|
|
53
|
+
for metric, config_id, count in orphans:
|
|
54
|
+
action = "pruned" if execute else "would prune"
|
|
55
|
+
children.append(f"{action} {metric} / {config_id[:16]}… ({count} rows)")
|
|
56
|
+
if execute:
|
|
57
|
+
tables.delete_results(
|
|
58
|
+
experiment.name,
|
|
59
|
+
metric=metric,
|
|
60
|
+
method_config_id=config_id,
|
|
61
|
+
mutations_sync=True,
|
|
62
|
+
)
|
|
63
|
+
pruned += count
|
|
64
|
+
echo_tree(experiment.name, children)
|
|
65
|
+
return experiments_touched, pruned
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _clean_orphaned_experiments(
|
|
69
|
+
context: ProjectContext,
|
|
70
|
+
tables: InternalTablesManager,
|
|
71
|
+
execute: bool,
|
|
72
|
+
yes: bool,
|
|
73
|
+
) -> int:
|
|
74
|
+
"""Purge experiments that have rows in the DB but no YAML in the project."""
|
|
75
|
+
known_in_db = tables.list_known_experiments()
|
|
76
|
+
known_in_yaml = {config.name for _, config in context.experiments}
|
|
77
|
+
orphaned = sorted(known_in_db - known_in_yaml)
|
|
78
|
+
if not orphaned:
|
|
79
|
+
echo_noop("orphaned-experiments", "none found")
|
|
80
|
+
return 0
|
|
81
|
+
|
|
82
|
+
purged = 0
|
|
83
|
+
for name in orphaned:
|
|
84
|
+
counts = tables.count_experiment_rows(name)
|
|
85
|
+
summary = ", ".join(f"{table}: {count}" for table, count in counts.items() if count)
|
|
86
|
+
if not execute:
|
|
87
|
+
echo_tree(name, [f"would purge ({summary or 'no rows'})"])
|
|
88
|
+
continue
|
|
89
|
+
if not yes and not click.confirm(f"Purge ALL rows for '{name}'?", default=False):
|
|
90
|
+
echo_noop(name, "skipped")
|
|
91
|
+
continue
|
|
92
|
+
tables.purge_experiment(name)
|
|
93
|
+
purged += 1
|
|
94
|
+
echo_tree(name, [f"purged ({summary or 'no rows'})"])
|
|
95
|
+
return purged
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def run_clean(
|
|
99
|
+
select: tuple[str, ...],
|
|
100
|
+
orphaned_experiments: bool,
|
|
101
|
+
execute: bool,
|
|
102
|
+
yes: bool,
|
|
103
|
+
profile: str | None,
|
|
104
|
+
) -> None:
|
|
105
|
+
context = load_project_context()
|
|
106
|
+
click.echo(f"Project root: {context.root}")
|
|
107
|
+
if not execute:
|
|
108
|
+
click.echo(click.style("DRY RUN — pass --execute to apply.", fg="yellow", bold=True))
|
|
109
|
+
|
|
110
|
+
manager = context.manager_factory(profile)()
|
|
111
|
+
try:
|
|
112
|
+
tables = InternalTablesManager(manager)
|
|
113
|
+
tables.ensure_tables()
|
|
114
|
+
|
|
115
|
+
if orphaned_experiments:
|
|
116
|
+
purged = _clean_orphaned_experiments(context, tables, execute, yes)
|
|
117
|
+
echo_done(
|
|
118
|
+
f"{'Purged' if execute else 'Would purge'} {purged} experiment(s)."
|
|
119
|
+
if execute
|
|
120
|
+
else "Dry run complete."
|
|
121
|
+
)
|
|
122
|
+
return
|
|
123
|
+
|
|
124
|
+
touched, pruned = _clean_drift(context, tables, select, execute)
|
|
125
|
+
if execute:
|
|
126
|
+
echo_done(f"Pruned {pruned} row(s) across {touched} experiment(s).")
|
|
127
|
+
else:
|
|
128
|
+
echo_done(f"Dry run: {touched} experiment(s) have orphaned series.")
|
|
129
|
+
except Exception as exc:
|
|
130
|
+
echo_error("clean", str(exc))
|
|
131
|
+
raise SystemExit(1) from exc
|
|
132
|
+
finally:
|
|
133
|
+
manager.close()
|