Skip to content
New issue

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

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

Already on GitHub? # to your account

Sets up metadata db for every llm class #1401

Merged
merged 8 commits into from
Aug 1, 2024

Conversation

PranavPuranik
Copy link
Contributor

@PranavPuranik PranavPuranik commented Jun 9, 2024

Description

The metadata database for storing chat history is a sqllite3 db. It is setup up in the app class by using setup_engine.

But running individual tests in llm folder fails because we don't create any app for tests. Individual llm classes are called independently. Thus, setup_engine is never called.

This change moves the setup to BaseLlmConfig, which is called every time we load an llm.

Fixes #1400

Type of change

Please delete options that are not relevant.

  • 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)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Tested individual tests in llm folder, and also tested running my demo app.

  • Unit Test
  • Test Script (please provide)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Made sure Checks passed

@Dev-Khant
Copy link
Collaborator

Hi @PranavPuranik Can you please check why tests are failing?

@Dev-Khant
Copy link
Collaborator

#1449 will fix psutil not found issue.

@PranavPuranik
Copy link
Contributor Author

PranavPuranik commented Jun 28, 2024

Nice, I will wait till its merged in. All tests are passing my laptop - for every commit. Funny how they end up failing here in CI... Investigating

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hey, what is the need of adding this test in LLM folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Original Problem: We couldn't run LLM tests individually.

Initially, I had the Alembic fixture under the original conftest file at tests/conftest.py. Tests were passing individually and overall on my laptop from the command line, but they failed on CI. I suspected it was an integration test failure because the error indicated a database issue.

To address this, I moved the fixture inside the LLM folder since we don't need to perform Alembic upgrades for LLM testing but might need it somewhere else. For LLMs, we only test assert_called_once or similar assertions. Moving it inside reduces the scope of the fixture to only run on these LLM tests.

Additionally, PyCharm now picks up this tests/llm/conftest.py, which is great because it wasn't able to pass individual tests when the fixture was in tests/conftest.py. Although this could be due to some configuration issue.

@deshraj
Copy link
Collaborator

deshraj commented Jul 5, 2024

@PranavPuranik can you please resolve the conflict here? Changes look good.

@PranavPuranik
Copy link
Contributor Author

PranavPuranik commented Jul 6, 2024

resolving

@CLAassistant
Copy link

CLAassistant commented Jul 26, 2024

CLA assistant check
All committers have signed the CLA.

@Dev-Khant Dev-Khant merged commit b386e24 into mem0ai:main Aug 1, 2024
6 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pytest individual tests fail for llms becuase default db setup is not executed.
4 participants