Optional dependencies
optional_dependencies
¶
Access to the dependencies shipped by the optional extras.
The mandatory dependencies of VIMSEO are kept to what is needed to build a model,
execute it and serialize its results, so that it can be installed on a machine with
no graphical stack, typically an HPC compute node. Everything else is shipped by an
extra, declared in the [project.optional-dependencies] table of pyproject.toml:
| Extra | Brings | Used by |
|---|---|---|
dashboard |
streamlit |
vimseo.dashboards |
mlflow |
mlflow |
MlflowArchive |
mesh |
pyvista |
extract_line |
jax |
jax |
vimseo.lib_vimseo.tan_lib_jax |
Import the modules they provide with import_optional
so that a missing extra reports how to install it instead of raising a bare
ModuleNotFoundError.
Attributes¶
EXTRA_TO_DISTRIBUTIONS
module-attribute
¶
EXTRA_TO_DISTRIBUTIONS: dict[str, tuple[str, ...]] = {
"dashboard": (
"streamlit",
"streamlit-pydantic-sebastienbocquet",
),
"mlflow": ("mlflow",),
"mesh": ("pyvista",),
"jax": ("jax", "jaxlib"),
}
The distributions brought by each extra, used for documentation and testing.
Functions:¶
import_optional
¶
import_optional(
module_name: str, extra: str, feature: str = ""
) -> ModuleType
Import a module shipped by an optional extra.
Parameters:
-
module_name(str) –The name of the module to import, e.g.
"pyvista". -
extra(str) –The name of the extra shipping it, e.g.
"mesh". -
feature(str, default:'') –The name of the VIMSEO feature requiring the module, used in the error message. If empty, the module name is used instead.
Returns:
-
ModuleType–The imported module.
Raises:
-
ImportError–If the module cannot be imported, with the command to install the extra shipping it.
Source code in src\vimseo\utilities\optional_dependencies.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |