Import Helpers
Module: polygraphy.mod
- LATEST_VERSION = '==latest'
Indicates that the latest version of the package is preferred in lazy_import
- lazy_import(name: str, log: Optional[bool] = None, pkg_name: Optional[str] = None, install_flags: Optional[List[str]] = None, requires: Optional[List[str]] = None)[source]
Lazily import a module.
If config.AUTOINSTALL_DEPS is set to 1, missing modules are automatically installed, and existing modules may be upgraded if newer versions are required.
- Parameters
name (str) – The name of the module and optionally the preferred version of the package, formatted as a version string. For example,
'example_module>=0.5.0'
or'example_module==1.8.0'
.log (bool) – Whether to log information about the module. Defaults to True.
pkg_name (str) – The name of the package that provides this module, if it is different from the module name. Used only if automatic installation of dependencies is enabled.
install_flags (List[str]) – Additional flags to provide to the installation command. Used only if automatic installation of dependencies is enabled.
requires (List[str]) – Additional dependencies required by the module which are not specified as dependencies. This parameter should only be required when a module does not correctly specify dependencies. Defaults to [].
- Returns
A lazily loaded module. When an attribute is first accessed, the module will be imported.
- Return type
LazyModule
- has_mod(modname)[source]
Checks whether a module is installed without importing the module.
- Parameters
modname (str) – The name of the module to check.
- Returns
Whether the module is installed.
- Return type
bool