From 5bdacf7f21204b113df1e24ee2d5a1214bfcf7a0 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Fri, 29 Sep 2023 16:55:13 +0200 Subject: [PATCH 01/15] rename workflow wo extension --- .../components_instructor_embedders.yml | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/components_instructor_embedders.yml diff --git a/.github/workflows/components_instructor_embedders.yml b/.github/workflows/components_instructor_embedders.yml new file mode 100644 index 000000000..884302d6d --- /dev/null +++ b/.github/workflows/components_instructor_embedders.yml @@ -0,0 +1,38 @@ +name: Test / instructor-embedders + +on: + push: + branches: + - main + pull_request: + paths: + - 'components/instructor-embedders/**' + - '.github/workflows/components_instructor_embedders.yml' + +defaults: + run: + working-directory: components/instructor-embedders + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install instructor-embedders + run: | + pip install -e .[dev] + + - name: Pylint + run: | + pylint -ry -j 0 ./instructor_embedders + + - name: Run tests + run: | + pytest \ No newline at end of file From 7e791ff15c45773bbf9e940a33f6910669abefd3 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Fri, 29 Sep 2023 16:57:07 +0200 Subject: [PATCH 02/15] delete workflow wo extension --- .../workflows/components_instructor_embedders | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 .github/workflows/components_instructor_embedders diff --git a/.github/workflows/components_instructor_embedders b/.github/workflows/components_instructor_embedders deleted file mode 100644 index 884302d6d..000000000 --- a/.github/workflows/components_instructor_embedders +++ /dev/null @@ -1,38 +0,0 @@ -name: Test / instructor-embedders - -on: - push: - branches: - - main - pull_request: - paths: - - 'components/instructor-embedders/**' - - '.github/workflows/components_instructor_embedders.yml' - -defaults: - run: - working-directory: components/instructor-embedders - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - - name: Install instructor-embedders - run: | - pip install -e .[dev] - - - name: Pylint - run: | - pylint -ry -j 0 ./instructor_embedders - - - name: Run tests - run: | - pytest \ No newline at end of file From 8a0cf6d9020414d155719436540cbb0908343be9 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Fri, 29 Sep 2023 17:43:08 +0200 Subject: [PATCH 03/15] try better workflow --- .../workflows/components_instructor_embedders.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/components_instructor_embedders.yml b/.github/workflows/components_instructor_embedders.yml index 884302d6d..654586a82 100644 --- a/.github/workflows/components_instructor_embedders.yml +++ b/.github/workflows/components_instructor_embedders.yml @@ -25,14 +25,15 @@ jobs: with: python-version: '3.10' + - name: Install Hatch + run: pip install --upgrade hatch + - name: Install instructor-embedders run: | pip install -e .[dev] - - name: Pylint - run: | - pylint -ry -j 0 ./instructor_embedders + - name: Lint + run: hatch run lint:all - - name: Run tests - run: | - pytest \ No newline at end of file + - name: Run tests and track code coverage + run: hatch run cov \ No newline at end of file From a526b77be4d3f3b0f6f90274695caf8bd083275a Mon Sep 17 00:00:00 2001 From: anakin87 Date: Fri, 29 Sep 2023 18:00:38 +0200 Subject: [PATCH 04/15] 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:", -] From 05e10a4b733bfbb30edbf05f6458454037e2a0e1 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Fri, 29 Sep 2023 18:03:59 +0200 Subject: [PATCH 05/15] fix --- components/instructor-embedders/pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/instructor-embedders/pyproject.toml b/components/instructor-embedders/pyproject.toml index affef1b9c..f8bf72091 100644 --- a/components/instructor-embedders/pyproject.toml +++ b/components/instructor-embedders/pyproject.toml @@ -52,7 +52,7 @@ 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" -Source = "https://github.com/deepset-ai/haystack-extras/tree/main/components/text2speech" +Source = "https://github.com/deepset-ai/haystack-extras/tree/main/components/instructor-embedders" [tool.hatch.version] path = "instructor_embedders/__about__.py" @@ -61,7 +61,7 @@ path = "instructor_embedders/__about__.py" dependencies = ["pytest", "pytest-cov"] [tool.hatch.envs.default.scripts] -cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=text2speech --cov=tests" +cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=instructor-embedders --cov=tests" no-cov = "cov --no-cov" [[tool.hatch.envs.test.matrix]] @@ -70,7 +70,7 @@ python = ["37", "38", "39", "310", "311"] [tool.coverage.run] branch = true parallel = true -omit = ["text2speech/__about__.py"] +omit = ["instructor_embedders/__about__.py"] [tool.coverage.report] exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"] From 7576d9b65adecd01b4d8194270e0b84969f527c5 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Fri, 29 Sep 2023 18:11:18 +0200 Subject: [PATCH 06/15] empty test --- .../instructor-embedders/tests/test_instructor_embedders.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 components/instructor-embedders/tests/test_instructor_embedders.py diff --git a/components/instructor-embedders/tests/test_instructor_embedders.py b/components/instructor-embedders/tests/test_instructor_embedders.py new file mode 100644 index 000000000..7ac2770c4 --- /dev/null +++ b/components/instructor-embedders/tests/test_instructor_embedders.py @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2023-present deepset GmbH +# +# SPDX-License-Identifier: Apache-2.0 +import pytest + From b8000ecbaf1b2596270932070fee90da8e4d40f6 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Fri, 29 Sep 2023 18:14:10 +0200 Subject: [PATCH 07/15] real empty test --- .../instructor-embedders/tests/test_instructor_embedders.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/instructor-embedders/tests/test_instructor_embedders.py b/components/instructor-embedders/tests/test_instructor_embedders.py index 7ac2770c4..7f3716644 100644 --- a/components/instructor-embedders/tests/test_instructor_embedders.py +++ b/components/instructor-embedders/tests/test_instructor_embedders.py @@ -3,3 +3,5 @@ # SPDX-License-Identifier: Apache-2.0 import pytest +def test_instructor_embedders(): + assert True \ No newline at end of file From 778e3805290a5b09b32381c5f01329f0c99c2319 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Fri, 29 Sep 2023 18:16:06 +0200 Subject: [PATCH 08/15] test proper path --- .github/workflows/components_instructor_embedders.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/components_instructor_embedders.yml b/.github/workflows/components_instructor_embedders.yml index 884302d6d..f2144551a 100644 --- a/.github/workflows/components_instructor_embedders.yml +++ b/.github/workflows/components_instructor_embedders.yml @@ -35,4 +35,4 @@ jobs: - name: Run tests run: | - pytest \ No newline at end of file + pytest ./instructor_embedders \ No newline at end of file From 0570b67118e0b6a2c39e1e7376dc41d73932c68a Mon Sep 17 00:00:00 2001 From: anakin87 Date: Fri, 29 Sep 2023 18:21:52 +0200 Subject: [PATCH 09/15] try --- .github/workflows/components_instructor_embedders.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/components_instructor_embedders.yml b/.github/workflows/components_instructor_embedders.yml index f2144551a..7acc2f4bd 100644 --- a/.github/workflows/components_instructor_embedders.yml +++ b/.github/workflows/components_instructor_embedders.yml @@ -35,4 +35,4 @@ jobs: - name: Run tests run: | - pytest ./instructor_embedders \ No newline at end of file + pytest ./instructor_embedders/tests \ No newline at end of file From 713f6a1b0dc16c2ab1705f504bb73571f91aecdd Mon Sep 17 00:00:00 2001 From: anakin87 Date: Fri, 29 Sep 2023 18:27:34 +0200 Subject: [PATCH 10/15] try --- .github/workflows/components_instructor_embedders.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/components_instructor_embedders.yml b/.github/workflows/components_instructor_embedders.yml index 7acc2f4bd..795ce9d8c 100644 --- a/.github/workflows/components_instructor_embedders.yml +++ b/.github/workflows/components_instructor_embedders.yml @@ -35,4 +35,4 @@ jobs: - name: Run tests run: | - pytest ./instructor_embedders/tests \ No newline at end of file + pytest From bf977610e43e7ef945ce05cd7ebfb092bfc649d5 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Mon, 2 Oct 2023 12:09:12 +0200 Subject: [PATCH 11/15] move to ruff --- .../components_instructor_embedders.yml | 5 +- .../instructor-embedders/pyproject.toml | 65 +++++++++++++++---- 2 files changed, 54 insertions(+), 16 deletions(-) diff --git a/.github/workflows/components_instructor_embedders.yml b/.github/workflows/components_instructor_embedders.yml index 795ce9d8c..9f4838284 100644 --- a/.github/workflows/components_instructor_embedders.yml +++ b/.github/workflows/components_instructor_embedders.yml @@ -29,9 +29,8 @@ jobs: run: | pip install -e .[dev] - - name: Pylint - run: | - pylint -ry -j 0 ./instructor_embedders + - name: Ruff + uses: chartboost/ruff-action@v1 - name: Run tests run: | diff --git a/components/instructor-embedders/pyproject.toml b/components/instructor-embedders/pyproject.toml index f8bf72091..bea7cc53a 100644 --- a/components/instructor-embedders/pyproject.toml +++ b/components/instructor-embedders/pyproject.toml @@ -47,7 +47,7 @@ dependencies = [ ] [project.optional-dependencies] -dev = ["pytest", "pylint", "black"] +dev = ["pytest"] [project.urls] Documentation = "https://github.com/deepset-ai/haystack-extras/tree/main/components/instructor-embedders#readme" @@ -75,21 +75,60 @@ omit = ["instructor_embedders/__about__.py"] [tool.coverage.report] exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"] -[tool.pylint.'MESSAGES CONTROL'] -max-line-length = 120 -disable = ["missing-module-docstring", "fixme", "R0913", "W0221"] +[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.'DESIGN'] -max-args = 7 +[tool.ruff.isort] +known-first-party = ["instructor_embedders"] -[tool.pylint.'SIMILARITIES'] -min-similarity-lines = 10 -ignore-comments = true +[tool.ruff.flake8-tidy-imports] +ban-relative-imports = "all" -[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.ruff.per-file-ignores] +# Tests can use magic values, assertions, and relative imports +"tests/**/*" = ["PLR2004", "S101", "TID252"] [tool.pytest.ini_options] minversion = "6.0" From 340b1da515e2db02bb37d5133537e2bcbad27bda Mon Sep 17 00:00:00 2001 From: anakin87 Date: Mon, 2 Oct 2023 12:19:44 +0200 Subject: [PATCH 12/15] try to fix ruff --- .github/workflows/components_instructor_embedders.yml | 7 ++++--- .../tests/test_instructor_embedders.py | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/components_instructor_embedders.yml b/.github/workflows/components_instructor_embedders.yml index 9f4838284..c6e8bfc6b 100644 --- a/.github/workflows/components_instructor_embedders.yml +++ b/.github/workflows/components_instructor_embedders.yml @@ -25,13 +25,14 @@ jobs: with: python-version: '3.10' + - name: Ruff + uses: chartboost/ruff-action@v1 + src: components/instructor-embedders + - name: Install instructor-embedders run: | pip install -e .[dev] - - name: Ruff - uses: chartboost/ruff-action@v1 - - name: Run tests run: | pytest diff --git a/components/instructor-embedders/tests/test_instructor_embedders.py b/components/instructor-embedders/tests/test_instructor_embedders.py index 7f3716644..129c33f3c 100644 --- a/components/instructor-embedders/tests/test_instructor_embedders.py +++ b/components/instructor-embedders/tests/test_instructor_embedders.py @@ -1,7 +1,6 @@ # SPDX-FileCopyrightText: 2023-present deepset GmbH # # SPDX-License-Identifier: Apache-2.0 -import pytest def test_instructor_embedders(): - assert True \ No newline at end of file + assert True From 4edd6b15c8509a9a860df2661bbea16c2b75e210 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Mon, 2 Oct 2023 12:33:29 +0200 Subject: [PATCH 13/15] fix workflow --- .github/workflows/components_instructor_embedders.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/components_instructor_embedders.yml b/.github/workflows/components_instructor_embedders.yml index c6e8bfc6b..710776d12 100644 --- a/.github/workflows/components_instructor_embedders.yml +++ b/.github/workflows/components_instructor_embedders.yml @@ -27,7 +27,8 @@ jobs: - name: Ruff uses: chartboost/ruff-action@v1 - src: components/instructor-embedders + with: + src: components/instructor-embedders - name: Install instructor-embedders run: | From bb4c83b983a4b497596d82ffa85b80073ec7a958 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Mon, 2 Oct 2023 12:34:46 +0200 Subject: [PATCH 14/15] try ruff --- .../instructor-embedders/tests/test_instructor_embedders.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/instructor-embedders/tests/test_instructor_embedders.py b/components/instructor-embedders/tests/test_instructor_embedders.py index 129c33f3c..fbec61e54 100644 --- a/components/instructor-embedders/tests/test_instructor_embedders.py +++ b/components/instructor-embedders/tests/test_instructor_embedders.py @@ -3,4 +3,4 @@ # SPDX-License-Identifier: Apache-2.0 def test_instructor_embedders(): - assert True + assert True \ No newline at end of file From 8cf9870cdb7090fce81ac792de299df03aa4a456 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Mon, 2 Oct 2023 12:37:57 +0200 Subject: [PATCH 15/15] ruff works! Reverting error --- .../instructor-embedders/tests/test_instructor_embedders.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/instructor-embedders/tests/test_instructor_embedders.py b/components/instructor-embedders/tests/test_instructor_embedders.py index fbec61e54..129c33f3c 100644 --- a/components/instructor-embedders/tests/test_instructor_embedders.py +++ b/components/instructor-embedders/tests/test_instructor_embedders.py @@ -3,4 +3,4 @@ # SPDX-License-Identifier: Apache-2.0 def test_instructor_embedders(): - assert True \ No newline at end of file + assert True