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

Print problem when importing this project #1021

Open
UserAEH opened this issue May 16, 2023 · 14 comments
Open

Print problem when importing this project #1021

UserAEH opened this issue May 16, 2023 · 14 comments
Assignees
Labels
🐛 Bug Something isn't working

Comments

@UserAEH
Copy link

UserAEH commented May 16, 2023

My problem is that no print is displayed in the command line when using this module:
A simple example could show this problem:

from super_gradients.training import models
print("hello")

but no print appears on the console.
I tried with sys.stdout.write("hello") and sys.stdout.flush() but no results.
Is there any conflict with default print function? Do you have any idea about how to solve this issue?

@dagshub
Copy link

dagshub bot commented May 16, 2023

@Louis-Dupont
Copy link
Contributor

Hi @UserAEH , can you try:

stdout = sys.stdout

from super_gradients.training import models

sys.stdout = stdout

print("hello")

@UserAEH
Copy link
Author

UserAEH commented May 16, 2023

Hi @UserAEH , can you try:

stdout = sys.stdout

from super_gradients.training import models

sys.stdout = stdout

print("hello")

It works perfectly, thanks.
Do you think there's some problem within the package or my environment? (In case there's a problem with the package, we could request a fix to enhance the project)

@Louis-Dupont
Copy link
Contributor

It's the first time someone faced this issue, I guess there must be a conflict between SuperGradients and something else in your environment. Did you import anything before the snippet you showed, or it happened when just importing super_gradients?

@UserAEH
Copy link
Author

UserAEH commented May 16, 2023

No, there's nothing before the snippet. I posted the full code.
I'm working with Python 3.10.11 if you want to test it.

@Louis-Dupont
Copy link
Contributor

Louis-Dupont commented May 16, 2023

Tried on 3.10.11 as well but it doesn't reproduce on my device.
I will investigate when I have some time, in the meantime I guess the workaround is to wrap the first super-gradient import with it. I think that the following imports won't create this issue.

You can also try the following code, it might work as well:

import sys
from super_gradients.training import models

sys.stdout = sys.__stdout__

print("hello")

@Louis-Dupont Louis-Dupont self-assigned this May 16, 2023
@Louis-Dupont Louis-Dupont added the 🐛 Bug Something isn't working label May 16, 2023
@UserAEH
Copy link
Author

UserAEH commented May 18, 2023

Tried on 3.10.11 as well but it doesn't reproduce on my device. I will investigate when I have some time, in the meantime I guess the workaround is to wrap the first super-gradient import with it. I think that the following imports won't create this issue.

You can also try the following code, it might work as well:

import sys
from super_gradients.training import models

sys.stdout = sys.__stdout__

print("hello")

This solution is working. It seems like the problem is coming from the file common/abstractions/mute_processes.py.
When i commented the line 30:
#sys.stdout = open(os.devnull, "w")

Print worked with the first code i posted and without reassigning original value to stdout.
Another thing to mention is that there was one line that was added in the console before printing hello which i think is normal:

The console stream is logged into some\path\logs\console.log.

@Louis-Dupont
Copy link
Contributor

Hi @UserAEH , I think this PR should fix it #1044 can try to install from master:
pip install git+https://github.com/Deci-AI/data-gradients

@UserAEH
Copy link
Author

UserAEH commented May 23, 2023

Hi @Louis-Dupont , i tried to install from master. The encoding is added but the issue persisted.

@ukoehler
Copy link

ukoehler commented Jun 2, 2023

Problem confirmed for
super-gradients 3.1.1
Platform Windows 10

from super_gradients.training import Trainer is enough to cause the problem for me.

Workaround sys.stdout = sys.stdout works, but it is still annoying.

@pcismyname
Copy link

pcismyname commented Jun 20, 2023

same problem here (Window 10)!
I discovered that my output shows up in the console where I open Jupyter lab.

@xcweric
Copy link

xcweric commented Sep 21, 2023

I found the solution:
(super_gradients 3.1.3)
\common\abstractions\abstract_logger.py
commented the line 9&18: 'mute_subprocesses()'
Then log and print() will show again:)
by default this func is always called which not friendly for some users like me:( , I spent a lot of time to find it...

@UserAEH
Copy link
Author

UserAEH commented Nov 6, 2023

I found the solution: (super_gradients 3.1.3) \common\abstractions\abstract_logger.py commented the line 9&18: 'mute_subprocesses()' Then log and print() will show again:) by default this func is always called which not friendly for some users like me:( , I spent a lot of time to find it...

The problem in your solution is that It prints also logger messages so I am not sure if it is a normal behavior. Logger should be written in log file not printed in the CLI.

@cobaltautomationdev
Copy link

this issue still exists until now 2024.01.14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants