当前位置: 首页>>代码示例>>Python>>正文


Python Experiment.find方法代码示例

本文整理汇总了Python中models.Experiment.find方法的典型用法代码示例。如果您正苦于以下问题:Python Experiment.find方法的具体用法?Python Experiment.find怎么用?Python Experiment.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Experiment的用法示例。


在下文中一共展示了Experiment.find方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: find_or_404

# 需要导入模块: from models import Experiment [as 别名]
# 或者: from models.Experiment import find [as 别名]
def find_or_404(experiment_name):
    try:
        exp = Experiment.find(experiment_name, db.REDIS)
        if request.args.get("kpi"):
            exp.set_kpi(request.args.get("kpi"))
        return exp
    except:
        abort(404)
开发者ID:repos-testing,项目名称:sixpack,代码行数:10,代码来源:web.py

示例2: find_or_404

# 需要导入模块: from models import Experiment [as 别名]
# 或者: from models.Experiment import find [as 别名]
def find_or_404(experiment_name):
    try:
        exp = Experiment.find(experiment_name, db.REDIS)
        if request.args.get('kpi'):
            exp.set_kpi(request.args.get('kpi'))
        return exp
    except ValueError:
        abort(404)
开发者ID:CypherSystems,项目名称:sixpack,代码行数:10,代码来源:web.py

示例3: find_or_404

# 需要导入模块: from models import Experiment [as 别名]
# 或者: from models.Experiment import find [as 别名]
def find_or_404(experiment_name):
    try:
        experiment_name = url=urllib.unquote(experiment_name).decode('utf8') 
        exp = Experiment.find(experiment_name, db.REDIS)
        if request.args.get('kpi'):
            exp.set_kpi(request.args.get('kpi'))
        return exp
    except ValueError:
        abort(404)
开发者ID:juggernaut451,项目名称:TeamRocket,代码行数:11,代码来源:web.py

示例4: convert

# 需要导入模块: from models import Experiment [as 别名]
# 或者: from models.Experiment import find [as 别名]
def convert(experiment, client_id,
    kpi=None,
    datetime=None,
    redis=None):

    exp = Experiment.find(experiment, redis=redis)

    if cfg.get('enabled', True):
        client = Client(client_id, redis=redis)
        alt = exp.convert(client, dt=datetime, kpi=kpi)
    else:
        alt = exp.control

    return alt
开发者ID:VPilitsyn,项目名称:sixpack,代码行数:16,代码来源:api.py

示例5: on_participate

# 需要导入模块: from models import Experiment [as 别名]
# 或者: from models.Experiment import find [as 别名]
    def on_participate(self, request):
        alts = request.args.getlist('alternatives')
        experiment_name = request.args.get('experiment')
        force = request.args.get('force')
        record_force = to_bool(request.args.get('record_force', 'false'))
        client_id = request.args.get('client_id')
        traffic_fraction = request.args.get('traffic_fraction')

        if traffic_fraction is not None:
            traffic_fraction = float(traffic_fraction)
        prefetch = to_bool(request.args.get('prefetch', 'false'))

        if client_id is None or experiment_name is None or alts is None:
            return json_error({'message': 'missing arguments'}, request, 400)

        dt = None
        if request.args.get("datetime"):
            dt = dateutil.parser.parse(request.args.get("datetime"))
        try:
            if should_exclude_visitor(request):
                exp = Experiment.find(experiment_name, redis=self.redis)
                if exp.winner is not None:
                    alt = exp.winner
                else:
                    alt = exp.control
            else:
                alt = participate(experiment_name, alts, client_id,
                                  force=force, record_force=record_force,
                                  traffic_fraction=traffic_fraction,
                                  prefetch=prefetch, datetime=dt, redis=self.redis)
        except ValueError as e:
            return json_error({'message': str(e)}, request, 400)

        resp = {
            'alternative': {
                'name': alt.name
            },
            'experiment': {
                'name': alt.experiment.name,
            },
            'client_id': client_id,
            'status': 'ok'
        }

        return json_success(resp, request)
开发者ID:seatgeek,项目名称:sixpack,代码行数:47,代码来源:server.py

示例6: on_convert

# 需要导入模块: from models import Experiment [as 别名]
# 或者: from models.Experiment import find [as 别名]
    def on_convert(self, request):
        if should_exclude_visitor(request):
            return json_success({'excluded': 'true'}, request)

        experiment_name = request.args.get('experiment')
        client_id = request.args.get('client_id')
        kpi = request.args.get('kpi', None)

        if client_id is None or experiment_name is None:
            return json_error({'message': 'missing arguments'}, request, 400)

        client = Client(client_id, self.redis)

        try:
            experiment = Experiment.find(experiment_name, self.redis)
            if cfg.get('enabled', True):
                dt = None
                if request.args.get("datetime"):
                    dt = dateutil.parser.parse(request.args.get("datetime"))
                alternative = experiment.convert(client, dt=dt, kpi=kpi)
            else:
                alternative = experiment.control.name
        except ValueError as e:
            return json_error({'message': str(e)}, request, 400)

        resp = {
            'alternative': {
                'name': alternative
            },
            'experiment': {
                'name': experiment.name,
            },
            'conversion': {
                'value': None,
                'kpi': kpi
            },
            'client_id': client_id
        }

        return json_success(resp, request)
开发者ID:Onasusweb,项目名称:sixpack,代码行数:42,代码来源:server.py

示例7: on_experiment_details

# 需要导入模块: from models import Experiment [as 别名]
# 或者: from models.Experiment import find [as 别名]
    def on_experiment_details(self, request, name):
        exp = Experiment.find(name, redis=self.redis)
        if exp is None:
            return json_error({'message': 'experiment not found'}, request, 404)

        return json_success(exp.objectify_by_period('day', True), request)
开发者ID:VerticodeLabs,项目名称:sixpack,代码行数:8,代码来源:server.py


注:本文中的models.Experiment.find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。