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

fix to sql query bug in dashboard #1531

Merged
merged 6 commits into from
Oct 3, 2024

Conversation

sfc-gh-pmardziel
Copy link
Contributor

@sfc-gh-pmardziel sfc-gh-pmardziel commented Oct 3, 2024

Description

Changed what order_by applies to in the orm relationships to prevent an incorrect SQL bug.

Added limit and offset to get_leaderboard. The bug was occurring only in the dashboard because it was using get_records_and_feedback with a limit whereas the notebooks did not use a limit inside their get_leaderboard.

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

Important

Fix SQL query bug in dashboard by disabling order_by in ORM relationships and adding limit and offset to get_leaderboard.

  • Behavior:
    • Disable order_by in ORM relationships in orm.py to prevent SQLAlchemy query generation issues with joinedload and limit.
    • Add limit and offset parameters to get_leaderboard in base.py and session.py to ensure consistent query behavior.
  • ORM Changes:
    • Modify Record, FeedbackResult, and GroundTruth classes in orm.py to remove order_by in relationships.
  • Misc:
    • Add print statement for debugging SQL statements in sqlalchemy.py.

This description was created by Ellipsis for 28f555c. It will automatically update as commits are pushed.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 3, 2024
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 3027a36 in 37 seconds

More details
  • Looked at 243 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_MwCPiyqiCgayWe4f


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -778,6 +778,8 @@ def get_records_and_feedback(

stmt = stmt.limit(limit).offset(offset)

print("stmt=", stmt)
Copy link
Contributor

Choose a reason for hiding this comment

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

Debugging print statement should be removed or replaced with proper logging before merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx guy.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on fe5bbb9 in 12 seconds

More details
  • Looked at 33 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. src/core/trulens/core/database/connector/base.py:369
  • Draft comment:
    The PR description mentions disabling relationship order_by in ORM classes, but the changes in the diff only include docstring updates. Ensure that the intended code changes are included in the PR.
  • Reason this comment was not posted:
    Comment did not seem useful.

Workflow ID: wflow_xqW2m3ngX3FvaHCl


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on a0cb8a2 in 9 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. src/core/trulens/core/database/sqlalchemy.py:779
  • Draft comment:
    The removal of the print statement for debugging SQL statements is a good practice for production code. However, the PR description mentioned adding a print statement for debugging, which seems contradictory. Please ensure the PR description accurately reflects the changes made.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The print statement for debugging SQL statements was removed, which is a good practice for production code. However, the PR description mentioned adding a print statement for debugging, which seems contradictory. This might be a mistake in the PR description or the code change.

Workflow ID: wflow_ni5W0qgBmuDybmHx


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Oct 3, 2024
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 4bc5548 in 15 seconds

More details
  • Looked at 30 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. src/core/trulens/core/database/sqlalchemy.py:765
  • Draft comment:
    The PR description mentions adding a print statement for debugging SQL statements, but this change is not present in the diff. Ensure that the intended debugging print statement is included in the commit.
  • Reason this comment was not posted:
    Comment did not seem useful.

Workflow ID: wflow_EujvLPMap0YBFeBm


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@sfc-gh-pmardziel sfc-gh-pmardziel changed the title temporary fix to sql query bug in dashboard fix to sql query bug in dashboard Oct 3, 2024
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 3d8e4d8 in 12 seconds

More details
  • Looked at 170 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. src/core/trulens/core/database/sqlalchemy.py:761
  • Draft comment:
    The PR description mentions adding a print statement for debugging SQL statements, but no such addition is present in the diff. Ensure that the intended debugging statement is included.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR description mentions adding a print statement for debugging SQL statements, but I don't see any such addition in the diff. This might be an oversight or a missed change.

Workflow ID: wflow_iH5R6EuWKxuMebjd


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 28f555c in 11 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. src/core/trulens/core/database/orm.py:404
  • Draft comment:
    The order_by in the backref for AppDefinition.records should be removed as per the PR description to prevent SQLAlchemy query generation issues. This applies to other order_by in backrefs as well.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_j5L0gyI6JtZH0wbN


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 3, 2024
@sfc-gh-jreini
Copy link
Contributor

Confirmed this resolves the dashboard bug


# Couldn't figure out how to avoid using prefix in ForeignKey here
# and in the other classes below.
app_id = Column(
Copy link
Contributor

Choose a reason for hiding this comment

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

does this require a migration?

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 don't think the schema has changed so I don't think so.

@sfc-gh-pmardziel sfc-gh-pmardziel merged commit 9799a7a into main Oct 3, 2024
7 checks passed
@sfc-gh-pmardziel sfc-gh-pmardziel deleted the piotrm/disable_relationship_order_by branch October 3, 2024 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants