Skip to content

Commit

Permalink
Fix sam2 sample artifact removal (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
yizhuoz004 authored Jan 7, 2025
1 parent ce7c17a commit d16814a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tripy/tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ def _get_file_list(self):

def _remove_artifacts(self, must_exist=True):
for artifact in self.artifacts:

artifact_found = glob.glob(artifact)

if must_exist:
print(f"Checking for the existence of artifact: {artifact}")
assert os.path.exists(artifact), f"{artifact} does not exist!"
elif not os.path.exists(artifact):
continue
assert artifact_found, f"{artifact} does not exist!"

if os.path.isdir(artifact):
shutil.rmtree(artifact)
else:
os.remove(artifact)
for f in artifact_found:
if os.path.isdir(f):
shutil.rmtree(f)
else:
os.remove(f)

def __enter__(self):
self._remove_artifacts(must_exist=False)
Expand Down Expand Up @@ -84,7 +86,7 @@ def __str__(self):
Example(["nanogpt"]),
Example(
["segment-anything-model-v2"],
artifact_names=["truck.jpg", "bedroom", "saved_engines/", "output/", "checkpoints/"],
artifact_names=["truck.jpg", "bedroom", "saved_engines/", "output/", "checkpoints/*.pt"],
),
]

Expand Down

0 comments on commit d16814a

Please sign in to comment.