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
File details
Details for the file reddit_experiments-1.9.0.tar.gz
.
File metadata
- Download URL: reddit_experiments-1.9.0.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.11.1 requests/2.32.3 setuptools/47.3.0 requests-toolbelt/1.0.0 tqdm/4.66.4 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f9ad4287fa2d825b745e4311c705c9dd61a5c6a2fb06ad5eb5c5ce4e3972ba4 |
|
MD5 | 4846bb2fc2fab811a68d06d907868abd |
|
BLAKE2b-256 | 07b4e7aaa930ff2416fbc79272e8c7dfde078ffaaae2247c92c775c9adb4d225 |
File details
Details for the file reddit_experiments-1.9.0-py3-none-any.whl
.
File metadata
- Download URL: reddit_experiments-1.9.0-py3-none-any.whl
- Upload date:
- Size: 39.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.11.1 requests/2.32.3 setuptools/47.3.0 requests-toolbelt/1.0.0 tqdm/4.66.4 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59d51d01049671e9a99657995c7634b6f1faf65f5448f1140cecca8b520d977e |
|
MD5 | fbe1f7b9503faa4354567fa8527e0838 |
|
BLAKE2b-256 | b3267af476e50cab52d684192f7aba3d3520edbcf6d13d90bd8d4a91d960d981 |