# ___________________________________________________________________________ # # Pyomo: Python Optimization Modeling Objects # Copyright 2017 National Technology and Engineering Solutions of Sandia, LLC # Under the terms of Contract DE-NA0003525 with National Technology and # Engineering Solutions of Sandia, LLC, the U.S. Government retains certain # rights in this software. # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ from pyomo.common.plugin import PluginGlobals PluginGlobals.add_env("pyomo") from pyomo.checker.checker import * from pyomo.checker.runner import * from pyomo.checker.script import * from pyomo.checker.hooks import * # Modules __all__ = [] # Checker classes __all__.extend(['IModelChecker']) #__all__.extend(['ImmediateDataChecker', 'IterativeDataChecker']) #__all__.extend(['ImmediateTreeChecker', 'IterativeTreeChecker']) # Other builtins __all__.extend(['ModelCheckRunner', 'ModelScript']) # Hooks __all__.extend(['IPreCheckHook', 'IPostCheckHook'])
# ___________________________________________________________________________ # # Pyomo: Python Optimization Modeling Objects # Copyright 2017 National Technology and Engineering Solutions of Sandia, LLC # Under the terms of Contract DE-NA0003525 with National Technology and # Engineering Solutions of Sandia, LLC, the U.S. Government retains certain # rights in this software. # This software is distributed under the 3-clause BSD License. # ___________________________________________________________________________ from pyomo.common.plugin import PluginGlobals PluginGlobals.add_env("pyomo") from pyomo.repn.standard_repn import * from pyomo.repn.standard_aux import * PluginGlobals.pop_env()
def test_deprecation(self): out = StringIO() with LoggingIntercept(out): PluginGlobals.add_env(None) self.assertIn("Pyomo only supports a single global environment", out.getvalue().replace('\n', ' ')) out = StringIO() with LoggingIntercept(out): PluginGlobals.pop_env() self.assertIn("Pyomo only supports a single global environment", out.getvalue().replace('\n', ' ')) out = StringIO() with LoggingIntercept(out): PluginGlobals.clear() self.assertIn("Pyomo only supports a single global environment", out.getvalue().replace('\n', ' ')) class IFoo(Interface): pass out = StringIO() with LoggingIntercept(out): class myFoo(Plugin): alias('myFoo', subclass=True) self.assertIn("alias() function does not support the subclass", out.getvalue().replace('\n', ' ')) out = StringIO() with LoggingIntercept(out): class myFoo(Plugin): implements(IFoo, namespace='here') self.assertIn("only supports a single global namespace.", out.getvalue().replace('\n', ' ')) class IGone(DeprecatedInterface): pass out = StringIO() with LoggingIntercept(out): class myFoo(Plugin): implements(IGone) self.assertIn("The IGone interface has been deprecated", out.getvalue().replace('\n', ' ')) out = StringIO() with LoggingIntercept(out): ExtensionPoint(IGone).extensions() self.assertIn("The IGone interface has been deprecated", out.getvalue().replace('\n', ' ')) class ICustomGone(DeprecatedInterface): __deprecated_message__ = 'This interface is gone!' out = StringIO() with LoggingIntercept(out): class myFoo(Plugin): implements(ICustomGone) self.assertIn("This interface is gone!", out.getvalue().replace('\n', ' ')) out = StringIO() with LoggingIntercept(out): ExtensionPoint(ICustomGone).extensions() self.assertIn("This interface is gone!", out.getvalue().replace('\n', ' '))
# # Import optional packages # for name in _optional_packages: pname = name + '.plugins' try: _do_import(pname) except ImportError: continue pkg = _sys.modules[pname] pkg.load() from pyomo.common.plugin import PluginGlobals as _PG _PG.add_env("pyomo") _import_packages() _PG.pop_env() # # Expose the symbols from pyomo.core # from pyomo.core import * from pyomo.opt import ( SolverFactory, SolverManagerFactory, UnknownSolver, TerminationCondition, SolverStatus, )