Skip to content

Commit

Permalink
refactor: Use delete_client instead of close
Browse files Browse the repository at this point in the history
  • Loading branch information
KShivendu committed Jan 15, 2024
1 parent 6d4e907 commit 369f114
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions engine/base_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ def run_experiment(
print("Experiment stage: Done")
print("Results saved to: ", RESULTS_DIR)

def close(self):
self.uploader.close()
self.configurator.close()
def delete_client(self):
self.uploader.delete_client()
self.configurator.delete_client()

for s in self.searchers:
s.close()
s.delete_client()
2 changes: 1 addition & 1 deletion engine/base_client/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ def configure(self, dataset: Dataset) -> Optional[dict]:
def execution_params(self, distance, vector_size) -> dict:
return {}

def close(self):
def delete_client(self):
pass
4 changes: 2 additions & 2 deletions engine/base_client/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def search_all(

total_time = time.perf_counter() - start

self.__class__.close()
self.__class__.delete_client()

return {
"total_time": total_time,
Expand All @@ -121,5 +121,5 @@ def post_search(self):
pass

@classmethod
def close(cls):
def delete_client(cls):
pass
4 changes: 2 additions & 2 deletions engine/base_client/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def upload(

print(f"Total import time: {total_time}")

self.close()
self.delete_client()

return {
"post_upload": post_upload_stats,
Expand Down Expand Up @@ -99,5 +99,5 @@ def upload_batch(
raise NotImplementedError()

@classmethod
def close(cls):
def delete_client(cls):
pass
2 changes: 1 addition & 1 deletion engine/clients/pgvector/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ def recreate(self, dataset: Dataset, collection_params):

self.conn.close()

def close(self):
def delete_client(self):
self.conn.close()
2 changes: 1 addition & 1 deletion engine/clients/pgvector/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def search_one(cls, vector, meta_conditions, top) -> List[Tuple[int, float]]:
return cls.cur.fetchall()

@classmethod
def close(cls):
def delete_client(cls):
if cls.cur:
cls.cur.close()
cls.conn.close()
2 changes: 1 addition & 1 deletion engine/clients/pgvector/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def upload_batch(
copy.write_row((i, embedding))

@classmethod
def close(cls):
def delete_client(cls):
if cls.cur:
cls.cur.close()
cls.conn.close()
2 changes: 1 addition & 1 deletion engine/clients/qdrant/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ def wait_collection_green(cls):
return total

@classmethod
def close(cls):
def delete_client(cls):
if cls.client is not None:
del cls.client
2 changes: 1 addition & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def run(
client.run_experiment(
dataset, skip_upload, skip_search, skip_if_exists
)
client.close()
client.delete_client()

# If the timeout is reached, the server might be still in the
# middle of some background processing, like creating the index.
Expand Down

0 comments on commit 369f114

Please sign in to comment.