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

trulens-legacy #1345

Merged
merged 15 commits into from
Aug 20, 2024
Merged

trulens-legacy #1345

merged 15 commits into from
Aug 20, 2024

Conversation

sfc-gh-pmardziel
Copy link
Contributor

@sfc-gh-pmardziel sfc-gh-pmardziel commented Aug 16, 2024

Description

Creates a new version of the trulens_eval package for backwards compatibility during a deprecation period.

  1. Preserved trulens_eval.* names defined in __init__.py files for backwards compatibility to be deprecated later. Until then, a warning is issued of an old module is imported or a class or function imported via the old name is invoked. This is tested by test_deprecation.py which was recently added.

Example warning when importing from trulens_eval

from trulens_eval import Tru
DeprecationWarning: The `trulens_eval` module is deprecated. See https://trulens.org/docs/migration-guide for instructions on migrating to `trulens.*` modules.

Example warning when using something imported from trulens_eval:

Tru(...)
DeprecationWarning: Class `Tru` has moved:
    New import: `from trulens.core.tru import Tru`
 See https://trulens.org/docs/migration-guide for instructions on migrating to `trulens` modules.
  1. Brought back some utilities for optional imports which will not be needed after the package is removed in the future. Optional imports are used to preserve how trulens_eval behaved with respect to optional imports in the past. However, in many cases, the packages that need to be installed have been changed to the optional trulens-* packages instead of what was is now these packages' dependencies.

Not covered

Other details good to know for developers

Please include any other details of this change useful for TruLens developers.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • New Tests
  • This change includes re-generated golden test results
  • This change requires a documentation update

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. dependencies Pull requests that update a dependency file labels Aug 16, 2024
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Aug 16, 2024
src/core/trulens/core/utils/deprecation.py Outdated Show resolved Hide resolved
src/core/trulens/core/utils/deprecation.py Outdated Show resolved Hide resolved
return _MovedClass


def moved(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If users have both trulens_eval installed already, and also installed new version trulens without uninstalling trulens_eval what would happen?

Copy link
Contributor Author

@sfc-gh-pmardziel sfc-gh-pmardziel Aug 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will try to enforce this with package constraints with this idea:

  • Rename the trulens-legacy package to trulens_eval, starting with version 1.0.0 which is greater than existing trulens_eval version.
  • In trulens_eval will now have requirements to install the required trulens-* packages.
  • With new trulens releases, the constraints in trulens_eval will have to be updated to keep track (or at least occasionally). Note that from discussions with @sfc-gh-chu , the plan is to have trulens package track the version of trulens-core.

This should cover the cases where people are still using and installing trulens_eval. To help with the migration to trulens we can suggest a two stage migration process:

  • We ask users to first replace their install trulens_eval with install trulens or merely upgrade their trulens_eval to this legacy version. As we added a constraint to trulens to install the legacy trulens_eval we can make sure the backwards compatibility trulens_eval replaces their old trulens_eval installation either way (whether they install trulens or install --upgrade trulens_eval.
  • The user can then observe deprecation warnings from their uses of trulens_eval to migrate the rest of their code so it does not refer to trulens_eval anywhere. Hopefully they do this before we remove the legacy package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sfc-gh-chu can you review this idea and check that the implementation of it in the PR is correct?

src/legacy/trulens_eval/__init__.py Outdated Show resolved Hide resolved
"AzureOpenAI",
"OpenAI",
"Langchain",
"LiteLLM",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen to this if those imports like Bedrock is not present, would it give a silent error? or do we create this list based on the conditional imports?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before, the optional imports mechanism will make Bedrock a dummy class.

Makefile Outdated Show resolved Hide resolved
src/core/trulens/core/utils/deprecation.py Outdated Show resolved Hide resolved
src/trulens_eval/pyproject.toml Show resolved Hide resolved
src/core/trulens/core/utils/requirements.txt Show resolved Hide resolved
deprecation_utils.packages_dep_warn("trulens_eval.database")

from trulens.core.database import *
from trulens.core.database import base
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are lines 13-19 necessary given 12?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but it looks like line 12 does nothing. import * only does anything if __all__ is defined in the module we are importing from. Removed line 12.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also adding a note explaining this.

# NOTE: This file had contents in trulens_eval none were public or aliases.
# Because of that, this backwards compatibility module is empty.

from trulens.core.database.migrations import *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused what's going on here, in lines 12-13 you said it's empty, so what are you importing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was just a copy and paste to capture __all__ exports but didn't remove it after realizing there was no __all__. However, I'm leaving this file in place because I want to also make the non __all__ names also backwards compatible in the next PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I'm deleting the import *, but leaving the file in place is what I meant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also adding a note explaining this.

Makefile Outdated Show resolved Hide resolved
src/trulens_eval/pyproject.toml Show resolved Hide resolved
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 20, 2024
Merge remote-tracking branch 'origin/main' into piotrm/tru-legacy
@sfc-gh-pmardziel sfc-gh-pmardziel merged commit 827b3ab into main Aug 20, 2024
7 checks passed
@sfc-gh-pmardziel sfc-gh-pmardziel deleted the piotrm/tru-legacy branch August 20, 2024 22:22
sfc-gh-chu pushed a commit that referenced this pull request Sep 25, 2024
* split from larger pr

* fix duplicates in makefile

* remove unneeded

* nits

* notes

* rename trulens-legacy to trulens_eval

* addressing prs

* addressing pr comments

* another one

* relock

* relock

* fix pr notes

* renamed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants