mirror of
https://github.com/hanzoai/anomalib.git
synced 2026-10-30 18:48:11 +00:00
The previous commit was meant to remove .github/workflows and removed every tracked path instead — 892 files, the whole repo. This puts back the 874 that were never in scope; the eighteen workflow files stay gone, for the reasons that commit gives. Content is byte-identical to 9d2aec9 outside .github/workflows.
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
"""Test lightning inference entrypoint script."""
|
|
|
|
# Copyright (C) 2023-2024 Intel Corporation
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
import sys
|
|
from collections.abc import Callable
|
|
from importlib.util import find_spec
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
sys.path.append("tools/inference")
|
|
|
|
|
|
class TestLightningInferenceEntrypoint:
|
|
"""This tests whether the entrypoints run without errors without quantitative measure of the outputs."""
|
|
|
|
@pytest.fixture()
|
|
@staticmethod
|
|
def get_functions() -> tuple[Callable, Callable]:
|
|
"""Get functions from lightning_inference.py."""
|
|
if find_spec("lightning_inference") is not None:
|
|
from tools.inference.lightning_inference import get_parser, infer
|
|
else:
|
|
msg = "Unable to import lightning_inference.py for testing"
|
|
raise ImportError(msg)
|
|
return get_parser, infer
|
|
|
|
@staticmethod
|
|
def test_lightning_inference(
|
|
get_functions: tuple[Callable, Callable],
|
|
project_path: Path,
|
|
get_dummy_inference_image: str,
|
|
ckpt_path: Callable[[str], Path],
|
|
) -> None:
|
|
"""Test lightning_inference.py."""
|
|
get_parser, infer = get_functions
|
|
arguments = get_parser().parse_args(
|
|
[
|
|
"--model",
|
|
"anomalib.models.Padim",
|
|
"--ckpt_path",
|
|
str(ckpt_path("Padim")),
|
|
"--data.path",
|
|
get_dummy_inference_image,
|
|
"--output",
|
|
str(project_path) + "/output",
|
|
],
|
|
)
|
|
infer(arguments)
|