drivendataorg / drivendataorg/nbautoexport

Cells with cell magic output the contents as a really long string!

Open
#101 2 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
87
Forks
10
PR merge metrics
No merged PRs in 30d

Description

* nbautoexport version: 0.5.0
* Python version: 3.9.13
* Operating System: Linux

### Description

The output of cell with cell magic is a function call with a very long string! For instance look at this [example output](https://github.com/azavea/noaa-hydro-data/blob/master/src/esip-2022-presentation/script/benchmark_queries.py#L119) from the corresponding cell ([cell number 15](https://github.com/azavea/noaa-hydro-data/blob/master/src/esip-2022-presentation/benchmark_queries.ipynb)) from the notebook. The generated python script is hard to navigate/review!

If calling the `run_cell_magic` function is unavoidable, can at least the third argument be formatted to read somewhat like normal python source code (maybe using triple quote string)?

---
Here is a small example of the above behavior. For a notebook with two cells:
```python
# Cell 1
import sys
print(sys.version)
```
and
```python
# Cell 2
%%time
x = 1
print(x)
```
the script output is:
```python
#!/usr/bin/env python
# coding: utf-8

import sys
print(sys.version)

get_ipython().run_cell_magic('time', '', 'x = 1\nprint(x)')
```
It would be tremendously helpful if the timed cell content appeared like *printed* python code.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.