Utilities for randomizing A/B tests
Project description
GetCohorts
GetCohorts provides an endpoint that will randomly determine a cohort for user in an A/B test, and is gauranteed to always assign the same user to the same cohort for the same experiment.
>>> import requests
>>> resp = requests.get('http://api.getcohorts.com/v1/cohorts', json={
... 'identifier': 'user1',
... 'experiment': 'homepage-test'
... })
>>> print(resp.json()['cohort'])
experimental
Quickstart
GetCohorts provides a web service at http://api.getcohorts.com
that you can use for testing. But that service runs on Heroku's free tier, and can occasionally have slow response times. We recommend that you deploy GetCohorts yourself.
The easiest way to deploy GetCohorts is with docker.
docker run --publish 8000:8000 tjwaterman99/getcohorts
For more details on using the service, you can read the documentation and API reference.
Development
Clone this repo.
git clone https://github.com/tjwaterman99/getcohorts.git
Install the package's dependencies, and install getcohorts
in editable mode.
pip install -r requirements.txt
pip install --editable .
To run the webserver, install the Heroku cli.
sudo snap install --clasic heroku
heroku local
The webserver will run on port 8000
.
Testing
Run the tests with pytest
pytest
You can run the github CI workflows locally if you have act installed. You'll also need to create a file .secrets
that contains deployment secrets for the staging environments.
# .secrets
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
DOCS_S3_BUCKET=...
PYPI_USERNAME=...
PYPI_REPOSITORY_URL=...
PYPI_ACCESS_TOKEN=...
Then run the Github workflows.
sudo act --secret-file .secrets
Documentation
Build the docs with sphinx-autobuild. The site is available at 0.0.0.0:8000
.
sphinx-autobuild docs docs/_build
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for getcohorts-0.1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 094deec031fa982ff923e4382edc2e1c086438ce0c77ed9e75fde5918d7f20ff |
|
MD5 | bded3b69c5e2941dae14e7f6611b64dc |
|
BLAKE2b-256 | b8749be31b8b50cc760c9ffca085e8d4250eec079a49de5dda8a97f39c9ac184 |