Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset_database only drops trulens tables #1676

Merged
merged 4 commits into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/core/trulens/core/database/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import pydantic
from pydantic import Field
import sqlalchemy as sa
from sqlalchemy import Table
from sqlalchemy.orm import joinedload
from sqlalchemy.orm import sessionmaker
from sqlalchemy.sql import text as sql_text
Expand Down Expand Up @@ -347,9 +348,16 @@ def reset_database(self):
"""See [DB.reset_database][trulens.core.database.base.DB.reset_database]."""

# meta = MetaData()
meta = self.orm.metadata #
meta.reflect(bind=self.engine)
meta.drop_all(bind=self.engine)
meta = self.orm.metadata

tables = [
Table(f"{self.table_prefix}alembic_version", self.orm.metadata)
] + [
c.__table__
for c in self.orm.registry.values()
if hasattr(c, "__table__")
]
meta.drop_all(bind=self.engine, tables=tables)

self.migrate_database()

Expand Down