From a526b77be4d3f3b0f6f90274695caf8bd083275a Mon Sep 17 00:00:00 2001 From: anakin87 Date: Fri, 29 Sep 2023 18:00:38 +0200 Subject: [PATCH] try to improve workflows --- .../components_instructor_embedders.yml | 13 +- .../instructor-embedders/pyproject.toml | 143 +++++------------- 2 files changed, 40 insertions(+), 116 deletions(-) diff --git a/.github/workflows/components_instructor_embedders.yml b/.github/workflows/components_instructor_embedders.yml index 654586a82..884302d6d 100644 --- a/.github/workflows/components_instructor_embedders.yml +++ b/.github/workflows/components_instructor_embedders.yml @@ -25,15 +25,14 @@ jobs: with: python-version: '3.10' - - name: Install Hatch - run: pip install --upgrade hatch - - name: Install instructor-embedders run: | pip install -e .[dev] - - name: Lint - run: hatch run lint:all + - name: Pylint + run: | + pylint -ry -j 0 ./instructor_embedders - - name: Run tests and track code coverage - run: hatch run cov \ No newline at end of file + - name: Run tests + run: | + pytest \ No newline at end of file diff --git a/components/instructor-embedders/pyproject.toml b/components/instructor-embedders/pyproject.toml index d419e3de8..affef1b9c 100644 --- a/components/instructor-embedders/pyproject.toml +++ b/components/instructor-embedders/pyproject.toml @@ -46,6 +46,9 @@ dependencies = [ "InstructorEmbedding" ] +[project.optional-dependencies] +dev = ["pytest", "pylint", "black"] + [project.urls] Documentation = "https://github.com/deepset-ai/haystack-extras/tree/main/components/instructor-embedders#readme" Issues = "https://github.com/deepset-ai/haystack-extras/issues" @@ -55,123 +58,45 @@ Source = "https://github.com/deepset-ai/haystack-extras/tree/main/components/tex path = "instructor_embedders/__about__.py" [tool.hatch.envs.default] -dependencies = [ - "coverage[toml]>=6.5", - "pytest", -] +dependencies = ["pytest", "pytest-cov"] + [tool.hatch.envs.default.scripts] -test = "pytest {args:tests}" -test-cov = "coverage run -m pytest {args:tests}" -cov-report = [ - "- coverage combine", - "coverage report", -] -cov = [ - "test-cov", - "cov-report", -] +cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=text2speech --cov=tests" +no-cov = "cov --no-cov" -[[tool.hatch.envs.all.matrix]] -python = ["3.7", "3.8", "3.9", "3.10", "3.11"] +[[tool.hatch.envs.test.matrix]] +python = ["37", "38", "39", "310", "311"] -[tool.hatch.envs.lint] -detached = true -dependencies = [ - "black>=23.1.0", - "mypy>=1.0.0", - "ruff>=0.0.243", -] -[tool.hatch.envs.lint.scripts] -typing = "mypy --install-types --non-interactive {args:instructor_embedders tests}" -style = [ - "ruff {args:.}", - "black --check --diff {args:.}", -] -fmt = [ - "black {args:.}", - "ruff --fix {args:.}", - "style", -] -all = [ - "style", - "typing", -] +[tool.coverage.run] +branch = true +parallel = true +omit = ["text2speech/__about__.py"] -[tool.black] -target-version = ["py37"] -line-length = 120 -skip-string-normalization = true +[tool.coverage.report] +exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"] -[tool.ruff] -target-version = "py37" -line-length = 120 -select = [ - "A", - "ARG", - "B", - "C", - "DTZ", - "E", - "EM", - "F", - "FBT", - "I", - "ICN", - "ISC", - "N", - "PLC", - "PLE", - "PLR", - "PLW", - "Q", - "RUF", - "S", - "T", - "TID", - "UP", - "W", - "YTT", -] -ignore = [ - # Allow non-abstract empty methods in abstract base classes - "B027", - # Allow boolean positional values in function calls, like `dict.get(... True)` - "FBT003", - # Ignore checks for possible passwords - "S105", "S106", "S107", - # Ignore complexity - "C901", "PLR0911", "PLR0912", "PLR0913", "PLR0915", -] -unfixable = [ - # Don't touch unused imports - "F401", -] +[tool.pylint.'MESSAGES CONTROL'] +max-line-length = 120 +disable = ["missing-module-docstring", "fixme", "R0913", "W0221"] -[tool.ruff.isort] -known-first-party = ["instructor_embedders"] +[tool.pylint.'DESIGN'] +max-args = 7 -[tool.ruff.flake8-tidy-imports] -ban-relative-imports = "all" +[tool.pylint.'SIMILARITIES'] +min-similarity-lines = 10 +ignore-comments = true -[tool.ruff.per-file-ignores] -# Tests can use magic values, assertions, and relative imports -"tests/**/*" = ["PLR2004", "S101", "TID252"] +[tool.pylint.'TYPECHECK'] +# List of members which are set dynamically and missed by Pylint inference +# system, and so shouldn't trigger E1101 when accessed. +generated-members = "torch.*" -[tool.coverage.run] -source_pkgs = ["instructor_embedders", "tests"] -branch = true -parallel = true -omit = [ - "instructor_embedders/__about__.py", -] +[tool.pytest.ini_options] +minversion = "6.0" +addopts = "--strict-markers" +markers = ["integration: integration tests", "unit: unit tests"] +log_cli = true -[tool.coverage.paths] -instructor_embedders = ["instructor_embedders", "*/instructor-embedders/instructor_embedders"] -tests = ["tests", "*/instructor-embedders/tests"] +[tool.black] +line-length = 120 -[tool.coverage.report] -exclude_lines = [ - "no cov", - "if __name__ == .__main__.:", - "if TYPE_CHECKING:", -]