|
| 1 | +``reddit_experiments (legacy)`` |
| 2 | +=============================== |
| 3 | + |
| 4 | +.. automodule:: reddit_experiments |
| 5 | + |
| 6 | +Please consider upgrading your service to use the latest :ref:`reddit_decider` SDK |
| 7 | +to gain access to new features, such as **Mutually Exclusive Groups**, **Holdout Groups**, and **Dynamic Configurations**. |
| 8 | + |
| 9 | + |
| 10 | +Initialize :py:class:`~reddit_experiments.Experiments` instance on Baseplate context |
| 11 | +------------------------------------------------------------------------------------ |
| 12 | + |
| 13 | +Add the :code:`Experiments` client to your application via:: |
| 14 | + |
| 15 | + baseplate.configure_context( |
| 16 | + { |
| 17 | + ... |
| 18 | + "experiments": ExperimentsClient(event_logger), |
| 19 | + ... |
| 20 | + } |
| 21 | + ) |
| 22 | + |
| 23 | +or alternatively using:: |
| 24 | + |
| 25 | + experiments_factory = experiments_client_from_config( |
| 26 | + app_config=app_config, |
| 27 | + event_logger=ExperimentLogger |
| 28 | + ) |
| 29 | + baseplate.add_to_context("experiments", experiments_factory) |
| 30 | + |
| 31 | + |
| 32 | +Configure :py:class:`~reddit_experiments.Experiments` client |
| 33 | +------------------------------------------------------------ |
| 34 | + |
| 35 | +Configure the client in your application's configuration file: |
| 36 | + |
| 37 | +.. code-block:: ini |
| 38 | +
|
| 39 | + [app:main] |
| 40 | +
|
| 41 | + ... |
| 42 | +
|
| 43 | + # optional: a path to the file where experiment configuration is written |
| 44 | + # (default: /var/local/experiments.json) |
| 45 | + experiments.path = /var/local/foo.json |
| 46 | +
|
| 47 | + # optional: how long to wait for the experiments file to exist before failing |
| 48 | + # (default: do not wait. fail immediately if not available) |
| 49 | + experiments.timeout = 60 seconds |
| 50 | +
|
| 51 | + # optional: the base amount of time for exponential backoff while waiting |
| 52 | + # for the file to be available. |
| 53 | + # (default: no backoff time between tries) |
| 54 | + experiments.backoff = 1 second |
| 55 | +
|
| 56 | + ... |
| 57 | +
|
| 58 | +
|
| 59 | +Usage |
| 60 | +----- |
| 61 | +Use the attached :py:class:`~reddit_experiments.Experiments` object in |
| 62 | +request to get a variant:: |
| 63 | + |
| 64 | + def my_method(request): |
| 65 | + if request.experiments.variant("foo") == "bar": |
| 66 | + pass |
| 67 | + |
| 68 | +Experiments API |
| 69 | +--------------- |
| 70 | + |
| 71 | +.. autoclass:: Experiments |
| 72 | + :members: |
| 73 | + |
| 74 | +Configuration Class |
| 75 | +------------------- |
| 76 | + |
| 77 | +.. autoclass:: ExperimentsClient |
| 78 | + |
| 79 | +Configuration Function |
| 80 | +---------------------- |
| 81 | + |
| 82 | +.. autofunction:: experiments_client_from_config |
| 83 | + |
| 84 | +Configuration Context Factory |
| 85 | +----------------------------- |
| 86 | + |
| 87 | +.. autoclass:: ExperimentsContextFactory |
| 88 | + |
| 89 | +Link to Latest SDK |
| 90 | +------------------ |
| 91 | +See :ref:`reddit_decider` |
0 commit comments