Commit 9366c7f
committed
exported modules can scrub_magics via settings.ini
This scrubs the cell magic lines out in the generated code. In some
sense, it is a follow-up to #905.
Would y'all be interested in a PR that adds a new option to the
settings.ini config? It would scrub any `%%magics` from the exported
modules. Fairly similar to how `black_formatting` works today.
---
The specific use-case is to simplify doing exploratory programming in
PySpark. We can now use nbdev notebooks to generate valid [pyspark][0]
code modules. At the same time, the Python-kernel notebook can continue
to use the [`%%spark`][1] magic. We can use a local notebook to interact
with a remote cluster running Livy.
[0]: https://github.com/apache/spark/tree/v3.1.1-rc3/examples/src/main/python
[1]: https://github.com/jupyter-incubator/sparkmagic
---
Please note that the implementation is just copying
`processors.clean_magics`. Not sure how much of an issue that is for
this repository. Should we add a code cell like below above the
scrub_magics method?
```
\#|hide
\# FIXME: reusing processors.clean_magics runs into a circular import
\# from .processors import clean_magics
```1 parent 46d05d4 commit 9366c7f
File tree
5 files changed
+38
-4
lines changed- nbdev
- nbs/api
5 files changed
+38
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
45 | 57 | | |
46 | 58 | | |
47 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
138 | 157 | | |
139 | 158 | | |
140 | 159 | | |
| |||
0 commit comments