Skip to content
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

Ignore "parameters" tagged cells? #108

Open
timkpaine opened this issue May 15, 2020 · 1 comment
Open

Ignore "parameters" tagged cells? #108

timkpaine opened this issue May 15, 2020 · 1 comment
Labels
part: notebook lint Relating to notebook linting tag: question Questions about use, potential features, or improvements type: enhancement Minor improvements

Comments

@timkpaine
Copy link
Collaborator

To use papermill, you need to tag the first cell with "parameters", and it should include only declarations. But it doesnt seem like we should enforce the same lint rules on this cell, since its basically "inputs" to the notebook.

@ceball
Copy link
Collaborator

ceball commented May 15, 2020

Yes, I think we should support this.

Also, I've noticed that it's easy to make mistakes with tags. E.g. accidentally tagging two cells with "parameters". We can't catch all such tagging mistakes, but it might be nice to help out a bit.

I'm overall not very familiar with projects using notebook tags, so I'm not sure if the following more general proposal will be useful or not. Please let me know what you think.

What about allowing rules that target specific tags? And maybe excluding such tagged cells from the global rules, where more specific rules for the tag have been supplied?

Say you have these global rules:

rules = {
  max_cells_per_notebook: 3,
  max_lines_per_cell: 3,
  max_function_definitions: 2,
  max_class_definitions: 0,
  magics_whitelist: []
}

But if you also want:

  • to allow at most one cell tagged with parameters in the notebook
  • that if there is such a cell, to not count it towards the global max_cells_per_notebook allowance
  • to limit the number of lines in this cell to 10 (i.e. to say roughly, "10 parameters should really be enough for this kind of notebook!")

Maybe in addition to rules, you should also be able to supply rules_for_tag:

rules_for_tag = {
  parameters: {
    max_cells_per_notebook: 1,
    max_lines_per_cell: 10
  }
}

Cells tagged parameters would not count towards the global max_cells_per_notebook, and would not be subject to the global max_lines_per_cell - they'd need to follow rules_per_tag["parameters"] instead. They would still need to follow/contribute to others, such as max_function_definitions, because those were not overridden for the tag.

As usual, I continue to feel the fear that notebooks are a disaster zone of duplicating an already well established way of doing things in a worse way in many respects. And that every tool/proposal to help out with notebooks is enabling this disaster. But at the same time, I haven't seen a better solution than notebooks - I need notebooks! :)

@ceball ceball added the part: notebook lint Relating to notebook linting label May 20, 2020
@timkpaine timkpaine added type: enhancement Minor improvements tag: question Questions about use, potential features, or improvements and removed feature labels Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part: notebook lint Relating to notebook linting tag: question Questions about use, potential features, or improvements type: enhancement Minor improvements
Projects
None yet
Development

No branches or pull requests

2 participants