[CI/Test] improve robustness of test (hf_runner) (#5347)

[CI/Test] improve robustness of test by replacing del with context manager (hf_runner) (#5347)
This commit is contained in:
youkaichao
2024-06-07 22:31:32 -07:00
committed by GitHub
parent c96fc06747
commit 9fb900f90c
14 changed files with 48 additions and 61 deletions
+4 -1
View File
@@ -354,7 +354,10 @@ class HfRunner:
def encode(self, prompts: List[str]) -> List[List[torch.Tensor]]:
return self.model.encode(prompts)
def __del__(self):
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
del self.model
cleanup()