Skip to content

add ability to directly connect to mongo with pymongo.MongoClient #54

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

sierra-moxon
Copy link
Member

@sierra-moxon sierra-moxon commented Jun 11, 2025

useful when instantiating a linkml_store.Client class with an existing mongodb connection, e.g. from an external job like Jenkins or Dagster

fixes #55

…n from pymongo. useful when instantiating a linkml_store.Client class with an existing mongodb connection, e.g. from an external job like Jenkins or Dagster
Copy link

hyperlint-ai bot commented Jun 11, 2025

PR Change Summary

Added support for directly connecting to MongoDB using existing MongoClient instances, enhancing the functionality of the linkml_store.Client class.

  • Enabled direct connection to MongoDB with pymongo.MongoClient
  • Updated documentation to reflect new MongoClient support
  • Improved integration with external job systems like Jenkins and Dagster

Modified Files

  • README.md

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

@sierra-moxon sierra-moxon requested a review from Copilot June 11, 2025 18:53
Copilot

This comment was marked as outdated.

@sierra-moxon sierra-moxon requested a review from Copilot June 11, 2025 19:09
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for attaching existing pymongo.MongoClient instances directly to a Client, alongside existing connection‐string workflows.

  • Introduces attach_native_connection and attach_mongodb_client methods in Client
  • Updates MongoDBDatabase to accept a mongo_client and override database name
  • Adds tests and documentation for direct MongoClient usage

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_api/test_mongodb_client.py New tests for attach_mongodb_client and attach_native_connection
src/linkml_store/api/stores/mongodb/mongodb_database.py Extended __init__ to accept mongo_client and db_name
src/linkml_store/api/client.py Added attach_native_connection and attach_mongodb_client
docs/how-to/Use-MongoDB.ipynb Tutorial updated with existing MongoClient examples
README.md Added feature note about direct MongoClient support
Comments suppressed due to low confidence (4)

tests/test_api/test_mongodb_client.py:27

  • [nitpick] Remove the duplicated # Setup comment on this line to avoid confusion and keep the setup section concise.
#    # Setup

docs/how-to/Use-MongoDB.ipynb:54

  • Notebook cells expect source as a list of strings, not a single string. Wrap each line (including newlines) as elements in an array to conform with the IPython notebook spec.
"source": "Next we'll attach to a MongoDB instance..."

src/linkml_store/api/stores/mongodb/mongodb_database.py:51

  • Indentation here is incorrect and will cause a SyntaxError. Align this if handle is None: with the other statements in the if mongo_client is not None: block (remove the extra spaces).
                if handle is None:

src/linkml_store/api/client.py:282

  • The code uses importlib.import_module but importlib is not imported. Add import importlib at the top of the file.
module = importlib.import_module(module_path)

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

Successfully merging this pull request may close these issues.

Allow Client instantiation (in particular MongoClient instantiation), with an existing pymongo.MongoClient object
1 participant