alibi_detect.utils.frameworks module
- class alibi_detect.utils.frameworks.BackendValidator(backend_options, construct_name)[source]
Bases:
object
- __init__(backend_options, construct_name)[source]
Checks for required sets of backend options.
Takes a dictionary of backends plus extra dependencies and generates correct error messages if they are unmet.
- Parameters:
backend_options (
Dict
[Optional
[str
],List
[str
]]) – Dictionary from backend to list of dependencies that must be satisfied. The keys are the available options for the user and the values should be a list of dependencies that are checked via the HAS_BACKEND map defined in this module. An example of backend_options would be {‘tensorflow’: [‘tensorflow’], ‘pytorch’: [‘pytorch’], None: []}.This would mean ‘tensorflow’, ‘pytorch’ or None are available backend options. If the user passes a different backend they will receive and error listing the correct backends. In addition, if one of the dependencies in the backend_option values is missing for the specified backend the validator will issue an error message telling the user what dependency bucket to install.construct_name (
str
) – Name of the object that has a set of backends we need to verify.
- verify_backend(backend)[source]
Verifies backend choice.
Verifies backend is implemented and that the correct dependencies are installed for the requested backend. If the backend is not implemented or a dependency is missing then an error is issued.
- Parameters:
backend (
str
) – Choice of backend the user wishes to initialize the alibi-detect construct with. Must be one of the keys in the self.backend_options dictionary.- Raises:
NotImplementedError – If backend is not a member of self.backend_options.keys() a NotImplementedError is raised. Note None is a valid choice of backend if it is set as a key on self.backend_options.keys(). If a backend is not implemented for an alibi-detect object then it should not have a key on self.backend_options.
ImportError – If one of the dependencies in self.backend_options[backend] is missing then an ImportError will be thrown including a message informing the user how to install.