Exemple #1
0
def retrieve_summary(model_task='.*',
                     model_name='.*',
                     dataset_name='.*',
                     expname='.*',
                     score_name='.*',
                     split='.*',
                     model_id=None):
    """
    Retrieve previously computed summary
    """
    with session_scope() as sess:
        query = sess.query(VegaiModelzoo).\
                filter(VegaiModelzoo.model_name.op('~')(model_name)).\
                filter(VegaiModelzoo.dataset_name.op('~')(dataset_name)).\
                filter(VegaiModelzoo.model_task.op('~')(model_task)).\
                filter(VegaiModelzoo.score_name.op('~')(score_name)).\
                filter(VegaiModelzoo.split.op('~')(split)).\
                filter(VegaiModelzoo.expname.op('~')(expname))
        if model_id is not None:
            query = query.filter(VegaiModelzoo.model_id == model_id)
        records = query.all()
        entries = []
        for record in records:
            record = Box(record.__dict__)
            record.pop('_sa_instance_state')
            entries.append(record)
    return pd.DataFrame(entries)
Exemple #2
0
 def update_task(self, expname, **kwargs):
     with session_scope() as sess:
         entry = dict(model_task=self.model_task,
                      model_name=self.model_name,
                      expname=expname)
         model_id = hashlib.sha1(json.dumps(entry).encode()).hexdigest()
         entry = sess.query(VegaiModelzoo).filter(
             VegaiModelzoo.model_id == model_id).all()[0]
         for key, value in kwargs.items():
             setattr(entry, key, value)
Exemple #3
0
 def log_task(self, expname: str):
     with session_scope() as sess:
         entry = dict(model_task=self.model_task,
                      model_name=self.model_name,
                      expname=expname)
         model_id = self.get_model_id(expname)
         entry = VegaiModelzoo(
             model_id=model_id,
             status="started",
             created_on=datetime.datetime.now().strftime("%Y-%m-%d %H:%M"),
             **entry)
         sess.add(entry)
Exemple #4
0
def get_dataset_name():
    with dionysos.session_scope() as sess:
        names = sess.query(dionysos.Dataset.dataset_name).all()
        names = [
            n.dataset_name for n in names
            if bool(re.match('cloglossv0.*(?<!overfit)$', n.dataset_name))
        ]
    i = 0
    while True:
        proposal = 'cloglossv0d{}'.format(i)
        if proposal not in names:
            break
        i += 1
    return proposal
Exemple #5
0
 def next_trial_name(self):
     with session_scope() as sess:
         results = sess.query(VegaiModelzoo).filter(
             VegaiModelzoo.model_task == self.model_task).filter(
                 VegaiModelzoo.model_name == self.model_name).filter(
                     VegaiModelzoo.expname.op('~')("{}.*".format(
                         self.config_name))).all()
         expnames = [r.expname for r in results]
         if not expnames:
             idx = 0
         else:
             idx = max(
                 [int(expname.split('t')[-1]) for expname in expnames])
     expname = "{}t{}".format(self.config_name, idx + 1)
     return expname
Exemple #6
0
def add_entry_to_dataset_table(entry):
    with session_scope() as sess:
        sess.query(Dataset).filter(
            Dataset.dataset_name == entry.dataset_name).delete()
        sess.add(entry)