idaes.util package

Submodules

idaes.util.sphinxdoctest_plugin module

This module implements pytest plugin for Sphinx doc tests.

In a nutshell, it uses the pytest pytest_collect_file() plugin hook to recognize the Sphinx Makefile. Then it does a quick and dirty parse of that Makefile to extract the command Sphinx is using to run the doctests, which it recognizes by being the first command in the Makefile target named by SPHINX_DOCTEST_TARGET. The parser is able to handle simple Makefile variable expansion, though not currently nested variables so don’t do that.

The mechanics of the pytest plugin mechanism are such that the Makefile is wrapped with a subclass of pytest.File, SphinxMakefile, which implements the collect method to yield a subclass of pytest.Item called SphinxItem, that in turn implements a few methods to run the test and report the result. The bulk of the code in running the test is parsing the output to look for errors, and thus decide whether all the doctests passed, or not.

The drawback of this whole setup is of course some extra complexity. The advantage is that (a) whatever the Makefile does is what this plugin should do, for running the command, as long as the command is the first (and only significant) thing that occurs in the target, and (b) if there ends up being more than one Makefile, it should all continue to work.

exception idaes.util.sphinxdoctest_plugin.SphinxCommandFailed[source]
class idaes.util.sphinxdoctest_plugin.SphinxDoctestFailure(name, parent, details)[source]
class idaes.util.sphinxdoctest_plugin.SphinxDoctestItem(name, parent, wd, cmd)[source]
repr_failure(excinfo)[source]

This is called when self.runtest() raises an exception.

runtest()[source]

Run the Sphinx doctest.

class idaes.util.sphinxdoctest_plugin.SphinxDoctestSuccess(name, parent=None, config=None, session=None, nodeid=None)[source]
exception idaes.util.sphinxdoctest_plugin.SphinxHadErrors[source]
class idaes.util.sphinxdoctest_plugin.SphinxMakefile(fspath: py._path.local.LocalPath, parent=None, config=None, session=None, nodeid=None)[source]
collect()[source]

returns a list of children (items and collectors) for this collection node.

warnings_file

Get warnings and errors output file, if any, from the Sphinx Makefile.

class idaes.util.sphinxdoctest_plugin.SphinxWarnings(fspath: py._path.local.LocalPath, parent=None, config=None, session=None, nodeid=None)[source]
collect()[source]

returns a list of children (items and collectors) for this collection node.

class idaes.util.sphinxdoctest_plugin.SphinxWarningsItem(name, parent, path: pathlib.Path)[source]
repr_failure(excinfo)[source]

This is called when self.runtest() raises an exception.

idaes.util.testutil module

Utility code for testing IDAES code.

idaes.util.testutil.run_notebook(path: str, name: str)[source]

Run a specific jupyter notebook ‘name’ located at path.

idaes.util.update_workshop_materials module

This script downloads a python file from pyomo.org that will allow us to update the workshop material easily during a workshop.

The file install_idaes_workshop_materials.py is downloaded from pyomo.org, imported,
and the method execute() is then called to do whatever actions are necessary.

Note: - update_workshop_materials.py is a module in the idaes/util folder that does the work - update_workshop_materials.ipynb is a Jupyter notebook in the examples/workshops folder

that calls this module
  • install_idaes_workshop_materials.py is posted on a site (for now pyomo.org, but later could be a repository on github).
  1. JupyterHub: User executes update_workshop_materials.ipynb which calls to update_workshop_materials.py in idaes/util
  2. update_workshop_materials.py downloads another python file (install_idaes_workshop_materials.py) from pyomo.org and calls “execute()” from that module.
  3. install_idaes_workshop_materials.py does whatever is necessary to get the workshop materials into the user folder (and perform any updates necessary).

TODO: This should probably be changed to get a zip file from an IDAES repository rather than install_idaes_workshop_materials.py from pyomo.org

idaes.util.update_workshop_materials.download_install_module()[source]

Downloads install_idaes_workshop_materials.py from pyomo.org

idaes.util.update_workshop_materials.import_install_module(download_dest)[source]

Imports the path in download_dest (install_idaes_workshop_materials.py module)