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


Python models.Experiment类代码示例

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


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

示例1: _process_experiment

def _process_experiment(reduction_obj, expt_string):
    """
        Process the experiment string of a form and find/create
        the appropriate Experiment object
        @param reduction_obj: ReductionProcess or ReductionConfiguration object
        @param expt_string: string taken from the reduction form
    """
    # Find experiment
    uncategorized_expt = Experiment.objects.get_uncategorized('eqsans')
    expts = expt_string.split(',')
    for item in expts:
        # Experiments have unique names of no more than 24 characters
        expt_objs = Experiment.objects.filter(name=item.upper().strip()[:24])
        if len(expt_objs)>0:
            if expt_objs[0] not in reduction_obj.experiments.all():
                reduction_obj.experiments.add(expt_objs[0])
        else:
            expt_obj = Experiment(name=item.upper().strip()[:24])
            expt_obj.save()
            reduction_obj.experiments.add(expt_obj)
    
    # Clean up the uncategorized experiment object if we found
    # at least one suitable experiment to associate with this reduction
    if len(expts)>0:
        if uncategorized_expt in reduction_obj.experiments.all():
            try:
                reduction_obj.experiments.remove(uncategorized_expt)
            except:
                logger.error("Could not remote uncategorized expt: %s" % sys.exc_value)
    else:
        reduction_obj.experiments.add(uncategorized_expt)
开发者ID:serena617,项目名称:reduction_service,代码行数:31,代码来源:forms.py

示例2: test_db

def test_db(req):
  print 'hit inside test_db'
  
  data = {
    "cpus":"1",
    "dogs":"3"
  }
  experiment = Experiment(name="experiment a", details=data) 
  experiment.save()


  return {}
开发者ID:ostrichjockey,项目名称:elbanalyze,代码行数:12,代码来源:views.py

示例3: participate

def participate(experiment, alternatives, client_id,
    force=None,
    record_force=False,
    traffic_fraction=None,
    prefetch=False,
    datetime=None,
    redis=None):

    exp = Experiment.find_or_create(experiment, alternatives, traffic_fraction=traffic_fraction, redis=redis)

    alt = None
    if force and force in alternatives:
        alt = Alternative(force, exp, redis=redis)

        if record_force:
            client = Client(client_id, redis=redis)
            alt.record_participation(client, datetime)

    elif not cfg.get('enabled', True):
        alt = exp.control
    elif exp.winner is not None:
        alt = exp.winner
    else:
        client = Client(client_id, redis=redis)
        alt = exp.get_alternative(client, dt=datetime, prefetch=prefetch)

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

示例4: find_or_404

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,代码行数:8,代码来源:web.py

示例5: find_or_404

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,代码行数:8,代码来源:web.py

示例6: find_or_404

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,代码行数:9,代码来源:web.py

示例7: config_upload

def config_upload(req):
  #print 'req is: '+str(req)
  #print 'req.post is: '+str(req.POST)
  #print 'req files is '+str(req.FILES)
  #data = req.FILES['uploadedFile'].read()
  data = json.load(req.FILES['uploadedFile'])
  filename = req.FILES['uploadedFile']
  #json_data = json.load(data)
  #for s in data:
  #print s
  #TODO filename != name...
  experiment = Experiment(name=filename, details=data)
  experiment.save()

  return render_to_response(
      'index.html', {
    }, context_instance=RequestContext(req)
  )
开发者ID:ostrichjockey,项目名称:elbanalyze,代码行数:18,代码来源:views.py

示例8: add_experiment

def add_experiment(req):
  experiment_name = req.POST['experiment_name']
  filename = req.FILES['uploadedFile']
  data = json.load(req.FILES['uploadedFile'])

  experiment = Experiment(experiment_name=experiment_name, filename=filename, config_options=data)
  experiment.save()
  print str(experiment.id)

  # chop off fractional second
  left = experiment.last_modified.isoformat()[0:19]
  right = experiment.last_modified.isoformat()[26:]
  last_modified_fix = left + right
  return {
    'id': experiment.id,
    'experiment_name': experiment_name,
    'filename': str(filename),
    'last_modified': last_modified_fix,
  }
开发者ID:ostrichjockey,项目名称:elbanalyze,代码行数:19,代码来源:views.py

示例9: convert

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,代码行数:14,代码来源:api.py

示例10: on_participate

    def on_participate(self, request):
        opts = {}
        alts = request.args.getlist('alternatives')
        experiment_name = request.args.get('experiment')
        force = request.args.get('force')
        client_id = request.args.get('client_id')
        distribution = request.args.get('traffic_dist')

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

        if distribution:
            opts['distribution'] = distribution

        try:
            experiment = Experiment.find_or_create(experiment_name, alts, self.redis, opts)
        except ValueError as e:
            return json_error({'message': str(e)}, request, 400)

        alternative = None
        if force and force in alts:
            alternative = force
        elif not cfg.get('enabled', True):
            alternative = alts[0]
        elif experiment.winner is not None:
            alternative = experiment.winner
        elif should_exclude_visitor(request):
            alternative = alts[0]
        else:
            dt = None
            if request.args.get("datetime"):
                dt = dateutil.parser.parse(request.args.get("datetime"))
            client = Client(client_id, self.redis)
            alternative = experiment.get_alternative(client, dt=dt).name

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

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

示例11: on_participate

    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,代码行数:45,代码来源:server.py

示例12: experiment_clone

def experiment_clone(expid=None):
    if not expid:
        expid = request.cookies.get('project')
        if not expid:
            return render_template('error.html',message="Proyecto no seleccionado",recent=recent.get())
        expid=int(expid)
    exp_=db_session.query(Experiment).get(expid)
    if not exp_:
        return render_template('error.html',message="Experimento no definido",recent=recent.get())
    exp=Experiment()
    exp.name="CLONE:"+exp_.name
    exp.definition=exp_.definition
    exp.description=exp_.description
    exp.instructions=exp_.instructions
    exp.invitation=exp_.invitation
    exp.reinvitation=exp_.reinvitation
    db_session.add(exp)
    db_session.commit()
    return redirect(url_for('.experiment_info',expid=exp.id))
开发者ID:ivanvladimir,项目名称:golempoll,代码行数:19,代码来源:dashboard.py

示例13: on_convert

    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,代码行数:40,代码来源:server.py

示例14: updateTaskInDb

def updateTaskInDb(name, status, pk=None):
    # acquire lock
    dbUpdateLock.acquire()
    try:
        # check if entry in db
        if pk is None:
            # if not in db, make new one
            ne = Experiment(name=name, status=status)
            ne.save()
            pk = ne.pk

        else:
            # if present, retrieve and update it
            ne = Experiment.objects.get(pk=pk)
            ne.status = status
            ne.save()
            pk = ne.pk
    except:
        print "Error in updating database entry"
        pk = None
    finally:
        dbUpdateLock.release()
    return pk
开发者ID:nagrajan,项目名称:exper,代码行数:23,代码来源:exprunner.py

示例15: hello

def hello():
    experiments = Experiment.all(db.REDIS)
    experiments = [exp.name for exp in experiments]
    return render_template('dashboard.html', experiments=experiments, page='home')
开发者ID:CypherSystems,项目名称:sixpack,代码行数:4,代码来源:web.py


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