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

capture / silence julia initialization in stdout #507

Closed
alexschroeter opened this issue May 31, 2024 · 2 comments
Closed

capture / silence julia initialization in stdout #507

alexschroeter opened this issue May 31, 2024 · 2 comments
Labels
question Further information is requested

Comments

@alexschroeter
Copy link

alexschroeter commented May 31, 2024

Hello,

I am trying to run a julia program inside python with juliacall and use the stdout. I am having a bit of trouble because stdout is polluted by me running from juliacall import Main as jl and I was wondering if there is a way to capture or silence this output.

Cheers,
Alex

@alexschroeter alexschroeter added the question Further information is requested label May 31, 2024
@alexschroeter alexschroeter changed the title capture stdout capture / silence julia initialization in stdout May 31, 2024
@cjdoris
Copy link
Collaborator

cjdoris commented Jun 1, 2024

If you're referring to the logging that happens when dependencies are resolved, then I'm afraid there is no way to turn those off currently.

For generic capturing of stdout, see https://www.devdungeon.com/content/python-use-stringio-capture-stdout-and-stderr

I can't really help without more specifics of what you're doing (ideally give a MWE).

@alexschroeter
Copy link
Author

alexschroeter commented Jun 5, 2024

Thank you for the quick reply. I was able to work around the issue as soon as I understood a bit more what was happening.

The part I left out in my post because I didn't consider it part of the issue was that I was running this in a docker container. As you correctly identified, I was referring to the dependency resolution (or is there more happening?). What I didn't realize because I am in a container is that this usually only happens once, so after adding RUN python3 -c "from juliacall import Main as jl to the container build, the dependencies are not checked every time I run but at container build.

This stops the stdout from being polluted, and I can read from it and process the output as I intended.

I am happy with my solution, so I am closing the issue, but if you are looking for a feature request it would be disabling the output of the dependency resolution by some environment variable or whatever you consider a good mechanism.

I also noticed that the first execution of my function takes longer (my interpretation is that this is because of the compilation of the function) and I was wondering if there is a recommendation on how to provide precompiled functions in docker?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants