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:
-
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
-
Do Migration coding
- Update init.py with the new version
- 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) }
-
add your version to the version list: migration_versions: list = [YOUR VERSION HERE,...,"0.3.0", "0.2.0", "0.1.2"]
-
To Test
-
replace your db file with an old version db first and see if the session.migrate_database() works.
-
Add a DB file for testing new breaking changes (Same as step 1: but with your new version)
- Do a sys.path.insert(0,TRULENS_PATH) to run with your version
Classes¶
UnknownClass
¶
Functions¶
_update_db_json_col
¶
Replaces an old json serialized db column with a migrated/new one.
PARAMETER | DESCRIPTION |
---|---|
db
|
the db object
TYPE:
|
table
|
the table to update (from the current DB)
TYPE:
|
old_entry
|
the db tuple to update
TYPE:
|
json_db_col_idx
|
the tuple idx to update
TYPE:
|
new_json
|
the new json object to be put in the D
TYPE:
|
_parse_version
¶
_get_compatibility_version
¶
Gets the db version that the pypi version is compatible with.
PARAMETER | DESCRIPTION |
---|---|
-
|
a pypi version
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
|
_migration_checker
¶
_migration_checker(db, warn: bool = False) -> None
Checks whether this db, if pre-populated, is compatible with this pypi version.
PARAMETER | DESCRIPTION |
---|---|
-
|
the db object to check
TYPE:
|
-
|
if warn is False, then a migration issue will raise an exception, otherwise allow passing but only warn. Defaults to False.
TYPE:
|
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:
|
version
|
The version string to set this DB to
TYPE:
|
_upgrade_possible
¶
Checks the upgrade paths to see if there is a valid migration from the DB to the current pypi version
PARAMETER | DESCRIPTION |
---|---|
-
|
the current db version.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
|
_check_needs_migration
¶
_check_needs_migration(version: str, warn=False) -> None
Checks whether the from DB version can be updated to the current DB version.
PARAMETER | DESCRIPTION |
---|---|
-
|
the pypi version
TYPE:
|
-
|
if warn is False, then a migration issue will raise an exception, otherwise allow passing but only warn. Defaults to False.
TYPE:
|
_serialization_asserts
¶
_serialization_asserts(db) -> None
After a successful migration, Do some checks if serialized jsons are loading properly.
PARAMETER | DESCRIPTION |
---|---|
db
|
the db object
TYPE:
|
migrate
¶
migrate(db) -> None
Migrate a db to the compatible version of this pypi version
PARAMETER | DESCRIPTION |
---|---|
db
|
the db object
TYPE:
|