Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: clarify ideas around usage #12

Closed
agoose77 opened this issue May 6, 2021 · 1 comment
Closed

Documentation: clarify ideas around usage #12

agoose77 opened this issue May 6, 2021 · 1 comment

Comments

@agoose77
Copy link
Owner

agoose77 commented May 6, 2021

Literary makes some opinionated decisions that might need to be relaxed. See #7 for more.

What are (Literary) literate notebooks?

To understand why one would write entire packages in Jupyter Notebooks, let's identify their benefits:

  • REPL for quick prototyping and experimentation.
  • Embed rich markup (Markdown) and visualisations
  • Magics for improved expressiveness

In Literary, the notebook is generally seen as the "ground truth".

  • Documentation is placed adjacent to implementation
  • Tests are defined and run in-line.

This makes it easy to show users how the code works without having a separate documentation system, and makes it easier to write docs first.

Nuance of the REPL

Without the REPL, we would only be able to embed rich static content around sections of code. However, Jupyter also has the rich display mechanism for rich-rendering of objects. To use this, we need to leverage a kernel. Although this could be done offline and the results embedded in the notebook, this would strongly undermine the user-friendliness of the paradigm.

Tangle/weave alternatives

Instead of (albeit similar to) tangle and weave, there can be several views of a notebook with certain modifications, e.g.

Testing

Tests are really just another form of documentation; they ensure that the code is correct, and enforce the API that it must satisfy.

Simple asserts can be placed in-line in the notebook in cells. As they shouldn't be exported, they won't be executed by clients of the module. So how do we rectify this requirement with test-runners like pytest, which provide useful parameterisation features, but require the tests to be encapsulated and called by the runner?

It looks like https://github.com/chmp/ipytest/ might be a good way to resolve this. It should be possible to pass the current module to pytest, but constrain the test functions to those defined in the cell. This might be done by performing an AST search for function nodes defined in the cell, or by inspecting the globals() items that change.

@agoose77
Copy link
Owner Author

agoose77 commented May 7, 2021

This is now in the wiki

@agoose77 agoose77 closed this as completed May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant