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


Python Experiment.save方法代码示例

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


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

示例1: _process_experiment

# 需要导入模块: from models import Experiment [as 别名]
# 或者: from models.Experiment import save [as 别名]
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,代码行数:33,代码来源:forms.py

示例2: test_db

# 需要导入模块: from models import Experiment [as 别名]
# 或者: from models.Experiment import save [as 别名]
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,代码行数:14,代码来源:views.py

示例3: config_upload

# 需要导入模块: from models import Experiment [as 别名]
# 或者: from models.Experiment import save [as 别名]
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,代码行数:20,代码来源:views.py

示例4: add_experiment

# 需要导入模块: from models import Experiment [as 别名]
# 或者: from models.Experiment import save [as 别名]
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,代码行数:21,代码来源:views.py

示例5: updateTaskInDb

# 需要导入模块: from models import Experiment [as 别名]
# 或者: from models.Experiment import save [as 别名]
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,代码行数:25,代码来源:exprunner.py

示例6: Dictator

# 需要导入模块: from models import Experiment [as 别名]
# 或者: from models.Experiment import save [as 别名]
class Dictator(object):
    executioner = None
    experiment = None
    eventObjects = None
    
    def __init__(self,protocol,nickname):
        dt = datetime.now()
        self.experiment = Experiment(name=nickname,protocol=protocol,time_start=dt)
        self.experiment.save()
        self.executioner = Executioner() 
        libarian.init_db_cache(self.experiment)
        # self.lock = Lock()
    
    def current_trial(self):
        return poke_cache(str(self.experiment.id)+'.trial_current',self.experiment.current_trial(),secs=60)
    
    def start(self):
        self.executioner.start()
    
    def complete(self):
        current_trial = self.experiment.current_trial()
        if current_trial!=None:
            current_trial.duration = libarian.time_since_trial(self.experiment.id)
            current_trial.save()
        self.experiment.total_duration = libarian.time_since_exp(self.experiment.id)
        self.experiment.set_trials_completed()
        self.experiment.time_complete = datetime.now()
        self.experiment.save()
        # libarian.clear_db_cache()

    def new_trial(self):
        total_time = libarian.time_since_exp(self.experiment.id)
        trial_time = libarian.time_since_trial(self.experiment.id)
        new_trial = Trial(experiment=self.experiment, duration=Decimal(0.0),completed=False,time_start=datetime.now())
        new_trial.save()
        old_trial = libarian.get_trial_current(self.experiment.id)
        if old_trial!=None:
            w.NextTrialThread(old_trial,new_trial,trial_time,total_time,self.experiment).start()
        else:
            w.NewHappening('TRL','New Trial',total_time,self.experiment).start()
        libarian.set_trial_current(new_trial,self.experiment.id)
        self.executioner.interval_pointer = 0
        self.executioner.is_new_trial = True
        libarian.set_interval_start(datetime.now(),self.experiment.id)
    
    def check_emulate_action(self,action_type):
        if em.Action.objects.filter(type=action_type).count()==1:
            act = em.Action.objects.filter(type=action_type)[0]
            try:
                ea =  EmulateAction.objects.filter(experiment=self.experiment, action=act).latest('id')
                self.action_happen('%s'%(action_type),action_type,ea.time_occurred)
                ea.delete()
                return True
            except ObjectDoesNotExist:
                return False
        else:
            return False
    
    def run_simulate_events(self):
        event_ids = SimEvent.objects.filter(experiment=self.experiment)
        for se in event_ids:
            self.eventObjects[se.eventid].perform(time=se.time_occurred)
        event_ids.delete()    
    
    def action_happen(self,description,keyname,given_time=None):
        if given_time==None:
            time = libarian.time_since_exp(self.experiment.id)
        else:
            time = given_time
        thready = w.NewHappening('ACT',keyname,description,time,self.experiment)
        thready.start()
        
    def event_happen(self,description,keyname,given_time=None):
        if given_time==None:
            time = libarian.time_since_exp(self.experiment.id)
        else:
            time = given_time
        thready = w.NewHappening('EVT',keyname,description,time,self.experiment)
        thready.start()
        
    def interval_happen(self,description,keyname):
        time = libarian.time_since_exp(self.experiment.id)
        thready = w.NewHappening('ITL',keyname,description,time,self.experiment)
        thready.start()
开发者ID:algobunny,项目名称:aed-web,代码行数:86,代码来源:boss.py


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