seatgeek正在开发的a/b测试框架python client for sixpack
Sixpack-client的Python项目详细描述
用于seatgeak的Sixpackab测试框架的python客户端库。
安装
首先在虚拟环境中安装:
$ pip install sixpack-client
用法
基本示例:
from sixpack.sixpack import Session session = Session() # Participate in a test (creates the test if necessary) session.participate("new-test", ["alternative-1", "alternative-2"]) # Convert session.convert("new-test")
每个会话都有一个与之关联的客户机id,必须在请求之间保留。以下是第一个请求的外观:
session = Session() resp = session.participate("new-test", ["alternative-1", "alternative-2"]) set_cookie_in_your_web_framework("sixpack-id", session.client_id)
然后,您可以根据resp['alternative']['name']在应用程序中做出决定:
session = Session() resp = session.participate("new-test", ["alt-1", "alt-2"]) if resp["alternative"]["name"] == "alt-1": set_variable_in_view("new-test-alternative", "alt-1")
对于以后的请求,使用存储在cookie中的客户机id创建会话
会话可以使用可选的选项字典,它将主机和超时作为键。这允许您自定义Sixpack的位置。 如果无法访问sixpack或发生其他错误,sixpack py将提供控制选项。client_id = get_cookie_from_web_framework("sixpack-id")
session = Session(client_id=client_id)
session.convert("new-test")
options = {'host': 'http://mysixpacklocation.com'}
session = Session(client_id="123", options=options)
贡献
- 叉开它
- 创建您的功能分支(git checkout-b my new feature)
- 提交更改(git commit-am'添加了一些功能')
- 推到分支(git push origin my new feature)
- 创建新的拉取请求