Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
hh-space-invader committed Sep 18, 2024
1 parent c46f27b commit 314e31c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_text_onnx_embeddings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import shutil
from pathlib import Path
import psutil


import numpy as np
Expand Down Expand Up @@ -86,6 +87,14 @@ def remove_tree_with_permissions(path: str):
MODELS_CACHE_DIR = Path("m")


def kill_processes_using_file(file_path):
for proc in psutil.process_iter(["pid", "name"]):
for file in proc.open_files():
if file.path == file_path:
print(f"Killing process {proc.info['pid']} using {file_path}")
proc.terminate() # or proc.kill()


def test_embedding():
for model_desc in TextEmbedding.list_supported_models():
if not CI and model_desc["size_in_GB"] > 1:
Expand Down Expand Up @@ -117,6 +126,7 @@ def test_embedding():
new_path = (
MODELS_CACHE_DIR / "models--qdrant--multilingual-e5-large-onnx" / "blobs" / "a"
)
kill_processes_using_file(model_path)
os.rename(str(model_path), str(new_path))
shutil.rmtree(str(MODELS_CACHE_DIR))
shutil.rmtree(MODELS_CACHE_DIR)
Expand Down

0 comments on commit 314e31c

Please sign in to comment.