Skip to content

Commit

Permalink
update exp_id when writing metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshnielsen committed Jun 19, 2023
1 parent 3bb63fe commit 628b826
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion qcodes/dataset/data_set_in_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ def write_metadata_to_db(self, path_to_db: str | Path | None = None) -> None:
sample_name=self.sample_name,
load_last_duplicate=True,
)
_, run_id = _add_run_to_runs_table(
counter, run_id, _ = _add_run_to_runs_table(
self, aconn, exp.exp_id, create_run_table=False
)
self._exp_id = exp.exp_id
self._run_id = run_id
self._counter = counter
self._path_to_db = conn.path_to_dbfile

@classmethod
Expand Down
4 changes: 3 additions & 1 deletion qcodes/dataset/database_extract_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ def _extract_single_dataset_into_db(dataset: DataSet,
if run_id is not None:
return

target_table_name, _ = _add_run_to_runs_table(dataset, target_conn, target_exp_id)
_, _, target_table_name = _add_run_to_runs_table(
dataset, target_conn, target_exp_id
)
assert target_table_name is not None
_populate_results_table(
source_conn, target_conn, dataset.table_name, target_table_name
Expand Down
7 changes: 4 additions & 3 deletions qcodes/dataset/dataset_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ def _add_run_to_runs_table(
target_conn: ConnectionPlus,
target_exp_id: int,
create_run_table: bool = True,
) -> tuple[str | None, int]:
) -> tuple[int, int, str | None]:
metadata = dataset.metadata
snapshot_raw = dataset._snapshot_raw
captured_run_id = dataset.captured_run_id
captured_counter = dataset.captured_counter
parent_dataset_links = links_to_str(dataset.parent_dataset_links)
_, target_run_id, target_table_name = create_run(
target_counter, target_run_id, target_table_name = create_run(
target_conn,
target_exp_id,
name=dataset.name,
Expand All @@ -41,4 +41,5 @@ def _add_run_to_runs_table(
dataset.run_timestamp_raw,
dataset.completed_timestamp_raw,
)
return target_table_name, target_run_id
# todo reorder to match the order in create_run
return target_counter, target_run_id, target_table_name

0 comments on commit 628b826

Please sign in to comment.