Update CONTRIBUTION guidelines and PR Template (#5140)

# Update contribution guidelines and PR template

This PR updates the contribution guidelines to include more information
on how to handle optional dependencies. 

The PR template is updated to include a link to the contribution guidelines document.
This commit is contained in:
Eugene Yurtsev 2023-05-26 10:18:11 -04:00 committed by GitHub
parent d481d887bc
commit a669abf16b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 68 additions and 17 deletions

View File

@ -115,8 +115,37 @@ To get a report of current coverage, run the following:
make coverage
```
### Working with Optional Dependencies
Langchain relies heavily on optional dependencies to keep the Langchain package lightweight.
If you're adding a new dependency to Langchain, assume that it will be an optional dependency, and
that most users won't have it installed.
Users that do not have the dependency installed should be able to **import** your code without
any side effects (no warnings, no errors, no exceptions).
To introduce the dependency to the pyproject.toml file correctly, please do the following:
1. Add the dependency to the main group as an optional dependency
```bash
poetry add --optional [package_name]
```
2. Open pyproject.toml and add the dependency to the `extended_testing` extra
3. Relock the poetry file to update the extra.
```bash
poetry lock --no-update
```
4. Add a unit test that the very least attempts to import the new code. Ideally the unit
test makes use of lightweight fixtures to test the logic of the code.
5. Please use the `@pytest.mark.requires(package_name)` decorator for any tests that require the dependency.
### Testing
See section about optional dependencies.
#### Unit Tests
Unit tests cover modular logic that does not require calls to outside APIs.
To run unit tests:
@ -133,8 +162,20 @@ make docker_tests
If you add new logic, please add a unit test.
#### Integration Tests
Integration tests cover logic that requires making calls to outside APIs (often integration with other services).
**warning** Almost no tests should be integration tests.
Tests that require making network connections make it difficult for other
developers to test the code.
Instead favor relying on `responses` library and/or mock.patch to mock
requests using small fixtures.
To run integration tests:
```bash

View File

@ -1,7 +1,7 @@
# Your PR Title (What it does)
<!--
Thank you for contributing to LangChain! Your PR will appear in our next release under the title you set. Please make sure it highlights your valuable contribution.
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.
Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.
@ -14,7 +14,17 @@ Fixes # (issue)
## Before submitting
<!-- If you're adding a new integration, include an integration test and an example notebook showing its use! -->
<!-- If you're adding a new integration, please include:
1. a test for the integration - favor unit tests that does not rely on network access.
2. an example notebook showing its use
See contribution guidelines for more information on how to write tests, lint
etc:
https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->
## Who can review?
@ -22,25 +32,25 @@ Community members can review the PR once tests pass. Tag maintainers/contributor
<!-- For a quicker response, figure out the right person to tag with @
@hwchase17 - project lead
@hwchase17 - project lead
Tracing / Callbacks
- @agola11
Tracing / Callbacks
- @agola11
Async
- @agola11
Async
- @agola11
DataLoaders
- @eyurtsev
DataLoaders
- @eyurtsev
Models
- @hwchase17
- @agola11
Models
- @hwchase17
- @agola11
Agents / Tools / Toolkits
- @vowelparrot
Agents / Tools / Toolkits
- @vowelparrot
VectorStores / Retrievers / Memory
- @dev2049
VectorStores / Retrievers / Memory
- @dev2049
-->