benchdog 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.
@@ -0,0 +1,32 @@
1
+ node_modules/
2
+ dist/
3
+ declarations/
4
+ test-apps/*/tmp/
5
+ _site/
6
+ # Written by `pnpm guide:build` (docs-app), as in the siblings.
7
+ docs/site/guide/
8
+ docs/site/404.html
9
+ *.tsbuildinfo
10
+ .DS_Store
11
+ .idea/
12
+ coverage/
13
+ tmp/
14
+
15
+ # Ruby
16
+ ruby/*/.bundle/
17
+ ruby/*/vendor/
18
+ ruby/*/pkg/
19
+
20
+ # Python
21
+ __pycache__/
22
+ *.py[cod]
23
+ .venv/
24
+ .mypy_cache/
25
+ .pytest_cache/
26
+ .ruff_cache/
27
+ python/*/dist/
28
+ packages/prisma/tests/.generated/
29
+
30
+ # Copies of the dashboard build, made by scripts/bundle-dashboard.sh for the gem and the wheel.
31
+ ruby/benchdog-rails/dashboard/
32
+ python/benchdog-django/src/benchdog_django/dashboard/
@@ -0,0 +1 @@
1
+ 3.11
benchdog-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joe Gaudet
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,76 @@
1
+ Metadata-Version: 2.5
2
+ Name: benchdog
3
+ Version: 0.1.0
4
+ Summary: Feature flags for Python: gates, rollouts, variants and audit.
5
+ Project-URL: Homepage, https://joegaudet.com/benchdog/
6
+ Project-URL: Source, https://github.com/joegaudet/benchdog/tree/main/python/benchdog
7
+ Project-URL: Issues, https://github.com/joegaudet/benchdog/issues
8
+ Author-email: Joe Gaudet <joe@joegaudet.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Classifier: Typing :: Typed
12
+ Requires-Python: >=3.11
13
+ Requires-Dist: jsonschema>=4.18
14
+ Description-Content-Type: text/markdown
15
+
16
+ # benchdog (Python)
17
+
18
+ The Python core of [Benchdog](https://joegaudet.com/benchdog/), feature flags for Ember, Rails,
19
+ Django and Node. It has:
20
+
21
+ - The evaluator. It passes the shared vectors in `spec/vectors/`.
22
+ - The audit hash chain (`benchdog.audit`).
23
+ - The `FlagStore` protocol and a `MemoryStore`.
24
+ - The `Client`, which keeps a snapshot of one environment and evaluates with no I/O.
25
+ - The scheduler (`benchdog.schedule.apply_due_schedules`).
26
+ - The admin and client API as one handler with no web framework (`benchdog.admin_api`). A host
27
+ makes a `Request`, calls the handler and sends the `Response`. `benchdog-django` is a host.
28
+
29
+ For Django, use [`benchdog-django`](../benchdog-django/README.md).
30
+
31
+ ## The client
32
+
33
+ ```python
34
+ from benchdog import Client, MemoryStore
35
+
36
+ client = Client(MemoryStore(), "production")
37
+ client.refresh() # Loads the snapshot. Evaluation does no I/O.
38
+ if client.enabled("new-checkout", {"id": "user:42"}):
39
+ ...
40
+ theme = client.value("theme", {"id": "user:42"}, "light")
41
+ ```
42
+
43
+ ## The admin API handler
44
+
45
+ ```python
46
+ from benchdog import MemoryStore
47
+ from benchdog.admin_api import Request, create_admin_api
48
+
49
+ handler = create_admin_api(
50
+ store=MemoryStore(),
51
+ environments=[{"name": "development", "promotes_to": "production"}, {"name": "production"}],
52
+ authenticate=lambda request: {"id": "alice"},
53
+ role_for=lambda user, environment: "admin",
54
+ )
55
+ response = handler(Request("GET", "/environments", {}, {"authorization": "Bearer alice"}))
56
+ ```
57
+
58
+ The HTTP contract suite (`packages/api-tests`) runs against this handler on a `wsgiref` server.
59
+ `tests/contract_server.py` is that server.
60
+
61
+ ## Store contract
62
+
63
+ `benchdog.store_contract.STORE_CONTRACT` is a list of cases. Run each case against a new store
64
+ to check it.
65
+
66
+ ## Checks
67
+
68
+ ```bash
69
+ uv run ruff check
70
+ uv run ruff format --check
71
+ uv run mypy
72
+ uv run pytest
73
+ ```
74
+
75
+ `pnpm python:check` at the root runs these checks for each Python package, and then the HTTP
76
+ contract.
@@ -0,0 +1,61 @@
1
+ # benchdog (Python)
2
+
3
+ The Python core of [Benchdog](https://joegaudet.com/benchdog/), feature flags for Ember, Rails,
4
+ Django and Node. It has:
5
+
6
+ - The evaluator. It passes the shared vectors in `spec/vectors/`.
7
+ - The audit hash chain (`benchdog.audit`).
8
+ - The `FlagStore` protocol and a `MemoryStore`.
9
+ - The `Client`, which keeps a snapshot of one environment and evaluates with no I/O.
10
+ - The scheduler (`benchdog.schedule.apply_due_schedules`).
11
+ - The admin and client API as one handler with no web framework (`benchdog.admin_api`). A host
12
+ makes a `Request`, calls the handler and sends the `Response`. `benchdog-django` is a host.
13
+
14
+ For Django, use [`benchdog-django`](../benchdog-django/README.md).
15
+
16
+ ## The client
17
+
18
+ ```python
19
+ from benchdog import Client, MemoryStore
20
+
21
+ client = Client(MemoryStore(), "production")
22
+ client.refresh() # Loads the snapshot. Evaluation does no I/O.
23
+ if client.enabled("new-checkout", {"id": "user:42"}):
24
+ ...
25
+ theme = client.value("theme", {"id": "user:42"}, "light")
26
+ ```
27
+
28
+ ## The admin API handler
29
+
30
+ ```python
31
+ from benchdog import MemoryStore
32
+ from benchdog.admin_api import Request, create_admin_api
33
+
34
+ handler = create_admin_api(
35
+ store=MemoryStore(),
36
+ environments=[{"name": "development", "promotes_to": "production"}, {"name": "production"}],
37
+ authenticate=lambda request: {"id": "alice"},
38
+ role_for=lambda user, environment: "admin",
39
+ )
40
+ response = handler(Request("GET", "/environments", {}, {"authorization": "Bearer alice"}))
41
+ ```
42
+
43
+ The HTTP contract suite (`packages/api-tests`) runs against this handler on a `wsgiref` server.
44
+ `tests/contract_server.py` is that server.
45
+
46
+ ## Store contract
47
+
48
+ `benchdog.store_contract.STORE_CONTRACT` is a list of cases. Run each case against a new store
49
+ to check it.
50
+
51
+ ## Checks
52
+
53
+ ```bash
54
+ uv run ruff check
55
+ uv run ruff format --check
56
+ uv run mypy
57
+ uv run pytest
58
+ ```
59
+
60
+ `pnpm python:check` at the root runs these checks for each Python package, and then the HTTP
61
+ contract.
@@ -0,0 +1,44 @@
1
+ [project]
2
+ name = "benchdog"
3
+ version = "0.1.0"
4
+ description = "Feature flags for Python: gates, rollouts, variants and audit."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ authors = [{ name = "Joe Gaudet", email = "joe@joegaudet.com" }]
9
+ requires-python = ">=3.11"
10
+ dependencies = [
11
+ "jsonschema>=4.18",
12
+ ]
13
+ classifiers = ["Typing :: Typed"]
14
+
15
+ [project.urls]
16
+ Homepage = "https://joegaudet.com/benchdog/"
17
+ Source = "https://github.com/joegaudet/benchdog/tree/main/python/benchdog"
18
+ Issues = "https://github.com/joegaudet/benchdog/issues"
19
+
20
+ [build-system]
21
+ requires = ["hatchling>=1.27"]
22
+ build-backend = "hatchling.build"
23
+
24
+ [dependency-groups]
25
+ dev = [
26
+ "mypy>=1.15",
27
+ "pytest>=8.3",
28
+ "ruff>=0.11",
29
+ "types-jsonschema>=4.26.0.20261006",
30
+ ]
31
+
32
+ [tool.ruff]
33
+ target-version = "py311"
34
+ line-length = 100
35
+
36
+ [tool.ruff.lint]
37
+ select = ["E", "F", "W", "I", "B", "UP", "SIM", "RUF"]
38
+
39
+ [tool.mypy]
40
+ strict = true
41
+ files = ["src", "tests"]
42
+
43
+ [tool.pytest.ini_options]
44
+ testpaths = ["tests"]
@@ -0,0 +1,30 @@
1
+ """Feature flags for Python. See https://joegaudet.com/benchdog/."""
2
+
3
+ from typing import Final
4
+
5
+ from . import audit
6
+ from .bucket import bucket
7
+ from .client import Client, client_payload
8
+ from .evaluate import Result, apply_schedule, evaluate
9
+ from .store import FlagStore, MemoryStore, NotFoundError
10
+
11
+ __all__ = [
12
+ "SPEC_VERSION",
13
+ "Client",
14
+ "FlagStore",
15
+ "MemoryStore",
16
+ "NotFoundError",
17
+ "Result",
18
+ "apply_schedule",
19
+ "audit",
20
+ "bucket",
21
+ "client_payload",
22
+ "evaluate",
23
+ ]
24
+
25
+ SPEC_VERSION: Final = "1"
26
+ """The version of spec/VERSION that this package follows.
27
+
28
+ The TypeScript and Ruby cores have the same constant, and each test suite checks it against
29
+ that file.
30
+ """