IDAES / examples

IDAES platform examples and tutorials
https://idaes-examples.readthedocs.io
Other
15 stars 36 forks source link

Errors calling 'idaesx' commands #41

Closed bpaul4 closed 1 year ago

bpaul4 commented 1 year ago

I am running through the installation in preparation to edit some existing example notebooks, and successfully executed the tests. However, the 'idaesx' commands for the GUI and documentation are throwing module-related errors. I've included these as comments below.

bpaul4 commented 1 year ago
(idaes-dev) C:\Users\BrandonLocal\GitHub\examples>idaesx gui
-> Load notebooks into GUI
Traceback (most recent call last):
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\Scripts\idaesx-script.py", line 33, in <module>
    sys.exit(load_entry_point('idaes-examples', 'console_scripts', 'idaesx')())
  File "c:\users\brandonlocal\github\examples\idaes_examples\build.py", line 585, in main
    sys.exit(func(args))
  File "c:\users\brandonlocal\github\examples\idaes_examples\build.py", line 437, in gui
    nb_dir = browse.find_notebook_dir().parent
  File "c:\users\brandonlocal\github\examples\idaes_examples\browse.py", line 81, in find_notebook_dir
    stack = [resources.files(idaes_examples)]
AttributeError: module 'importlib.resources' has no attribute 'files'
bpaul4 commented 1 year ago
(idaes-dev) C:\Users\BrandonLocal\GitHub\examples>idaesx build
-> Pre-process notebooks
-> Build Jupyterbook
Running Jupyter-Book v0.13.2
Source Folder: C:\Users\BrandonLocal\GitHub\examples\idaes_examples\notebooks
Config Path: C:\Users\BrandonLocal\GitHub\examples\idaes_examples\notebooks\_config.yml
Output Path: C:\Users\BrandonLocal\GitHub\examples\idaes_examples\notebooks\_build\html
←[01mRunning Sphinx v4.5.0←[39;49;00m
[etoc] Excluded 155 extra file(s) not in toc
checking bibtex cache... out of date
parsing bibtex file C:\Users\BrandonLocal\GitHub\examples\idaes_examples\notebooks\references.bib... parsed 1 entries
←[01mmyst v0.15.2:←[39;49;00m MdParserConfig(renderer='sphinx', commonmark_only=False, enable_extensions=['colon_fence', 'dollarmath', 'linkify', 'substitution', 'tasklist'], dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', disable_syntax=[], url_schemes=['mailto', 'http', 'https'], heading_anchors=None, heading_slug_func=None, html_meta=[], footnote_transition=True, substitutions=[], sub_delimiters=['{', '}'], words_per_minute=200)
←[01mbuilding [mo]: ←[39;49;00mtargets for 0 po files that are out of date
←[01mbuilding [html]: ←[39;49;00mtargets for 47 source files that are out of date
←[01mupdating environment: ←[39;49;00m←[01mexecuting outdated notebooks... ←[39;49;00mfailed

←[91mExtension error (myst_nb.execution):←[39;49;00m
Handler <function update_execution_cache at 0x0000015F68C5BF70> for event 'env-get-outdated' threw an exception (exception: jsonschema 4.4.0 has no such extra feature 'format-nongpl')
Traceback (most recent call last):
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\pkg_resources\__init__.py", line 2739, in requires
    deps.extend(dm[safe_extra(ext)])
KeyError: 'format-nongpl'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\sphinx\events.py", line 94, in emit
    results.append(listener.handler(self.app, *args))
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\myst_nb\execution.py", line 76, in update_execution_cache
    _stage_and_execute(
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\myst_nb\execution.py", line 279, in _stage_and_execute
    execute_staged_nb(
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\myst_nb\execution.py", line 311, in execute_staged_nb
    executor = load_executor("basic", cache_base, logger=LOGGER)
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\jupyter_cache\executors\base.py", line 78, in load_executor
    execute_cls = entry_points[0].load()
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\pkg_resources\__init__.py", line 2449, in load
    self.require(*args, **kwargs)
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\pkg_resources\__init__.py", line 2472, in require
    items = working_set.resolve(reqs, env, installer, extras=self.extras)
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\pkg_resources\__init__.py", line 780, in resolve
    new_requirements = dist.requires(req.extras)[::-1]
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\pkg_resources\__init__.py", line 2741, in requires
    raise UnknownExtra(
pkg_resources.UnknownExtra: jsonschema 4.4.0 has no such extra feature 'format-nongpl'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\jupyter_book\sphinx.py", line 171, in build_sphinx
    app.build(force_all, filenames)
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\sphinx\application.py", line 330, in build
    self.builder.build_update()
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\sphinx\builders\__init__.py", line 286, in build_update
    self.build(to_build,
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\sphinx\builders\__init__.py", line 300, in build
    updated_docnames = set(self.read())
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\sphinx\builders\__init__.py", line 371, in read
    for docs in self.events.emit('env-get-outdated', self.env, added, changed, removed):
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\sphinx\events.py", line 102, in emit
    raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function update_execution_cache at 0x0000015F68C5BF70> for event 'env-get-outdated' threw an exception (exception: jsonschema 4.4.0 has no such extra feature 'format-nongpl')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\Scripts\jupyter-book.exe\__main__.py", line 7, in <module>
  File "C:\Users\BrandonLocal\AppData\Roaming\Python\Python38\site-packages\click\core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\BrandonLocal\AppData\Roaming\Python\Python38\site-packages\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "C:\Users\BrandonLocal\AppData\Roaming\Python\Python38\site-packages\click\core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\BrandonLocal\AppData\Roaming\Python\Python38\site-packages\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\BrandonLocal\AppData\Roaming\Python\Python38\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\jupyter_book\cli\main.py", line 322, in build
    builder_specific_actions(
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\site-packages\jupyter_book\cli\main.py", line 530, in builder_specific_actions
    raise RuntimeError(_message_box(msg, color="red", doprint=False)) from result
RuntimeError:
←[91m===============================================================================←[0m

There was an error in building your book. Look above for the cause.

←[91m===============================================================================←[0m

[ERROR] 2023-05-09 15:25:18,646 build - During 'build jupyterbook': Command '['jupyter-book', 'build', 'idaes_examples\\notebooks']' returned non-zero exit status 1.
[ERROR] 2023-05-09 15:25:18,648 build - Traceback (most recent call last):
  File "c:\users\brandonlocal\github\examples\idaes_examples\build.py", line 462, in _run
    func(**kwargs)
  File "c:\users\brandonlocal\github\examples\idaes_examples\build.py", line 283, in jupyterbook
    check_call(commandline)
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\lib\subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['jupyter-book', 'build', 'idaes_examples\\notebooks']' returned non-zero exit status 1.
lbianchi-lbl commented 1 year ago

Hi @bpaul4, thanks for opening this issue. Can you run the following commands and paste their output?

bpaul4 commented 1 year ago
(idaes-dev) C:\Users\BrandonLocal\GitHub\examples>idaes environment-info

IDAES
    Version: 2.0.0.dev3
    Git Hash: bb403dd583f99db31c975cd3e7953629f18c69ab
    Binary Directory: C:\Users\BrandonLocal\AppData\Local\idaes\bin
    Data Directory: C:\Users\BrandonLocal\AppData\Local\idaes
    Global Config: C:\Users\BrandonLocal\AppData\Local\idaes\idaes.conf

Pyomo
    Version: 6.5.1a0

Python
    Version: 3.8.12 (default, Oct 12 2021, 03:01:40) [MSC v.1916 64 bit (AMD64)]
    Executable: C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\python.exe

OS
    Platform: Windows
    Release: 10
    Version: 10.0.19044

Dependencies
    click: 8.0.4
    colorama: 0.4.4
    ipython: 7.32.0
    jupyter: 1.0.0
    lxml: 4.8.0
    matplotlib: 3.5.1
    nbconvert: 6.4.4
    nbformat: 5.7.3
    networkx: 2.7.1
    numpy: 1.22.3
    omlt: 1.1
    openpyxl: 3.0.9
    pandas: 1.4.4
    pint: 0.18
    pytest: 7.1.0
    pyyaml: 6.0
    requests: 2.28.2
    scipy: 1.8.0
    sympy: 1.10
    tinydb: 4.7.0
    xlrd: 2.0.1

Extras
    seaborn: 0.11.2

Solvers
    bonmin: 1.8.8.0
    cbc: 2.10.8.0
    couenne: 0.5.8.0
    dot_sens: 1.0.0.0
    ipopt: 3.13.2.0
    ipopt_l1: 3.13.3.0
    ipopt_sens: 3.13.2.0
    k_aug: 0.1.0.0
bpaul4 commented 1 year ago
(idaes-dev) C:\Users\BrandonLocal\GitHub\examples>pip list
Package                            Version             Location
---------------------------------- ------------------- --------------------------------------
absl-py                            1.0.0
addheader                          0.3.2
alabaster                          0.7.12
anyio                              3.6.2
argon2-cffi                        21.3.0
argon2-cffi-bindings               21.2.0
astroid                            2.9.3
asttokens                          2.0.5
astunparse                         1.6.3
atomicwrites                       1.4.0
attrs                              21.4.0
Babel                              2.11.0
backcall                           0.2.0
backports.shutil-get-terminal-size 1.0.0
beautifulsoup4                     4.10.0
black                              22.3.0
bleach                             4.1.0
bunch                              1.0.1
cachetools                         5.0.0
certifi                            2021.10.8
cffi                               1.15.0
cfgv                               3.3.1
charset-normalizer                 2.0.12
click                              8.0.4
cloudpickle                        2.0.0
colorama                           0.4.4
CoolProp                           6.4.1
coramin                            0.1.1
coverage                           6.3.2
cycler                             0.11.0
debugpy                            1.5.1
decorator                          5.1.1
defusedxml                         0.7.1
distlib                            0.3.6
distro                             1.8.0
docutils                           0.17.1
entrypoints                        0.4
et-xmlfile                         1.1.0
execnet                            1.9.0
executing                          0.8.3
fastjsonschema                     2.16.3
filelock                           3.8.2
flake8                             4.0.1
Flask                              2.0.3
Flask-Cors                         3.0.10
flatbuffers                        1.12
fonttools                          4.30.0
gast                               0.4.0
gitdb                              4.0.10
GitPython                          3.1.31
google-auth                        2.6.0
google-auth-oauthlib               0.4.6
google-pasta                       0.2.0
greenlet                           2.0.2
gridx-egret                        0.5.5
gridx-prescient                    2.2.2
grpcio                             1.44.0
h5py                               3.6.0
idaes-examples                     2.0.0a2             c:\users\brandonlocal\github\examples
idaes-pse                          2.0.0.dev3          c:\users\brandonlocal\github\idaes-pse
identify                           2.5.10
idna                               3.3
imagesize                          1.4.1
importlib-metadata                 4.11.2
importlib-resources                5.4.0
iniconfig                          1.1.1
ipykernel                          6.9.2
ipython                            7.32.0
ipython-genutils                   0.2.0
ipywidgets                         7.7.0
isort                              5.11.2
itsdangerous                       2.1.1
jedi                               0.18.1
Jinja2                             3.0.3
joblib                             1.1.0
jsonschema                         4.4.0
jupyter                            1.0.0
jupyter-book                       0.13.2
jupyter-cache                      0.4.3
jupyter_client                     7.4.9
jupyter-console                    6.4.3
jupyter-contrib-core               0.3.3
jupyter-contrib-nbextensions       0.5.1
jupyter_core                       5.3.0
jupyter-events                     0.6.3
jupyter-highlight-selected-word    0.2.0
jupyter-latex-envs                 1.4.6
jupyter-nbextensions-configurator  0.4.1
jupyter_server                     2.5.0
jupyter-server-mathjax             0.2.6
jupyter_server_terminals           0.4.4
jupyter-sphinx                     0.3.2
jupyterlab-pygments                0.1.2
jupyterlab-widgets                 1.1.0
keras                              2.9.0
Keras-Preprocessing                1.1.2
kiwisolver                         1.4.0
latexcodec                         2.0.1
lazy-object-proxy                  1.8.0
libclang                           13.0.0
linkify-it-py                      2.0.0
lxml                               4.8.0
Markdown                           3.4.1
markdown-it-py                     1.1.0
MarkupSafe                         2.1.1
matplotlib                         3.5.1
matplotlib-inline                  0.1.3
mccabe                             0.6.1
mdit-py-plugins                    0.2.8
mistune                            0.8.4
mpmath                             1.2.1
mypy-extensions                    0.4.3
myst-nb                            0.13.2
myst-parser                        0.15.2
nbclient                           0.5.13
nbconvert                          6.4.4
nbdime                             3.1.1
nbformat                           5.7.3
nbmake                             1.3.0
nest-asyncio                       1.5.4
networkx                           2.7.1
nodeenv                            1.7.0
notebook                           6.4.10
numpy                              1.22.3
oauthlib                           3.2.0
omlt                               1.1
openpyxl                           3.0.9
opt-einsum                         3.3.0
packaging                          21.3
pandas                             1.4.4
pandocfilters                      1.5.0
parso                              0.8.3
pathspec                           0.9.0
pecos                              0.2.0
pickleshare                        0.7.5
Pillow                             9.4.0
Pint                               0.18
pip                                21.2.2
platformdirs                       2.5.2
pluggy                             1.0.0
ply                                3.11
pockets                            0.9.1
pre-commit                         2.20.0
prometheus-client                  0.13.1
prompt-toolkit                     3.0.28
protobuf                           3.19.4
psutil                             5.9.0
pure-eval                          0.2.2
py                                 1.11.0
pyasn1                             0.4.8
pyasn1-modules                     0.2.8
pybtex                             0.24.0
pybtex-docutils                    1.0.2
pycodestyle                        2.8.0
pycparser                          2.21
pydantic                           1.10.6
pydata-sphinx-theme                0.8.1
pyflakes                           2.4.0
Pygments                           2.11.2
pylint                             2.12.2
Pyomo                              6.5.1a0
pyparsing                          3.0.7
PyQtWebEngine                      5.12.1
pyrsistent                         0.18.1
PySimpleGUI                        4.60.4
pytest                             7.1.0
pytest-cov                         3.0.0
pytest-reportlog                   0.1.2
pytest-xdist                       3.0.2
python-dateutil                    2.8.2
python-json-logger                 2.0.7
python-slugify                     6.1.1
pytz                               2021.3
pywin32                            303
pywinpty                           2.0.5
PyYAML                             6.0
pyzmq                              25.0.2
qtconsole                          5.2.2
QtPy                               2.0.1
rbfopt                             4.2.3
requests                           2.28.2
requests-oauthlib                  1.3.1
rfc3339-validator                  0.1.4
rfc3986-validator                  0.1.1
rsa                                4.8
scikit-learn                       1.0.2
scipy                              1.8.0
seaborn                            0.11.2
Send2Trash                         1.8.0
setuptools                         58.0.4
six                                1.16.0
smmap                              5.0.0
sniffio                            1.3.0
snowballstemmer                    1.2.1
soupsieve                          2.3.1
Sphinx                             4.5.0
sphinx-argparse                    0.3.1
sphinx-book-theme                  0.3.3
sphinx-comments                    0.0.3
sphinx-copybutton                  0.5.1
sphinx_design                      0.1.0
sphinx_external_toc                0.3.1
sphinx-jupyterbook-latex           0.5.2
sphinx-multitoc-numbering          0.1.3
sphinx-rtd-theme                   1.0.0
sphinx-thebe                       0.2.1
sphinx-togglebutton                0.3.2
sphinxcontrib-applehelp            1.0.2
sphinxcontrib-bibtex               2.5.0
sphinxcontrib-devhelp              1.0.2
sphinxcontrib-htmlhelp             2.0.0
sphinxcontrib-jsmath               1.0.1
sphinxcontrib-napoleon             0.7
sphinxcontrib-qthelp               1.0.3
sphinxcontrib-serializinghtml      1.1.5
spyder-kernels                     2.1.3
SQLAlchemy                         1.4.47
stack-data                         0.2.0
sympy                              1.10
tensorboard                        2.9.1
tensorboard-data-server            0.6.1
tensorboard-plugin-wit             1.8.1
tensorflow                         2.9.1
tensorflow-estimator               2.9.0
tensorflow-io-gcs-filesystem       0.24.0
termcolor                          1.1.0
terminado                          0.13.3
testpath                           0.6.0
text-unidecode                     1.3
tf-estimator-nightly               2.8.0.dev2021122109
threadpoolctl                      3.1.0
tinydb                             4.7.0
tkhtmlview                         0.1.1.post5
tokenize-rt                        5.0.0
toml                               0.10.2
tomli                              2.0.1
tornado                            6.2
traitlets                          5.9.0
typing_extensions                  4.5.0
uc-micro-py                        1.0.1
urllib3                            1.26.8
virtualenv                         20.17.1
wcwidth                            0.2.5
webencodings                       0.5.1
websocket-client                   1.5.1
Werkzeug                           2.0.3
wheel                              0.37.1
widgetsnbextension                 3.6.0
wincertstore                       0.2
wrapt                              1.13.3
xlrd                               2.0.1
zipp                               3.7.0
lbianchi-lbl commented 1 year ago
(idaes-dev) C:\Users\BrandonLocal\GitHub\examples>idaesx gui
-> Load notebooks into GUI
Traceback (most recent call last):
  File "C:\Users\BrandonLocal\miniconda3\envs\idaes-dev\Scripts\idaesx-script.py", line 33, in <module>
    sys.exit(load_entry_point('idaes-examples', 'console_scripts', 'idaesx')())
  File "c:\users\brandonlocal\github\examples\idaes_examples\build.py", line 585, in main
    sys.exit(func(args))
  File "c:\users\brandonlocal\github\examples\idaes_examples\build.py", line 437, in gui
    nb_dir = browse.find_notebook_dir().parent
  File "c:\users\brandonlocal\github\examples\idaes_examples\browse.py", line 81, in find_notebook_dir
    stack = [resources.files(idaes_examples)]
AttributeError: module 'importlib.resources' has no attribute 'files'

This error seems to be due to importlib.resources.files() only being available since Python 3.9. As the versions we're currently supporting include Python 3.8, we need to add a compatibility dependency such as importlib-resources. We should also make sure that these steps are properly tested in CI.

lbianchi-lbl commented 1 year ago

@bpaul4 I believe the first error has been fixed by #42 (I've added a test calling that function to make sure).

Can you try again after incorporating the changes from the current main branch and see if the second error still occurs?

bpaul4 commented 1 year ago

Hi @lbianchi-lbl , thank you for troubleshooting. I updated from main, manually ran pip install idaes_examples, ran pip install -U idaes_examples, and ran pip install -U . testing idaesx build after each and still encounter the second error. The tests ran with no issues, just the ALAMO one I need to fix - any added tests in #42 passed.

I also noted that setup.py was removed in the #42 and pip install requirements-dev.txt no longer works.

lbianchi-lbl commented 1 year ago

Thanks for running the checks @bpaul4.

I can confirm that setup.py was removed in #42, but pip install -r requirements-dev.txt should still work (this is what is being run in the CI tests). Also, depending on the details on the environment where those pip install commands were run, the package may or may not have actually being updated because of some internal intricacies.

Can you try again after creating a new environment?

git log -n 1  # just to make sure that the commit is the expected one
conda create --yes -n dev-idaes-examples python=3.8 && conda activate dev-idaes-examples
pip install -r requirements-dev.txt
idaesx build
bpaul4 commented 1 year ago

Creating a new environment resolved the issues - thank you @lbianchi-lbl ! I will continue working to address #20 with the working environment.