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

Update Makefile #302

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.vs/
.vscode/
.idea/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -59,6 +60,7 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
.mypy_cache_test/

# Translations
*.mo
Expand Down
76 changes: 54 additions & 22 deletions libs/aws/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
######################
# NON FILE TARGETS
######################
.PHONY: all format lint test tests integration_tests docker_tests help extended_tests

# Default target executed when no arguments are given to make.
all: help
######################
# ALL TARGETS
######################

all: help ## Default target = help

######################
# TEST CASES
######################

# Define a variable for the test file path.
TEST_FILE ?= tests/unit_tests/
test test_watch tests: TEST_FILE ?= tests/unit_tests/
integration_test integration_tests: TEST_FILE = tests/integration_tests/

test tests integration_test integration_tests:
# Define a variable for Python and notebook files.
PYTHON_FILES=.

tests: ## Run all unit tests
poetry run pytest $(TEST_FILE)

test: ## Run individual unit test: make test TEST_FILE=tests/unit_test/test.py
poetry run pytest $(TEST_FILE)

test_watch:
integration_tests: ## Run all integration tests
poetry run pytest $(TEST_FILE)

integration_test: ## Run individual integration test: make integration_test TEST_FILE=tests/integration_tests/integ_test.py
poetry run pytest $(TEST_FILE)

test_watch: ## Run and interactively watch unit tests
poetry run ptw --snapshot-update --now . -- -vv $(TEST_FILE)

######################
Expand All @@ -26,34 +48,44 @@ lint_package: PYTHON_FILES=langchain_aws
lint_tests: PYTHON_FILES=tests
lint_tests: MYPY_CACHE=.mypy_cache_test

lint lint_diff lint_package lint_tests:
poetry run ruff .
lint: ## Run linter
poetry run ruff check

lint_diff: ## Run linter
poetry run ruff format $(PYTHON_FILES) --diff
poetry run ruff --select I $(PYTHON_FILES)

lint_package: ## Run linter on package
poetry run ruff check --select I $(PYTHON_FILES)

lint_tests: ## Run linter tests
mkdir -p $(MYPY_CACHE); poetry run mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)

format format_diff:
format: ## Run code formatter
poetry run ruff format $(PYTHON_FILES)
poetry run ruff --select I --fix $(PYTHON_FILES)

spell_check:
format_diff: ## Run code formatter and show differences
poetry run ruff check --select I --fix $(PYTHON_FILES)

spell_check: ## Run code spell check
poetry run codespell --toml pyproject.toml

spell_fix:
spell_fix: ## Run code spell fix
poetry run codespell --toml pyproject.toml -w

check_imports: $(shell find langchain_aws -name '*.py')
poetry run python ./scripts/check_imports.py $^
######################
# DEPENDENCIES
######################

install_dev: ## Install development environment
@pip install --no-cache -U poetry
@poetry install --with dev,test,codespell,lint,typing

check_imports: $(shell find langchain_aws -name '*.py') ## Check missing imports
@poetry run python ./scripts/check_imports.py $^

######################
# HELP
######################

help:
@echo '----'
@echo 'check_imports - check imports'
@echo 'format - run code formatters'
@echo 'lint - run linters'
@echo 'test - run unit tests'
@echo 'tests - run unit tests'
@echo 'test TEST_FILE=<test_file> - run all tests in file'
help: ## Print this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
2 changes: 1 addition & 1 deletion libs/aws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ There are three different search methods we can use to do retrieval. By default,

```python
retriever=vds.as_retriever()
```
```
4 changes: 3 additions & 1 deletion libs/aws/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ pytest-watcher = "^0.3.4"
langchain-tests = "0.3.1"
langchain = "^0.3.7"


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

[tool.codespell]
ignore-words-list = "HSA, notIn"

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

Expand Down
3 changes: 2 additions & 1 deletion libs/aws/scripts/check_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
if __name__ == "__main__":
files = sys.argv[1:]
has_failure = False

for file in files:
try:
SourceFileLoader("x", file).load_module()
except Exception:
has_faillure = True
has_failure = True
print(file) # noqa: T201
traceback.print_exc()
print() # noqa: T201
Expand Down
2 changes: 1 addition & 1 deletion libs/aws/tests/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BaseFakeCallbackHandler(BaseModel):
ignore_retriever_: bool = False
ignore_chat_model_: bool = False

# to allow for similar callback handlers that are not technicall equal
# to allow for similar callback handlers that are not technically equal
fake_id: Union[str, None] = None

# add finer-grained counters for easier debugging of failing tests
Expand Down
2 changes: 1 addition & 1 deletion libs/aws/tests/unit_tests/retrievers/test_bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_retriever_invoke(amazon_retriever, mock_client):
retrievalConfiguration={
"vectorSearchConfiguration": {
"numberOfResults": 5,
# Expecting to be called with correct "in" operatior instead of "in_"
# Expecting to be called with correct "in" operator instead of "in_"
"filter": {"in": {"key": "key", "value": ["value1", "value2"]}},
}
},
Expand Down
Loading