IDAES / examples

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

idaesx new command fails to register new examples #96

Closed dallan-keylogic closed 1 month ago

dallan-keylogic commented 3 months ago

I attempted to create a new example following the instructions in the README-developer.md file:

If you want to add an example in an existing section of notebooks/docs, you can run idaesx new to get a guided terminal-based UI that will create a skeleton of the new notebook and add it to the table of contents, and also add all the variations of the notebook (see Notebook Names) and, if git is enabled and found, add and commit them to git. Then you just need to edit your notebook.

If you need to create a new section in notebooks/docs or notebooks/held:

  • add the appropriate subdirectory, e.g. notebooks/docs/fantastic
  • add a section into notebooks/_toc.yml, imitating an existing entry
  • create and populate a notebooks/docs/fantastic/index.md file
  • now you can add your notebook(s) manually, e.g. notebooks/docs/fantastic/my_notebook.ipynb, or use the idaesx new command

I created a new folder, added an index.md file to it, and registered it in _toc.yml in the following way:

  chapters:
  - file: docs/power_gen/supercritical/index
    sections:
    - file: docs/power_gen/supercritical/supercritical_power_plant_doc
    - file: docs/power_gen/supercritical/supercritical_steam_cycle_doc
  - file: docs/power_gen/solid_oxide_cell/index

Afterwards, the idaesx gui command would crash in the following way:

(idaes-fresh) C:\Users\[REDACTED]\Repos\examples>idaesx gui
-> Load notebooks into GUI
[ERROR] 2024-03-26 13:59:38,527 build - During 'pre-process notebooks': Could not find notebook at: C:\Users\[REDACTED]\Repos\examples\idaes_examples\notebooks\docs\power_gen\solid_oxide_cell\i.ipynb
During 'pre-process notebooks': Could not find notebook at: C:\Users\[REDACTED]\Repos\examples\idaes_examples\notebooks\docs\power_gen\solid_oxide_cell\i.ipynb
[ERROR] 2024-03-26 13:59:38,535 build - Check that your working or `-d/--dir` directory contains the Jupyter source notebooks
Check that your working or `-d/--dir` directory contains the Jupyter source notebooks
Traceback (most recent call last):
  File "C:\Users\[REDACTED]\.conda\envs\idaes-fresh\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\[REDACTED]\.conda\envs\idaes-fresh\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\[REDACTED]\.conda\envs\idaes-fresh\Scripts\idaesx.exe\__main__.py", line 7, in <module>
  File "C:\Users\[REDACTED]\Repos\examples\idaes_examples\build.py", line 981, in main
    sys.exit(func(args))
  File "C:\Users\[REDACTED]\Repos\examples\idaes_examples\build.py", line 780, in gui
    nb = browse.Notebooks()
  File "C:\Users\[REDACTED]\Repos\examples\idaes_examples\browse.py", line 128, in __init__
    find_notebooks(self._root, self._toc, self._add_notebook)
  File "C:\Users\[REDACTED]\Repos\examples\idaes_examples\util.py", line 186, in find_notebooks
    raise FileNotFoundError(f"Could not find notebook at: {path}")
FileNotFoundError: Could not find notebook at: C:\Users\[REDACTED]\Repos\examples\idaes_examples\notebooks\docs\power_gen\solid_oxide_cell\i.ipynb

Editing the _toc.yml file in the following way fixed the issue:

  chapters:
  - file: docs/power_gen/supercritical/index
    sections:
    - file: docs/power_gen/supercritical/supercritical_power_plant_doc
    - file: docs/power_gen/supercritical/supercritical_steam_cycle_doc
  - file: docs/power_gen/solid_oxide_cell/index
    sections:
    - file: docs/power_gen/solid_oxide_cell/soc_pid_control_doc

It seems like idaesx new should create the - file: docs/power_gen/solid_oxide_cell/soc_pid_control_doc entry and either add sections: or complain if it's not there.

dangunter commented 3 months ago

Note that the idaesx gui is going away, so this may not be as much of an immediate problem.

dallan-keylogic commented 3 months ago

Good news: it successfully added a missing sections tag. Bad (or weird) news: it did so after a comment: image