Skip to content

Commit d80c23d

Browse files
committed
include legacy docs
1 parent 4d077a8 commit d80c23d

File tree

5 files changed

+129
-18
lines changed

5 files changed

+129
-18
lines changed

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
master_doc = "index"
3939

4040
# General information about the project.
41-
project = "Experiments"
41+
project = "Experiments.py"
4242

4343
# The language for content autogenerated by Sphinx. Refer to documentation
4444
# for a list of supported languages.
@@ -67,7 +67,7 @@
6767
# which templates to put in the sidebar. we're just removing the relations
6868
# section from the defaults here, that's "next article" and "previous article"
6969
html_sidebars = {
70-
"**": []
70+
"**": ["about.html", "searchbox.html", "navigation.html"]
7171
}
7272

7373
html_theme_options = {

docs/index.rst

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
``reddit_experiments``
1+
.. _reddit_decider:
2+
3+
``reddit_decider``
24
===============================
35

46
.. automodule:: reddit_decider
@@ -51,6 +53,17 @@ Setup :code:`reddit-experiments` in your application's configuration file:
5153
5254
Integrate :code:`reddit-experiments` into Baseplate service
5355
-----------------------------------------------------------
56+
57+
Upgrade or integrate reddit-experiments package:
58+
59+
.. code-block:: python
60+
61+
# import latest reddit-experiments package in service requirements.txt
62+
reddit-experiments>=1.3.7
63+
64+
Initialize :code:`decider` instance on Baseplate context
65+
--------------------------------------------------------
66+
5467
In your service's initialization process, add a :code:`decider` instance to baseplate's context:
5568
(Note the use of the :code:`ExperimentLogger`, which is used to publish exposure V2 events,
5669
an example can be seen `here <https://github.snooguts.net/reddit/reddit-service-graphql/blob/3734b51732c29d07eef32aced86677cce5064dbb/graphql-py/graphql_api/events/utils.py#L205>`_)
@@ -68,7 +81,7 @@ an example can be seen `here <https://github.snooguts.net/reddit/reddit-service-
6881
def make_wsgi_app(app_config):
6982
baseplate = Baseplate(app_config)
7083
decider_factory = decider_client_from_config(app_config=app_config,
71-
event_logger=ExperimentLogger,
84+
event_logger=ExperimentLogger(),
7285
prefix="experiments.",
7386
request_field_extractor=my_field_extractor) # this is optional, can be `None` if edge_context contains all the fields you need
7487
baseplate.add_to_context("decider", decider_factory)
@@ -143,7 +156,7 @@ Configuration Class
143156
144157
.. autoclass:: DeciderClient
145158
146-
Configuration function
159+
Configuration Function
147160
----------------------
148161
149162
.. autofunction:: decider_client_from_config
@@ -153,3 +166,10 @@ Configuration Context Factory
153166
-----------------------------
154167
155168
.. autoclass:: DeciderContextFactory
169+
170+
Legacy API docs:
171+
----------------
172+
173+
.. toctree::
174+
175+
legacy/index

docs/legacy/index.rst

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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`

reddit_decider/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ def decider_client_from_config(
11971197
The keys used in your app's :code:`some_config.ini` file should be prefixed, e.g.
11981198
``experiments.path``, etc.
11991199
1200-
Supported :code:`.ini` keys:
1200+
Supported config keys:
12011201
12021202
``path`` (optional)
12031203
The path to the experiment configuration file generated by the

reddit_experiments/__init__.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -348,20 +348,20 @@ def experiments_client_from_config(
348348
) -> ExperimentsContextFactory:
349349
"""Configure and return an :py:class:`ExperimentsContextFactory` object.
350350
351-
The keys useful to :py:func:`experiments_client_from_config` should be prefixed, e.g.
351+
The keys used in your app's :code:`some_config.ini` file should be prefixed, e.g.
352352
``experiments.path``, etc.
353353
354-
Supported keys:
355-
356-
``path`` (optional)
357-
The path to the experiment configuration file generated by the
358-
experiment configuration fetcher daemon.
359-
``timeout`` (optional)
360-
The time that we should wait for the file specified by ``path`` to
361-
exist. Defaults to `None` which is `infinite`.
362-
``backoff`` (optional)
363-
The base amount of time for exponential backoff when trying to find the
364-
experiments config file. Defaults to no backoff between tries.
354+
Supported config keys:
355+
356+
``path`` (optional)
357+
The path to the experiment configuration file generated by the
358+
experiment configuration fetcher daemon.
359+
``timeout`` (optional)
360+
The time that we should wait for the file specified by ``path`` to
361+
exist. Defaults to `None` which is `infinite`.
362+
``backoff`` (optional)
363+
The base amount of time for exponential backoff when trying to find the
364+
experiments config file. Defaults to no backoff between tries.
365365
366366
:param raw_config: The application configuration which should have
367367
settings for the experiments client.

0 commit comments

Comments
 (0)