|
| 1 | +.PHONY: all clean docs_build docs_clean docs_linkcheck api_docs_build api_docs_clean api_docs_linkcheck format lint test tests test_watch integration_tests docker_tests help extended_tests |
| 2 | + |
| 3 | +# Default target executed when no arguments are given to make. |
| 4 | +all: help |
| 5 | + |
| 6 | +###################### |
| 7 | +# TESTING AND COVERAGE |
| 8 | +###################### |
| 9 | + |
| 10 | +# Run unit tests and generate a coverage report. |
| 11 | +coverage: |
| 12 | + poetry run pytest --cov \ |
| 13 | + --cov-config=.coveragerc \ |
| 14 | + --cov-report xml \ |
| 15 | + --cov-report term-missing:skip-covered |
| 16 | + |
| 17 | +###################### |
| 18 | +# DOCUMENTATION |
| 19 | +###################### |
| 20 | + |
| 21 | +clean: docs_clean api_docs_clean |
| 22 | + |
| 23 | + |
| 24 | +docs_build: |
| 25 | + docs/.local_build.sh |
| 26 | + |
| 27 | +docs_clean: |
| 28 | + rm -r docs/_dist |
| 29 | + |
| 30 | +docs_linkcheck: |
| 31 | + poetry run linkchecker docs/_dist/docs_skeleton/ --ignore-url node_modules |
| 32 | + |
| 33 | +api_docs_build: |
| 34 | + poetry run python docs/api_reference/create_api_rst.py |
| 35 | + cd docs/api_reference && poetry run make html |
| 36 | + |
| 37 | +api_docs_clean: |
| 38 | + rm -f docs/api_reference/api_reference.rst |
| 39 | + cd docs/api_reference && poetry run make clean |
| 40 | + |
| 41 | +api_docs_linkcheck: |
| 42 | + poetry run linkchecker docs/api_reference/_build/html/index.html |
| 43 | + |
| 44 | +# Define a variable for the test file path. |
| 45 | +TEST_FILE ?= tests/unit_tests/ |
| 46 | + |
| 47 | +test: |
| 48 | + poetry run pytest --disable-socket --allow-unix-socket $(TEST_FILE) |
| 49 | + |
| 50 | +tests: |
| 51 | + poetry run pytest --disable-socket --allow-unix-socket $(TEST_FILE) |
| 52 | + |
| 53 | +extended_tests: |
| 54 | + poetry run pytest --disable-socket --allow-unix-socket --only-extended tests/unit_tests |
| 55 | + |
| 56 | +test_watch: |
| 57 | + poetry run ptw --now . -- tests/unit_tests |
| 58 | + |
| 59 | +integration_tests: |
| 60 | + poetry run pytest tests/integration_tests |
| 61 | + |
| 62 | +docker_tests: |
| 63 | + docker build -t my-langchain-image:test . |
| 64 | + docker run --rm my-langchain-image:test |
| 65 | + |
| 66 | +###################### |
| 67 | +# LINTING AND FORMATTING |
| 68 | +###################### |
| 69 | + |
| 70 | +# Define a variable for Python and notebook files. |
| 71 | +PYTHON_FILES=. |
| 72 | +lint format: PYTHON_FILES=. |
| 73 | +lint_diff format_diff: PYTHON_FILES=$(shell git diff --name-only --diff-filter=d master | grep -E '\.py$$|\.ipynb$$') |
| 74 | + |
| 75 | +lint lint_diff: |
| 76 | + poetry run mypy $(PYTHON_FILES) |
| 77 | + poetry run black $(PYTHON_FILES) --check |
| 78 | + poetry run ruff . |
| 79 | + |
| 80 | +format format_diff: |
| 81 | + poetry run black $(PYTHON_FILES) |
| 82 | + poetry run ruff --select I --fix $(PYTHON_FILES) |
| 83 | + |
| 84 | +spell_check: |
| 85 | + poetry run codespell --toml pyproject.toml |
| 86 | + |
| 87 | +spell_fix: |
| 88 | + poetry run codespell --toml pyproject.toml -w |
| 89 | + |
| 90 | +###################### |
| 91 | +# HELP |
| 92 | +###################### |
| 93 | + |
| 94 | +help: |
| 95 | + @echo '----' |
| 96 | + @echo 'coverage - run unit tests and generate coverage report' |
| 97 | + @echo 'docs_build - build the documentation' |
| 98 | + @echo 'docs_clean - clean the documentation build artifacts' |
| 99 | + @echo 'docs_linkcheck - run linkchecker on the documentation' |
| 100 | + @echo 'format - run code formatters' |
| 101 | + @echo 'lint - run linters' |
| 102 | + @echo 'test - run unit tests' |
| 103 | + @echo 'tests - run unit tests' |
| 104 | + @echo 'test TEST_FILE=<test_file> - run all tests in file' |
| 105 | + @echo 'extended_tests - run only extended unit tests' |
| 106 | + @echo 'test_watch - run unit tests in watch mode' |
| 107 | + @echo 'integration_tests - run integration tests' |
| 108 | + @echo 'docker_tests - run unit tests in docker' |
0 commit comments