Closed Saif807380 closed 2 years ago
Hey @Saif807380,
Actually, you can see in the last log line that is Python framework that is returning an error...
File "/Users/saifkazi/Desktop/preprocessy/venv/lib/python3.9/site-packages/alive_progress/utils/terminal/tty.py", line 32, in cols
return os.get_terminal_size()[0]
OSError: [Errno 25] Inappropriate ioctl for device
In this tty.py
file of mine, I just try to get the terminal size...
Where are you running this?
Can you please try to run this?
import os
os.get_terminal_size()
Below is the output when I ran this in iterm2
And this is the output in vscode's terminal
I replaced os.get_terminal_size()
in tty.py
with shutil.get_terminal_size()
and everything worked perfectly. Since shutil
is wrapper on os
it must be handling exceptions underneath.
Yes, the shutil
one will always work, since it is just a wrapper over the os
one, which includes a try/except to just return 80 cols in case of error. But I use the raw one, which has a much smaller overhead.
How are you starting your project? You certainly are in a different environment...
I run everything inside the virtual environment. I tried out different terminal applications -
And since my project uses GitHub actions for running test, it too failed with the same error.
For testing, I am using pytest and run the tests by running pytest locally.
Ohh yes, forgot you was saying your tests were not working!
Well, these new terminal abstractions came exactly to fix a bug in 2.0, in which the terminal ANSI Escape Codes were being disabled based only on the terminal report (sys.stdout.isatty()
), so a force_tty
param wasn't being taken into account... Your tests should probably work on 2.0.
But on 2.1 where this was fixed, that force_tty
will actually enable the full feature set of alive_progress
, including the background thread and print/logging hooks, which may not be a good idea in a pytest environment...
Could you please include that snippet on the first line of your test_pipeline_with_default_reader
?
import os
os.get_terminal_size()
I think the test will break on the first line, without ever getting to alive_progres
...
Yes, the test broke on the first line itself as you mentioned. Is there a workaround to this? Setting force_tty = None
, fixes the running of tests. But are there any side effects to doing so? Right now with force_tty
at its default value, satisfies all my use cases, but is there some feature that I'll miss out on by doing this?
Nice, as I thought... And great that it works with the default value of force_tty
.
But unfortunately I don't know of any fix for that. I even tried to search about it, but couldn't find anything relevant...
No, not at all! You won't miss out anything! This param exists just as a workaround for terminals that do not report themselves as "interactive", such as Pycharm's terminal and Jupyter Notebook. So, if you're running your software anywhere else, it won't make any difference 👍
I'll close this ticket than, but feel free to reply if you want.
A project of mine uses
alive-progress
. I updated from1.6.2
to2.1.0
and the above error was raised when I ran my tests. I tried running the test in different terminals - iterm2, vscode and pycharm but got the same exception. Below is the stack trace for the same.The code that uses alive-progress
The test for above
Version Numbers
Python - 3.8, 3.9 alive-progress - 2.1.0
From what I could debug, this has something to do with
utils/terminal/tty.py
.