Skip to content

Commit

Permalink
release test fixes (#1078)
Browse files Browse the repository at this point in the history
* fixes

* one more
  • Loading branch information
piotrm0 authored Apr 17, 2024
1 parent 02c1bf9 commit 3d33ffb
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion trulens_eval/examples/experimental/db_populate.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"\n",
"Tru().migrate_database()\n",
"\n",
"from trulens_eval.database.migrations.db_data_migration import _sql_alchemy_serialization_asserts\n",
"from trulens_eval.database.migrations.data import _sql_alchemy_serialization_asserts\n",
"_sql_alchemy_serialization_asserts(tru.db)"
]
},
Expand Down
2 changes: 1 addition & 1 deletion trulens_eval/tests/docs_notebooks/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def preprocess_cell(self, cell, resources, index, **kwargs):
cell["source"] = cell[
"source"
] + f"\nfrom trulens_eval import Tru\ntru=Tru()\ntru.migrate_database()\n" \
+ f"\nfrom trulens_eval.database.migrations.db_data_migration import _sql_alchemy_serialization_asserts\n_sql_alchemy_serialization_asserts(tru.db)\n"
+ f"\nfrom trulens_eval.database.migrations.data import _sql_alchemy_serialization_asserts\n_sql_alchemy_serialization_asserts(tru.db)\n"
ret = super().preprocess_cell(cell, resources, index, **kwargs)

return ret
Expand Down
1 change: 1 addition & 0 deletions trulens_eval/trulens_eval/database/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def check_db_revision(self):
Raises:
ValueError: If the database is not up to date.
"""
raise NotImplementedError()

@abc.abstractmethod
def insert_record(
Expand Down
11 changes: 2 additions & 9 deletions trulens_eval/trulens_eval/database/legacy/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class VersionException(Exception):

MIGRATION_UNKNOWN_STR = "unknown[db_migration]"
migration_versions: List[str] = [
"0.25.2", "0.19.0", "0.9.0", "0.3.0", "0.2.0", "0.1.2"
"0.19.0", "0.9.0", "0.3.0", "0.2.0", "0.1.2"
]


Expand Down Expand Up @@ -152,12 +152,6 @@ def unknown_method(self):
"""


def migrate_0_25_2(db):
# Change in alchemy version table name.

pass


def migrate_0_9_0(db):
rename_classinfo = jsonlike_rename_key("__tru_class_info", "tru_class_info")
rename_objserial = jsonlike_rename_value("ObjSerial", "Obj")
Expand Down Expand Up @@ -429,8 +423,7 @@ def migrate_0_1_2(db):
"0.1.2": ("0.2.0", migrate_0_1_2),
"0.2.0": ("0.3.0", migrate_0_2_0),
"0.3.0": ("0.9.0", migrate_0_3_0),
"0.9.0": ("0.19.0", migrate_0_9_0),
"0.19.0": ("0.25.2.0", migrate_0_25_2)
"0.9.0": ("0.19.0", migrate_0_9_0)
}


Expand Down
14 changes: 10 additions & 4 deletions trulens_eval/trulens_eval/database/legacy/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import json
from pathlib import Path
import sqlite3
from typing import Any, ClassVar, Dict, List, Optional, Sequence, Tuple, Union
from typing import (Any, ClassVar, Dict, Iterable, List, Optional, Sequence,
Tuple, Union)

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -434,7 +435,7 @@ def map_row(row):
# Add a try-catch here as latency is a DB breaking change, but not a functionality breaking change.
# If it fails, we can still continue.
row.perf_json = json.loads(row.perf_json) # perf_json (Perf)
row['latency'] = Perf(**row.perf_json).latency
row['latency'] = schema.Perf(**row.perf_json).latency
except:
# If it comes here, it is because we have filled the DB with a migration tag that cannot be loaded into perf_json
# This is not migrateable because start/end times were not logged and latency is required, but adding a real latency
Expand Down Expand Up @@ -527,7 +528,7 @@ def get_records_and_feedback(
df_records['total_cost'] = cost.map(lambda v: v.cost)

perf = df_records['perf_json'].apply(
lambda perf_json: Perf.model_validate_json(perf_json)
lambda perf_json: schema.Perf.model_validate_json(perf_json)
if perf_json != MIGRATION_UNKNOWN_STR else MIGRATION_UNKNOWN_STR
)

Expand Down Expand Up @@ -603,4 +604,9 @@ def get_feedback_count_by_status(

def delete_app(self, app_id: schema.AppID) -> None:
raise NotImplementedError("This database implementation is deprecated.")


def get_apps(self) -> Iterable[JSON]:
raise NotImplementedError("This database implementation is deprecated.")

def check_db_revision(self):
raise NotImplementedError("This database implementation is deprecated.")
4 changes: 2 additions & 2 deletions trulens_eval/trulens_eval/database/migrations/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def _sql_alchemy_serialization_asserts(db: DB) -> None:

import inspect

from trulens_eval.database import orm
#from trulens_eval.database import orm

# Dynamically check the orm classes since these could change version to version
for _, orm_obj in inspect.getmembers(orm):
for _, orm_obj in inspect.getmembers(db.orm):

# Check only classes
if inspect.isclass(orm_obj):
Expand Down

0 comments on commit 3d33ffb

Please sign in to comment.