assay-bittensor 0.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.
- assay_bittensor-0.4.0/.github/workflows/assay.yml +140 -0
- assay_bittensor-0.4.0/.github/workflows/publish.yml +81 -0
- assay_bittensor-0.4.0/.gitignore +22 -0
- assay_bittensor-0.4.0/LICENSE +21 -0
- assay_bittensor-0.4.0/Makefile +44 -0
- assay_bittensor-0.4.0/PKG-INFO +653 -0
- assay_bittensor-0.4.0/README.md +634 -0
- assay_bittensor-0.4.0/action.yml +113 -0
- assay_bittensor-0.4.0/ci/assay_adapter.py +21 -0
- assay_bittensor-0.4.0/docs/PUBLISHING.md +127 -0
- assay_bittensor-0.4.0/docs/STATUS.md +196 -0
- assay_bittensor-0.4.0/docs/checkpoint-1.md +262 -0
- assay_bittensor-0.4.0/examples/hardened.py +72 -0
- assay_bittensor-0.4.0/examples/naive_flat.py +27 -0
- assay_bittensor-0.4.0/examples/quality_only.py +33 -0
- assay_bittensor-0.4.0/examples/single_sample.py +36 -0
- assay_bittensor-0.4.0/examples/winner_take_all.py +37 -0
- assay_bittensor-0.4.0/examples/workflows/assay-example.yml +63 -0
- assay_bittensor-0.4.0/publish.sh +80 -0
- assay_bittensor-0.4.0/pyproject.toml +39 -0
- assay_bittensor-0.4.0/src/assay/__init__.py +40 -0
- assay_bittensor-0.4.0/src/assay/cli.py +543 -0
- assay_bittensor-0.4.0/src/assay/conformance.py +257 -0
- assay_bittensor-0.4.0/src/assay/consensus.py +230 -0
- assay_bittensor-0.4.0/src/assay/fidelity.py +393 -0
- assay_bittensor-0.4.0/src/assay/live.py +492 -0
- assay_bittensor-0.4.0/src/assay/mechanism.py +140 -0
- assay_bittensor-0.4.0/src/assay/population.py +274 -0
- assay_bittensor-0.4.0/src/assay/report.py +127 -0
- assay_bittensor-0.4.0/src/assay/runner.py +309 -0
- assay_bittensor-0.4.0/src/assay/scan.py +368 -0
- assay_bittensor-0.4.0/src/assay/scenarios.py +363 -0
- assay_bittensor-0.4.0/src/assay/types.py +212 -0
- assay_bittensor-0.4.0/src/assay/validator_scenarios.py +257 -0
- assay_bittensor-0.4.0/tests/test_conformance.py +83 -0
- assay_bittensor-0.4.0/tests/test_consensus.py +206 -0
- assay_bittensor-0.4.0/tests/test_fidelity.py +269 -0
- assay_bittensor-0.4.0/tests/test_harness.py +135 -0
- assay_bittensor-0.4.0/tests/test_live.py +297 -0
- assay_bittensor-0.4.0/tests/test_report.py +140 -0
- assay_bittensor-0.4.0/tests/test_scan.py +315 -0
- assay_bittensor-0.4.0/tests/test_validator_scenarios.py +150 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
name: assay
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
# The package claims >=3.10, so the syntax has to actually work there. This
|
|
10
|
+
# caught a nested same-quote f-string during development, which is 3.12-only.
|
|
11
|
+
compat:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
python: ["3.10", "3.11", "3.12", "3.13"]
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: astral-sh/setup-uv@v5
|
|
19
|
+
with:
|
|
20
|
+
enable-cache: true
|
|
21
|
+
- name: Environment (${{ matrix.python }})
|
|
22
|
+
run: |
|
|
23
|
+
uv venv --python ${{ matrix.python }}
|
|
24
|
+
uv pip install -e ".[chain,dev]"
|
|
25
|
+
- name: Tests (${{ matrix.python }})
|
|
26
|
+
run: uv run python -m pytest -q
|
|
27
|
+
|
|
28
|
+
verify:
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
|
|
33
|
+
- name: Install uv
|
|
34
|
+
uses: astral-sh/setup-uv@v5
|
|
35
|
+
with:
|
|
36
|
+
enable-cache: true
|
|
37
|
+
|
|
38
|
+
- name: Create environment
|
|
39
|
+
run: |
|
|
40
|
+
uv venv --python 3.12
|
|
41
|
+
uv pip install -e ".[chain,dev]"
|
|
42
|
+
|
|
43
|
+
- name: Unit tests
|
|
44
|
+
run: uv run python -m pytest -q
|
|
45
|
+
|
|
46
|
+
- name: btauth/1 conformance
|
|
47
|
+
run: uv run assay conformance
|
|
48
|
+
|
|
49
|
+
- name: Gate — hardened reference must hold every scenario
|
|
50
|
+
run: |
|
|
51
|
+
uv run assay run examples/hardened.py -f markdown -o assay-report.md
|
|
52
|
+
cat assay-report.md
|
|
53
|
+
|
|
54
|
+
- name: Gate — hardened must hold the gated validator scenario
|
|
55
|
+
run: |
|
|
56
|
+
uv run assay consensus examples/hardened.py -f markdown -o consensus-report.md
|
|
57
|
+
cat consensus-report.md
|
|
58
|
+
|
|
59
|
+
- name: Report — winner-take-all must fail concentration
|
|
60
|
+
run: |
|
|
61
|
+
if uv run assay consensus examples/winner_take_all.py -f json -o wtl.json; then
|
|
62
|
+
echo "::error::winner_take_all passed the concentration gate — the check lost its teeth"
|
|
63
|
+
exit 1
|
|
64
|
+
fi
|
|
65
|
+
python3 -c "
|
|
66
|
+
import json
|
|
67
|
+
d = json.load(open('wtl.json'))
|
|
68
|
+
failed = [v['scenario'] for v in d['verdicts'] if v['status'] == 'FAIL']
|
|
69
|
+
assert failed == ['weight_concentration'], failed
|
|
70
|
+
peak = next(v for v in d['verdicts'] if v['scenario'] == 'weight_concentration')['value']
|
|
71
|
+
assert peak > 0.99, peak
|
|
72
|
+
print(f'winner_take_all correctly failed on {failed} at {peak}')
|
|
73
|
+
"
|
|
74
|
+
|
|
75
|
+
- name: Report — known-bad mechanisms must be caught
|
|
76
|
+
run: |
|
|
77
|
+
# these are expected to fail; the job passes only if they DO fail
|
|
78
|
+
for bad in naive_flat quality_only; do
|
|
79
|
+
if uv run assay run examples/$bad.py -f json -o $bad.json; then
|
|
80
|
+
echo "::error::$bad passed the suite — the harness lost its teeth"
|
|
81
|
+
exit 1
|
|
82
|
+
fi
|
|
83
|
+
echo "$bad correctly failed $(python3 -c "import json;print(json.load(open('$bad.json'))['summary']['failed'])") scenarios"
|
|
84
|
+
done
|
|
85
|
+
|
|
86
|
+
- name: Upload report
|
|
87
|
+
if: always()
|
|
88
|
+
uses: actions/upload-artifact@v4
|
|
89
|
+
with:
|
|
90
|
+
name: assay-report
|
|
91
|
+
path: |
|
|
92
|
+
assay-report.md
|
|
93
|
+
consensus-report.md
|
|
94
|
+
naive_flat.json
|
|
95
|
+
quality_only.json
|
|
96
|
+
wtl.json
|
|
97
|
+
if-no-files-found: ignore
|
|
98
|
+
|
|
99
|
+
# Exercise the composite action itself, through the adapter shape a real
|
|
100
|
+
# subnet repo would write. This is the only way to know action.yml works.
|
|
101
|
+
action-selftest:
|
|
102
|
+
runs-on: ubuntu-latest
|
|
103
|
+
steps:
|
|
104
|
+
- uses: actions/checkout@v4
|
|
105
|
+
- uses: ./
|
|
106
|
+
id: assay
|
|
107
|
+
with:
|
|
108
|
+
mechanism: ci/assay_adapter.py
|
|
109
|
+
seed: "0"
|
|
110
|
+
fail-on-regression: "true"
|
|
111
|
+
report-path: selftest-report.md
|
|
112
|
+
- name: Assert the action reported success
|
|
113
|
+
shell: bash
|
|
114
|
+
run: |
|
|
115
|
+
echo "failures=${{ steps.assay.outputs.failures }} passed=${{ steps.assay.outputs.passed }}"
|
|
116
|
+
test "${{ steps.assay.outputs.failures }}" = "0"
|
|
117
|
+
test "${{ steps.assay.outputs.passed }}" = "7"
|
|
118
|
+
test -f selftest-report.md
|
|
119
|
+
grep -qi "scenarios held" selftest-report.md
|
|
120
|
+
|
|
121
|
+
# The gate has to bite. Run the same action against a mechanism that must
|
|
122
|
+
# fail, with fail-on-regression off so the counts can be inspected, then
|
|
123
|
+
# assert they are what the library is supposed to report.
|
|
124
|
+
action-detects-bad:
|
|
125
|
+
runs-on: ubuntu-latest
|
|
126
|
+
steps:
|
|
127
|
+
- uses: actions/checkout@v4
|
|
128
|
+
- uses: ./
|
|
129
|
+
id: assay
|
|
130
|
+
with:
|
|
131
|
+
mechanism: examples/naive_flat.py
|
|
132
|
+
fail-on-regression: "false"
|
|
133
|
+
report-path: bad-report.md
|
|
134
|
+
- name: Assert the action counted the failures
|
|
135
|
+
shell: bash
|
|
136
|
+
run: |
|
|
137
|
+
echo "failures=${{ steps.assay.outputs.failures }} passed=${{ steps.assay.outputs.passed }}"
|
|
138
|
+
test "${{ steps.assay.outputs.failures }}" = "6"
|
|
139
|
+
test "${{ steps.assay.outputs.passed }}" = "1"
|
|
140
|
+
grep -q "What broke" bad-report.md
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
|
|
3
|
+
# Publishes to PyPI using Trusted Publishing — no API token exists anywhere.
|
|
4
|
+
#
|
|
5
|
+
# One-time setup, on PyPI:
|
|
6
|
+
# https://pypi.org/manage/account/publishing/
|
|
7
|
+
# Add a new *pending publisher* with:
|
|
8
|
+
# PyPI Project Name assay-bittensor
|
|
9
|
+
# Owner yu7dan
|
|
10
|
+
# Repository name assay
|
|
11
|
+
# Workflow name publish.yml
|
|
12
|
+
# Environment name pypi
|
|
13
|
+
#
|
|
14
|
+
# After that, pushing a tag like v0.4.0 publishes automatically. Nothing to
|
|
15
|
+
# store, nothing to leak, nothing to rotate.
|
|
16
|
+
|
|
17
|
+
on:
|
|
18
|
+
push:
|
|
19
|
+
tags:
|
|
20
|
+
- "v*"
|
|
21
|
+
workflow_dispatch:
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
build:
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
with:
|
|
29
|
+
fetch-depth: 0
|
|
30
|
+
|
|
31
|
+
- uses: astral-sh/setup-uv@v5
|
|
32
|
+
with:
|
|
33
|
+
enable-cache: true
|
|
34
|
+
|
|
35
|
+
- name: Verify the tag matches the package version
|
|
36
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
37
|
+
shell: bash
|
|
38
|
+
run: |
|
|
39
|
+
TAG="${GITHUB_REF#refs/tags/v}"
|
|
40
|
+
PKG=$(python3 -c "
|
|
41
|
+
import re, pathlib
|
|
42
|
+
s = pathlib.Path('pyproject.toml').read_text()
|
|
43
|
+
print(re.search(r'^version = \"([^\"]+)\"', s, re.M).group(1))
|
|
44
|
+
")
|
|
45
|
+
echo "tag=$TAG package=$PKG"
|
|
46
|
+
if [ "$TAG" != "$PKG" ]; then
|
|
47
|
+
echo "::error::tag v$TAG does not match pyproject version $PKG"
|
|
48
|
+
exit 1
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
- name: Build
|
|
52
|
+
run: uv build
|
|
53
|
+
|
|
54
|
+
- name: Check the built artifacts
|
|
55
|
+
run: |
|
|
56
|
+
uv venv --python 3.12 .check
|
|
57
|
+
uv pip install --python .check/bin/python dist/*.whl
|
|
58
|
+
.check/bin/assay --version
|
|
59
|
+
.check/bin/assay list > /dev/null
|
|
60
|
+
echo "wheel installs and runs"
|
|
61
|
+
|
|
62
|
+
- uses: actions/upload-artifact@v4
|
|
63
|
+
with:
|
|
64
|
+
name: dist
|
|
65
|
+
path: dist/
|
|
66
|
+
|
|
67
|
+
publish:
|
|
68
|
+
needs: build
|
|
69
|
+
runs-on: ubuntu-latest
|
|
70
|
+
environment:
|
|
71
|
+
name: pypi
|
|
72
|
+
url: https://pypi.org/p/assay-bittensor
|
|
73
|
+
permissions:
|
|
74
|
+
id-token: write # required for trusted publishing
|
|
75
|
+
steps:
|
|
76
|
+
- uses: actions/download-artifact@v4
|
|
77
|
+
with:
|
|
78
|
+
name: dist
|
|
79
|
+
path: dist/
|
|
80
|
+
|
|
81
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.venv/
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.pytest_cache/
|
|
6
|
+
.ruff_cache/
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
|
|
10
|
+
# probe artifacts
|
|
11
|
+
subnetprobe.json
|
|
12
|
+
probe-report.md
|
|
13
|
+
*.localnet.log
|
|
14
|
+
|
|
15
|
+
# wallets — never commit keys
|
|
16
|
+
wallets/
|
|
17
|
+
*.keyfile
|
|
18
|
+
.env
|
|
19
|
+
.env.*
|
|
20
|
+
!.env.example
|
|
21
|
+
|
|
22
|
+
.DS_Store
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 subnetprobe contributors
|
|
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,44 @@
|
|
|
1
|
+
.PHONY: install test probe conformance fidelity consensus all clean live
|
|
2
|
+
|
|
3
|
+
install:
|
|
4
|
+
uv venv --python 3.12 2>/dev/null || true
|
|
5
|
+
. .venv/bin/activate && uv pip install -e ".[chain,dev]"
|
|
6
|
+
|
|
7
|
+
test:
|
|
8
|
+
. .venv/bin/activate && python -m pytest -q
|
|
9
|
+
|
|
10
|
+
probe:
|
|
11
|
+
@. .venv/bin/activate && \
|
|
12
|
+
for m in naive_flat quality_only hardened winner_take_all; do \
|
|
13
|
+
echo ""; echo "=============== $$m ==============="; \
|
|
14
|
+
assay run examples/$$m.py --no-color || true; \
|
|
15
|
+
done
|
|
16
|
+
|
|
17
|
+
conformance:
|
|
18
|
+
. .venv/bin/activate && assay conformance
|
|
19
|
+
|
|
20
|
+
# validator-side: consensus, stake capture, concentration
|
|
21
|
+
consensus:
|
|
22
|
+
@. .venv/bin/activate && \
|
|
23
|
+
for m in hardened winner_take_all; do \
|
|
24
|
+
echo ""; echo "=============== $$m ==============="; \
|
|
25
|
+
assay consensus examples/$$m.py --no-color || true; \
|
|
26
|
+
done
|
|
27
|
+
|
|
28
|
+
# verify the weights-into-rewards model against the chain
|
|
29
|
+
fidelity:
|
|
30
|
+
. .venv/bin/activate && assay fidelity --netuid 64
|
|
31
|
+
|
|
32
|
+
# what CI runs
|
|
33
|
+
all: test conformance
|
|
34
|
+
@. .venv/bin/activate && assay run examples/hardened.py -f json -o assay.json \
|
|
35
|
+
&& echo "gate: hardened mechanism still holds"
|
|
36
|
+
|
|
37
|
+
# live replay needs network + the chain extra
|
|
38
|
+
live:
|
|
39
|
+
@. .venv/bin/activate && \
|
|
40
|
+
for n in 1 4 8 64; do assay live --netuid $$n --no-color || true; done
|
|
41
|
+
|
|
42
|
+
clean:
|
|
43
|
+
rm -rf .pytest_cache assay.json
|
|
44
|
+
find . -name __pycache__ -type d -prune -exec rm -rf {} +
|