示例#1
0
 def parameters(self) -> str:
     if self.pristine:
         psnames = [ps.name for ps in self.description.interdeps.paramspecs]
         return ','.join(psnames)
     else:
         return select_one_where(self.conn, "runs", "parameters", "run_id",
                                 self.run_id)
示例#2
0
 def snapshot_raw(self) -> Optional[str]:
     """Snapshot of the run as a JSON-formatted string (or None)"""
     if is_column_in_table(self.conn, "runs", "snapshot"):
         return select_one_where(self.conn, "runs", "snapshot", "run_id",
                                 self.run_id)
     else:
         return None
示例#3
0
 def _get_run_description_from_db(self) -> RunDescriber:
     """
     Look up the run_description from the database
     """
     desc_str = select_one_where(self.conn, "runs", "run_description",
                                 "run_id", self.run_id)
     return RunDescriber.from_json(desc_str)
示例#4
0
def fix_wrong_run_descriptions(conn: ConnectionPlus,
                               run_ids: Sequence[int]) -> None:
    """
    NB: This is a FIX function. Do not use it unless your database has been
    diagnosed with the problem that this function fixes.

    Overwrite faulty run_descriptions by using information from the layouts and
    dependencies tables. If a correct description is found for a run, that
    run is left untouched.

    Args:
        conn: The connection to the database
        run_ids: The runs to (potentially) fix
    """

    user_version = get_user_version(conn)

    if not user_version == 3:
        raise RuntimeError('Database of wrong version. Will not apply fix. '
                           'Expected version 3, found version {user_version}')

    log.info('[*] Fixing run descriptions...')
    for run_id in run_ids:
        trusted_paramspecs = get_parameters(conn, run_id)
        trusted_desc = RunDescriber(interdeps=InterDependencies(
            *trusted_paramspecs))

        actual_desc_str = select_one_where(conn, "runs", "run_description",
                                           "run_id", run_id)

        if actual_desc_str == trusted_desc.to_json():
            log.info(f'[+] Run id: {run_id} had an OK description')
        else:
            log.info(f'[-] Run id: {run_id} had a broken description. '
                     f'Description found: {actual_desc_str}')
            update_run_description(conn, run_id, trusted_desc.to_json())
            log.info(f'    Run id: {run_id} has been updated.')
示例#5
0
 def exp_id(self) -> int:
     return select_one_where(self.conn, "runs",
                             "exp_id", "run_id", self.run_id)
示例#6
0
 def parameters(self) -> str:
     return select_one_where(self.conn, "runs",
                             "parameters", "run_id", self.run_id)
示例#7
0
 def counter(self):
     return select_one_where(self.conn, "runs",
                             "result_counter", "run_id", self.run_id)
示例#8
0
 def table_name(self):
     return select_one_where(self.conn, "runs",
                             "result_table_name", "run_id", self.run_id)
示例#9
0
 def name(self):
     return select_one_where(self.conn, "runs",
                             "name", "run_id", self.run_id)
示例#10
0
 def finished_at(self) -> int:
     return select_one_where(self.conn, "experiments", "exp_id", "end_time",
                             self.exp_id)
示例#11
0
 def started_at(self) -> int:
     return select_one_where(self.conn, "experiments", "exp_id",
                             "start_time", self.exp_id)
示例#12
0
 def sample_name(self) -> str:
     return select_one_where(self.conn, "experiments", "sample_name",
                             "exp_id", self.exp_id)
示例#13
0
 def format_string(self) -> str:
     return select_one_where(self.conn, "experiments", "format_string",
                             "exp_id", self.exp_id)
示例#14
0
 def snapshot_raw(self) -> Optional[str]:
     """Snapshot of the run as a JSON-formatted string (or None)"""
     return select_one_where(self.conn, "runs", "snapshot",
                             "run_id", self.run_id)