ultralytics 8.0.191 fix yolo checks for missing packages (#5179)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Muhammad Rizwan Munawar <62513924+RizwanMunawar@users.noreply.github.com>
This commit is contained in:
parent
9aaa5d5ed0
commit
525c8b0294
17 changed files with 110 additions and 74 deletions
|
|
@ -5,10 +5,7 @@ from pathlib import Path
|
|||
|
||||
import pytest
|
||||
|
||||
from ultralytics.utils import ROOT
|
||||
from ultralytics.utils.torch_utils import init_seeds
|
||||
|
||||
TMP = (ROOT / '../tests/tmp').resolve() # temp directory for test files
|
||||
TMP = Path(__file__).resolve().parent / 'tmp' # temp directory for test files
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
|
|
@ -62,6 +59,8 @@ def pytest_sessionstart(session):
|
|||
Args:
|
||||
session (pytest.Session): The pytest session object.
|
||||
"""
|
||||
from ultralytics.utils.torch_utils import init_seeds
|
||||
|
||||
init_seeds()
|
||||
shutil.rmtree(TMP, ignore_errors=True) # delete any existing tests/tmp directory
|
||||
TMP.mkdir(parents=True, exist_ok=True) # create a new empty directory
|
||||
|
|
@ -79,10 +78,14 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config):
|
|||
exitstatus (int): The exit status of the test run.
|
||||
config (pytest.config.Config): The pytest config object.
|
||||
"""
|
||||
from ultralytics.utils import WEIGHTS_DIR
|
||||
|
||||
# Remove files
|
||||
for file in ['bus.jpg', 'decelera_landscape_min.mov']:
|
||||
models = [path for x in ['*.onnx', '*.torchscript'] for path in WEIGHTS_DIR.rglob(x)]
|
||||
for file in ['bus.jpg', 'yolov8n.onnx', 'yolov8n.torchscript'] + models:
|
||||
Path(file).unlink(missing_ok=True)
|
||||
|
||||
# Remove directories
|
||||
for directory in [ROOT / '../.pytest_cache', TMP]:
|
||||
models = [path for x in ['*.mlpackage', '*_openvino_model'] for path in WEIGHTS_DIR.rglob(x)]
|
||||
for directory in [TMP.parents[1] / '.pytest_cache', TMP] + models:
|
||||
shutil.rmtree(directory, ignore_errors=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue