Rut*_*ste 4 python gsutil gcloud google-colaboratory
我在 Google Cloud Storage 中存储了大量图像 (.jpg),我想在 Google Colab 中使用它们。
为此我使用(在谷歌Colab中)
GCS_PATH = "gs://bucket/prefix"
!gsutil -m cp -r {GCS_PATH} ./data
Run Code Online (Sandbox Code Playgroud)
然而,在运行时,Google colab 会将每次传输打印到单元格的输出,这使我的浏览器变慢。我想知道 gsutil cp 是否有 --quiet 或 --silent 标志。我检查了gsutil help cp但找不到任何东西。
如果您运行gsutil help options,您会发现它有一个顶级-q标志,应该可以执行您想要的操作:
-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.
Run Code Online (Sandbox Code Playgroud)
如果你想要绝对没有输出,你总是可以将 stdout 和 stderr 重定向到一个单独的文件(例如,在大多数 *nix 系统上,这看起来像somecommand >/dev/null 2>&1,但我不确定 Colab 提供了什么文件/设备您写入访问权限)。