-
Notifications
You must be signed in to change notification settings - Fork 293
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
Add support for parameters and/or tags assignment (papermill) #1121
Comments
Thanks for letting us know! |
I want to second this. I am very happy with VSCode as my primary Python editor but when looking for a way to parameterize my notebook via papermill I ran into the above issue of not being able to set |
Any possible work around the missing tag options in VS Code? |
+1 |
+1 |
+1. This would be really helpful when using with JupyterBook. |
+1. Is this being planned for VSCode Jupyter or the new native notebook integration? |
Once we are ready to roll out the new notebook for everyone, we'll come back to adding more features like this one. |
FYI, a workaround is mentioned in #1182 (comment) |
Please add this feature soon. The workaround, jupyter power tools extension, does not work with latest vs code insider. |
As mentioned, it is possible to do so manually for now. I do it by right-clicking the .ipynb file in the Explorer window, selecting "Open With..." and choosing "Text Editor". Then you can just find the cell you want to add tags to and put something like "tags": ["abc123"] inside the "metadata" curly brackets. This is the only way I've been able to use the TagRemovePreprocessor capabilities from nbconvert while attempting to hide certain code input cells when converting to HTML. |
This would be very needed when using unit tests with https://github.com/nteract/testbook/. Thanks for considering! |
+1! |
Is this implemented yet? Would be very useful for papermill! |
Does anybody know how to add parameter "add tag" in VS code? |
This seems like pure user interface work, so hoping this won't be pushed out for much longer. |
+1 |
+1! |
I need tags! |
would be helpful, yes... |
Meanwhile, I've created a script which can automate adding certain tags, e.g. 'parameters' for papermill, to a notebook. It requires an indicator comment. (by default, it looks for the first occurrence of "default param".) You'd need to add the indicator as a comment to the cell you wish to add the tag to. import json
def add_tag_to_nb(nb_path: str, tag: str = "parameters", indicator: str = "default param"):
# read notebook
with open(nb_path) as file:
nb = json.load(file)
for i, cell in enumerate(nb["cells"]):
cell_text = "".join(cell["source"])
# find first cell with the indicator
if indicator in cell_text:
cell["metadata"]["tags"] = cell["metadata"].get("tags", []) # existing tags
if tag not in cell["metadata"]["tags"]:
cell["metadata"]["tags"].append(tag) # add tag
break
else:
print(f"{indicator} not found in {nb_path}!")
return None
nb["cells"][i] = cell
# save
with open(nb_path, "w") as file:
json.dump(nb, file) |
Hi all, thank you for the suggestion and all your feedbacks! We published a new extension Jupyter Cell Tags https://marketplace.visualstudio.com/items?itemName=ms-toolsai.vscode-jupyter-cell-tags to the marketplace which you can play around with today. The extension will be available through Jupyter extension pack later. With this extension, you should be able to mark a cell as papermill parameters, or insert a new random tag from the cell toolbar Once a tag is added to a cell, it will be rendered in the cell status bar so you can delete them with ease You can add new cell tags through status bar item + Tag as well Give it a try and feel free to share your thoughts on how it works and what else we can do to improve the tag editing experience. |
Cannot edit cell tags in R kernel. The JSON editor doesnt open. |
Feature: Notebook Editor, Interactive Window, Python Editor cells
Add ability to set metadata tags on a cell, like notebook classic supports in the gif below (but maybe with a better interface for it).
Description
Cell tags are used as a convention based pattern for converting notebooks in a few contexts. The papermill library uses the
parameters
andinjected-parameters
tags to manage user inputs to notebook executions. NBConvert has notebook manipulation processors that filter or convert cells based on tags. Overall while it was originally used for metadata matching purposes, it's use for production execution paths has become a necessity with Jupyter today. Have a minimal way to manage the cell tags would go a long way for cross-tooling support.The text was updated successfully, but these errors were encountered: