0

In Short: Besides exporting code to a python module, what tools exist to get us closer to actual re-usable code: For instance, without the hard-coded inputs of the jupyter notebook.

More details: Faced with a new problem, a common pattern for myself and many data scientists around me is:

  • Start developing with a jupyter notebook, and when the problem is solved...
  • export to a .py file, and
  • clean up and structure into a re-usable set of objects.

It seems like there should be tools to help out with that last steps. Theoretically, one should be able to analyze the AST, identify the functional components as well as the input and output "nodes" of these. That should be enough to get us closer to clean reusable code.

Note: To those that will want to say "that's a hard problem" I answer, in advance, with two numbers: 80/20. The fact that the 100% is difficult shouldn't deter us from creating solutions that bring us closer.

A similar question, but without a good answer

Frank C.
  • 7,758
  • 4
  • 35
  • 45
thorwhalen
  • 1,920
  • 14
  • 26
  • Unless I misunderstand the question, we use the opposite approach; write python modules in ,py files and import them to the notebook as needed. – stever Jan 31 '20 at 15:19
  • 2
    [Jupytext](https://github.com/mwouts/jupytext) is nice for conversion to a `.py` file. And I feel [nbdev](https://github.com/fastai/nbdev) is targeted in part at addressing some of the issues you raise; however, isn't probably (yet?) as automated as you seem to hope. – Wayne Jan 31 '20 at 15:51
  • I'm looking for reusable components a well – Marcello DeSales Feb 07 '22 at 21:20

0 Answers0