piccolomo / plotext

plotting on terminal
MIT License
1.74k stars 80 forks source link

Terminal Output for Docker-Compose #202

Open kevroy314 opened 6 months ago

kevroy314 commented 6 months ago

I love this package, and I got it working immediately running a python script locally. However, when I run the same script in a docker-compose standard out, I don't see the graph. I get all my other colorful formatting by setting tty: true in the docker-compose file, but it appears whatever cool stuff is happening in this package isn't making it through. I've confirmed the small chunk of code is running, just not rendering. Here's the plot I'm making in case it matters (where texts is a list of strings of various lengths and len(texts) is ~250):

plt.hist([len(t.page_content) for t in texts], bins=30)
plt.title(f'Distribution of Text Lengths (n={len(texts)})', )
plt.theme('dark')
plt.show()

The render only fails under specific conditions. If I run:

docker-compose up - it does not render docker-compose run <app_name> - it does render.

kevroy314 commented 6 months ago

Maybe related stackoverflows? I'm not sure this is an issue at all with this package - it seems to be expected behavior between these two ways of using docker-compose. Might be nice to have a published workaround though.

https://stackoverflow.com/questions/70781537/python-3-app-running-in-docker-compose-will-not-print-using-printtext-end https://stackoverflow.com/questions/33066528/should-i-use-docker-compose-up-or-run