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

Add teardown method to components #773

Merged
merged 1 commit into from
Jan 11, 2024
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
3 changes: 3 additions & 0 deletions components/index_aws_opensearch/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def __init__(
)
self.create_index(index_body)

def teardown(self) -> None:
self.client.close()

def create_index(self, index_body: Dict[str, Any]):
"""Creates an index if not existing in AWS OpenSearch.

Expand Down
3 changes: 3 additions & 0 deletions components/index_qdrant/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def __init__(
self.batch_size = batch_size
self.parallelism = parallelism

def teardown(self) -> None:
self.client.close()

def write(self, dataframe: dd.DataFrame) -> None:
"""
Writes the data from the given Dask DataFrame to the Qdrant collection.
Expand Down
3 changes: 3 additions & 0 deletions components/index_weaviate/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def __init__(
},
)

def teardown(self) -> None:
del self.client

def write(self, dataframe: dd.DataFrame) -> None:
with self.client.batch as batch:
for part in tqdm(
Expand Down
3 changes: 3 additions & 0 deletions components/retrieve_from_weaviate/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def __init__(
self.class_name = class_name
self.k = top_k

def teardown(self) -> None:
del self.client

def retrieve_chunks(self, vector_query: list):
"""Get results from weaviate database."""
result = (
Expand Down
Loading