This commit is contained in:
Erick Friis
2023-12-14 16:53:29 -08:00
parent b3c828ebaf
commit 3ed67e9ebf
4 changed files with 96 additions and 4 deletions

View File

@@ -42,6 +42,7 @@ jobs:
secrets: inherit
test:
if: ${{ ! startsWith(inputs.working-directory, 'templates/') }}
uses: ./.github/workflows/_test.yml
with:
working-directory: ${{ inputs.working-directory }}

View File

@@ -9,12 +9,22 @@ from pathlib import Path
from typing import Optional
import typer
from typing_extensions import Annotated
from typing_extensions import Annotated, TypedDict
from langchain_cli.utils.packages import get_langserve_export, get_package_root
package_cli = typer.Typer(no_args_is_help=True, add_completion=False)
Replacements = TypedDict(
"Replacements",
{
"__package_name__": str,
"__module_name__": str,
"__ModuleName__": str,
"__package_name_short__": str,
},
)
@package_cli.command()
def new(

View File

@@ -0,0 +1,46 @@
.PHONY: all format lint test tests help
# Default target executed when no arguments are given to make.
all: help
# Define a variable for the test file path.
TEST_FILE ?= tests/
test:
poetry run pytest $(TEST_FILE)
PYTHON_FILES=.
MYPY_CACHE=.mypy_cache
lint format: PYTHON_FILES=.
lint_diff format_diff: PYTHON_FILES=$(shell git diff --relative=templates/__package_name__ --name-only --diff-filter=d master | grep -E '\.py$$|\.ipynb$$')
lint_package: PYTHON_FILES=__module_name__
lint_tests: PYTHON_FILES=tests
lint_tests: MYPY_CACHE=.mypy_cache_test
lint lint_diff lint_package lint_tests:
poetry run ruff .
poetry run ruff format $(PYTHON_FILES) --diff
poetry run ruff --select I $(PYTHON_FILES)
poetry run mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)
format format_diff:
poetry run ruff format $(PYTHON_FILES)
poetry run ruff --select I --fix $(PYTHON_FILES)
spell_check:
poetry run codespell --toml pyproject.toml
spell_fix:
poetry run codespell --toml pyproject.toml -w
######################
# HELP
######################
help:
@echo '----'
@echo 'check_imports - check imports'
@echo 'format - run code formatters'
@echo 'lint - run linters'
@echo 'test - run unit tests'
@echo 'test TEST_FILE=<test_file> - run all tests in file'

View File

@@ -7,11 +7,46 @@ readme = "README.md"
[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
langchain = ">=0.0.313, <0.1"
openai = "^0.28.1"
langchain = ">=0.0.350, <0.2"
[tool.poetry.group.test]
optional = true
[tool.poetry.group.test.dependencies]
pytest = "^7.3.0"
freezegun = "^1.2.2"
pytest-mock = "^3.10.0"
syrupy = "^4.0.2"
pytest-watcher = "^0.3.4"
pytest-asyncio = "^0.21.1"
langchain-core = {path = "../../libs/core", develop = true}
[tool.poetry.group.codespell]
optional = true
[tool.poetry.group.codespell.dependencies]
codespell = "^2.2.6"
[tool.poetry.group.test_integration]
optional = true
[tool.poetry.group.test_integration.dependencies]
[tool.poetry.group.lint]
optional = true
[tool.poetry.group.lint.dependencies]
ruff = "^0.1.8"
[tool.poetry.group.typing.dependencies]
mypy = "^1.7.1"
langchain-core = {path = "../../libs/core", develop = true}
[tool.poetry.group.dev]
optional = true
[tool.poetry.group.dev.dependencies]
langchain-cli = ">=0.0.4"
langchain-cli = ">=0.0.19"
fastapi = "^0.104.0"
sse-starlette = "^1.6.5"