Skip to content

trulens.core.database.legacy.migration

trulens.core.database.legacy.migration

This is pre-sqlalchemy db migration. This file should not need changes. It is here for backwards compatibility of oldest TruLens versions.

Attributes

logger module-attribute

logger = getLogger(__name__)

How to make a db migrations:

  1. Create a compatibility DB (checkout the last pypi rc branch https://github.com/truera/trulens/tree/releases/rc-trulens-X.x.x/): In trulens/tests/docs_notebooks/notebooks_to_test remove any local dbs

    • rm rf default.sqlite run below notebooks (Making sure you also run with the same X.x.x version trulens)
    • all_tools.ipynb # cp cp ../generated_files/all_tools.ipynb ./
    • llama_index_quickstart.ipynb # cp frameworks/llama_index/llama_index_quickstart.ipynb ./
    • langchain-retrieval-augmentation-with-trulens.ipynb # cp vector-dbs/pinecone/langchain-retrieval-augmentation-with-trulens.ipynb ./
    • Add any other notebooks you think may have possible breaking changes replace the last compatible db with this new db file
    • See the last COMPAT_VERSION: compatible version in leftmost below: migration_versions
    • mv default.sqlite trulens/release_dbs/COMPAT_VERSION/default.sqlite
  2. Do Migration coding

  3. Update init.py with the new version
  4. The upgrade methodology is determined by this data structure upgrade_paths = { # from_version: (to_version,migrate_function) "0.1.2": ("0.2.0", migrate_0_1_2), "0.2.0": ("0.3.0", migrate_0_2_0) }
  5. add your version to the version list: migration_versions: list = [YOUR VERSION HERE,...,"0.3.0", "0.2.0", "0.1.2"]

  6. To Test

  7. replace your db file with an old version db first and see if the session.migrate_database() works.

  8. Add a DB file for testing new breaking changes (Same as step 1: but with your new version)

  9. Do a sys.path.insert(0,TRULENS_PATH) to run with your version

Classes

UnknownClass

Bases: BaseModel

Functions
unknown_method
unknown_method()

This is a placeholder put into the database in place of methods whose information was not recorded in earlier versions of trulens.

Functions

commit_migrated_version

commit_migrated_version(db, version: str) -> None

After a successful migration, update the DB meta version

PARAMETER DESCRIPTION
db

the db object

TYPE: DB

version

The version string to set this DB to

TYPE: str

migrate

migrate(db) -> None

Migrate a db to the compatible version of this pypi version

PARAMETER DESCRIPTION
db

the db object

TYPE: DB