Skip to content

Commit

Permalink
Merge pull request #6305 from GOTYGuyOfTheYear/hotfix/exp_id-range-no…
Browse files Browse the repository at this point in the history
…t-checked

Fix: Check exp_id in experiment list
  • Loading branch information
jenshnielsen authored Aug 2, 2024
2 parents e7dd669 + 071736e commit 68589ff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/qcodes/dataset/experiment_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ def __init__(

self.conn = conn_from_dbpath_or_conn(conn, path_to_db)

max_id = len(get_experiments(self.conn))
experiments_list = get_experiments(self.conn)

if exp_id is not None:
if exp_id not in range(1, max_id+1):
if exp_id not in experiments_list:
raise ValueError('No such experiment in the database')
self._exp_id = exp_id
else:
Expand All @@ -86,7 +86,7 @@ def __init__(
"(name, exp_id, run_counter)") from e

log.info(f"creating new experiment in {self.path_to_db}")

max_id = max(experiments_list, default=0)
name = name or f"experiment_{max_id+1}"
sample_name = sample_name or "some_sample"
self._exp_id = ne(self.conn, name, sample_name, format_string)
Expand Down

0 comments on commit 68589ff

Please sign in to comment.