reddit's python experiments framework
Project description
experiments.py
Experiments allow us to determine the impact of changes we make. This library helps you run and track them in Baseplate.py services.
Documentation: https://reddit-experiments.readthedocs.io/
Usage
Install the library:
# `reddit-v2-events` is a Reddit internal package used for emitting exposure events
$ pip install reddit-experiments reddit-v2-events>=2.8.2
Add the client to your application's Baseplate context:
from event_utils.v2_event_utils import ExperimentLogger
from reddit_decider import decider_client_from_config
decider = decider_client_from_config(
app_config=app_config,
event_logger=ExperimentLogger(),
request_field_extractor=decider_field_extractor,
)
baseplate.add_to_context("decider", decider)
and use it in request:
def my_method(request):
if request.decider.get_variant("foo") == "bar":
pass
See the documentation for more information (documentation builds can be found here) .
Development
A Dockerfile is provided to get a development environment running. To use it, build the base Docker image:
$ docker build -t experiments .
And then fire up the environment and use the provided Makefile targets to do common tasks:
$ docker run -it -v $PWD:/src -w /src experiments
$ make fmt
The following make targets are provided:
fmt
: Apply automatic formatting to the source code.lint
: Run linters on the code.test
: Run the test suite.docs
: Build the docs. Output can be found inbuild/html/
.
Note: some tests are skipped by default locally because they are quite slow.
Enable these by setting CI=true in the environment: CI=true make test
.
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 reddit_experiments-1.8.0b1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94975d67a98eb6d3bfa9555ea3723e91a07f9f68dded7eed8dbf6567d786b7d0 |
|
MD5 | 439be9c76857ca338009a54355553ecf |
|
BLAKE2b-256 | 05aefb14f8b2370228deb5472c8bb90ed0749815e57dbf2679e419de01a73781 |
Hashes for reddit_experiments-1.8.0b1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aad67d94d34b748bd646cb99260266e83013b7867f4fbcda1f62b023cb81a596 |
|
MD5 | 09e7b41a420c7f0b59a03c86289e8f67 |
|
BLAKE2b-256 | 566c3ce63ef7e2fb17d11213fa44110fc502ead10c3347f596293074ac063263 |