Skip to content

PYTHON-4134: Update LangChain test to run langchain-mongodb partner package rather than community #7

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

Merged
merged 10 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ buildvariants:
DIR: langchain-python
REPO_NAME: langchain
CLONE_URL: https://github.com/langchain-ai/langchain.git
DATABASE: langchain_test_db
run_on:
- rhel87-small
tasks:
Expand Down
8 changes: 6 additions & 2 deletions .evergreen/scaffold_atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ def upload_data(db: Database, filename: Path) -> None:
)
if not isinstance(loaded_collection, list):
loaded_collection = [loaded_collection]
result: InsertManyResult = db[collection_name].insert_many(loaded_collection)
logger.debug("Uploaded results for %s: %s", filename.name, result.inserted_ids)
if loaded_collection:
result: InsertManyResult = db[collection_name].insert_many(loaded_collection)
logger.debug("Uploaded results for %s: %s", filename.name, result.inserted_ids)
else:
logger.debug("Empty collection named %s created", collection_name)
db.create_collection(collection_name)


def walk_collection_directory() -> list[str]:
Expand Down
1 change: 1 addition & 0 deletions langchain-python/database/langchain_test_cache.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions langchain-python/database/langchain_test_chat.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions langchain-python/database/langchain_test_vectorstores.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
18 changes: 18 additions & 0 deletions langchain-python/indexes/langchain_test_index_semantic_cache.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"fields": [
{
"numDimensions": 1536,
"path": "embedding",
"similarity": "cosine",
"type": "vector"
},
{
"path": "llm_string",
"type": "filter"
}
],
"name": "langchain-test-index-semantic-cache",
"type": "vectorSearch",
"database": "langchain_test_db",
"collectionName": "langchain_test_cache"
}
18 changes: 18 additions & 0 deletions langchain-python/indexes/langchain_test_index_vectorstores.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"fields": [
{
"numDimensions": 1536,
"path": "embedding",
"similarity": "cosine",
"type": "vector"
},
{
"path": "c",
"type": "filter"
}
],
"name": "langchain-test-index-vectorstores",
"type": "vectorSearch",
"database": "langchain_test_db",
"collectionName": "langchain_test_vectorstores"
}
16 changes: 6 additions & 10 deletions langchain-python/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,17 @@ set -x

PYTHON_BINARY=$(find_python3)

cd libs/langchain
cd libs/partners/mongodb

$PYTHON_BINARY -m venv .
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not the recommended way to use poetry. You don't want to use venv. Look at the implementation in llama_index/run.sh for an example. chatgpt does the same. There are comments explaining what is happening on each line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah yeah, I think the one thing about that is the evergreen urges not "writing outside of the directory" which is what I interpreted a pip install with the binary to be under that general umbrella.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah. You're right. Using a venv will keep all in one place. Hmmm. Maybe I should update the others...

source ./bin/activate

pip install poetry
pip install filelock
pip install msgpack
pip install requests_toolbelt
pip install motor

poetry install --with test
# Workaround provided in https://github.com/langchain-ai/langchain/issues/12237
pip install build pyproject-hooks requests-toolbelt
pip install --upgrade rapidfuzz filelock msgpack

# Current hack to run just the mongo tests
TEST_FILE="tests/unit_tests -- -k mongo" make test
export MONGODB_ATLAS_URI=$($atlas deployments connect $DIR --connectWith connectionString)

make test

make integration_test