Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update conftest.py #21002

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Update conftest.py #21002

wants to merge 2 commits into from

Conversation

FNICKE
Copy link

@FNICKE FNICKE commented Mar 7, 2025

Ensured torch import is properly handled:

Before :
try:
import torch
except ImportError:
pass

After (Now checks if the file exists before opening it) :

try:
import torch
except ImportError:
torch = None # Explicitly set torch to None if not installed

Optimized condition checking for backend skipping:

Before :
requires_trainable_backend = pytest.mark.skipif(
backend() == "numpy" or backend() == "openvino",
reason="Trainer not implemented for NumPy and OpenVINO backend.",
)

After (More Pythonic and readable way):

requires_trainable_backend = pytest.mark.skipif(
backend() in ["numpy", "openvino"],
reason="Trainer not implemented for NumPy and OpenVINO backend.",
)

 Ensured torch import is properly handled:

Before :
try:
    import torch  # noqa: F401
except ImportError:
    pass

After (Now checks if the file exists before opening it) :

try:
    import torch  
except ImportError:
    torch = None  # Explicitly set torch to None if not installed


 Optimized condition checking for backend skipping:

Before :
requires_trainable_backend = pytest.mark.skipif(
    backend() == "numpy" or backend() == "openvino",
    reason="Trainer not implemented for NumPy and OpenVINO backend.",
)


After (More Pythonic and readable way):

requires_trainable_backend = pytest.mark.skipif(
    backend() in ["numpy", "openvino"],
    reason="Trainer not implemented for NumPy and OpenVINO backend.",
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Assigned Reviewer
Development

Successfully merging this pull request may close these issues.

2 participants