This repository has been archived by the owner on Jun 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from delira-dev/fix_utils_imports
Fix Utils imports
- Loading branch information
Showing
5 changed files
with
93 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from delira import get_backends | ||
import os | ||
|
||
|
||
def check_for_environment_variable(variable: str, value: str): | ||
if variable not in os.environ or os.environ[variable] == value: | ||
return True | ||
return False | ||
|
||
|
||
def check_for_backend(backend_name, environment_variable): | ||
backend_installed = backend_name in get_backends() | ||
backend_specified = check_for_environment_variable("BACKEND", | ||
environment_variable) | ||
|
||
return backend_installed and backend_specified | ||
|
||
|
||
def check_for_torch_backend(): | ||
return check_for_backend("TORCH", "Torch") | ||
|
||
|
||
def check_for_torchscript_backend(): | ||
return check_for_backend("TORCH", "TorchScript") | ||
|
||
|
||
def check_for_tf_eager_backend(): | ||
return check_for_backend("TF", "TFEager") | ||
|
||
|
||
def check_for_tf_graph_backend(): | ||
return check_for_backend("TF", "TFGraph") | ||
|
||
|
||
def check_for_chainer_backend(): | ||
return check_for_backend("CHAINER", "Chainer") | ||
|
||
|
||
def check_for_sklearn_backend(): | ||
return check_for_backend("SKLEARN", "Sklearn") | ||
|
||
|
||
def check_for_no_backend(): | ||
# sklearn backend is always installed, so this check is mainly a check if | ||
# installation was successfull and checks for environment variable | ||
return check_for_backend("SKLEARN", "None") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters