Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Check exp_id in experiment list #6305

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading