sokrypton / sokrypton/ColabFold
Log messages not appearing
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 2.9k
- Forks
- 747
- PR merge metrics
- No merged PRs in 30d
Description
There is a bug in the setup_logging() routine in colabfold/colabfold/utils.py. If setup_logging() is called twice for two consecutive runs in a Python notebook then no log messages appear. ChimeraX was calling setup_logging() on each run and had this problem. The cause is that this code in setup_logging():
if root.handlers:
for handler in root.handlers:
root.removeHandler(handler)
Loops over a list (root.handler) and the body deletes entries from the same list (root.removeHandler(handler)). Python does not give an error but all the logger handlers don't get removed. Only the iPython notebook handler is removed when a second setup_logging() call is made. Then the next line in setup_logging() logging.basicConfig() does nothing as it is documented not to do anything if handlers already exist.
I've worked around this bug in ChimeraX use of ColabFold by making sure setup_logging() is only called once, but it would be good to fix this subtle error using
for handler in list(root.handlers):
...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open colabfold/colabfold/utils.py and read setup_logging(), focusing on how it iterates over root.handlers before calling logging.basicConfig(). Update the handler-removal loop so repeated setup_logging() calls remove every existing handler, then verify that log messages appear on a second consecutive call in a Python notebook.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100