-
Notifications
You must be signed in to change notification settings - Fork 12
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
Hmmsearch callback tqdm update #60
Comments
Hi Jérôme, The callback needs to take two arguments, the In your snippet, that means: options = {"bit_cutoffs": bit_cutoffs, 'callback': lambda hmm, total: bar.update()} If i use only one argument like you did the progress bar is never updated, but since the exception is silenced the code enters a deadlock (the worker threads die on the exception, while the main thread still tries to pass them queries to process). |
I've patched the deadlock, so now with the code above you'd actually get the error and traceback: 0%| | 0/20795 [00:00<?, ?hmm/s]Traceback (most recent call last):
File "/home/althonos/Code/pyhmmer/issue.py", line 18, in <module>
for top_hits in pyhmmer.hmmsearch(hmms, sequences, cpus=2, callback=callback):
File "/home/althonos/Code/pyhmmer/pyhmmer/hmmer.py", line 520, in _multi_threaded
yield results[0].get()
^^^^^^^^^^^^^^^^
File "/home/althonos/Code/pyhmmer/pyhmmer/hmmer.py", line 122, in get
raise self.exception
File "/home/althonos/Code/pyhmmer/pyhmmer/hmmer.py", line 215, in run
hits = self.process(chore.query)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/althonos/Code/pyhmmer/pyhmmer/hmmer.py", line 232, in process
self.callback(query, self.query_count.value) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: <lambda>() takes 1 positional argument but 2 were given I'll publish a patch shortly for the deadlock issue, but you don't need to wait for it, just to change the |
Hi, Thank you very much for your quick reply. |
You basically have two choices:
|
Hi,
I have a question about callback in the hmmsearch function. I would update my progress after each query, but my code does not work as expected.
Maybe I do not understand how to use it.
I update it manually at the end of the for loop to make it work for the time, but I would also use this to write the name of the HMM in a debug (with the logging package). So, it seems a good idea to define a callback function.
Thanks for your help
The text was updated successfully, but these errors were encountered: