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

find a replacement for halo #1812

Closed
williballenthin opened this issue Oct 17, 2023 · 6 comments
Closed

find a replacement for halo #1812

williballenthin opened this issue Oct 17, 2023 · 6 comments
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request good first issue Good for newcomers gsoc Work related to Google Summer of Code project. help wanted Extra attention is needed usability Related to using capa and displaying results (CLI/GUI)

Comments

@williballenthin
Copy link
Collaborator

we use the halo package to show a spinner during long running computations. unfortunately, the package hasn't been updated in a long time, and while this typically isn't an issue itself, it calls a deprecated API:

.../capa/.direnv/python-3.11/lib/python3.11/site-packages/halo/halo.py:497: DeprecationWarning: setDaemon() is deprecated, set the daemon attribute instead
    self._spinner_thread.setDaemon(True)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
@williballenthin williballenthin added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed dependencies Pull requests that update a dependency file labels Oct 17, 2023
@williballenthin
Copy link
Collaborator Author

maybe https://pypi.org/project/yaspin/ ?

@bpshaver
Copy link

Was cruising for issues with good-first-issue and saw this. Took a crack at it, but I still need to make sure it streams to stderr:

bpshaver@ac742f7

@bpshaver
Copy link

bpshaver commented Oct 17, 2023

It looks like yaspin only writes to sys.stdout

@williballenthin
Copy link
Collaborator Author

williballenthin commented Oct 17, 2023

the STDOUT consideration is around things like: capa.exe > output.txt but still wanting to see the progress bar while it executes? this is a good point, thanks for mentioning it.

this is a nice set of requirements: pavdmyt/yaspin#31 (comment) and the associated issue is rather worrying for yaspin - it doesn't seem to be especially hardened/mature if this isn't addressed yet.

totally open to other libraries, too. this was just the first one on google. also ok with doing it ourselves if the implementation is simple.

@bpshaver
Copy link

Yeah, I read that issue too. At first I was thinking of just disabling the spinner if stdout is not a TTY, but now I see that you want the spinner on stderr while stdout safely goes through the pipe.

Would it be too hacky to just patch sys.stdout to sys.stderr? I'll give it a shot.

@bpshaver
Copy link

bpshaver commented Oct 18, 2023

import sys
from unittest.mock import patch

with patch("sys.stdout", sys.stderr):
    with yaspin(text="spinning"):

Something like this accomplishes the job if you're not writing to stdout within the context of the spinner. In the second instance of main.py, though, there are calls to the logger methods, and I'm unsure how they are affected by the patch. Probably best to modify the handler for the logger so its explicit about going to stdout or stderr.

I've updated my branch with this patch applied to main.py

diffs are here: master...bpshaver:capa:chore/replace-halo-dependency

@mr-tz mr-tz added gsoc Work related to Google Summer of Code project. usability Related to using capa and displaying results (CLI/GUI) labels May 22, 2024
@fariss fariss closed this as completed by moving to Done in @s-ff GSoC 2024 May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request good first issue Good for newcomers gsoc Work related to Google Summer of Code project. help wanted Extra attention is needed usability Related to using capa and displaying results (CLI/GUI)
Projects
Status: Done
Development

No branches or pull requests

4 participants