# 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:
```console
# `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:
```python
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:
```python
def my_method(request):
if request.decider.get_variant("foo") == "bar":
pass
```
See [the documentation] for more information (documentation builds can be found [here](https://readthedocs.org/projects/reddit-experiments/builds/))
.
[the documentation]: https://reddit-experiments.readthedocs.io/
## Development
A Dockerfile is provided to get a development environment running. To use it,
build the base Docker image:
```console
$ docker build -t experiments .
```
And then fire up the environment and use the provided Makefile targets to do
common tasks:
```console
$ 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`.
Raw data
{
"_id": null,
"home_page": "https://github.com/reddit/experiments.py",
"name": "reddit-experiments",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "reddit",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/19/5b/5913bcb2261cda563b633f30d2a9233e597e7fde8cbabe70c4d3d7bb65e9/reddit_experiments-1.8.0.tar.gz",
"platform": null,
"description": "# experiments.py\n\nExperiments allow us to determine the impact of changes we make. This library\nhelps you run and track them in Baseplate.py services.\n\nDocumentation: https://reddit-experiments.readthedocs.io/\n\n## Usage\n\nInstall the library:\n\n```console\n# `reddit-v2-events` is a Reddit internal package used for emitting exposure events\n$ pip install reddit-experiments reddit-v2-events>=2.8.2\n```\n\nAdd the client to your application's Baseplate context:\n\n```python\n from event_utils.v2_event_utils import ExperimentLogger\n from reddit_decider import decider_client_from_config\n\n decider = decider_client_from_config(\n app_config=app_config,\n event_logger=ExperimentLogger(),\n request_field_extractor=decider_field_extractor,\n )\n baseplate.add_to_context(\"decider\", decider)\n```\n\nand use it in request:\n\n```python\ndef my_method(request):\n if request.decider.get_variant(\"foo\") == \"bar\":\n pass\n```\n\nSee [the documentation] for more information (documentation builds can be found [here](https://readthedocs.org/projects/reddit-experiments/builds/))\n.\n\n[the documentation]: https://reddit-experiments.readthedocs.io/\n\n## Development\n\nA Dockerfile is provided to get a development environment running. To use it,\nbuild the base Docker image:\n\n```console\n$ docker build -t experiments .\n```\n\nAnd then fire up the environment and use the provided Makefile targets to do\ncommon tasks:\n\n```console\n$ docker run -it -v $PWD:/src -w /src experiments\n$ make fmt\n```\n\nThe following make targets are provided:\n\n* `fmt`: Apply automatic formatting to the source code.\n* `lint`: Run linters on the code.\n* `test`: Run the test suite.\n* `docs`: Build the docs. Output can be found in `build/html/`.\n\nNote: some tests are skipped by default locally because they are quite slow.\nEnable these by setting CI=true in the environment: `CI=true make test`.\n\n\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "reddit's python experiments framework",
"version": "1.8.0",
"project_urls": {
"Documentation": "https://reddit-experiments.readthedocs.io/",
"Homepage": "https://github.com/reddit/experiments.py"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ff075e1deb3c5f8467671fdef25172dd9b5801e19ecbe862189cdd3cefbe4a4f",
"md5": "4336ef7708525228dc4015ea32cb92f1",
"sha256": "08e03c3ed3ce92ebd4d985bcb07b2bd43b30d547d07a8b8968c831f26482eb2f"
},
"downloads": -1,
"filename": "reddit_experiments-1.8.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4336ef7708525228dc4015ea32cb92f1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 39050,
"upload_time": "2023-08-28T22:45:16",
"upload_time_iso_8601": "2023-08-28T22:45:16.306738Z",
"url": "https://files.pythonhosted.org/packages/ff/07/5e1deb3c5f8467671fdef25172dd9b5801e19ecbe862189cdd3cefbe4a4f/reddit_experiments-1.8.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "195b5913bcb2261cda563b633f30d2a9233e597e7fde8cbabe70c4d3d7bb65e9",
"md5": "3daa22f596c3f25e45f0ffe7709d3a92",
"sha256": "1a633023bb94c0d73d92868e48a62d818f231b7d7ef7cf556bd33efd189daab0"
},
"downloads": -1,
"filename": "reddit_experiments-1.8.0.tar.gz",
"has_sig": false,
"md5_digest": "3daa22f596c3f25e45f0ffe7709d3a92",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 1443246,
"upload_time": "2023-08-28T22:45:18",
"upload_time_iso_8601": "2023-08-28T22:45:18.298859Z",
"url": "https://files.pythonhosted.org/packages/19/5b/5913bcb2261cda563b633f30d2a9233e597e7fde8cbabe70c4d3d7bb65e9/reddit_experiments-1.8.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-28 22:45:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "reddit",
"github_project": "experiments.py",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "reddit-experiments"
}