mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-22 14:49:29 +00:00
Update testing workflow to test with both pydantic versions (#9206)
* PR updates test.yml to test with both pydantic versions * Code should be refactored to make it easier to do testing in matrix format w/ packages * Added steps to assert that pydantic version in the environment is as expected
This commit is contained in:
parent
e0162baa3b
commit
a091b4bf4c
41
.github/workflows/_test.yml
vendored
41
.github/workflows/_test.yml
vendored
@ -10,7 +10,7 @@ on:
|
|||||||
test_type:
|
test_type:
|
||||||
type: string
|
type: string
|
||||||
description: "Test types to run"
|
description: "Test types to run"
|
||||||
default: '["core", "extended"]'
|
default: '["core", "extended", "core-pydantic-2"]'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
POETRY_VERSION: "1.4.2"
|
POETRY_VERSION: "1.4.2"
|
||||||
@ -43,19 +43,42 @@ jobs:
|
|||||||
if [ "${{ matrix.test_type }}" == "core" ]; then
|
if [ "${{ matrix.test_type }}" == "core" ]; then
|
||||||
echo "Running core tests, installing dependencies with poetry..."
|
echo "Running core tests, installing dependencies with poetry..."
|
||||||
poetry install
|
poetry install
|
||||||
|
elif [ "${{ matrix.test_type }}" == "core-pydantic-2" ]; then
|
||||||
|
echo "Running core-pydantic-v2 tests, installing dependencies with poetry..."
|
||||||
|
poetry install
|
||||||
|
poetry add pydantic@2.1
|
||||||
else
|
else
|
||||||
echo "Running extended tests, installing dependencies with poetry..."
|
echo "Running extended tests, installing dependencies with poetry..."
|
||||||
poetry install -E extended_testing
|
poetry install -E extended_testing
|
||||||
fi
|
fi
|
||||||
- name: Install langchain editable
|
- name: Verify pydantic version
|
||||||
if: ${{ inputs.working-directory != 'langchain' }}
|
|
||||||
run: |
|
run: |
|
||||||
pip install -e ../langchain
|
if [ "${{ matrix.test_type }}" == "core-pydantic-2" ]; then
|
||||||
|
EXPECTED_VERSION=2
|
||||||
|
else
|
||||||
|
EXPECTED_VERSION=1
|
||||||
|
fi
|
||||||
|
echo "Checking pydantic version... Expecting ${EXPECTED_VERSION}"
|
||||||
|
|
||||||
|
# Determine the major part of pydantic version
|
||||||
|
VERSION=$(poetry run python -c "import pydantic; print(pydantic.__version__)" | cut -d. -f1)
|
||||||
|
|
||||||
|
# Check that the major part of pydantic version is as expected, if not
|
||||||
|
# raise an error
|
||||||
|
if [[ "$VERSION" -ne $EXPECTED_VERSION ]]; then
|
||||||
|
echo "Error: pydantic version must be equal to ${EXPECTED_VERSION}; Found: ${VERSION}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Found pydantic version ${VERSION}, as expected"
|
||||||
|
shell: bash
|
||||||
- name: Run ${{matrix.test_type}} tests
|
- name: Run ${{matrix.test_type}} tests
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ matrix.test_type }}" == "core" ]; then
|
case "${{ matrix.test_type }}" in
|
||||||
make test
|
core | core-pydantic-2)
|
||||||
else
|
make test
|
||||||
make extended_tests
|
;;
|
||||||
fi
|
*)
|
||||||
|
make extended_tests
|
||||||
|
;;
|
||||||
|
esac
|
||||||
shell: bash
|
shell: bash
|
||||||
|
1
.github/workflows/langchain_ci.yml
vendored
1
.github/workflows/langchain_ci.yml
vendored
@ -24,4 +24,5 @@ jobs:
|
|||||||
./.github/workflows/_test.yml
|
./.github/workflows/_test.yml
|
||||||
with:
|
with:
|
||||||
working-directory: libs/langchain
|
working-directory: libs/langchain
|
||||||
|
test_type: '["core", "extended", "core-pydantic-2"]'
|
||||||
secrets: inherit
|
secrets: inherit
|
@ -3,7 +3,7 @@ import threading
|
|||||||
from typing import Any, Dict, List, Mapping, Optional
|
from typing import Any, Dict, List, Mapping, Optional
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from pydantic import root_validator
|
from pydantic_v1 import root_validator
|
||||||
|
|
||||||
from langchain.callbacks.manager import CallbackManagerForLLMRun
|
from langchain.callbacks.manager import CallbackManagerForLLMRun
|
||||||
from langchain.chat_models.base import BaseChatModel
|
from langchain.chat_models.base import BaseChatModel
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import uuid
|
import uuid
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from pydantic import Field
|
from pydantic_v1 import Field
|
||||||
|
|
||||||
from langchain.callbacks.manager import CallbackManagerForRetrieverRun
|
from langchain.callbacks.manager import CallbackManagerForRetrieverRun
|
||||||
from langchain.schema.document import Document
|
from langchain.schema.document import Document
|
||||||
|
879
libs/langchain/poetry.lock
generated
879
libs/langchain/poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,7 @@ langchain-server = "langchain.server:main"
|
|||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = ">=3.8.1,<4.0"
|
python = ">=3.8.1,<4.0"
|
||||||
pydantic = "^1"
|
pydantic = ">=1,<3"
|
||||||
SQLAlchemy = ">=1.4,<3"
|
SQLAlchemy = ">=1.4,<3"
|
||||||
requests = "^2"
|
requests = "^2"
|
||||||
PyYAML = ">=5.3"
|
PyYAML = ">=5.3"
|
||||||
@ -107,7 +107,6 @@ mwxml = {version = "^0.3.3", optional = true}
|
|||||||
awadb = {version = "^0.3.9", optional = true}
|
awadb = {version = "^0.3.9", optional = true}
|
||||||
azure-search-documents = {version = "11.4.0b6", optional = true}
|
azure-search-documents = {version = "11.4.0b6", optional = true}
|
||||||
esprima = {version = "^4.0.1", optional = true}
|
esprima = {version = "^4.0.1", optional = true}
|
||||||
openllm = {version = ">=0.1.19", optional = true}
|
|
||||||
streamlit = {version = "^1.18.0", optional = true, python = ">=3.8.1,<3.9.7 || >3.9.7,<4.0"}
|
streamlit = {version = "^1.18.0", optional = true, python = ">=3.8.1,<3.9.7 || >3.9.7,<4.0"}
|
||||||
psychicapi = {version = "^0.8.0", optional = true}
|
psychicapi = {version = "^0.8.0", optional = true}
|
||||||
cassio = {version = "^0.0.7", optional = true}
|
cassio = {version = "^0.0.7", optional = true}
|
||||||
@ -197,7 +196,7 @@ playwright = "^1.28.0"
|
|||||||
setuptools = "^67.6.1"
|
setuptools = "^67.6.1"
|
||||||
|
|
||||||
[tool.poetry.extras]
|
[tool.poetry.extras]
|
||||||
llms = ["clarifai", "cohere", "openai", "openllm", "openlm", "nlpcloud", "huggingface_hub", "manifest-ml", "torch", "transformers", ]
|
llms = ["clarifai", "cohere", "openai", "openlm", "nlpcloud", "huggingface_hub", "manifest-ml", "torch", "transformers"]
|
||||||
qdrant = ["qdrant-client"]
|
qdrant = ["qdrant-client"]
|
||||||
openai = ["openai", "tiktoken"]
|
openai = ["openai", "tiktoken"]
|
||||||
text_helpers = ["chardet"]
|
text_helpers = ["chardet"]
|
||||||
|
210
poetry.lock
generated
210
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user