Fix `make docs_build` and related scripts (#7276)
**Description: a description of the change**
Fixed `make docs_build` and related scripts which caused errors. There
are several changes.
First, I made the build of the documentation and the API Reference into
two separate commands. This is because it takes less time to build. The
commands for documents are `make docs_build`, `make docs_clean`, and
`make docs_linkcheck`. The commands for API Reference are `make
api_docs_build`, `api_docs_clean`, and `api_docs_linkcheck`.
It looked like `docs/.local_build.sh` could be used to build the
documentation, so I used that. Since `.local_build.sh` was also building
API Rerefence internally, I removed that process. `.local_build.sh` also
added some Bash options to stop in error or so. Futher more added `cd
"${SCRIPT_DIR}"` at the beginning so that the script will work no matter
which directory it is executed in.
`docs/api_reference/api_reference.rst` is removed, because which is
generated by `docs/api_reference/create_api_rst.py`, and added it to
.gitignore.
Finally, the description of CONTRIBUTING.md was modified.
**Issue: the issue # it fixes (if applicable)**
https://github.com/hwchase17/langchain/issues/6413
**Dependencies: any dependencies required for this change**
`nbdoc` was missing in group docs so it was added. I installed it with
the `poetry add --group docs nbdoc` command. I am concerned if any
modifications are needed to poetry.lock. I would greatly appreciate it
if you could pay close attention to this file during the review.
**Tag maintainer**
- General / Misc / if you don't know who to tag: @baskaryan
If this PR needs any additional changes, I'll be happy to make them!
---------
Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-07-12 02:05:14 +00:00
|
|
|
.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
|
2022-10-24 21:51:15 +00:00
|
|
|
|
2023-07-12 01:03:17 +00:00
|
|
|
# Default target executed when no arguments are given to make.
|
2023-02-14 05:08:47 +00:00
|
|
|
all: help
|
2023-04-01 16:00:09 +00:00
|
|
|
|
2023-07-12 01:03:17 +00:00
|
|
|
######################
|
|
|
|
# TESTING AND COVERAGE
|
|
|
|
######################
|
|
|
|
|
|
|
|
# Run unit tests and generate a coverage report.
|
2022-12-13 13:48:53 +00:00
|
|
|
coverage:
|
|
|
|
poetry run pytest --cov \
|
|
|
|
--cov-config=.coveragerc \
|
|
|
|
--cov-report xml \
|
|
|
|
--cov-report term-missing:skip-covered
|
|
|
|
|
Fix `make docs_build` and related scripts (#7276)
**Description: a description of the change**
Fixed `make docs_build` and related scripts which caused errors. There
are several changes.
First, I made the build of the documentation and the API Reference into
two separate commands. This is because it takes less time to build. The
commands for documents are `make docs_build`, `make docs_clean`, and
`make docs_linkcheck`. The commands for API Reference are `make
api_docs_build`, `api_docs_clean`, and `api_docs_linkcheck`.
It looked like `docs/.local_build.sh` could be used to build the
documentation, so I used that. Since `.local_build.sh` was also building
API Rerefence internally, I removed that process. `.local_build.sh` also
added some Bash options to stop in error or so. Futher more added `cd
"${SCRIPT_DIR}"` at the beginning so that the script will work no matter
which directory it is executed in.
`docs/api_reference/api_reference.rst` is removed, because which is
generated by `docs/api_reference/create_api_rst.py`, and added it to
.gitignore.
Finally, the description of CONTRIBUTING.md was modified.
**Issue: the issue # it fixes (if applicable)**
https://github.com/hwchase17/langchain/issues/6413
**Dependencies: any dependencies required for this change**
`nbdoc` was missing in group docs so it was added. I installed it with
the `poetry add --group docs nbdoc` command. I am concerned if any
modifications are needed to poetry.lock. I would greatly appreciate it
if you could pay close attention to this file during the review.
**Tag maintainer**
- General / Misc / if you don't know who to tag: @baskaryan
If this PR needs any additional changes, I'll be happy to make them!
---------
Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-07-12 02:05:14 +00:00
|
|
|
######################
|
|
|
|
# DOCUMENTATION
|
|
|
|
######################
|
|
|
|
|
|
|
|
clean: docs_clean api_docs_clean
|
|
|
|
|
|
|
|
|
|
|
|
docs_build:
|
|
|
|
docs/.local_build.sh
|
|
|
|
|
|
|
|
docs_clean:
|
|
|
|
rm -r docs/_dist
|
|
|
|
|
|
|
|
docs_linkcheck:
|
|
|
|
poetry run linkchecker docs/_dist/docs_skeleton/ --ignore-url node_modules
|
|
|
|
|
|
|
|
api_docs_build:
|
|
|
|
poetry run python docs/api_reference/create_api_rst.py
|
|
|
|
cd docs/api_reference && poetry run make html
|
|
|
|
|
|
|
|
api_docs_clean:
|
|
|
|
rm -f docs/api_reference/api_reference.rst
|
|
|
|
cd docs/api_reference && poetry run make clean
|
|
|
|
|
|
|
|
api_docs_linkcheck:
|
|
|
|
poetry run linkchecker docs/api_reference/_build/html/index.html
|
|
|
|
|
2023-07-12 01:03:17 +00:00
|
|
|
# Define a variable for the test file path.
|
|
|
|
TEST_FILE ?= tests/unit_tests/
|
|
|
|
|
|
|
|
test:
|
|
|
|
poetry run pytest --disable-socket --allow-unix-socket $(TEST_FILE)
|
|
|
|
|
|
|
|
tests:
|
|
|
|
poetry run pytest --disable-socket --allow-unix-socket $(TEST_FILE)
|
|
|
|
|
|
|
|
extended_tests:
|
|
|
|
poetry run pytest --disable-socket --allow-unix-socket --only-extended tests/unit_tests
|
|
|
|
|
|
|
|
test_watch:
|
|
|
|
poetry run ptw --now . -- tests/unit_tests
|
|
|
|
|
|
|
|
integration_tests:
|
|
|
|
poetry run pytest tests/integration_tests
|
|
|
|
|
|
|
|
docker_tests:
|
|
|
|
docker build -t my-langchain-image:test .
|
|
|
|
docker run --rm my-langchain-image:test
|
|
|
|
|
|
|
|
######################
|
|
|
|
# LINTING AND FORMATTING
|
|
|
|
######################
|
2022-10-24 21:51:15 +00:00
|
|
|
|
2023-07-12 01:03:17 +00:00
|
|
|
# Define a variable for Python and notebook files.
|
2023-04-05 16:34:24 +00:00
|
|
|
PYTHON_FILES=.
|
2023-07-12 01:03:17 +00:00
|
|
|
lint format: PYTHON_FILES=.
|
|
|
|
lint_diff format_diff: PYTHON_FILES=$(shell git diff --name-only --diff-filter=d master | grep -E '\.py$$|\.ipynb$$')
|
2023-04-05 16:34:24 +00:00
|
|
|
|
|
|
|
lint lint_diff:
|
|
|
|
poetry run mypy $(PYTHON_FILES)
|
|
|
|
poetry run black $(PYTHON_FILES) --check
|
2023-02-25 16:59:52 +00:00
|
|
|
poetry run ruff .
|
2022-10-24 21:51:15 +00:00
|
|
|
|
2023-07-12 01:03:17 +00:00
|
|
|
format format_diff:
|
|
|
|
poetry run black $(PYTHON_FILES)
|
|
|
|
poetry run ruff --select I --fix $(PYTHON_FILES)
|
2023-02-14 05:08:47 +00:00
|
|
|
|
2023-07-12 01:03:17 +00:00
|
|
|
######################
|
|
|
|
# HELP
|
|
|
|
######################
|
2023-04-01 16:00:09 +00:00
|
|
|
|
2023-02-14 05:08:47 +00:00
|
|
|
help:
|
|
|
|
@echo '----'
|
2023-05-10 13:39:22 +00:00
|
|
|
@echo 'coverage - run unit tests and generate coverage report'
|
|
|
|
@echo 'docs_build - build the documentation'
|
|
|
|
@echo 'docs_clean - clean the documentation build artifacts'
|
|
|
|
@echo 'docs_linkcheck - run linkchecker on the documentation'
|
|
|
|
@echo 'format - run code formatters'
|
|
|
|
@echo 'lint - run linters'
|
|
|
|
@echo 'test - run unit tests'
|
2023-05-15 14:34:44 +00:00
|
|
|
@echo 'tests - run unit tests'
|
2023-05-10 13:39:22 +00:00
|
|
|
@echo 'test TEST_FILE=<test_file> - run all tests in file'
|
2023-05-12 18:50:08 +00:00
|
|
|
@echo 'extended_tests - run only extended unit tests'
|
2023-05-10 13:39:22 +00:00
|
|
|
@echo 'test_watch - run unit tests in watch mode'
|
|
|
|
@echo 'integration_tests - run integration tests'
|
|
|
|
@echo 'docker_tests - run unit tests in docker'
|