|
| 1 | +.PHONY: all format lint test tests integration_tests help extended_tests |
| 2 | + |
| 3 | +# Default target executed when no arguments are given to make. |
| 4 | +all: help |
| 5 | + |
| 6 | +.EXPORT_ALL_VARIABLES: |
| 7 | +UV_FROZEN = true |
| 8 | + |
| 9 | +# Define a variable for the test file path. |
| 10 | +TEST_FILE ?= tests/unit_tests/ |
| 11 | +integration_test integration_tests: TEST_FILE = tests/integration_tests/ |
| 12 | + |
| 13 | + |
| 14 | +# unit tests are run with the --disable-socket flag to prevent network calls |
| 15 | +test tests: |
| 16 | + uv run --group test pytest --disable-socket --allow-unix-socket $(TEST_FILE) |
| 17 | + |
| 18 | +test_watch: |
| 19 | + uv run --group test ptw --snapshot-update --now . -- -vv $(TEST_FILE) |
| 20 | + |
| 21 | +# integration tests are run without the --disable-socket flag to allow network calls |
| 22 | +integration_test integration_tests: |
| 23 | + uv run --group test --group test_integration pytest --timeout=30 $(TEST_FILE) |
| 24 | + |
| 25 | +###################### |
| 26 | +# LINTING AND FORMATTING |
| 27 | +###################### |
| 28 | + |
| 29 | +# Define a variable for Python and notebook files. |
| 30 | +PYTHON_FILES=. |
| 31 | +MYPY_CACHE=.mypy_cache |
| 32 | +lint format: PYTHON_FILES=. |
| 33 | +lint_diff format_diff: PYTHON_FILES=$(shell git diff --relative=libs/partners/deepseek --name-only --diff-filter=d master | grep -E '\.py$$|\.ipynb$$') |
| 34 | +lint_package: PYTHON_FILES=langchain_deepseek |
| 35 | +lint_tests: PYTHON_FILES=tests |
| 36 | +lint_tests: MYPY_CACHE=.mypy_cache_test |
| 37 | + |
| 38 | +lint lint_diff lint_package lint_tests: |
| 39 | + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check $(PYTHON_FILES) |
| 40 | + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) --diff |
| 41 | + [ "$(PYTHON_FILES)" = "" ] || mkdir -p $(MYPY_CACHE) && uv run --all-groups mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE) |
| 42 | + |
| 43 | +format format_diff: |
| 44 | + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) |
| 45 | + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) |
| 46 | + |
| 47 | +check_imports: $(shell find langchain_deepseek -name '*.py') |
| 48 | + uv run --all-groups python ./scripts/check_imports.py $^ |
| 49 | + |
| 50 | +###################### |
| 51 | +# HELP |
| 52 | +###################### |
| 53 | + |
| 54 | +help: |
| 55 | + @echo '----' |
| 56 | + @echo 'check_imports - check imports' |
| 57 | + @echo 'format - run code formatters' |
| 58 | + @echo 'lint - run linters' |
| 59 | + @echo 'test - run unit tests' |
| 60 | + @echo 'tests - run unit tests' |
| 61 | + @echo 'test TEST_FILE=<test_file> - run all tests in file' |
0 commit comments