diff --git a/integrations/gradient/pyproject.toml b/integrations/gradient/pyproject.toml index 8b7ca65c4..22140bba5 100644 --- a/integrations/gradient/pyproject.toml +++ b/integrations/gradient/pyproject.toml @@ -37,6 +37,9 @@ Documentation = "https://github.com/deepset-ai/haystack-core-integrations/tree/m Issues = "https://github.com/deepset-ai/haystack-core-integrations/issues" Source = "https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/gradient" +[tool.hatch.build.targets.wheel] +packages = ["src/haystack_integrations"] + [tool.hatch.version] source = "vcs" tag-pattern = 'integrations\/gradient-v(?P.*)' @@ -73,7 +76,7 @@ dependencies = [ "ruff>=0.0.243", ] [tool.hatch.envs.lint.scripts] -typing = "mypy --install-types --non-interactive {args:src/gradient_haystack tests}" +typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}" style = [ "ruff {args:.}", "black --check --diff {args:.}", @@ -139,25 +142,22 @@ unfixable = [ ] [tool.ruff.isort] -known-first-party = ["gradient_haystack"] +known-first-party = ["haystack_integrations"] [tool.ruff.flake8-tidy-imports] -ban-relative-imports = "all" +ban-relative-imports = "parents" [tool.ruff.per-file-ignores] # Tests can use magic values, assertions, and relative imports "tests/**/*" = ["PLR2004", "S101", "TID252"] [tool.coverage.run] -source_pkgs = ["gradient_haystack", "tests"] +source_pkgs = ["src", "tests"] branch = true parallel = true -omit = [ - "src/gradient_haystack/__about__.py", -] [tool.coverage.paths] -gradient_haystack = ["src/gradient_haystack", "*/gradient-haystack/src/gradient_haystack"] +gradient_haystack = ["src"] tests = ["tests", "*/gradient-haystack/tests"] [tool.coverage.report] @@ -171,6 +171,7 @@ exclude_lines = [ module = [ "gradientai.*", "haystack.*", + "haystack_integrations.*", "pytest.*", "numpy.*", ] diff --git a/integrations/gradient/src/gradient_haystack/embedders/__init__.py b/integrations/gradient/src/gradient_haystack/embedders/__init__.py deleted file mode 100644 index e873bc332..000000000 --- a/integrations/gradient/src/gradient_haystack/embedders/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-FileCopyrightText: 2023-present deepset GmbH -# -# SPDX-License-Identifier: Apache-2.0 diff --git a/integrations/gradient/src/gradient_haystack/generator/__init__.py b/integrations/gradient/src/gradient_haystack/generator/__init__.py deleted file mode 100644 index e873bc332..000000000 --- a/integrations/gradient/src/gradient_haystack/generator/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-FileCopyrightText: 2023-present deepset GmbH -# -# SPDX-License-Identifier: Apache-2.0 diff --git a/integrations/gradient/src/haystack_integrations/components/embedders/gradient/__init__.py b/integrations/gradient/src/haystack_integrations/components/embedders/gradient/__init__.py new file mode 100644 index 000000000..7fbba1bab --- /dev/null +++ b/integrations/gradient/src/haystack_integrations/components/embedders/gradient/__init__.py @@ -0,0 +1,7 @@ +# SPDX-FileCopyrightText: 2023-present deepset GmbH +# +# SPDX-License-Identifier: Apache-2.0 +from .gradient_document_embedder import GradientDocumentEmbedder +from .gradient_text_embedder import GradientTextEmbedder + +__all__ = ["GradientDocumentEmbedder", "GradientTextEmbedder"] diff --git a/integrations/gradient/src/gradient_haystack/embedders/gradient_document_embedder.py b/integrations/gradient/src/haystack_integrations/components/embedders/gradient/gradient_document_embedder.py similarity index 100% rename from integrations/gradient/src/gradient_haystack/embedders/gradient_document_embedder.py rename to integrations/gradient/src/haystack_integrations/components/embedders/gradient/gradient_document_embedder.py diff --git a/integrations/gradient/src/gradient_haystack/embedders/gradient_text_embedder.py b/integrations/gradient/src/haystack_integrations/components/embedders/gradient/gradient_text_embedder.py similarity index 100% rename from integrations/gradient/src/gradient_haystack/embedders/gradient_text_embedder.py rename to integrations/gradient/src/haystack_integrations/components/embedders/gradient/gradient_text_embedder.py diff --git a/integrations/gradient/src/gradient_haystack/__init__.py b/integrations/gradient/src/haystack_integrations/components/generators/gradient/__init__.py similarity index 61% rename from integrations/gradient/src/gradient_haystack/__init__.py rename to integrations/gradient/src/haystack_integrations/components/generators/gradient/__init__.py index e873bc332..a9d7cd421 100644 --- a/integrations/gradient/src/gradient_haystack/__init__.py +++ b/integrations/gradient/src/haystack_integrations/components/generators/gradient/__init__.py @@ -1,3 +1,6 @@ # SPDX-FileCopyrightText: 2023-present deepset GmbH # # SPDX-License-Identifier: Apache-2.0 +from .base import GradientGenerator + +__all__ = ["GradientGenerator"] diff --git a/integrations/gradient/src/gradient_haystack/generator/base.py b/integrations/gradient/src/haystack_integrations/components/generators/gradient/base.py similarity index 100% rename from integrations/gradient/src/gradient_haystack/generator/base.py rename to integrations/gradient/src/haystack_integrations/components/generators/gradient/base.py diff --git a/integrations/gradient/tests/test_gradient_document_embedder.py b/integrations/gradient/tests/test_gradient_document_embedder.py index dc59a76fb..738d1e8a4 100644 --- a/integrations/gradient/tests/test_gradient_document_embedder.py +++ b/integrations/gradient/tests/test_gradient_document_embedder.py @@ -5,7 +5,7 @@ from gradientai.openapi.client.models.generate_embedding_success import GenerateEmbeddingSuccess from haystack import Document -from gradient_haystack.embedders.gradient_document_embedder import GradientDocumentEmbedder +from haystack_integrations.components.embedders.gradient import GradientDocumentEmbedder access_token = "access_token" workspace_id = "workspace_id" @@ -52,8 +52,9 @@ def test_init_from_params_precedence(self, monkeypatch): def test_to_dict(self): component = GradientDocumentEmbedder(access_token=access_token, workspace_id=workspace_id) data = component.to_dict() + t = "haystack_integrations.components.embedders.gradient.gradient_document_embedder.GradientDocumentEmbedder" assert data == { - "type": "gradient_haystack.embedders.gradient_document_embedder.GradientDocumentEmbedder", + "type": t, "init_parameters": {"workspace_id": workspace_id, "model": "bge-large"}, } diff --git a/integrations/gradient/tests/test_gradient_rag_pipelines.py b/integrations/gradient/tests/test_gradient_rag_pipelines.py index 9d3b11486..af987620c 100644 --- a/integrations/gradient/tests/test_gradient_rag_pipelines.py +++ b/integrations/gradient/tests/test_gradient_rag_pipelines.py @@ -9,9 +9,8 @@ from haystack.components.writers import DocumentWriter from haystack.document_stores.in_memory import InMemoryDocumentStore -from gradient_haystack.embedders.gradient_document_embedder import GradientDocumentEmbedder -from gradient_haystack.embedders.gradient_text_embedder import GradientTextEmbedder -from gradient_haystack.generator.base import GradientGenerator +from haystack_integrations.components.embedders.gradient import GradientDocumentEmbedder, GradientTextEmbedder +from haystack_integrations.components.generators.gradient import GradientGenerator @pytest.mark.skipif( diff --git a/integrations/gradient/tests/test_gradient_text_embedder.py b/integrations/gradient/tests/test_gradient_text_embedder.py index bd4b396ca..3350c02b3 100644 --- a/integrations/gradient/tests/test_gradient_text_embedder.py +++ b/integrations/gradient/tests/test_gradient_text_embedder.py @@ -4,7 +4,7 @@ import pytest from gradientai.openapi.client.models.generate_embedding_success import GenerateEmbeddingSuccess -from gradient_haystack.embedders.gradient_text_embedder import GradientTextEmbedder +from haystack_integrations.components.embedders.gradient import GradientTextEmbedder access_token = "access_token" workspace_id = "workspace_id" @@ -52,7 +52,7 @@ def test_to_dict(self): component = GradientTextEmbedder(access_token=access_token, workspace_id=workspace_id) data = component.to_dict() assert data == { - "type": "gradient_haystack.embedders.gradient_text_embedder.GradientTextEmbedder", + "type": "haystack_integrations.components.embedders.gradient.gradient_text_embedder.GradientTextEmbedder", "init_parameters": {"workspace_id": workspace_id, "model": "bge-large"}, }