Skip to content

Commit

Permalink
infra: import CI fix (#14562)
Browse files Browse the repository at this point in the history
TIL `**` globstar doesn't work in make

Makefile changes fix that.

`__getattr__` changes allow import of all files, but raise error when
accessing anything from the module.

file deletions were corresponding libs change from #14559
  • Loading branch information
efriis committed Dec 11, 2023
1 parent 48b7a05 commit 5418d8b
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 212 deletions.
2 changes: 1 addition & 1 deletion libs/community/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tests:
test_watch:
poetry run ptw --snapshot-update --now . -- -vv -x tests/unit_tests

check_imports: langchain_community/**/*.py
check_imports: $(shell find langchain_community -name '*.py')
for f in $^ ; do \
python -c "from importlib.machinery import SourceFileLoader; SourceFileLoader('x', '$$f').load_module()" || exit 1; \
done
Expand Down

This file was deleted.

106 changes: 0 additions & 106 deletions libs/community/langchain_community/agent_toolkits/vectorstore/base.py

This file was deleted.

2 changes: 1 addition & 1 deletion libs/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tests:
test_watch:
poetry run ptw --snapshot-update --now . -- -vv -x tests/unit_tests

check_imports: langchain_core/**/*.py
check_imports: $(shell find langchain_core -name '*.py')
for f in $^ ; do \
python -c "from importlib.machinery import SourceFileLoader; SourceFileLoader('x', '$$f').load_module()" || exit 1; \
done
Expand Down
2 changes: 1 addition & 1 deletion libs/experimental/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extended_tests:
integration_tests:
poetry run pytest tests/integration_tests

check_imports: langchain_experimental/**/*.py
check_imports: $(shell find langchain_experimental -name '*.py')
for f in $^ ; do \
python -c "from importlib.machinery import SourceFileLoader; SourceFileLoader('x', '$$f').load_module()" || exit 1; \
done
Expand Down
2 changes: 1 addition & 1 deletion libs/langchain/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ docker_tests:
docker build -t my-langchain-image:test .
docker run --rm my-langchain-image:test

check_imports: langchain/**/*.py
check_imports: $(shell find langchain -name '*.py')
for f in $^ ; do \
python -c "from importlib.machinery import SourceFileLoader; SourceFileLoader('x', '$$f').load_module()" || exit 1; \
done
Expand Down
5 changes: 1 addition & 4 deletions libs/langchain/langchain/chains/llm_bash/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def raise_on_import() -> None:
def __getattr__(name: str = "") -> None:
"""Raise an error on import since is deprecated."""
raise ImportError(
"This module has been moved to langchain-experimental. "
Expand All @@ -7,6 +7,3 @@ def raise_on_import() -> None:
"`from langchain_experimental.llm_bash.base "
"import LLMBashChain`"
)


raise_on_import()
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def raise_on_import() -> None:
def __getattr__(name: str = "") -> None:
"""Raise an error on import since is deprecated."""
raise ImportError(
"This module has been moved to langchain-experimental. "
Expand All @@ -7,6 +7,3 @@ def raise_on_import() -> None:
"`from langchain_experimental.llm_symbolic_math.base "
"import LLMSymbolicMathChain`"
)


raise_on_import()
9 changes: 4 additions & 5 deletions libs/langchain/langchain/tools/python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
def raise_on_import() -> None:
"""Raise on import letting users know that underlying code is deprecated."""
from typing import Any


def __getattr__(name: str = "") -> Any:
raise ImportError(
"This tool has been moved to langchain experiment. "
"This tool has access to a python REPL. "
Expand All @@ -8,6 +10,3 @@ def raise_on_import() -> None:
"To keep using this code as is, install langchain experimental and "
"update relevant imports replacing 'langchain' with 'langchain_experimental'"
)


raise_on_import()

0 comments on commit 5418d8b

Please sign in to comment.