Copying large number of files from Google Cloud Storage to Google Colab without logging/printing
Asked Answered
O

1

5

I have a large number of images (.jpg) stored in a Google Cloud Storage that I would like to use in Google Colab.

For this I use (in google Colab)

GCS_PATH = "gs://bucket/prefix"
!gsutil -m cp -r {GCS_PATH} ./data

However when running, Google colab prints each transfer to the cell's output which makes my browser slow. I was wondering if there is a --quiet or --silent flag for gsutil cp. I checked gsutil help cp but couldn't find anything.

Outgrow answered 20/11, 2018 at 11:9 Comment(0)
W
6

If you run gsutil help options, you'll find that it has a top-level -q flag that should do what you're wanting:

-q          Causes gsutil to perform operations quietly, i.e., without
            reporting progress indicators of files being copied or removed,
            etc. Errors are still reported. This option can be useful for
            running gsutil from a cron job that logs its output to a file, for
            which the only information desired in the log is failures.

And if you want absolutely no output ever, you can always redirect stdout and stderr to a separate file (e.g. on most *nix systems, this looks like somecommand >/dev/null 2>&1, but I'm not sure off the top of my head what files/devices Colab gives you write access to).

Whomp answered 20/11, 2018 at 22:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.