papermill
papermill copied to clipboard
parameters comment instead of tag
- What: support writing
#parametersas a comment at the top of a cell as an alternative way to tag - Why: it's annoying to use the
tagsmechanism, especially if it's just for papermill (related: #192)
Paraphrasing https://papermill.readthedocs.io/en/latest/usage-parameterize.html#how-parameters-work (which I may have written :P):
- if multiple
parameterstags are found, injection only occurs after the first one (related: #328) - if none are found, injection is at the start of the notebook
proposed here: insert 2. if none are found, injection occurs after the first cell that starts with #parameters (possibly also variants such as """ PaRaMeTeRs""")
This will not break backward-compatibility.
Happy to implement this if there's support for it.
The concern here is it becomes a bit complicated in order to not be language specific, which puts more code complexity in papermill to understand how to parse various languages and complex kernels. Now we'd have to be concerned with magic functions or special kernel operators that papermill doesn't need to ever think about today. It also makes 2 ways of doing things, rather than keeping it simpler at the cost of requiring users to learn about tagging. I'm slightly against adding this, but the added complexity would be manageable if others were strongly for it.
I am sympathetic to the arguments about complexity, and understand if that is the reason not to go forward, but I would like to write in support of this. Comments are already a natural way of saying "this is what this code is for." Tags still don't exist in JupyterLab core (though it's coming) and it's not clear if it'll ever exist in environments like the VS Code notebooks. It would be very nice to see something like this.
Noted the +1 for comment based parameter management. I'm still worried that supporting users would be nasty with comments. We'd have to handle whitespacing, comments not at the top of the cell, and it'll be easier for users to specify parameters in a different place by comment vs tag if they're not aware of a tag assignment. These things make me hesitant to change behavior of the library here.
JupyterLab should have had built-in tag support a while ago, they're through most of their primary feature crunching they did for 1.0 so I believe that'll happen relatively quickly now, or at least have no resistance to adding to the core and out of the extension.
On the VS Code front, we've had success with opening issues and getting feature changes into the extension. I opened https://github.com/microsoft/vscode-python/issues/8368 and @captainsafia has also been helpful in getting issue raised for notebook integrations with Microsoft tooling if we need more support for the idea there.
In future, it might also be possible to define tags via comments, see this https://github.com/markellekelly/celltags/issues/1#issuecomment-546431806
Another hack is to do something along these lines: https://stackoverflow.com/questions/36194865/configure-a-first-cell-by-default-in-jupyter-notebooks
Here's how @technic solved it with magic: https://habr.com/en/users/technic93/
+1. There's no movement on the VSCode issue. It would be great to be able to specify a parameter cell without using tags.
It would be great since it would allow to use with VScode. Also, tag as metadata is invisible, while as comment it is clear and visible in the notebook.