Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove LazyImport from integrations #83

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import logging
from typing import Any, Dict, List, Optional

from gradientai import Gradient
from haystack import Document, component, default_to_dict
from haystack.lazy_imports import LazyImport

with LazyImport(message="Run 'pip install gradientai'") as gradientai_import:
from gradientai import Gradient

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -49,7 +46,6 @@ def __init__(
variable GRADIENT_WORKSPACE_ID.
:param host: The Gradient host. By default it uses https://api.gradient.ai/.
"""
gradientai_import.check()
self._batch_size = batch_size
self._host = host
self._model_name = model_name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from typing import Any, Dict, List, Optional

from gradientai import Gradient
from haystack import component, default_to_dict
from haystack.lazy_imports import LazyImport

with LazyImport(message="Run 'pip install gradientai'") as gradientai_import:
from gradientai import Gradient


@component
Expand Down Expand Up @@ -43,7 +40,6 @@ def __init__(
variable GRADIENT_WORKSPACE_ID.
:param host: The Gradient host. By default it uses https://api.gradient.ai/.
"""
gradientai_import.check()
self._host = host
self._model_name = model_name

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import logging
from typing import Any, Dict, List, Optional

from gradientai import Gradient
from haystack import component, default_to_dict
from haystack.lazy_imports import LazyImport

with LazyImport(message="Run 'pip install gradientai'") as gradientai_import:
from gradientai import Gradient

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -57,8 +54,6 @@ def __init__(
:param workspace_id: The Gradient workspace ID. If not provided it's read from the environment
variable GRADIENT_WORKSPACE_ID.
"""
gradientai_import.check()

self._access_token = access_token
self._base_model_slug = base_model_slug
self._host = host
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
from typing import ClassVar, Dict, List, Optional, Union

from haystack.lazy_imports import LazyImport

with LazyImport(message="Run 'pip install InstructorEmbedding'") as instructor_embeddings_import:
from InstructorEmbedding import INSTRUCTOR
from InstructorEmbedding import INSTRUCTOR


class _InstructorEmbeddingBackendFactory:
Expand Down Expand Up @@ -40,7 +37,6 @@ class _InstructorEmbeddingBackend:
def __init__(
self, model_name_or_path: str, device: Optional[str] = None, use_auth_token: Union[bool, str, None] = None
):
instructor_embeddings_import.check()
self.model = INSTRUCTOR(model_name_or_path=model_name_or_path, device=device, use_auth_token=use_auth_token)

def embed(self, data: List[List[str]], **kwargs) -> List[List[float]]:
Expand Down