Skip to main content

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 in build/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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reddit_experiments-1.10.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reddit_experiments-1.10.0-py3-none-any.whl (39.1 kB view details)

Uploaded Python 3

File details

Details for the file reddit_experiments-1.10.0.tar.gz.

File metadata

  • Download URL: reddit_experiments-1.10.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.12.1.2 requests/2.32.3 setuptools/47.3.0 requests-toolbelt/1.0.0 tqdm/4.67.1 CPython/3.8.18

File hashes

Hashes for reddit_experiments-1.10.0.tar.gz
Algorithm Hash digest
SHA256 27fbe9e3fcfa39a08bbf648a1947fe5c13a8eb04dc52a4bddc5c0750f7493ced
MD5 548552eb6de552620235970ceface4f0
BLAKE2b-256 8fe6789b4811b466165ea98cbf5cc5db3cdc056d47bdde253c2f49841f92e371

See more details on using hashes here.

File details

Details for the file reddit_experiments-1.10.0-py3-none-any.whl.

File metadata

  • Download URL: reddit_experiments-1.10.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.12.1.2 requests/2.32.3 setuptools/47.3.0 requests-toolbelt/1.0.0 tqdm/4.67.1 CPython/3.8.18

File hashes

Hashes for reddit_experiments-1.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e3718ba750c9bef996e5b4e908a71aa9f8fafb9aa7967687272fc9e24c129ce1
MD5 4eeb7574ecf5321033b9124079c1598d
BLAKE2b-256 340fc3cff4c6f5ccbbd97c6c5e2d768c8039ef4f64bc0ef087923d24cef6beda

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page