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

Support multiple cells with the same tag #66

Open
fcollonval opened this issue Nov 3, 2020 · 8 comments
Open

Support multiple cells with the same tag #66

fcollonval opened this issue Nov 3, 2020 · 8 comments

Comments

@fcollonval
Copy link
Member

First of thanks for this really interesting package.

Here is a suggestion: could the code gather all cells with the provided tags to be executed instead of returning the first tagged cell found?

@rohitsanj
Copy link
Member

rohitsanj commented Nov 3, 2020

Hey, thanks for raising this issue. I think it definitely makes sense to gather all cells with the same tag. I will take this up.

Edit: Seems like there are a few edge cases where gathering all cells with same tag would not make sense, I will document these and come up with a solution soon and post it here.

@fcollonval
Copy link
Member Author

@rohitsanj Thanks a lot for the reply. I look forward to hear about your solution.

@devstein
Copy link

@fcollonval @rohitsanj Any updates on this? A few of user want the ability to separate cells for readability purposes, but group them logically when testing via the same tag

@rohitsanj
Copy link
Member

@devstein Thanks for the follow up! I apologize for the delay. I will try and implement this over the coming weekend.

@rohitsanj
Copy link
Member

So, I ran into some design issues while trying to implement this. Maybe you can give me your feedback on this.

Let's say you have a notebook with cells as:

cell 0 ('tag1', 'tag2')
cell 1 ('tag3')
cell 2 ('tag2')
cell 3 ('tag1')
cell 4
cell 5 ('tag1')

The issue is as follows: with the current implementation, when we specify testbook('nb.ipynb', execute=['tag3', 'tag1'], it will execute the cells tagged by those tags in the specified order i.e execute cell 1 and then cell 0. If we were to support multiple cells with same tag, we will have to execute the cells linearly, because otherwise the order becomes ambiguous.

For example, if execute=['tag3', 'tag1'] which means tag3 will fetch cells [1] and tag1 will fetch cells [0, 3, 5]
Now, there'd be two ways to go about this:

  • Does the user want testbook to execute all cells tagged by 'tag3' and then, execute all cells tagged with 'tag1' ?
  • OR, Does the user want testbook to execute linearly, which would combine to give [0, 1, 3, 5]

It is these ambiguities that I wanted to highlight earlier. I'd like to hear your thoughts on this. @devstein @fcollonval

cc @MSeal

@fcollonval
Copy link
Member Author

I would say

the user want testbook to execute linearly, which would combine to give [0, 1, 3, 5]

The unordered execution sounds odd as it means the intrinsic way to execute the notebook is unordered; aka when you run manually the notebook. This is a bad practice that will confuse most users.

@devstein
Copy link

@rohitsanj I agree with @fcollonval, keeping it linear is most intuitive.

If executing the notebook in a tag-based order is desirable, then I think it makes sense to have a separate execution flag for enabling that behavior.

@Uznick
Copy link

Uznick commented Aug 31, 2022

@rohitsanj +1 for keeping it linear, as it's consistent with how manual runs work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants