Skip to content

Commit

Permalink
mount import path under haystack_integrations (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
masci authored Jan 19, 2024
1 parent 9e0474f commit cd78080
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 21 deletions.
17 changes: 9 additions & 8 deletions integrations/gradient/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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<version>.*)'
Expand Down Expand Up @@ -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:.}",
Expand Down Expand Up @@ -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]
Expand All @@ -171,6 +171,7 @@ exclude_lines = [
module = [
"gradientai.*",
"haystack.*",
"haystack_integrations.*",
"pytest.*",
"numpy.*",
]
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: 2023-present deepset GmbH <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
from .gradient_document_embedder import GradientDocumentEmbedder
from .gradient_text_embedder import GradientTextEmbedder

__all__ = ["GradientDocumentEmbedder", "GradientTextEmbedder"]
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2023-present deepset GmbH <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
from .base import GradientGenerator

__all__ = ["GradientGenerator"]
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"},
}

Expand Down
5 changes: 2 additions & 3 deletions integrations/gradient/tests/test_gradient_rag_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions integrations/gradient/tests/test_gradient_text_embedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"},
}

Expand Down

0 comments on commit cd78080

Please sign in to comment.