Skip to content

Tags: an attempted overview #2826

@mpacer

Description

@mpacer

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:

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:

  1. nbformat should document the overall policy regarding tags.
    1. 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.
    2. We should specify whether we intend that people should use tags as features that can apply to multiple cells or as unique identifiers
      a. nameis specified in cell.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
  2. notebook docs should include screenshots of assigning tags to cells.
    1. notebook docs should mention any magic values that tags have and their matching scope
  3. jupyterlab docs should include screenshots of assigning tags to cells.
    1. jupyterlab docs should mention any magic values that tags have and their matching scope
  4. nbconvert docs should describe how to specify tags for any of its purposes.

Examples of tags as user-defined values

Examples of tags as hard-coded magic values

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions