cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
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() ?

1 ACCEPTED SOLUTION

Accepted Solutions

Kaniz
Community Manager
Community Manager

Hi @Jordan Foxโ€‹ , Thank you for your detailed explanation.

dbutils.fs.put() is a method in Databricks that allows you to write a file to DBFS (Databricks File System).

DBFS is a distributed file system integrated with Databricks and provides a scalable and reliable way to store and access data.

The dbutils.fs.put takes just three arguments:-

  1. Path - the path of the file to be written to DBFS.
  2. Data - The data to be reported to the file. This can be a string, a byte array, or a file-like object.
  3. Overwrite - A boolean value indicating whether to overwrite the file if it already exists. If set to true, the file will be overwritten; if set to false, an error will be thrown if the file already exists.

It does not take the 4th argument as of now. We will take down your suggestions and update them soon.

imageYou can also submit your suggestion in our "DEAS" portal. The Ideas Portal lets you influence the Databricks product roadmap by providing feedback directly to the product team.

Note:-

If you go directly to ideas.databricks.com and do not have an active Databricks workspace session, you will be prompted to log into Databricks first.

If the sign-in system cannot determine your Databricks workspace, you may be prompted to enter your workspace domain, which has the format <deployment-name>.cloud.databricks.com.

View solution in original post

5 REPLIES 5

Aviral-Bhardwaj
Esteemed Contributor III

what mean by suppress , can you please share code block

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.

Kaniz
Community Manager
Community Manager

Hi @Jordan Foxโ€‹ , Thank you for your detailed explanation.

dbutils.fs.put() is a method in Databricks that allows you to write a file to DBFS (Databricks File System).

DBFS is a distributed file system integrated with Databricks and provides a scalable and reliable way to store and access data.

The dbutils.fs.put takes just three arguments:-

  1. Path - the path of the file to be written to DBFS.
  2. Data - The data to be reported to the file. This can be a string, a byte array, or a file-like object.
  3. Overwrite - A boolean value indicating whether to overwrite the file if it already exists. If set to true, the file will be overwritten; if set to false, an error will be thrown if the file already exists.

It does not take the 4th argument as of now. We will take down your suggestions and update them soon.

imageYou can also submit your suggestion in our "DEAS" portal. The Ideas Portal lets you influence the Databricks product roadmap by providing feedback directly to the product team.

Note:-

If you go directly to ideas.databricks.com and do not have an active Databricks workspace session, you will be prompted to log into Databricks first.

If the sign-in system cannot determine your Databricks workspace, you may be prompted to enter your workspace domain, which has the format <deployment-name>.cloud.databricks.com.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.