declare_deferred_modules_as_importable
(function from pyomo.common.dependencies
)
- pyomo.common.dependencies.declare_deferred_modules_as_importable(globals_dict)[source]
DEPRECATED.
Make all
DeferredImportModules
inglobals_dict
importableThis function will go throughout the specified
globals_dict
dictionary and add any instances ofDeferredImportModule
that it finds (and any of their deferred submodules) tosys.modules
so that the modules can be imported through theglobals_dict
namespace.For example,
pyomo/common/dependencies.py
declares:>>> scipy, scipy_available = attempt_import( ... 'scipy', callback=_finalize_scipy, ... deferred_submodules=['stats', 'sparse', 'spatial', 'integrate']) >>> declare_deferred_modules_as_importable(globals()) WARNING: DEPRECATED: ...
Which enables users to use:
>>> import pyomo.common.dependencies.scipy.sparse as spa
If the deferred import has not yet been triggered, then the
DeferredImportModule
is returned and namedspa
. However, if the import has already been triggered, thenspa
will either be thescipy.sparse
module, or aModuleUnavailable
instance.Deprecated since version 6.7.2:
declare_deferred_modules_as_importable()
is deprecated. Use thedeclare_modules_as_importable
context manager.