choixpeau
Install
pip install choixpeau
Usage
from choixpeau import choixpeau
redis_config = {
"host": "localhost
}
choixpeau = choixpeau.Choixpeau(
redis_config=redis_config,
ab_test_ids=["poudlard"],
buckets=["gryffondor", "poufsouffle", "serdaigle", "serpentard"] # ["A", "B"] by default
)
get
choixpeau.get("harrypotter")
# if the key already exists
> [(None, { "ab_test_group": "gryffondor", "created_at": "2021-01-29" }, "poudlard")]
# if it does not
> [("ab:poudlard:harrypotter", { "ab_test_group": "gryffondor", "created_at": "2021-01-29" }, "poudlard")]
store
choixpeau.store(
"ab:poudlard:harrypotter",
{ "ab_test_group": "gryffondor", "created_at": "2021-01-29" }
)
FastAPI
from fastapi import FastAPI, Request, BackgroundTasks
from choixpeau import choixpeau
from choixpeau.decorators.fastapi import ab
app = fastapi.FastAPI()
redis_config = {
"host": "localhost
}
@app.on_event("startup")
async def startup():
# Initialize choixpeau at the app level
app.state.choixpeau = choixpeau.Choixpeau(
redis_config=redis_config,
ab_test_ids=["poudlard"],
buckets=["gryffondor", "poufsouffle", "serdaigle", "serpentard"]
)
@app.post("/")
@ab # requires the request body to have a user_id field
async def read_house(request: Request, background_tasks: BackgroundTasks):
wizard = request.state.user # the user attribute is automatically added to the request
if wizard["ab_test_group"] == "gryffondor":
return { "message": "Welcome to Gryffondor!" }
else:
return { "message": "Welcome!" }
Metadata
Release files for choixpeau 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| choixpeau-0.0.9.tar.gz | 4.5 kB | Without provenance | Details for choixpeau-0.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| choixpeau-0.0.9-py3-none-any.whl | Python 3 | none | any | Details for choixpeau-0.0.9-py3-none-any.whl |
Total release size: 9.2 kB
Release files / choixpeau-0.0.9.tar.gz
| Download URL | choixpeau-0.0.9.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e058ec4370970c4da0244a7daddb9aa3d9b085db302875313553e769310bb3a
|
|
BLAKE2b-256 checksum How to use checksums |
f5c65376cf45c548e6f754641fc0a4acb67d01103c9d9897f4085c19c9fcc3f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.5
|
Release files / choixpeau-0.0.9-py3-none-any.whl
| Download URL | choixpeau-0.0.9-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
113bb8c302184e2cd0d92f356c81e92f1722b44f2f4c1f773700554b86a11f03
|
|
BLAKE2b-256 checksum How to use checksums |
9d0c49f50bce1ed959611b806a20f85a6860a877f6e827a7a4884c1d7f9ee97c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.5
|
Security for choixpeau 0.0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.