Skip to content

Commit 79f63f4

Browse files
fix: #280 NotADirectoryError message and fixed test_import_export test. (#289)
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
1 parent 3b5adc3 commit 79f63f4

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@pytest.fixture
1212
def temp_dir(monkeypatch):
1313
"""Fixture that creates a temporary TRACKIO_DIR."""
14-
with tempfile.TemporaryDirectory() as tmpdir:
14+
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as tmpdir:
1515
for name in ["trackio.sqlite_storage"]:
1616
monkeypatch.setattr(f"{name}.TRACKIO_DIR", Path(tmpdir))
1717
for name in ["trackio.media", "trackio.file_storage"]:

tests/test_sqlite_storage.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gc
12
import multiprocessing
23
import os
34
import platform
@@ -65,13 +66,17 @@ def test_import_export(temp_dir):
6566
SQLiteStorage.log(project="proj1", run="run1", metrics={"a": 1})
6667
SQLiteStorage.log(project="proj2", run="run2", metrics={"b": 2})
6768
SQLiteStorage.export_to_parquet()
69+
6870
metrics_before = {}
6971
for proj in SQLiteStorage.get_projects():
7072
if proj not in metrics_before:
7173
metrics_before[proj] = {}
7274
for run in SQLiteStorage.get_runs(proj):
7375
metrics_before[proj][run] = SQLiteStorage.get_logs(proj, run)
7476

77+
## there might be open connections from previous test, hence closing them
78+
gc.collect()
79+
[conn.close() for conn in gc.get_objects() if isinstance(conn, sqlite3.Connection)]
7580
# clear existing SQLite data
7681
os.unlink(db_path_1)
7782
os.unlink(db_path_2)

0 commit comments

Comments
 (0)