Skip to content

Refactor Jupyter Notebook support #485

@fdxmw

Description

@fdxmw

PyRTL's Jupyter Notebook support is quite messy, see _currently_in_jupyter_notebook() and its callsites. There are several problems:

  1. _currently_in_jupyter_notebook() does not work reliably across different notebook implementations.
  2. It is confusing that PyRTL functions like render_trace() behave differently depending on whether they're running in a notebook environment or not, and even more confusing when we can't reliably detect notebook environments.
  3. PyRTL modules often mix data and how that data is presented. See Block.__str__() for example. This approach tends to spray UI code across core PyRTL modules, for example every __str__() method would end up with tons of if statements to support all presentation styles.

To clean this up:

  1. Refactor PyRTL's core modules so they only return data.
  2. All presentation and formatting code should move into separate modules built on top of these core-data modules.
  3. Most of these formatting modules should not be top-level components in the pyrtl module.
  4. Users should invoke these formatting modules explicitly, for predictable behavior.
  5. Avoid magic code that guesses what the user wants to see. Magic code inevitably does the wrong thing for someone at at some point. Magic code is a maintenance burden because it usually can't be fixed, only slightly improved by piling on more heuristics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions