question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a function to find cells with the requested tags

See original GitHub issue

This is a simple, isolated issue.

We have a function to iterate over cells to find one with the given tag:

https://github.com/ploomber/ploomber/blob/3b7997d88a34f75855c0b5ec4391c82dce4213b6/src/ploomber/sources/nb_utils.py#L1

However, this function has to clean up all cells with the given cells:

https://github.com/ploomber/ploomber/blob/3b7997d88a34f75855c0b5ec4391c82dce4213b6/src/ploomber/sources/notebooksource.py#L556

We’re currently iterating the notebook one per tag but it’d be better to search for all tags on a single pass.

For example, if my input is:

tags = ['a', 'b', 'c']

After running the function, the output should return a dictionary with the tags and its corresponding index:

# 'a' is in the first cell, etc...
result = {'a': 0, 'b': 10, 'c': 20}

Note that cells may have more than one tag, but as long as it contains the one we are looking for, we don’t care about the rest.

If the cell is not in the notebook, it should not appear in the output. Following our previous example:

# input
tags = ['a', 'b', 'c']

Output:

# if we only get 'a', it means 'b' and 'c' are not in the notebook
result = {'a': 0}

I recently wrote something like this, except it looks for lines in a text file, as opposed to cells in a notebook, but the general logic remains the same.

Tasks:

  • Write a function that supports multiple tags
  • Have _cleanup_rendered_nb use that new function

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
edublancascommented, Oct 17, 2021

Sure! feel free to open a PR!

1reaction
edublancascommented, Oct 17, 2021

thanks for your interest!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way to apply tags to cells in Excel, and calculate with ...
The usual approach in Excel is to put the"tag" in an adjacent cell and then use =SUMIF(), etc. – Gary's Student. Feb 20,...
Read more >
Need help tagging in excel - Super User
1 Answer 1 ... Instead of tagging column B cells to identify their column A counterparts, this functionality is built into Excel's custom...
Read more >
Get geographic location data - Microsoft Support
To create a table, go to Insert > Table. With the cells still selected, go to the Data tab, and then click Geography....
Read more >
Excel: If cell contains formula examples - Ablebits
Finding cells containing certain text (or numbers or dates) is easy. You write a regular IF formula that checks whether a target cell...
Read more >
Using Tags in Excel - YouTube
https://howtoexcel.net/2021/10/using- tags -in-excel.html.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found