Skip to content

Commit 6b0c494

Browse files
authored
bug/drop use of file utils in vertexai from unstructured (#132)
* Drop use of file utils in vertexai from unstructured * create file if it does not exist
1 parent 8536dc1 commit 6b0c494

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.0.17
2+
3+
### Fixes
4+
5+
* **Drop use of unstructued in embed** Remove remnant import from unstructured dependency in embed implementations.
6+
7+
18
## 0.0.16
29

310
### Fixes

unstructured_ingest/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.16" # pragma: no cover
1+
__version__ = "0.0.17" # pragma: no cover

unstructured_ingest/embed/vertexai.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import json
33
import os
44
from dataclasses import dataclass
5+
from pathlib import Path
56
from typing import TYPE_CHECKING, Annotated, Any, List, Optional
67

78
import numpy as np
89
from pydantic import Field, Secret, ValidationError
910
from pydantic.functional_validators import BeforeValidator
10-
from unstructured.utils import FileHandler
1111

1212
from unstructured_ingest.embed.interfaces import BaseEmbeddingEncoder, EmbeddingConfig
1313
from unstructured_ingest.utils.dep_check import requires_dependencies
@@ -35,10 +35,10 @@ class VertexAIEmbeddingConfig(EmbeddingConfig):
3535

3636
def register_application_credentials(self):
3737
# TODO look into passing credentials in directly, rather than via env var and tmp file
38-
application_credentials_path = os.path.join("/tmp", "google-vertex-app-credentials.json")
39-
credentials_file = FileHandler(application_credentials_path)
40-
credentials_file.write_file(json.dumps(self.api_key.get_secret_value()))
41-
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = application_credentials_path
38+
application_credentials_path = Path("/tmp") / "google-vertex-app-credentials.json"
39+
with application_credentials_path.open("w+") as credentials_file:
40+
json.dump(self.api_key.get_secret_value(), credentials_file)
41+
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = str(application_credentials_path)
4242

4343
@requires_dependencies(
4444
["langchain", "langchain_google_vertexai"],

0 commit comments

Comments
 (0)