|
5 | 5 | """ |
6 | 6 | import os |
7 | 7 | import sys |
| 8 | +from contextlib import closing |
8 | 9 | from itertools import chain |
9 | 10 | from operator import attrgetter |
10 | 11 | from typing import Dict, List, Set, Union, TYPE_CHECKING, Any, Tuple, Optional, cast |
@@ -191,22 +192,23 @@ def get_runs_from_db(path: str, start: int = 0, |
191 | 192 | """ |
192 | 193 | initialise_or_create_database_at(path) |
193 | 194 | if sys.version_info >= (3, 11): |
194 | | - conn = conn_from_dbpath_or_conn(read_only=True) |
| 195 | + conn = conn_from_dbpath_or_conn(conn=None, path_to_db=path, read_only=True) |
195 | 196 | else: |
196 | | - conn = conn_from_dbpath_or_conn() |
197 | | - exps = experiments(conn=conn) |
| 197 | + conn = conn_from_dbpath_or_conn(conn=None, path_to_db=path) |
| 198 | + with closing(conn) as conn_: |
| 199 | + exps = experiments(conn=conn_) |
198 | 200 |
|
199 | | - datasets = sorted( |
200 | | - chain.from_iterable(exp.data_sets() for exp in exps), |
201 | | - key=attrgetter('run_id') |
202 | | - ) |
| 201 | + datasets = sorted( |
| 202 | + chain.from_iterable(exp.data_sets() for exp in exps), |
| 203 | + key=attrgetter('run_id') |
| 204 | + ) |
203 | 205 |
|
204 | | - # There is no need for checking whether ``stop`` is ``None`` because if |
205 | | - # it is the following is simply equivalent to ``datasets[start:]`` |
206 | | - datasets = datasets[start:stop] |
| 206 | + # There is no need for checking whether ``stop`` is ``None`` because if |
| 207 | + # it is the following is simply equivalent to ``datasets[start:]`` |
| 208 | + datasets = datasets[start:stop] |
207 | 209 |
|
208 | | - overview = {ds.run_id: get_ds_info(ds, get_structure=get_structure) |
209 | | - for ds in datasets} |
| 210 | + overview = {ds.run_id: get_ds_info(ds, get_structure=get_structure) |
| 211 | + for ds in datasets} |
210 | 212 | return overview |
211 | 213 |
|
212 | 214 |
|
|
0 commit comments