From 3ed67e9ebf20f56358c24d52fe521834a1c2c46e Mon Sep 17 00:00:00 2001 From: Erick Friis Date: Thu, 14 Dec 2023 16:53:29 -0800 Subject: [PATCH] no test --- .github/workflows/_all_ci.yml | 1 + libs/cli/langchain_cli/namespaces/template.py | 12 ++++- .../langchain_cli/package_template/Makefile | 46 +++++++++++++++++++ .../package_template/pyproject.toml | 41 +++++++++++++++-- 4 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 libs/cli/langchain_cli/package_template/Makefile diff --git a/.github/workflows/_all_ci.yml b/.github/workflows/_all_ci.yml index 48ff0bdf81d..7900e27c714 100644 --- a/.github/workflows/_all_ci.yml +++ b/.github/workflows/_all_ci.yml @@ -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 }} diff --git a/libs/cli/langchain_cli/namespaces/template.py b/libs/cli/langchain_cli/namespaces/template.py index a7ce0a0545d..6df374b0517 100644 --- a/libs/cli/langchain_cli/namespaces/template.py +++ b/libs/cli/langchain_cli/namespaces/template.py @@ -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( diff --git a/libs/cli/langchain_cli/package_template/Makefile b/libs/cli/langchain_cli/package_template/Makefile new file mode 100644 index 00000000000..8bd19883c86 --- /dev/null +++ b/libs/cli/langchain_cli/package_template/Makefile @@ -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= - run all tests in file' diff --git a/libs/cli/langchain_cli/package_template/pyproject.toml b/libs/cli/langchain_cli/package_template/pyproject.toml index 937c4a16a2d..a7ae1449d00 100644 --- a/libs/cli/langchain_cli/package_template/pyproject.toml +++ b/libs/cli/langchain_cli/package_template/pyproject.toml @@ -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"