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

refactor: use MongoDB singleton for connection management #1335

Merged
merged 8 commits into from
Oct 31, 2024

Conversation

kom-senapati
Copy link
Contributor

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Adds a file core/mongo_db.py for the singleton class of pymongo client which is used to get connections across all files and no extra connection is created.

  • Why was this change needed? (You can also link to an open issue here)

Closes #1170

Copy link

vercel bot commented Oct 18, 2024

@kom-senapati is attempting to deploy a commit to the Arc53 Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Oct 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-gpt ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 31, 2024 11:34am

@dartpain
Copy link
Contributor

Hey please check the imports and test the application.
Thank you

@kom-senapati
Copy link
Contributor Author

I had tested it locally before doing PR

@dartpain
Copy link
Contributor

It seems like tests are failing for it:
https://github.com/arc53/DocsGPT/actions/runs/11397141420/job/31712108327?pr=1335

______________________ ERROR collecting tests/test_app.py ______________________
ImportError while importing test module '/home/runner/work/DocsGPT/DocsGPT/tests/test_app.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.11.10/x[64](https://github.com/arc53/DocsGPT/actions/runs/11397141420/job/31712108327?pr=1335#step:5:65)/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_app.py:3: in <module>
    from application.api.answer.routes import answer
application/api/answer/routes.py:14: in <module>
    from core.mongo_db import MongoDB
E   ModuleNotFoundError: No module named 'core'
=============================== warnings summary ===============================
../../../../../opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/flask_restx/api.py:19
../../../../../opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/flask_restx/api.py:19
  /opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/flask_restx/api.py:19: DeprecationWarning: jsonschema.RefResolver is deprecated as of v4.18.0, in favor of the https://github.com/python-jsonschema/referencing library, which provides more compliant referencing behavior as well as more flexible APIs for customization. A future release will remove RefResolver. Please file a feature request (on referencing) if you are missing an API for the kind of customization you need.
    from jsonschema import RefResolver

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

---------- coverage: platform linux, python 3.11.10-final-0 ----------
Coverage XML written to file coverage.xml

=========================== short test summary info ============================
ERROR tests/llm/test_anthropic.py
ERROR tests/llm/test_openai.py
ERROR tests/llm/test_sagemaker.py
ERROR tests/test_app.py
!!!!!!!!!!!!!!!!!!! Interrupted: 4 errors during collection !!!!!!!!!!!!!!!!!!!!
======================== 2 warnings, 4 errors in 6.[82](https://github.com/arc53/DocsGPT/actions/runs/11397141420/job/31712108327?pr=1335#step:5:83)s =========================

@kom-senapati kom-senapati changed the title Use MongoDB singleton for connection management refactor: use MongoDB singleton for connection management Oct 27, 2024
Copy link

codecov bot commented Oct 28, 2024

Codecov Report

Attention: Patch coverage is 86.95652% with 3 lines in your changes missing coverage. Please review.

Project coverage is 34.00%. Comparing base (355fd2b) to head (82189b0).
Report is 232 commits behind head on main.

Files with missing lines Patch % Lines
application/core/mongo_db.py 78.57% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1335      +/-   ##
==========================================
+ Coverage   32.93%   34.00%   +1.06%     
==========================================
  Files          62       68       +6     
  Lines        3112     3347     +235     
==========================================
+ Hits         1025     1138     +113     
- Misses       2087     2209     +122     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@dartpain dartpain left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-structure mongodb connection
2 participants