toggley 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.
- toggley-0.1.0/.gitignore +6 -0
- toggley-0.1.0/LICENSE +21 -0
- toggley-0.1.0/PKG-INFO +63 -0
- toggley-0.1.0/README.md +39 -0
- toggley-0.1.0/pyproject.toml +40 -0
- toggley-0.1.0/spec/SOURCE +3 -0
- toggley-0.1.0/spec/bucketing-vectors.json +1505 -0
- toggley-0.1.0/spec/evaluation-vectors.json +4914 -0
- toggley-0.1.0/src/toggley/__init__.py +5 -0
- toggley-0.1.0/src/toggley/client.py +320 -0
- toggley-0.1.0/src/toggley/engine/__init__.py +5 -0
- toggley-0.1.0/src/toggley/engine/bucketer.py +51 -0
- toggley-0.1.0/src/toggley/engine/context.py +30 -0
- toggley-0.1.0/src/toggley/engine/evaluator.py +253 -0
- toggley-0.1.0/src/toggley/engine/operators.py +89 -0
- toggley-0.1.0/src/toggley/summarizer.py +57 -0
- toggley-0.1.0/src/toggley/transport.py +21 -0
- toggley-0.1.0/tests/__init__.py +0 -0
- toggley-0.1.0/tests/test_client.py +167 -0
- toggley-0.1.0/tests/test_vectors.py +35 -0
toggley-0.1.0/.gitignore
ADDED
toggley-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Albright Labs LLC
|
|
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.
|
toggley-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: toggley
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Toggley feature flags for Python servers: evaluates flags locally from a polled config.
|
|
5
|
+
Project-URL: Homepage, https://toggleyapp.com
|
|
6
|
+
Project-URL: Repository, https://github.com/albrightlabs/toggley-python
|
|
7
|
+
Project-URL: Issues, https://github.com/albrightlabs/toggley-python/issues
|
|
8
|
+
Author: Albright Labs
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: feature flags,feature toggles,toggley
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# Toggley for Python
|
|
26
|
+
|
|
27
|
+
Feature flags from [Toggley](https://toggleyapp.com) for Python servers. The client downloads your environment's config, keeps it current in a background thread, and evaluates flags in your process. No network call per check, no dependencies, and user data never leaves your server.
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
pip install toggley
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Python 3.10+.
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
import os
|
|
37
|
+
import toggley
|
|
38
|
+
|
|
39
|
+
client = toggley.Client(server_key=os.environ["TOGGLEY_SERVER_KEY"])
|
|
40
|
+
client.wait_for_initialization(timeout=5)
|
|
41
|
+
|
|
42
|
+
context = {"key": str(user.id), "email": user.email, "plan": user.plan}
|
|
43
|
+
|
|
44
|
+
if client.bool_variation("new-checkout", context, False):
|
|
45
|
+
...
|
|
46
|
+
|
|
47
|
+
theme = client.string_variation("theme", context, "light")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Create one client per process and reuse it. Getters never raise: on any problem you get your default, and the `*_variation_detail` versions say why (`reason["kind"] == "ERROR"`, `reason["errorKind"]`).
|
|
51
|
+
|
|
52
|
+
| Method | |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `bool_variation`, `string_variation`, `number_variation`, `json_variation`, `variation` | the value |
|
|
55
|
+
| `..._detail` | `{value, variation, reason, assignment, flagVersion}` |
|
|
56
|
+
| `all_flags(context)` | `{flag_key: value}` |
|
|
57
|
+
| `flush()`, `close()`, `with toggley.Client(...) as client:` | |
|
|
58
|
+
|
|
59
|
+
Options: `base_url` (default `https://my.toggleyapp.com`), `poll_interval` (30s), `timeout` (5s), `bootstrap` (config dict or JSON file path), `offline`, `events` (send evaluation counts every minute; counts only), `on_error`.
|
|
60
|
+
|
|
61
|
+
If Toggley can't be reached the client keeps serving the last config it received and retries with backoff. A rejected key stops polling.
|
|
62
|
+
|
|
63
|
+
Forking servers (gunicorn, uWSGI) are handled: the polling thread restarts in each worker. Counts are sent at exit.
|
toggley-0.1.0/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Toggley for Python
|
|
2
|
+
|
|
3
|
+
Feature flags from [Toggley](https://toggleyapp.com) for Python servers. The client downloads your environment's config, keeps it current in a background thread, and evaluates flags in your process. No network call per check, no dependencies, and user data never leaves your server.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pip install toggley
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Python 3.10+.
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
import os
|
|
13
|
+
import toggley
|
|
14
|
+
|
|
15
|
+
client = toggley.Client(server_key=os.environ["TOGGLEY_SERVER_KEY"])
|
|
16
|
+
client.wait_for_initialization(timeout=5)
|
|
17
|
+
|
|
18
|
+
context = {"key": str(user.id), "email": user.email, "plan": user.plan}
|
|
19
|
+
|
|
20
|
+
if client.bool_variation("new-checkout", context, False):
|
|
21
|
+
...
|
|
22
|
+
|
|
23
|
+
theme = client.string_variation("theme", context, "light")
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Create one client per process and reuse it. Getters never raise: on any problem you get your default, and the `*_variation_detail` versions say why (`reason["kind"] == "ERROR"`, `reason["errorKind"]`).
|
|
27
|
+
|
|
28
|
+
| Method | |
|
|
29
|
+
|---|---|
|
|
30
|
+
| `bool_variation`, `string_variation`, `number_variation`, `json_variation`, `variation` | the value |
|
|
31
|
+
| `..._detail` | `{value, variation, reason, assignment, flagVersion}` |
|
|
32
|
+
| `all_flags(context)` | `{flag_key: value}` |
|
|
33
|
+
| `flush()`, `close()`, `with toggley.Client(...) as client:` | |
|
|
34
|
+
|
|
35
|
+
Options: `base_url` (default `https://my.toggleyapp.com`), `poll_interval` (30s), `timeout` (5s), `bootstrap` (config dict or JSON file path), `offline`, `events` (send evaluation counts every minute; counts only), `on_error`.
|
|
36
|
+
|
|
37
|
+
If Toggley can't be reached the client keeps serving the last config it received and retries with backoff. A rejected key stops polling.
|
|
38
|
+
|
|
39
|
+
Forking servers (gunicorn, uWSGI) are handled: the polling thread restarts in each worker. Counts are sent at exit.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "toggley"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Toggley feature flags for Python servers: evaluates flags locally from a polled config."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [{ name = "Albright Labs" }]
|
|
13
|
+
keywords = ["feature flags", "feature toggles", "toggley"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
25
|
+
]
|
|
26
|
+
dependencies = []
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://toggleyapp.com"
|
|
30
|
+
Repository = "https://github.com/albrightlabs/toggley-python"
|
|
31
|
+
Issues = "https://github.com/albrightlabs/toggley-python/issues"
|
|
32
|
+
|
|
33
|
+
[tool.hatch.build.targets.sdist]
|
|
34
|
+
include = ["src/toggley", "tests", "spec", "README.md", "LICENSE", "pyproject.toml"]
|
|
35
|
+
|
|
36
|
+
[tool.hatch.build.targets.wheel]
|
|
37
|
+
packages = ["src/toggley"]
|
|
38
|
+
|
|
39
|
+
[tool.pytest.ini_options]
|
|
40
|
+
pythonpath = ["src"]
|