Skip to content

Commit 881ced0

Browse files
authored
Merge branch 'main' into changeset-release/main
2 parents 1e8bad8 + 1657dfd commit 881ced0

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

trackio/bucket_storage.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import shutil
2-
import sqlite3
32
import tempfile
43
from pathlib import Path
54

@@ -11,7 +10,7 @@
1110

1211

1312
def create_bucket_if_not_exists(bucket_id: str, private: bool | None = None) -> None:
14-
huggingface_hub.create_bucket(bucket_id, private=private or False, exist_ok=True)
13+
huggingface_hub.create_bucket(bucket_id, private=private, exist_ok=True)
1514

1615

1716
def download_bucket_to_trackio_dir(bucket_id: str) -> None:
@@ -64,14 +63,14 @@ def _local_db_has_data(project: str) -> bool:
6463
db_path = SQLiteStorage.get_project_db_path(project)
6564
if not db_path.exists() or db_path.stat().st_size == 0:
6665
return False
67-
conn = sqlite3.connect(str(db_path), timeout=5.0)
6866
try:
69-
count = conn.execute("SELECT COUNT(*) FROM metrics").fetchone()[0]
70-
return count > 0
67+
with SQLiteStorage._get_connection(
68+
db_path, configure_pragmas=False, row_factory=None
69+
) as conn:
70+
count = conn.execute("SELECT COUNT(*) FROM metrics").fetchone()[0]
71+
return count > 0
7172
except Exception:
7273
return False
73-
finally:
74-
conn.close()
7574

7675

7776
def upload_project_to_bucket_for_static(project: str, bucket_id: str) -> None:

0 commit comments

Comments
 (0)