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)
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
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)
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.')
def exp_id(self) -> int: return select_one_where(self.conn, "runs", "exp_id", "run_id", self.run_id)
def parameters(self) -> str: return select_one_where(self.conn, "runs", "parameters", "run_id", self.run_id)
def counter(self): return select_one_where(self.conn, "runs", "result_counter", "run_id", self.run_id)
def table_name(self): return select_one_where(self.conn, "runs", "result_table_name", "run_id", self.run_id)
def name(self): return select_one_where(self.conn, "runs", "name", "run_id", self.run_id)
def finished_at(self) -> int: return select_one_where(self.conn, "experiments", "exp_id", "end_time", self.exp_id)
def started_at(self) -> int: return select_one_where(self.conn, "experiments", "exp_id", "start_time", self.exp_id)
def sample_name(self) -> str: return select_one_where(self.conn, "experiments", "sample_name", "exp_id", self.exp_id)
def format_string(self) -> str: return select_one_where(self.conn, "experiments", "format_string", "exp_id", self.exp_id)
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)