Skip to content
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

core[patch], langchain[patch]: fix required deps #14373

Merged
merged 30 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 17 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
3 changes: 1 addition & 2 deletions .github/workflows/_all_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ jobs:

compile-integration-tests:
uses: ./.github/workflows/_compile_integration_test.yml
if: ${{ inputs.working-directory != 'libs/core' }}
with:
working-directory: ${{ inputs.working-directory }}
secrets: inherit
Expand Down Expand Up @@ -88,7 +87,7 @@ jobs:
shell: bash
run: |
echo "Running extended tests, installing dependencies with poetry..."
poetry install -E extended_testing
poetry install -E extended_testing --with test

- name: Install langchain core editable
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_compile_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

- name: Install integration dependencies
shell: bash
run: poetry install --with=test_integration
run: poetry install --with=test_integration,test

- name: Check integration tests compile
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_pydantic_compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

- name: Install dependencies
shell: bash
run: poetry install
run: poetry install --with test

- name: Install langchain editable
working-directory: ${{ inputs.working-directory }}
Expand Down
2 changes: 1 addition & 1 deletion libs/core/langchain_core/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def messages(self) -> Sequence[BaseMessage]:


def _convert_agent_action_to_messages(
agent_action: AgentAction
agent_action: AgentAction,
Copy link
Member

Choose a reason for hiding this comment

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

was linting messing up somehow?

) -> Sequence[BaseMessage]:
"""Convert an agent action to a message.

Expand Down
7 changes: 6 additions & 1 deletion libs/core/langchain_core/tracers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
"Run",
"RunLog",
"RunLogPatch",
"LogStreamCallbackHandler",
]

from langchain_core.tracers.base import BaseTracer
from langchain_core.tracers.evaluation import EvaluatorCallbackHandler
from langchain_core.tracers.langchain import LangChainTracer
from langchain_core.tracers.log_stream import RunLog, RunLogPatch
from langchain_core.tracers.log_stream import (
LogStreamCallbackHandler,
RunLog,
RunLogPatch,
)
from langchain_core.tracers.schemas import Run
from langchain_core.tracers.stdout import ConsoleCallbackHandler
27 changes: 26 additions & 1 deletion libs/core/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions libs/core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,26 @@ pydantic = ">=1,<3"
langsmith = "~0.0.63"
tenacity = "^8.1.0"
jsonpatch = "^1.33"
anyio = ">=3,<5"
PyYAML = ">=5.3"

[tool.poetry.group.lint]
optional = true

[tool.poetry.group.lint.dependencies]
ruff = "^0.1.5"

[tool.poetry.group.typing]
optional = true

[tool.poetry.group.typing.dependencies]
mypy = "^0.991"
types-pyyaml = "^6.0.12.2"
types-requests = "^2.28.11.5"
types-jinja2 = "^2.11.9"

[tool.poetry.group.dev]
optional = true

[tool.poetry.group.dev.dependencies]
jupyter = "^1.0.0"
Expand All @@ -37,6 +49,7 @@ pytest-mock = "^3.10.0"
syrupy = "^4.0.2"
pytest-watcher = "^0.3.4"
pytest-asyncio = "^0.21.1"
jinja2 = "^3"


[tool.poetry.group.test_integration]
Expand Down
Empty file.
7 changes: 7 additions & 0 deletions libs/core/tests/integration_tests/test_compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest


@pytest.mark.compile
def test_placeholder() -> None:
"""Used for compiling integration tests without running any real tests."""
pass
6 changes: 3 additions & 3 deletions libs/core/tests/unit_tests/prompts/test_few_shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def test_partial() -> None:

@pytest.mark.requires("jinja2")
def test_prompt_jinja2_functionality(
example_jinja2_prompt: Tuple[PromptTemplate, List[Dict[str, str]]]
example_jinja2_prompt: Tuple[PromptTemplate, List[Dict[str, str]]],
) -> None:
prefix = "Starting with {{ foo }}"
suffix = "Ending with {{ bar }}"
Expand All @@ -256,7 +256,7 @@ def test_prompt_jinja2_functionality(

@pytest.mark.requires("jinja2")
def test_prompt_jinja2_missing_input_variables(
example_jinja2_prompt: Tuple[PromptTemplate, List[Dict[str, str]]]
example_jinja2_prompt: Tuple[PromptTemplate, List[Dict[str, str]]],
) -> None:
"""Test error is raised when input variables are not provided."""
prefix = "Starting with {{ foo }}"
Expand Down Expand Up @@ -303,7 +303,7 @@ def test_prompt_jinja2_missing_input_variables(

@pytest.mark.requires("jinja2")
def test_prompt_jinja2_extra_input_variables(
example_jinja2_prompt: Tuple[PromptTemplate, List[Dict[str, str]]]
example_jinja2_prompt: Tuple[PromptTemplate, List[Dict[str, str]]],
) -> None:
"""Test error is raised when there are too many input variables."""
prefix = "Starting with {{ foo }}"
Expand Down
Empty file.
1 change: 1 addition & 0 deletions libs/core/tests/unit_tests/tracers/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"Run",
"RunLog",
"RunLogPatch",
"LogStreamCallbackHandler",
]


Expand Down
8 changes: 4 additions & 4 deletions libs/experimental/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/langchain/langchain/vectorstores/clarifai.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from typing import Any, Iterable, List, Optional, Tuple

import requests
from google.protobuf.struct_pb2 import Struct
from langchain_core.documents import Document
from langchain_core.embeddings import Embeddings
from langchain_core.vectorstores import VectorStore
Expand Down Expand Up @@ -87,6 +86,7 @@ def add_texts(
"""
try:
from clarifai.client.input import Inputs
from google.protobuf.struct_pb2 import Struct
except ImportError as e:
raise ImportError(
"Could not import clarifai python package. "
Expand Down
3 changes: 2 additions & 1 deletion libs/langchain/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion libs/langchain/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ PyYAML = ">=5.3"
numpy = "^1"
aiohttp = "^3.8.3"
tenacity = "^8.1.0"
anyio = "<4.0"
jsonpatch = "^1.33"
azure-core = {version = "^1.26.4", optional=true}
tqdm = {version = ">=4.48.0", optional = true}
Expand Down Expand Up @@ -151,6 +150,9 @@ couchbase = {version = "^4.1.9", optional = true}
dgml-utils = {version = "^0.3.0", optional = true}
datasets = {version = "^2.15.0", optional = true}

[tool.poetry.group.test]
optional = true

[tool.poetry.group.test.dependencies]
# The only dependencies that should be added are
# dependencies used for running tests (e.g., pytest, freezegun, response).
Expand All @@ -171,6 +173,9 @@ syrupy = "^4.0.2"
requests-mock = "^1.11.0"
langchain-core = {path = "../core", develop = true}

[tool.poetry.group.codespell]
optional = true

[tool.poetry.group.codespell.dependencies]
codespell = "^2.2.0"

Expand Down Expand Up @@ -201,6 +206,9 @@ cassio = "^0.1.0"
tiktoken = "^0.3.2"
anthropic = "^0.3.11"

[tool.poetry.group.lint]
optional = true

[tool.poetry.group.lint.dependencies]
ruff = "^0.1.5"
types-toml = "^0.10.8.1"
Expand All @@ -209,6 +217,9 @@ types-pytz = "^2023.3.0.0"
types-chardet = "^5.0.4.6"
mypy-protobuf = "^3.0.0"

[tool.poetry.group.typing]
optional = true

[tool.poetry.group.typing.dependencies]
mypy = "^0.991"
types-pyyaml = "^6.0.12.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from langchain.document_loaders.google_speech_to_text import GoogleSpeechToTextLoader


@pytest.mark.requires("google_api_core")
@pytest.mark.requires("google.api_core")
def test_initialization() -> None:
loader = GoogleSpeechToTextLoader(
project_id="test_project_id", file_path="./testfile.mp3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)


@pytest.mark.requires("google_api_core")
@pytest.mark.requires("google.api_core")
def test_google_vertex_ai_search_get_relevant_documents() -> None:
"""Test the get_relevant_documents() method."""
retriever = GoogleVertexAISearchRetriever()
Expand All @@ -36,7 +36,7 @@ def test_google_vertex_ai_search_get_relevant_documents() -> None:
assert doc.metadata["source"]


@pytest.mark.requires("google_api_core")
@pytest.mark.requires("google.api_core")
def test_google_vertex_ai_multiturnsearch_get_relevant_documents() -> None:
"""Test the get_relevant_documents() method."""
retriever = GoogleVertexAIMultiTurnSearchRetriever()
Expand All @@ -49,7 +49,7 @@ def test_google_vertex_ai_multiturnsearch_get_relevant_documents() -> None:
assert doc.metadata["source"]


@pytest.mark.requires("google_api_core")
@pytest.mark.requires("google.api_core")
def test_google_vertex_ai_search_enterprise_search_deprecation() -> None:
"""Test the deprecation of GoogleCloudEnterpriseSearchRetriever."""
with pytest.warns(
Expand Down
6 changes: 5 additions & 1 deletion libs/langchain/tests/unit_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ def test_something():
# If we haven't yet checked whether the pkg is installed
# let's check it and store the result.
if pkg not in required_pkgs_info:
required_pkgs_info[pkg] = util.find_spec(pkg) is not None
try:
installed = util.find_spec(pkg) is not None
Copy link
Collaborator

Choose a reason for hiding this comment

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

when does this result in an exception?

Copy link
Collaborator

Choose a reason for hiding this comment

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

i think it works for top level packages without an error?

Copy link
Collaborator Author

@baskaryan baskaryan Dec 7, 2023

Choose a reason for hiding this comment

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

was giving errors for "google": https://github.com/langchain-ai/langchain/actions/runs/7133277557/job/19425640725

but let me try again, maybe was symptom of different issue

except Exception:
installed = False
required_pkgs_info[pkg] = installed

if not required_pkgs_info[pkg]:
if only_extended:
Expand Down
1 change: 0 additions & 1 deletion libs/langchain/tests/unit_tests/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def test_required_dependencies(poetry_conf: Mapping[str, Any]) -> None:
"PyYAML",
"SQLAlchemy",
"aiohttp",
"anyio",
"async-timeout",
"dataclasses-json",
"jsonpatch",
Expand Down
Loading