diff --git a/integrations/jina/pyproject.toml b/integrations/jina/pyproject.toml index 0fa01a7ab..1136db797 100644 --- a/integrations/jina/pyproject.toml +++ b/integrations/jina/pyproject.toml @@ -31,6 +31,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/jina" +[tool.hatch.build.targets.wheel] +packages = ["src/haystack_integrations"] + [tool.hatch.version] source = "vcs" tag-pattern = 'integrations\/jina-v(?P.*)' @@ -67,7 +70,7 @@ dependencies = [ "ruff>=0.0.243", ] [tool.hatch.envs.lint.scripts] -typing = "mypy --install-types --non-interactive {args:src/jina_haystack tests}" +typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}" style = [ "ruff {args:.}", "black --check --diff {args:.}", @@ -133,7 +136,7 @@ unfixable = [ known-first-party = ["jina_haystack"] [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 @@ -143,12 +146,9 @@ ban-relative-imports = "all" source_pkgs = ["jina_haystack", "tests"] branch = true parallel = true -omit = [ - "src/jina_haystack/__about__.py", -] [tool.coverage.paths] -jina_haystack = ["src/jina_haystack", "*/jina-haystack/src/jina_haystack"] +jina_haystack = ["src"] tests = ["tests", "*/jina-haystack/tests"] [tool.coverage.report] @@ -161,6 +161,7 @@ exclude_lines = [ [[tool.mypy.overrides]] module = [ "haystack.*", + "haystack_integrations.*", "pytest.*" ] ignore_missing_imports = true diff --git a/integrations/jina/src/jina_haystack/__init__.py b/integrations/jina/src/haystack_integrations/components/embedders/jina/__init__.py similarity index 57% rename from integrations/jina/src/jina_haystack/__init__.py rename to integrations/jina/src/haystack_integrations/components/embedders/jina/__init__.py index 581b23df5..c98f63398 100644 --- a/integrations/jina/src/jina_haystack/__init__.py +++ b/integrations/jina/src/haystack_integrations/components/embedders/jina/__init__.py @@ -1,8 +1,7 @@ # SPDX-FileCopyrightText: 2023-present deepset GmbH # # SPDX-License-Identifier: Apache-2.0 - -from jina_haystack.document_embedder import JinaDocumentEmbedder -from jina_haystack.text_embedder import JinaTextEmbedder +from .document_embedder import JinaDocumentEmbedder +from .text_embedder import JinaTextEmbedder __all__ = ["JinaDocumentEmbedder", "JinaTextEmbedder"] diff --git a/integrations/jina/src/jina_haystack/document_embedder.py b/integrations/jina/src/haystack_integrations/components/embedders/jina/document_embedder.py similarity index 100% rename from integrations/jina/src/jina_haystack/document_embedder.py rename to integrations/jina/src/haystack_integrations/components/embedders/jina/document_embedder.py diff --git a/integrations/jina/src/jina_haystack/text_embedder.py b/integrations/jina/src/haystack_integrations/components/embedders/jina/text_embedder.py similarity index 100% rename from integrations/jina/src/jina_haystack/text_embedder.py rename to integrations/jina/src/haystack_integrations/components/embedders/jina/text_embedder.py diff --git a/integrations/jina/tests/test_document_embedder.py b/integrations/jina/tests/test_document_embedder.py index 43b6930c5..4dd91860e 100644 --- a/integrations/jina/tests/test_document_embedder.py +++ b/integrations/jina/tests/test_document_embedder.py @@ -7,8 +7,7 @@ import pytest import requests from haystack import Document - -from jina_haystack import JinaDocumentEmbedder +from haystack_integrations.components.embedders.jina import JinaDocumentEmbedder def mock_session_post_response(*args, **kwargs): # noqa: ARG001 @@ -65,7 +64,7 @@ def test_to_dict(self): component = JinaDocumentEmbedder(api_key="fake-api-key") data = component.to_dict() assert data == { - "type": "jina_haystack.document_embedder.JinaDocumentEmbedder", + "type": "haystack_integrations.components.embedders.jina.document_embedder.JinaDocumentEmbedder", "init_parameters": { "model": "jina-embeddings-v2-base-en", "prefix": "", @@ -90,7 +89,7 @@ def test_to_dict_with_custom_init_parameters(self): ) data = component.to_dict() assert data == { - "type": "jina_haystack.document_embedder.JinaDocumentEmbedder", + "type": "haystack_integrations.components.embedders.jina.document_embedder.JinaDocumentEmbedder", "init_parameters": { "model": "model", "prefix": "prefix", diff --git a/integrations/jina/tests/test_text_embedder.py b/integrations/jina/tests/test_text_embedder.py index e2b68603d..a4f6fd934 100644 --- a/integrations/jina/tests/test_text_embedder.py +++ b/integrations/jina/tests/test_text_embedder.py @@ -6,8 +6,7 @@ import pytest import requests - -from jina_haystack import JinaTextEmbedder +from haystack_integrations.components.embedders.jina import JinaTextEmbedder class TestJinaTextEmbedder: @@ -39,7 +38,7 @@ def test_to_dict(self): component = JinaTextEmbedder(api_key="fake-api-key") data = component.to_dict() assert data == { - "type": "jina_haystack.text_embedder.JinaTextEmbedder", + "type": "haystack_integrations.components.embedders.jina.text_embedder.JinaTextEmbedder", "init_parameters": { "model": "jina-embeddings-v2-base-en", "prefix": "", @@ -56,7 +55,7 @@ def test_to_dict_with_custom_init_parameters(self): ) data = component.to_dict() assert data == { - "type": "jina_haystack.text_embedder.JinaTextEmbedder", + "type": "haystack_integrations.components.embedders.jina.text_embedder.JinaTextEmbedder", "init_parameters": { "model": "model", "prefix": "prefix",