From 6689cfdc64d94283e8f037fe3fcd7a1b1c053846 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 16 Dec 2024 09:05:27 -0500 Subject: [PATCH] INTPYTHON-453 Update folder name and add contributing guide (#40) --- .github/scripts/check_diff.py | 2 +- .github/workflows/_release.yml | 4 +- CONTRIBUTING.md | 131 ++++++++++++++++++ README.md | 2 +- .../{mongodb => langchain-mongodb}/.gitignore | 0 libs/{mongodb => langchain-mongodb}/LICENSE | 0 libs/{mongodb => langchain-mongodb}/Makefile | 0 libs/{mongodb => langchain-mongodb}/README.md | 0 .../langchain_mongodb/__init__.py | 0 .../langchain_mongodb/cache.py | 0 .../chat_message_histories.py | 0 .../langchain_mongodb/docstores.py | 0 .../langchain_mongodb/index.py | 0 .../langchain_mongodb/pipelines.py | 0 .../langchain_mongodb/py.typed | 0 .../langchain_mongodb/retrievers/__init__.py | 0 .../retrievers/full_text_search.py | 0 .../retrievers/hybrid_search.py | 0 .../retrievers/parent_document.py | 0 .../langchain_mongodb/utils.py | 0 .../langchain_mongodb/vectorstores.py | 0 .../poetry.lock | 0 .../pyproject.toml | 0 .../scripts/check_imports.py | 0 .../scripts/lint_imports.sh | 0 .../tests/__init__.py | 0 .../tests/integration_tests/__init__.py | 0 .../tests/integration_tests/conftest.py | 0 .../tests/integration_tests/test_cache.py | 0 .../integration_tests/test_chain_example.py | 0 .../test_chat_message_histories.py | 0 .../tests/integration_tests/test_compile.py | 0 .../tests/integration_tests/test_docstore.py | 0 .../tests/integration_tests/test_index.py | 0 .../tests/integration_tests/test_mmr.py | 0 .../integration_tests/test_parent_document.py | 0 .../integration_tests/test_retrievers.py | 0 .../test_vectorstore_add_delete.py | 0 .../test_vectorstore_from_documents.py | 0 .../test_vectorstore_from_texts.py | 0 .../tests/unit_tests/__init__.py | 0 .../tests/unit_tests/test_cache.py | 0 .../unit_tests/test_chat_message_histories.py | 0 .../tests/unit_tests/test_imports.py | 0 .../tests/unit_tests/test_index.py | 0 .../tests/unit_tests/test_vectorstores.py | 0 .../tests/utils.py | 0 47 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 CONTRIBUTING.md rename libs/{mongodb => langchain-mongodb}/.gitignore (100%) rename libs/{mongodb => langchain-mongodb}/LICENSE (100%) rename libs/{mongodb => langchain-mongodb}/Makefile (100%) rename libs/{mongodb => langchain-mongodb}/README.md (100%) rename libs/{mongodb => langchain-mongodb}/langchain_mongodb/__init__.py (100%) rename libs/{mongodb => langchain-mongodb}/langchain_mongodb/cache.py (100%) rename libs/{mongodb => langchain-mongodb}/langchain_mongodb/chat_message_histories.py (100%) rename libs/{mongodb => langchain-mongodb}/langchain_mongodb/docstores.py (100%) rename libs/{mongodb => langchain-mongodb}/langchain_mongodb/index.py (100%) rename libs/{mongodb => langchain-mongodb}/langchain_mongodb/pipelines.py (100%) rename libs/{mongodb => langchain-mongodb}/langchain_mongodb/py.typed (100%) rename libs/{mongodb => langchain-mongodb}/langchain_mongodb/retrievers/__init__.py (100%) rename libs/{mongodb => langchain-mongodb}/langchain_mongodb/retrievers/full_text_search.py (100%) rename libs/{mongodb => langchain-mongodb}/langchain_mongodb/retrievers/hybrid_search.py (100%) rename libs/{mongodb => langchain-mongodb}/langchain_mongodb/retrievers/parent_document.py (100%) rename libs/{mongodb => langchain-mongodb}/langchain_mongodb/utils.py (100%) rename libs/{mongodb => langchain-mongodb}/langchain_mongodb/vectorstores.py (100%) rename libs/{mongodb => langchain-mongodb}/poetry.lock (100%) rename libs/{mongodb => langchain-mongodb}/pyproject.toml (100%) rename libs/{mongodb => langchain-mongodb}/scripts/check_imports.py (100%) rename libs/{mongodb => langchain-mongodb}/scripts/lint_imports.sh (100%) rename libs/{mongodb => langchain-mongodb}/tests/__init__.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/integration_tests/__init__.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/integration_tests/conftest.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/integration_tests/test_cache.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/integration_tests/test_chain_example.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/integration_tests/test_chat_message_histories.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/integration_tests/test_compile.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/integration_tests/test_docstore.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/integration_tests/test_index.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/integration_tests/test_mmr.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/integration_tests/test_parent_document.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/integration_tests/test_retrievers.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/integration_tests/test_vectorstore_add_delete.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/integration_tests/test_vectorstore_from_documents.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/integration_tests/test_vectorstore_from_texts.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/unit_tests/__init__.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/unit_tests/test_cache.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/unit_tests/test_chat_message_histories.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/unit_tests/test_imports.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/unit_tests/test_index.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/unit_tests/test_vectorstores.py (100%) rename libs/{mongodb => langchain-mongodb}/tests/utils.py (100%) diff --git a/.github/scripts/check_diff.py b/.github/scripts/check_diff.py index 85ee197..830f650 100644 --- a/.github/scripts/check_diff.py +++ b/.github/scripts/check_diff.py @@ -2,7 +2,7 @@ import sys from typing import Dict -LIB_DIRS = ["libs/mongodb", "libs/langgraph-checkpoint-mongodb"] +LIB_DIRS = ["libs/langchain-mongodb", "libs/langgraph-checkpoint-mongodb"] if __name__ == "__main__": files = sys.argv[1:] # changed files diff --git a/.github/workflows/_release.yml b/.github/workflows/_release.yml index 75f44be..a95d10f 100644 --- a/.github/workflows/_release.yml +++ b/.github/workflows/_release.yml @@ -13,9 +13,9 @@ on: required: true type: choice options: - - libs/mongodb + - libs/langchain-mongodb - libs/langgraph-checkpoint-mongodb - default: libs/mongodb + default: libs/langchain-mongodb description: "From which folder this pipeline executes" env: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..3acab2a --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,131 @@ +# Contributing Guide + +We welcome contributions to this project! Please follow the following guidance to setup the project for development and start contributing. + +### Fork and clone the repository + +To contribute to this project, please follow the ["fork and pull request"](https://docs.github.com/en/get-started/exploring-projects-on-github/contributing-to-a-project) workflow. Please do not try to push directly to this repo unless you are a maintainer. + + +### Dependency Management: Poetry and other env/dependency managers + +This project utilizes [Poetry](https://python-poetry.org/) v1.7.1+ as a dependency manager. + +Install Poetry: **[documentation on how to install it](https://python-poetry.org/docs/#installation)**. + +### Local Development Dependencies + +The project configuration and the makefile for running dev commands are located under the `libs/langchain-mongodb` or `libs/langgraph-checkpoint-mongodb` directories. + +```bash +cd libs/langchain-mongodb +``` + +Install langchain-mongodb development requirements (for running langchain, running examples, linting, formatting, tests, and coverage): + +```bash +poetry install --with dev +``` + +Then verify the installation. + +```bash +make test +``` + +### Testing + +Unit tests cover modular logic that does not require calls to outside APIs. +If you add new logic, please add a unit test. + +To run unit tests: + +```bash +make test +``` + +Integration tests cover the end-to-end service calls as much as possible. +However, in certain cases this might not be practical, so you can mock the +service response for these tests. There are examples of this in the repo, +that can help you write your own tests. If you have suggestions to improve +this, please raise an issue. + +To run the integration tests: + +```bash +make integration_test +``` + +### Formatting and Linting + +Formatting ensures that the code in this repo has consistent style so that the +code looks more presentable and readable. It corrects these errors when you run +the formatting command. Linting finds and highlights the code errors and helps +avoid coding practicies that can lead to errors. + +Run both of these locally before submitting a PR. The CI scripts will run these +when you submit a PR, and you won't be able to merge changes without fixing +issues identified by the CI. + +#### Code Formatting + +Formatting for this project is done via [ruff](https://docs.astral.sh/ruff/rules/). + +To run format: + +```bash +make format +``` + +Additionally, you can run the formatter only on the files that have been modified in your current branch +as compared to the master branch using the `format_diff` command. This is especially useful when you have +made changes to a subset of the project and want to ensure your changes are properly formatted without +affecting the rest of the codebase. + +```bash +make format_diff +``` + +#### Linting + +Linting for this project is done via a combination of [ruff](https://docs.astral.sh/ruff/rules/) and [mypy](http://mypy-lang.org/). + +To run lint: + +```bash +make lint +``` + +In addition, you can run the linter only on the files that have been modified in your current branch as compared to the master branch using the `lint_diff` command. This can be very helpful when you've made changes to only certain parts of the project and want to ensure your changes meet the linting standards without having to check the entire codebase. + +```bash +make lint_diff +``` + +We recognize linting can be annoying - if you do not want to do it, please contact a project maintainer, and they can help you with it. We do not want this to be a blocker for good code getting contributed. + +#### Spellcheck + +Spellchecking for this project is done via [codespell](https://github.com/codespell-project/codespell). +Note that `codespell` finds common typos, so it could have false-positive (correctly spelled but rarely used) and false-negatives (not finding misspelled) words. + +To check spelling for this project: + +```bash +make spell_check +``` + +To fix spelling in place: + +```bash +make spell_fix +``` + +If codespell is incorrectly flagging a word, you can skip spellcheck for that word by adding it to the codespell config in the `pyproject.toml` file. + +```python +[tool.codespell] +... +# Add here: +ignore-words-list = 'momento,collison,ned,foor,reworkd,parth,whats,aapply,mysogyny,unsecure' +``` diff --git a/README.md b/README.md index d2b7b0e..8b1eafb 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ pip install langgraph-checkpoint-mongodb ## Usage -See [langchain-mongodb usage](libs/mongodb/README.md#usage) and [langgraph-checkpoint-mongodb usage](libs/langgraph-checkpoint-mongodb/README.md#usage). +See [langchain-mongodb usage](libs/langchain-mongodb/README.md#usage) and [langgraph-checkpoint-mongodb usage](libs/langgraph-checkpoint-mongodb/README.md#usage). For more detailed usage examples and documentation, please refer to the [LangChain documentation](https://python.langchain.com/docs/integrations/providers/mongodb_atlas/). diff --git a/libs/mongodb/.gitignore b/libs/langchain-mongodb/.gitignore similarity index 100% rename from libs/mongodb/.gitignore rename to libs/langchain-mongodb/.gitignore diff --git a/libs/mongodb/LICENSE b/libs/langchain-mongodb/LICENSE similarity index 100% rename from libs/mongodb/LICENSE rename to libs/langchain-mongodb/LICENSE diff --git a/libs/mongodb/Makefile b/libs/langchain-mongodb/Makefile similarity index 100% rename from libs/mongodb/Makefile rename to libs/langchain-mongodb/Makefile diff --git a/libs/mongodb/README.md b/libs/langchain-mongodb/README.md similarity index 100% rename from libs/mongodb/README.md rename to libs/langchain-mongodb/README.md diff --git a/libs/mongodb/langchain_mongodb/__init__.py b/libs/langchain-mongodb/langchain_mongodb/__init__.py similarity index 100% rename from libs/mongodb/langchain_mongodb/__init__.py rename to libs/langchain-mongodb/langchain_mongodb/__init__.py diff --git a/libs/mongodb/langchain_mongodb/cache.py b/libs/langchain-mongodb/langchain_mongodb/cache.py similarity index 100% rename from libs/mongodb/langchain_mongodb/cache.py rename to libs/langchain-mongodb/langchain_mongodb/cache.py diff --git a/libs/mongodb/langchain_mongodb/chat_message_histories.py b/libs/langchain-mongodb/langchain_mongodb/chat_message_histories.py similarity index 100% rename from libs/mongodb/langchain_mongodb/chat_message_histories.py rename to libs/langchain-mongodb/langchain_mongodb/chat_message_histories.py diff --git a/libs/mongodb/langchain_mongodb/docstores.py b/libs/langchain-mongodb/langchain_mongodb/docstores.py similarity index 100% rename from libs/mongodb/langchain_mongodb/docstores.py rename to libs/langchain-mongodb/langchain_mongodb/docstores.py diff --git a/libs/mongodb/langchain_mongodb/index.py b/libs/langchain-mongodb/langchain_mongodb/index.py similarity index 100% rename from libs/mongodb/langchain_mongodb/index.py rename to libs/langchain-mongodb/langchain_mongodb/index.py diff --git a/libs/mongodb/langchain_mongodb/pipelines.py b/libs/langchain-mongodb/langchain_mongodb/pipelines.py similarity index 100% rename from libs/mongodb/langchain_mongodb/pipelines.py rename to libs/langchain-mongodb/langchain_mongodb/pipelines.py diff --git a/libs/mongodb/langchain_mongodb/py.typed b/libs/langchain-mongodb/langchain_mongodb/py.typed similarity index 100% rename from libs/mongodb/langchain_mongodb/py.typed rename to libs/langchain-mongodb/langchain_mongodb/py.typed diff --git a/libs/mongodb/langchain_mongodb/retrievers/__init__.py b/libs/langchain-mongodb/langchain_mongodb/retrievers/__init__.py similarity index 100% rename from libs/mongodb/langchain_mongodb/retrievers/__init__.py rename to libs/langchain-mongodb/langchain_mongodb/retrievers/__init__.py diff --git a/libs/mongodb/langchain_mongodb/retrievers/full_text_search.py b/libs/langchain-mongodb/langchain_mongodb/retrievers/full_text_search.py similarity index 100% rename from libs/mongodb/langchain_mongodb/retrievers/full_text_search.py rename to libs/langchain-mongodb/langchain_mongodb/retrievers/full_text_search.py diff --git a/libs/mongodb/langchain_mongodb/retrievers/hybrid_search.py b/libs/langchain-mongodb/langchain_mongodb/retrievers/hybrid_search.py similarity index 100% rename from libs/mongodb/langchain_mongodb/retrievers/hybrid_search.py rename to libs/langchain-mongodb/langchain_mongodb/retrievers/hybrid_search.py diff --git a/libs/mongodb/langchain_mongodb/retrievers/parent_document.py b/libs/langchain-mongodb/langchain_mongodb/retrievers/parent_document.py similarity index 100% rename from libs/mongodb/langchain_mongodb/retrievers/parent_document.py rename to libs/langchain-mongodb/langchain_mongodb/retrievers/parent_document.py diff --git a/libs/mongodb/langchain_mongodb/utils.py b/libs/langchain-mongodb/langchain_mongodb/utils.py similarity index 100% rename from libs/mongodb/langchain_mongodb/utils.py rename to libs/langchain-mongodb/langchain_mongodb/utils.py diff --git a/libs/mongodb/langchain_mongodb/vectorstores.py b/libs/langchain-mongodb/langchain_mongodb/vectorstores.py similarity index 100% rename from libs/mongodb/langchain_mongodb/vectorstores.py rename to libs/langchain-mongodb/langchain_mongodb/vectorstores.py diff --git a/libs/mongodb/poetry.lock b/libs/langchain-mongodb/poetry.lock similarity index 100% rename from libs/mongodb/poetry.lock rename to libs/langchain-mongodb/poetry.lock diff --git a/libs/mongodb/pyproject.toml b/libs/langchain-mongodb/pyproject.toml similarity index 100% rename from libs/mongodb/pyproject.toml rename to libs/langchain-mongodb/pyproject.toml diff --git a/libs/mongodb/scripts/check_imports.py b/libs/langchain-mongodb/scripts/check_imports.py similarity index 100% rename from libs/mongodb/scripts/check_imports.py rename to libs/langchain-mongodb/scripts/check_imports.py diff --git a/libs/mongodb/scripts/lint_imports.sh b/libs/langchain-mongodb/scripts/lint_imports.sh similarity index 100% rename from libs/mongodb/scripts/lint_imports.sh rename to libs/langchain-mongodb/scripts/lint_imports.sh diff --git a/libs/mongodb/tests/__init__.py b/libs/langchain-mongodb/tests/__init__.py similarity index 100% rename from libs/mongodb/tests/__init__.py rename to libs/langchain-mongodb/tests/__init__.py diff --git a/libs/mongodb/tests/integration_tests/__init__.py b/libs/langchain-mongodb/tests/integration_tests/__init__.py similarity index 100% rename from libs/mongodb/tests/integration_tests/__init__.py rename to libs/langchain-mongodb/tests/integration_tests/__init__.py diff --git a/libs/mongodb/tests/integration_tests/conftest.py b/libs/langchain-mongodb/tests/integration_tests/conftest.py similarity index 100% rename from libs/mongodb/tests/integration_tests/conftest.py rename to libs/langchain-mongodb/tests/integration_tests/conftest.py diff --git a/libs/mongodb/tests/integration_tests/test_cache.py b/libs/langchain-mongodb/tests/integration_tests/test_cache.py similarity index 100% rename from libs/mongodb/tests/integration_tests/test_cache.py rename to libs/langchain-mongodb/tests/integration_tests/test_cache.py diff --git a/libs/mongodb/tests/integration_tests/test_chain_example.py b/libs/langchain-mongodb/tests/integration_tests/test_chain_example.py similarity index 100% rename from libs/mongodb/tests/integration_tests/test_chain_example.py rename to libs/langchain-mongodb/tests/integration_tests/test_chain_example.py diff --git a/libs/mongodb/tests/integration_tests/test_chat_message_histories.py b/libs/langchain-mongodb/tests/integration_tests/test_chat_message_histories.py similarity index 100% rename from libs/mongodb/tests/integration_tests/test_chat_message_histories.py rename to libs/langchain-mongodb/tests/integration_tests/test_chat_message_histories.py diff --git a/libs/mongodb/tests/integration_tests/test_compile.py b/libs/langchain-mongodb/tests/integration_tests/test_compile.py similarity index 100% rename from libs/mongodb/tests/integration_tests/test_compile.py rename to libs/langchain-mongodb/tests/integration_tests/test_compile.py diff --git a/libs/mongodb/tests/integration_tests/test_docstore.py b/libs/langchain-mongodb/tests/integration_tests/test_docstore.py similarity index 100% rename from libs/mongodb/tests/integration_tests/test_docstore.py rename to libs/langchain-mongodb/tests/integration_tests/test_docstore.py diff --git a/libs/mongodb/tests/integration_tests/test_index.py b/libs/langchain-mongodb/tests/integration_tests/test_index.py similarity index 100% rename from libs/mongodb/tests/integration_tests/test_index.py rename to libs/langchain-mongodb/tests/integration_tests/test_index.py diff --git a/libs/mongodb/tests/integration_tests/test_mmr.py b/libs/langchain-mongodb/tests/integration_tests/test_mmr.py similarity index 100% rename from libs/mongodb/tests/integration_tests/test_mmr.py rename to libs/langchain-mongodb/tests/integration_tests/test_mmr.py diff --git a/libs/mongodb/tests/integration_tests/test_parent_document.py b/libs/langchain-mongodb/tests/integration_tests/test_parent_document.py similarity index 100% rename from libs/mongodb/tests/integration_tests/test_parent_document.py rename to libs/langchain-mongodb/tests/integration_tests/test_parent_document.py diff --git a/libs/mongodb/tests/integration_tests/test_retrievers.py b/libs/langchain-mongodb/tests/integration_tests/test_retrievers.py similarity index 100% rename from libs/mongodb/tests/integration_tests/test_retrievers.py rename to libs/langchain-mongodb/tests/integration_tests/test_retrievers.py diff --git a/libs/mongodb/tests/integration_tests/test_vectorstore_add_delete.py b/libs/langchain-mongodb/tests/integration_tests/test_vectorstore_add_delete.py similarity index 100% rename from libs/mongodb/tests/integration_tests/test_vectorstore_add_delete.py rename to libs/langchain-mongodb/tests/integration_tests/test_vectorstore_add_delete.py diff --git a/libs/mongodb/tests/integration_tests/test_vectorstore_from_documents.py b/libs/langchain-mongodb/tests/integration_tests/test_vectorstore_from_documents.py similarity index 100% rename from libs/mongodb/tests/integration_tests/test_vectorstore_from_documents.py rename to libs/langchain-mongodb/tests/integration_tests/test_vectorstore_from_documents.py diff --git a/libs/mongodb/tests/integration_tests/test_vectorstore_from_texts.py b/libs/langchain-mongodb/tests/integration_tests/test_vectorstore_from_texts.py similarity index 100% rename from libs/mongodb/tests/integration_tests/test_vectorstore_from_texts.py rename to libs/langchain-mongodb/tests/integration_tests/test_vectorstore_from_texts.py diff --git a/libs/mongodb/tests/unit_tests/__init__.py b/libs/langchain-mongodb/tests/unit_tests/__init__.py similarity index 100% rename from libs/mongodb/tests/unit_tests/__init__.py rename to libs/langchain-mongodb/tests/unit_tests/__init__.py diff --git a/libs/mongodb/tests/unit_tests/test_cache.py b/libs/langchain-mongodb/tests/unit_tests/test_cache.py similarity index 100% rename from libs/mongodb/tests/unit_tests/test_cache.py rename to libs/langchain-mongodb/tests/unit_tests/test_cache.py diff --git a/libs/mongodb/tests/unit_tests/test_chat_message_histories.py b/libs/langchain-mongodb/tests/unit_tests/test_chat_message_histories.py similarity index 100% rename from libs/mongodb/tests/unit_tests/test_chat_message_histories.py rename to libs/langchain-mongodb/tests/unit_tests/test_chat_message_histories.py diff --git a/libs/mongodb/tests/unit_tests/test_imports.py b/libs/langchain-mongodb/tests/unit_tests/test_imports.py similarity index 100% rename from libs/mongodb/tests/unit_tests/test_imports.py rename to libs/langchain-mongodb/tests/unit_tests/test_imports.py diff --git a/libs/mongodb/tests/unit_tests/test_index.py b/libs/langchain-mongodb/tests/unit_tests/test_index.py similarity index 100% rename from libs/mongodb/tests/unit_tests/test_index.py rename to libs/langchain-mongodb/tests/unit_tests/test_index.py diff --git a/libs/mongodb/tests/unit_tests/test_vectorstores.py b/libs/langchain-mongodb/tests/unit_tests/test_vectorstores.py similarity index 100% rename from libs/mongodb/tests/unit_tests/test_vectorstores.py rename to libs/langchain-mongodb/tests/unit_tests/test_vectorstores.py diff --git a/libs/mongodb/tests/utils.py b/libs/langchain-mongodb/tests/utils.py similarity index 100% rename from libs/mongodb/tests/utils.py rename to libs/langchain-mongodb/tests/utils.py