Skip to content

Commit e865b70

Browse files
committed
Allow one-time migration of old experiment stats from older H2O-LLMStudio versions
1 parent bb2b85d commit e865b70

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

llm_studio/app_utils/utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from diskcache import Cache
3535
from h2o_wave import Choice, Q, ui
3636
from pandas.core.frame import DataFrame
37+
from sqlitedict import SqliteDict
3738

3839
from llm_studio.app_utils.db import Experiment
3940
from llm_studio.python_configs.base import DefaultConfigProblemBase
@@ -1643,9 +1644,21 @@ def get_experiments_info(df: DataFrame, q: Q) -> defaultdict:
16431644
loss_function = ""
16441645

16451646
charts_db_path = os.path.join(row.path, "charts_cache")
1647+
old_db_path = os.path.join(row.path, "charts.db")
16461648
if os.path.exists(charts_db_path):
16471649
with Cache(charts_db_path) as cache:
16481650
logs = {key: cache.get(key) for key in cache}
1651+
1652+
if not logs and os.path.exists(old_db_path):
1653+
# migrate the old DB over to the new diskcache, should only need to be run once
1654+
# we could delete the old charts.db, but we don't want to risk the user stopping
1655+
# the service during the migration and therefore causing permanent data loss
1656+
with SqliteDict(old_db_path) as sqlite_logs:
1657+
keys = list(sqlite_logs.iterkeys())
1658+
for key in keys:
1659+
cache.add(key, sqlite_logs[key])
1660+
logs = {key: cache.get(key) for key in cache}
1661+
16491662
if "internal" in logs.keys():
16501663
if "current_step" in logs["internal"].keys():
16511664
curr_step = int(logs["internal"]["current_step"]["values"][-1])

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@ soupsieve==2.8
523523
# via beautifulsoup4
524524
sqlalchemy==2.0.43
525525
# via h2o-llmstudio
526+
sqlitedict==2.1.0
527+
# via h2o-llmstudio
526528
starlette==0.47.3
527529
# via h2o-wave
528530
swagger-spec-validator==3.0.4

0 commit comments

Comments
 (0)