From 426baf56d373b08c0dd55e9b1cfa275d74d32a81 Mon Sep 17 00:00:00 2001 From: Michele Pangrazzi Date: Thu, 19 Dec 2024 10:52:34 +0100 Subject: [PATCH 01/13] Update requires-python to support 3.9 as minimum --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e44b332..055ed72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "hayhooks" dynamic = ["version"] description = 'Grab and deploy Haystack pipelines' readme = "README.md" -requires-python = ">=3.7,<3.13" +requires-python = ">=3.9,<3.13" license = "Apache-2.0" keywords = [] authors = [ From 1c73e9e9145b58f92dd36f7349a09dad6de6bec5 Mon Sep 17 00:00:00 2001 From: Michele Pangrazzi Date: Thu, 19 Dec 2024 10:53:03 +0100 Subject: [PATCH 02/13] Add basic workflow to run current tests --- .github/workflows/tests.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..bc3be10 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,34 @@ +name: Tests + +on: + push: + branches: + - main + pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + +env: + HATCH_VERSION: "1.14.0" + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.9, 3.10, 3.11, 3.12] + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Hatch + run: pip install hatch==${{ env.HATCH_VERSION }} + + - name: Run tests + run: hatch run test From 02cd9377bcbc98b9da26f528cd1b0ad095b106a4 Mon Sep 17 00:00:00 2001 From: Michele Pangrazzi Date: Thu, 19 Dec 2024 10:57:06 +0100 Subject: [PATCH 03/13] Fix for python 3.10 being treated as 3.1 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bc3be10..93eec49 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9, 3.10, 3.11, 3.12] + python-version: [3.9, 3.10.x, 3.11, 3.12] steps: - uses: actions/checkout@v4 From 0cd218513f8b76522f93f3c3d6221ed124866ca8 Mon Sep 17 00:00:00 2001 From: Michele Pangrazzi Date: Thu, 19 Dec 2024 11:00:32 +0100 Subject: [PATCH 04/13] Add OPENAI_API_KEY to make tests pass (not used, checked when deserializing pipelines) --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 93eec49..c54f4cd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,6 +13,7 @@ on: env: HATCH_VERSION: "1.14.0" + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} jobs: tests: From 64e38aca0777518857fadc11e12a1de4d9863c9d Mon Sep 17 00:00:00 2001 From: Michele Pangrazzi Date: Thu, 19 Dec 2024 11:04:47 +0100 Subject: [PATCH 05/13] Run matrix test serially to avoid conflict on IT tests --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c54f4cd..6626571 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,6 +19,7 @@ jobs: tests: runs-on: ubuntu-latest strategy: + max-parallel: 1 matrix: python-version: [3.9, 3.10.x, 3.11, 3.12] steps: From b1c70f024eca7bc424a4e715e5e9e61260eee015 Mon Sep 17 00:00:00 2001 From: Michele Pangrazzi Date: Thu, 19 Dec 2024 11:07:25 +0100 Subject: [PATCH 06/13] Remove deprecated NoneType import and use type(None) --- tests/test_handle_callable_type.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_handle_callable_type.py b/tests/test_handle_callable_type.py index 529b6cf..1b68b24 100644 --- a/tests/test_handle_callable_type.py +++ b/tests/test_handle_callable_type.py @@ -1,5 +1,4 @@ from collections.abc import Callable as CallableABC -from types import NoneType from typing import Any, Callable, Optional, Union import haystack @@ -20,7 +19,7 @@ (str, False), (Any, False), (Union[int, str], False), - (Optional[Callable[[haystack.dataclasses.streaming_chunk.StreamingChunk], NoneType]], True), + (Optional[Callable[[haystack.dataclasses.streaming_chunk.StreamingChunk], type(None)]], True), ], ) def test_is_callable_type(t, expected): @@ -33,7 +32,7 @@ def test_skip_callables_when_creating_pipeline_models(): "generator": { "system_prompt": {"type": Optional[str], "is_mandatory": False, "default_value": None}, "streaming_callback": { - "type": Optional[Callable[[haystack.dataclasses.streaming_chunk.StreamingChunk], NoneType]], + "type": Optional[Callable[[haystack.dataclasses.streaming_chunk.StreamingChunk], type(None)]], "is_mandatory": False, "default_value": None, }, From 83327a7b3fa32e13dbab4b6747c8574600ca7d3f Mon Sep 17 00:00:00 2001 From: Michele Pangrazzi Date: Thu, 19 Dec 2024 11:12:19 +0100 Subject: [PATCH 07/13] Add verbose options to tests --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 055ed72..891f084 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ dependencies = [ "pytest-mock", ] [tool.hatch.envs.default.scripts] -test = "pytest {args:tests}" +test = "pytest -vv -s {args:tests}" test-cov = "coverage run -m pytest {args:tests}" cov-report = [ "- coverage combine", From 54a45eedb5ff8270392c17d7cbad6d6a6e062517 Mon Sep 17 00:00:00 2001 From: Michele Pangrazzi Date: Thu, 19 Dec 2024 11:20:54 +0100 Subject: [PATCH 08/13] Add required deps only on test env --- .github/workflows/tests.yml | 4 ++-- pyproject.toml | 23 +++++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6626571..96fd5f1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,5 +32,5 @@ jobs: - name: Install Hatch run: pip install hatch==${{ env.HATCH_VERSION }} - - name: Run tests - run: hatch run test + - name: Run unit and integration tests + run: hatch run test:all diff --git a/pyproject.toml b/pyproject.toml index 891f084..87b07c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,15 +43,9 @@ hayhooks = "hayhooks.cli:hayhooks" [tool.hatch.version] source = "vcs" -[tool.hatch.envs.default] -dependencies = [ - "coverage[toml]>=6.5", - "pytest", - "pytest-mock", -] -[tool.hatch.envs.default.scripts] -test = "pytest -vv -s {args:tests}" -test-cov = "coverage run -m pytest {args:tests}" +[tool.hatch.envs.test.scripts] +all = "pytest -vv {args:tests}" +all-cov = "coverage run -m pytest {args:tests}" cov-report = [ "- coverage combine", "coverage report", @@ -61,8 +55,17 @@ cov = [ "cov-report", ] +[tool.hatch.envs.test] +extra-dependencies = [ + "coverage[toml]>=6.5", + "pytest", + "pytest-mock", + "qdrant-haystack", + "trafilatura", +] + [[tool.hatch.envs.all.matrix]] -python = ["3.10", "3.11", "3.12"] +python = ["3.9", "3.10", "3.11", "3.12"] [tool.hatch.envs.lint] detached = true From a365009105fbdb3624c4a697683ac2d18549797a Mon Sep 17 00:00:00 2001 From: Michele Pangrazzi Date: Thu, 19 Dec 2024 12:39:21 +0100 Subject: [PATCH 09/13] Remove max-parallel: 1 --- .github/workflows/tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 96fd5f1..4794eb4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,7 +19,6 @@ jobs: tests: runs-on: ubuntu-latest strategy: - max-parallel: 1 matrix: python-version: [3.9, 3.10.x, 3.11, 3.12] steps: From bb62867d99d8afd816927523f1c22562d0ac9bab Mon Sep 17 00:00:00 2001 From: Michele Pangrazzi Date: Thu, 19 Dec 2024 12:39:47 +0100 Subject: [PATCH 10/13] Fix '3.10' in matrix --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4794eb4..de7f1c7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9, 3.10.x, 3.11, 3.12] + python-version: [3.9, '3.10', 3.11, 3.12] steps: - uses: actions/checkout@v4 From 087e7d2d7a8daa7bff117cdb3a4b0a5f798ea0f5 Mon Sep 17 00:00:00 2001 From: Michele Pangrazzi Date: Thu, 19 Dec 2024 12:46:58 +0100 Subject: [PATCH 11/13] Add uv as installer --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 87b07c7..2b401c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,6 +43,9 @@ hayhooks = "hayhooks.cli:hayhooks" [tool.hatch.version] source = "vcs" +[tool.hatch.envs.default] +installer = "uv" + [tool.hatch.envs.test.scripts] all = "pytest -vv {args:tests}" all-cov = "coverage run -m pytest {args:tests}" @@ -56,6 +59,7 @@ cov = [ ] [tool.hatch.envs.test] +installer = "uv" extra-dependencies = [ "coverage[toml]>=6.5", "pytest", From e0d0f3035b7da42e63fbc52d3f96a218d86721c7 Mon Sep 17 00:00:00 2001 From: Michele Pangrazzi Date: Thu, 19 Dec 2024 12:53:37 +0100 Subject: [PATCH 12/13] Run test:cov to have a coverage report output --- .github/workflows/tests.yml | 4 ++-- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index de7f1c7..ccc743c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,5 +31,5 @@ jobs: - name: Install Hatch run: pip install hatch==${{ env.HATCH_VERSION }} - - name: Run unit and integration tests - run: hatch run test:all + - name: Run tests and generate coverage report + run: hatch run test:cov diff --git a/pyproject.toml b/pyproject.toml index 2b401c7..6e1d10e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ cov-report = [ "coverage report", ] cov = [ - "test-cov", + "all-cov", "cov-report", ] From ffb37be579b096a3fb5bcbf94965a9e35d03b1bb Mon Sep 17 00:00:00 2001 From: Michele Pangrazzi Date: Thu, 19 Dec 2024 13:56:20 +0100 Subject: [PATCH 13/13] Update pyproject.toml Co-authored-by: Stefano Fiorucci --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6e1d10e..3987b26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,6 @@ cov = [ ] [tool.hatch.envs.test] -installer = "uv" extra-dependencies = [ "coverage[toml]>=6.5", "pytest",