-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Jupyter-wide policy regarding tags in the core projects
We really need to make a decision about core projects handle cell tags before the final release of notebook 5.1.
There has been ongoing discussion amongst @rgbkrk @takluyver @jasongrout @ellisonbg @Carreau and others regarding the purpose of tags… Right now we are not shipping any magic values with core Jupyter projects.
N.B.: by "magic values", I mean values that are hard-coded and that map onto specific behaviour by default, usually with no ability for users to override this behaviour mapping.
Notebook 5.1 includes a magic value (#2549) which violates some of the expectations that had arisen in earlier discussions around allowed magic vlaues.
psuedo-namespaces with colons
@jasongrout and @ellisonbg had been extremely concerned about stepping on users' namespaces in any privileged jupyter tags. This would allow other projects/users to assign their own "namespace" by prefixing their tags with the namespace value postceded by a colon (e.g., namespace:tag
).
We had discussed the possibility of saving for jupyter the "null string" namespace (which would then require no :
. This would make the raises_exception
tag a candidate for meeting that namespace requirement. Unfortunately that is not the only value that matches the current "magic value".
Potential problem: "*raises_exception*"
matching
Right now, #2549 makes the namespaces convention impossible. It includes any string that contains the characters raises_exception
anywhere inside of it, regardless of the namespace+:
that might prefix it.
The value is not customisable, and is specified deep within the codecell execute functionality meaning it will not be able to be easily overwritten:
notebook/notebook/static/notebook/js/codecell.js
Lines 314 to 325 in d4c6fe4
if (stop_on_error === undefined) { | |
if (this.metadata !== undefined && | |
this.metadata.tags !== undefined) { | |
if (this.metadata.tags.indexOf('raises-exception') !== -1) { | |
stop_on_error = false; | |
} else { | |
stop_on_error = true; | |
} | |
} else { | |
stop_on_error = true; | |
} | |
} |
Compromise to resolve issues around #2549
I think the simplest suggestion would be to allow raises_exception
and nbval_raises_exception
as the two tags that the core notebook
"knows" about. This greatly reduces namespace stompage while not breaking the behaviour that @takluyver and @mscuthbert introduced in merging #2549. It's less than ideal to have a non-core project determining magic values inside the core project… but without making it configurable via a traitlet (or something), I can't think of another way to handle this.
Even so it would seem to be a good idea to modularise this chunk of functionality so that it can be overwritten by external libraries without needing to rewrite the entirety of CodeCell.prototype.execute
just to access this one feature.
Document how tags are used outside of changelogs.
Now that tags are supported in at least a couple of different ways in the core projects and in 3rd party projects, we should explicitly document those ways of using them. I list the ones I know about at the bottom of this issue.
We need to start this effort and its closely tied to how we decide to handle the policy in general. Here are a couple of my initial thoughts:
- nbformat should document the overall policy regarding tags.
- We should have a policy for 3rd party libraries to know how to specify the tags they want to use; if we want to use namespaces with colons, we need to start promulgating that now.
- We should specify whether we intend that people should use tags as features that can apply to multiple cells or as unique identifiers
a.name
is specified incell.metadata
as an explicit unique id across notebook
i. we should have an interface similar cell tags that allows assigning a single unique name to each cell that will enforce the uniqueness condition as a part of the UI
- notebook docs should include screenshots of assigning tags to cells.
- notebook docs should mention any magic values that tags have and their matching scope
- jupyterlab docs should include screenshots of assigning tags to cells.
- jupyterlab docs should mention any magic values that tags have and their matching scope
- nbconvert docs should describe how to specify tags for any of its purposes.
Examples of tags as user-defined values
- nbconvert, via traitlet values ,
TagRemovePreprocessor.remove_cell_tags
: removes cells with specified tags (Tag remove preprocessor nbconvert#640)TagRemovePreprocessor.remove_input_tags
: removes inputs with specified tags (enables input removal via preprocessor, template and invalid nb intermediate representation nbconvert#643)TagRemovePreprocessor.remove_all_outputs_tags
: removes outputs with specified tags (Tag remove preprocessor nbconvert#640)
Examples of tags as hard-coded magic values
notebook
"*raises-exception*"
: allows exceptions to pass allow raises-exception to continue #2549
computationalmodelling/nbval
:"pytest-validate-ignore-output"
: avoids testing cell (deprecated)"nbval-ignore-output"
: avoids testing cell"nbval-check-output"
: ensures testing cell even with--nbval-lax
"nbval-raises-exception"
: allows exceptions to pass (analogous to notebook value)"nbval-skip"
: skips cell during testing
- nteract/papermill
"parameters"
: identifies a single unique cell (https://github.com/nteract/papermill/blob/master/papermill/execute.py#L157)
Are there other projects that the core in any way maintains that use tags in either of these ways?
Regarding jupyterlab: @blink1073 @ian-r-rose @afshin are tags being used for anything meaningful in jupyterlab as of yet? Is there an official policy of how to handle them there?