Subprocess logs

Hello! I have a number of R scripts that get run as part of my ETLs. I run them using a really simple deployment that is just a wrapper for["Rscript", "myscript.R"]). This is working really well, the only problem being that the print logs come through with a lot of special characters:

All I’m doing is log_prints=True. Is there something else you recommend to clean up these logs?

hi @1beb

I’m not certain why this would be happening, is it possible that your output from the R script is in a different encoding?

It might be worth checking the encoding the R script’s stdout.

log_prints should only be patching the builtin python print function so that they are sent to the Prefect logger, which shouldnt directly affect your R output unless you’re printing it with print

Yes, I think you’re right. Thanks @nate. Your recommendation led to a fix. Basically the stderr/stdout buffer was encoded. All I had to do was .decode() and I get much nice prefect logs now.


1 Like