hespas.estimator.check_available
Functions
|
Convenience function for checking that external programs exist and work for the estimators that require them. |
Exceptions
|
Custom exception to mark that an Estimator isn't available (usually due to not installing optional dependencies) Should be thrown instead of ImportError if an optionally-installable estimator has dependencies that are not available |
- exception hespas.estimator.check_available.EstimatorNotAvailableError(message: str, estimator_name: str)
Bases:
ExceptionCustom exception to mark that an Estimator isn’t available (usually due to not installing optional dependencies) Should be thrown instead of ImportError if an optionally-installable estimator has dependencies that are not available
- __init__(message: str, estimator_name: str)
Custom __init__() that allows passing of the estimator name for using in collecting failure reasons
- Parameters:
message – Message string as per Exception
estimator_name – Display name for the estimator that failed to import
- hespas.estimator.check_available.check_programs(estimator_name: str, programs: list[str | list[str] | dict[str, str | list[str]]], default_arg: str = '-h') dict[str, str] | None
Convenience function for checking that external programs exist and work for the estimators that require them. Throws an exception if any of the programs tested fail.
- Parameters:
estimator_name – Display name of the estimator, for the exception that is raised if any of the programs fail
programs – List of program names to test. If the element is a string or a list, it is assumed to be a non-conditional depedency. If the element is a dict, it is assumed to be a dict of conditional dependencies with the keys representing the config option names. If an element is a str, or the value of a dict is a str, this is called as the binary with the default argument specified at ‘default_arg’. If the element is a list, or the value of the dict is a list, it is directly fed into subprocess as a list of a binary as its arguments.
default_arg – Default argument to use if arguments aren’t specified in the programs list. -h is chosen as a reasonable guess
- Returns:
Either None if all are found or a dict containing the conditionally failed programs
- Raises:
EstimatorNotAvailableError – Raises EstimatorNotAvailableError if any of the unconditional programs fail (i.e.: return non-zero) or the program cannot be found