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

feat: control all comunity dependencies as poetry groups #175

Merged
merged 5 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 2 additions & 1 deletion libs/community/langchain_google_community/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def load(self) -> List[Document]:
except ImportError as ex:
raise ImportError(
"Could not import google-cloud-bigquery python package. "
"Please install it with `pip install google-cloud-bigquery`."
"Please, install bigquery dependency group: "
"poetry install --with bigquery"
svidiella marked this conversation as resolved.
Show resolved Hide resolved
) from ex

bq_client = bigquery.Client(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ def __init__(
)
except ModuleNotFoundError:
raise ImportError(
"Please, install or upgrade the google-cloud-bigquery library: "
"pip install google-cloud-bigquery"
"Could not import google-cloud-bigquery python package. "
"Please, install bigquery dependency group: "
"poetry install --with bigquery"
)
self._logger = logging.getLogger(__name__)
self._creating_index = False
Expand Down
5 changes: 3 additions & 2 deletions libs/community/langchain_google_community/docai.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ def online_process(
)
except ImportError as exc:
raise ImportError(
"documentai package not found, please install it with"
" `pip install google-cloud-documentai`"
"Could not import google-cloud-documentai python package. "
"Please, install docai dependency group: "
"poetry install --with docai"
) from exc
try:
from google.cloud.documentai_toolbox.wrappers.page import ( # type: ignore[import]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ def validate_environment(cls, values: Dict) -> Dict:
from google.cloud.contentwarehouse_v1 import DocumentServiceClient
except ImportError as exc:
raise ImportError(
"google.cloud.contentwarehouse is not installed."
"Please install it with pip install google-cloud-contentwarehouse"
"Could not import google-cloud-documentai python package. "
"Please, install docai dependency group: "
"poetry install --with docai"
) from exc

values["project_number"] = get_from_dict_or_env(
Expand Down
8 changes: 3 additions & 5 deletions libs/community/langchain_google_community/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,9 @@ def _load_credentials(self) -> Any:
)
except ImportError:
raise ImportError(
"Install prerequisites by running: "
"`pip install --upgrade "
"google-api-python-client google-auth-httplib2 "
"google-auth-oauthlib` "
"to use the Google Drive loader."
"Could execute GoogleDriveLoader. "
"Please, install drive dependency group: "
"poetry install --with drive"
)

creds = None
Expand Down
3 changes: 2 additions & 1 deletion libs/community/langchain_google_community/gcs_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def load(self) -> List[Document]:
except ImportError:
raise ImportError(
"Could not import google-cloud-storage python package. "
"Please install it with `pip install google-cloud-storage`."
"Please, install gcs dependency group: "
"poetry install --with gcs"
)
client = storage.Client(
project=self.project_name,
Expand Down
7 changes: 4 additions & 3 deletions libs/community/langchain_google_community/gcs_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def default_loader_func(file_path: str) -> BaseLoader:
message = (
"UnstructuredFileLoader loader not found! Either provide a "
"custom loader with loader_func argument, or install "
" `pip install langchain_community`"
" `poetry install`"
)
print(message)
return UnstructuredFileLoader(file_path)
Expand All @@ -64,8 +64,9 @@ def load(self) -> List[Document]:
from google.cloud import storage # type: ignore[attr-defined]
except ImportError:
raise ImportError(
"Could not import google-cloud-storage python package. "
"Please install it with `pip install google-cloud-storage`."
"Could not import google-cloud-documentai python package. "
"Please, install docai dependency group: "
"poetry install --with docai"
)

# initialize a client
Expand Down
12 changes: 6 additions & 6 deletions libs/community/langchain_google_community/gmail/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def import_google() -> Tuple[Request, Credentials]:
from google.oauth2.credentials import Credentials # noqa: F401
except ImportError:
raise ImportError(
"You need to install google-auth-httplib2 to use this toolkit. "
"Try running pip install --upgrade google-auth-httplib2"
"You need to install gmail dependencies to use this toolkit. "
"Try running poetry install --with gmail"
)
return Request, Credentials

Expand All @@ -43,8 +43,8 @@ def import_installed_app_flow() -> InstalledAppFlow:
from google_auth_oauthlib.flow import InstalledAppFlow
except ImportError:
raise ImportError(
"You need to install google-auth-oauthlib to use this toolkit. "
"Try running pip install --upgrade google-auth-oauthlib"
"You need to install gmail dependencies to use this toolkit. "
"Try running poetry install --with gmail"
)
return InstalledAppFlow

Expand All @@ -59,8 +59,8 @@ def import_googleapiclient_resource_builder() -> build_resource:
from googleapiclient.discovery import build
except ImportError:
raise ImportError(
"You need to install googleapiclient to use this toolkit. "
"Try running pip install --upgrade google-api-python-client"
"You need to install all dependencies to use this toolkit. "
"Try running poetry install"
)
return build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def __init__(
except ImportError as exc:
raise ImportError(
"Could not import google-cloud-speech python package. "
"Please install it with `pip install google-cloud-speech`."
"Please, install speech dependency group: "
"poetry install --with speech"
) from exc

self.project_id = project_id
Expand Down
3 changes: 2 additions & 1 deletion libs/community/langchain_google_community/places_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def validate_environment(cls, values: Dict) -> Dict:
except ImportError:
raise ImportError(
"Could not import googlemaps python package. "
"Please install it with `pip install googlemaps`."
"Please, install places dependency group: "
"poetry install --with places"
)
return values

Expand Down
3 changes: 1 addition & 2 deletions libs/community/langchain_google_community/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def validate_environment(cls, values: Dict) -> Dict:
except ImportError:
raise ImportError(
"google-api-python-client is not installed. "
"Please install it with `pip install google-api-python-client"
">=2.100.0`"
"Please install it with `poetry install`"
)

service = build("customsearch", "v1", developerKey=google_api_key)
Expand Down
5 changes: 3 additions & 2 deletions libs/community/langchain_google_community/texttospeech.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def _import_google_cloud_texttospeech() -> Any:
from google.cloud import texttospeech # type: ignore[attr-defined]
except ImportError as e:
raise ImportError(
"Cannot import google.cloud.texttospeech, please install "
"`pip install google-cloud-texttospeech`."
"Could not import google-cloud-texttospeech python package. "
"Please, install texttospeech dependency group: "
"poetry install --with texttospeech"
) from e
return texttospeech

Expand Down
5 changes: 3 additions & 2 deletions libs/community/langchain_google_community/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ def __init__(
from google.cloud import translate # type: ignore[attr-defined]
except ImportError as exc:
raise ImportError(
"Install Google Cloud Translate to use this parser."
"(pip install google-cloud-translate)"
"Could not import google-cloud-translate python package. "
"Please, install translate dependency group: "
"poetry install --with translate"
) from exc

self.project_id = project_id
Expand Down
11 changes: 6 additions & 5 deletions libs/community/langchain_google_community/vertex_ai_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def validate_environment(cls, values: Dict) -> Dict:
from google.cloud import discoveryengine_v1beta # noqa: F401
except ImportError as exc:
raise ImportError(
"google.cloud.discoveryengine is not installed."
"Please install it with pip install "
"google-cloud-discoveryengine>=0.11.0"
"Could not import google-cloud-discoveryengine python package. "
"Please, install vertexaisearch dependency group: "
"poetry install --with vertexaisearch"
) from exc

values["project_id"] = get_from_dict_or_env(values, "project_id", "PROJECT_ID")
Expand Down Expand Up @@ -250,8 +250,9 @@ def __init__(self, **kwargs: Any) -> None:
from google.cloud.discoveryengine_v1beta import SearchServiceClient
except ImportError as exc:
raise ImportError(
"google.cloud.discoveryengine is not installed."
"Please install it with pip install google-cloud-discoveryengine"
"Could not import google-cloud-discoveryengine python package. "
"Please, install vertexaisearch dependency group: "
"poetry install --with vertexaisearch"
) from exc

super().__init__(**kwargs)
Expand Down
10 changes: 6 additions & 4 deletions libs/community/langchain_google_community/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ def __init__(self, project: Optional[str] = None):
from google.cloud import vision # type: ignore[attr-defined]
except ImportError as e:
raise ImportError(
"Cannot import google.cloud.vision, please install "
"`pip install google-cloud-vision`."
"Could not import google-cloud-vision python package. "
"Please, install vision dependency group: "
"poetry install --with vision"
) from e
client_options = None
if project:
Expand Down Expand Up @@ -48,8 +49,9 @@ def __init__(self, file_path: str, project: Optional[str] = None):
from google.cloud import vision # type: ignore[attr-defined]
except ImportError as e:
raise ImportError(
"Cannot import google.cloud.vision, please install "
"`pip install google-cloud-vision`."
"Could not import google-cloud-vision python package. "
"Please, install vision dependency group: "
"poetry install --with vision"
) from e
client_options = None
if project:
Expand Down
Loading
Loading