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

Don't continue to execute after an ImportError #161

Open
matthewfeickert opened this issue Jun 17, 2024 · 0 comments
Open

Don't continue to execute after an ImportError #161

matthewfeickert opened this issue Jun 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@matthewfeickert
Copy link
Member

matthewfeickert commented Jun 17, 2024

This is an antipattern, by the way. The Python core devs specifically say it’s invalid to continue executing after an ImportError. (In the core.py podcast) — @henryiii

BACKENDS = {}
try:
from .reana import ReanaBackend
BACKENDS["reana"] = ReanaBackend()
except (ImportError, exceptions.BackendNotAvailableException):
pass
try:
from .kubernetes import KubernetesBackend
BACKENDS["kubernetes"] = KubernetesBackend()
except (ImportError, exceptions.BackendNotAvailableException):
pass
try:
from .local import LocalBackend
BACKENDS["local"] = LocalBackend()
except (ImportError, exceptions.BackendNotAvailableException):
pass
try:
from .docker import DockerBackend, setup_docker
BACKENDS["docker"] = DockerBackend()
except (ImportError, exceptions.BackendNotAvailableException):
pass

So need to find a better way to discover what execution backends are available for use.

@matthewfeickert matthewfeickert added the bug Something isn't working label Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant