cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Disable dbutils.fs.put() write to console "Wrote x bytes"

Jfoxyyc
Valued Contributor

Hey all, does anyone know how to suppress the output of dbutils.fs.put() ?

4 REPLIES 4

Aviral-Bhardwaj
Esteemed Contributor III

what mean by suppress , can you please share code block

AviralBhardwaj

Jfoxyyc
Valued Contributor

write dbutils.fs.put('abfs://some_address_to_some_abfs_location_you_have/helloworld.txt','Hello World',True) and notice that it outputs "Wrote X bytes." to the console stdout. I don't want "Wrote X bytes" to be written to the console.

You can suppress dbutils.fs.put()'s output by setting sys.stdout = open("/dev/null","w") and just writing it out somewhere useless, but this doesn't work in a threaded application.

I could suppress the output by getting rid of sys.stdout like above, and then use logging, and write warnings, but I'd rather not have a warning written as I'm using warnings and errors for other purposes.image.png

Anonymous
Not applicable

Hi @Jordan Fox​ 

Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help. 

We'd love to hear from you.

Thanks!

Jfoxyyc
Valued Contributor

No, have not resolved the issue. Still Wrote 105783245 bytes. If dbutils.fs.put(), which is:

put(file: String, contents: String, overwrite: boolean = false): boolean -> Writes the given String out to a file, encoded in UTF-8

Could instead be:

put(file: String, contents: String, overwrite: boolean = false, verbose: boolean = true): boolean -> Writes the given String out to a file, encoded in UTF-8, defaults message to stdout unless verbose=false

That would be great.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group