Comments (16)
Seems like probably an issue regarding how TF tells whether RStudio is an interactive environment. https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/platform/tf_logging.py#L55
Perhaps we can also have a function for capturing standard error which is where logs in non-interactive environment go to.
from reticulate.
Yes, py_capture_output
only captures output. We do however already have some hooks to interact with the TF logging system (we use them in py_suppress_warnings
. If you let me know exactly the behavior you want here (perhaps with a simple repro) I can make some combination of py_capture_output
and py_suppress_warnings
make it happen.
from reticulate.
Oh I see. Yea I am expecting the following as part of the output:
INFO:tensorflow:Create CheckpointSaverHook.
INFO:tensorflow:Saving checkpoints for 2 into /var/folders/ln/c7r_x26x46b7vzpftbfh64zc0000gp/T//RtmpbD66eR/tflearn_a32c5e4d2404/model.ckpt.
INFO:tensorflow:loss = 438.822, step = 2
INFO:tensorflow:global_step = 2
INFO:tensorflow:global_step = 6 (0.016 sec)
INFO:tensorflow:global_step = 10 (0.002 sec)
from reticulate.
I think the problem may be here:
You can that TF is trying to determine whether the session is interactive. In the case that it is it will pipe output to stdout (which we could then capture) however in the case where it's not it sends it to stderr. That relies on the state of sys.flags.interactive
which we maybe able to set by passing the correct command line flag to startup.
from reticulate.
Okay, the function is now renamed py_capture_output
. By default it captures both stdout and stderr but it can be configured to capture just one or the other:
This should get you what you are looking for, let me know if it doesn't.
from reticulate.
Thanks, will try!
from reticulate.
Closing this. Feel free to re-open if you have additional issues.
from reticulate.
Just gave it a try. Still looks like not able to capture those output. Not a blocker though.
from reticulate.
from reticulate.
Here it is:
> output <- reticulate::py_capture_output(tf$logging$warn("asdf"))
WARNING:tensorflow:asdf
> output
[1] ""
from reticulate.
Interesting, for me this actually successfully captures the output! Here's my exact code as executed (I think it's the same):
library(tensorflow)
output <- reticulate::py_capture_output(tf$logging$warn("asdf"))
Are you certain you've upgraded to the latest versions of tensorflow and reticulate?
from reticulate.
Yes, I've removed all packages and reinstalled everything. Otherwise py_capture_output
won't be available in old versions.
from reticulate.
from reticulate.
Okay apologize that I didn't clean up my environment properly. That one worked as expected. However, here's what's weird:
> library(tensorflow)
> tf$logging$get_verbosity()
[1] 30
> tf$logging$WARN
[1] 30
> tf$logging$set_verbosity(tf$logging$INFO)
> tf$logging$get_verbosity()
[1] 20
> output <- reticulate::py_capture_output(tf$logging$info("asdf"))
INFO:tensorflow:asdf
> output
[1] ""
Verbosity is set to info correctly but the output is not captured.
Could you try if you can reproduce it?
from reticulate.
It looks to me like the INFO stream is bypassing stderr. If I write this then the output is correctly captured:
output <- reticulate::py_capture_output({
sys <- import("sys")
sys$stderr$write("foo")
})
Are you just trying to prevent INFO messages from being printed at all? If so we could do something like we do for py_suppress_warnings
:
https://github.com/rstudio/tensorflow/blob/master/R/package.R#L35-L45
from reticulate.
I am trying to capture a regex in the output. But it's not super important. I think this is an issue on the Python API end. I'll reopen if this turns out to be very critical.
from reticulate.
Related Issues (20)
- Support `results = 'hide'` directly in python engine HOT 2
- Interrupting keras training reliably produces a segfault HOT 5
- FR: R Print method for Python callables should show signature HOT 1
- Installing miniconda on Raspberry Pi HOT 2
- Release reticulate 1.37.0
- Custom conversion function no longer works with reticulate >= 1.36.0 HOT 4
- Convert NumPy recarray directly to R data.frame
- Need to reinstall reticulate whenever I want to access arcpy HOT 4
- Timeout when calling Async python function HOT 1
- Corrupt dataframe when converting from pandas to R HOT 5
- Release reticulate 1.38.0 HOT 1
- Reticulate 1.38.0 for R 4.2.1 can install but not import numpy, ... HOT 5
- Error in reticulate::use_python(): failed to initialize requested version of Python HOT 2
- Namespace conflict with python config package HOT 1
- Python variables sourced via `reticulate::source_python()` are not contained within `py` list HOT 6
- Reticulate does not play nice with Rich progressbars HOT 1
- R Studio Global Options Conflict with `use_virtualenv()` embedded in `.onLoad()` HOT 1
- Converting a python datatype using mutate in dplyr HOT 6
- Feature request: export `conda_run2` HOT 3
- Extracting data from Google Earth Engine HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reticulate.