Skip to main content

GetCohorts

CI Actions Status PyPI version codecov

GetCohorts provides an endpoint that will randomly determine a cohort for a 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

More details on using the service are available on the documentation site.

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. So we recommend that you deploy GetCohorts yourself.

Deploy with Docker

docker run --publish 8000:8000 tjwaterman99/getcohorts

Deploy to Heroku

You can also deploy to Heroku directly with the button below.

Deploy

Deploy from PyPI

You can also download the Python package from PyPI and deploy yourself. For instructions, see the docs section on deploying with pypi.

Development

Clone this repo.

git clone https://github.com/tjwaterman99/getcohorts.git

Install the package's dependencies. This will also install getcohorts in editable mode.

pip install -r requirements.txt

Run the uvicorn server locally in development mode.

uvicorn getcohorts.web:app --host 0.0.0.0 --port 8000 --reload

Testing

Run the tests with pytest. Note that the tests assume the webserver is running locally on port 8000, and they will fail if you have not started the webserver.

pytest

You can run the github CI workflows locally if you have act installed.

act

Documentation

Build the docs with mkdocs. The site is available at 0.0.0.0:8000.

mkdocs serve

Release files for getcohorts 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for getcohorts 1.0.0
File Size Uploaded
getcohorts-1.0.0.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for getcohorts 1.0.0
File Interpreter ABI Platform
getcohorts-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.6 kB

Release files / getcohorts-1.0.0.tar.gz

Download URL getcohorts-1.0.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
77da5855d27dfaa5edad63420c88bb5ef047dd6c7ece6cc43b12fa0d1664f80c
BLAKE2b-256 checksum
How to use checksums
7406e830ad0116ea89c3f0381efdbbc5542ff7c61fd73c2dfc609d7d8eec1e33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9

Release files / getcohorts-1.0.0-py3-none-any.whl

Download URL getcohorts-1.0.0-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cfd0d0a4aba0ec4092b75511b3727aa74fb14838ab8860b36070d22e991f7015
BLAKE2b-256 checksum
How to use checksums
674e76ff02fa9b6c81a88e4ab8860f45b0413d2aa9fb8380edc274436d068c54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.4

2 release files

0.1.2

2 release files

0.1.0

2 release files

0.0.5

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page