<i id='vqXm3'><tr id='vqXm3'><dt id='vqXm3'><q id='vqXm3'><span id='vqXm3'><b id='vqXm3'><form id='vqXm3'><ins id='vqXm3'></ins><ul id='vqXm3'></ul><sub id='vqXm3'></sub></form><legend id='vqXm3'></legend><bdo id='vqXm3'><pre id='vqXm3'><center id='vqXm3'></center></pre></bdo></b><th id='vqXm3'></th></span></q></dt></tr></i><div id='vqXm3'><tfoot id='vqXm3'></tfoot><dl id='vqXm3'><fieldset id='vqXm3'></fieldset></dl></div>

      <small id='vqXm3'></small><noframes id='vqXm3'>

    1. <legend id='vqXm3'><style id='vqXm3'><dir id='vqXm3'><q id='vqXm3'></q></dir></style></legend>
    2. <tfoot id='vqXm3'></tfoot>
        • <bdo id='vqXm3'></bdo><ul id='vqXm3'></ul>
      1. 使用 Google Cloud Storage python 客户端的批处理请求

        Batch request with Google Cloud Storage python client(使用 Google Cloud Storage python 客户端的批处理请求)

        1. <tfoot id='98CBa'></tfoot>

          • <legend id='98CBa'><style id='98CBa'><dir id='98CBa'><q id='98CBa'></q></dir></style></legend>
                <bdo id='98CBa'></bdo><ul id='98CBa'></ul>

                1. <small id='98CBa'></small><noframes id='98CBa'>

                  <i id='98CBa'><tr id='98CBa'><dt id='98CBa'><q id='98CBa'><span id='98CBa'><b id='98CBa'><form id='98CBa'><ins id='98CBa'></ins><ul id='98CBa'></ul><sub id='98CBa'></sub></form><legend id='98CBa'></legend><bdo id='98CBa'><pre id='98CBa'><center id='98CBa'></center></pre></bdo></b><th id='98CBa'></th></span></q></dt></tr></i><div id='98CBa'><tfoot id='98CBa'></tfoot><dl id='98CBa'><fieldset id='98CBa'></fieldset></dl></div>
                    <tbody id='98CBa'></tbody>
                  本文介绍了使用 Google Cloud Storage python 客户端的批处理请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我找不到任何关于如何使用 python 谷歌云存储的批处理功能的示例.我看到它存在 这里.

                  I can't find any examples on how to use the python google cloud storage's batch functionality. I see it exists here.

                  我想要一个具体的例子.假设我想删除一堆具有给定前缀的 blob.我将开始获取 blob 列表,如下所示

                  I'd love a concrete example. Let's say I want to delete a bunch of blobs with a given prefix. I'd start getting the list of blobs as follows

                  from google.cloud import storage
                  
                  storage_client = storage.Client()
                  bucket = storage_client.get_bucket('my_bucket_name')
                  blobs_to_delete = bucket.list_blobs(prefix="my/prefix/here")
                  
                  # how do I delete the blobs in blobs_to_delete in a single batch?
                  
                  # bonus: if I have more than 100 blobs to delete, handle the limitation
                  #        that a batch can only handle 100 operations
                  

                  推荐答案

                  TL;DR - 只需在 batch() 上下文管理器(可用在 google-cloud-python 库中)

                  TL;DR - Just send all the requests within the batch() context manager (available in the google-cloud-python library)

                  试试这个例子:

                  from google.cloud import storage
                  
                  storage_client = storage.Client()
                  bucket = storage_client.get_bucket('my_bucket_name')
                  # Accumulate the iterated results in a list prior to issuing
                  # batch within the context manager
                  blobs_to_delete = [blob for blob in bucket.list_blobs(prefix="my/prefix/here")]
                  
                  # Use the batch context manager to delete all the blobs    
                  with storage_client.batch():
                      for blob in blobs_to_delete:
                          blob.delete()
                  

                  如果您直接使用 REST API,则只需担心每批 100 个项目.batch() 上下文管理器 自动处理此限制,并在需要时发出多个批处理请求.

                  You only need to worry about the 100 items per batch if you're using the REST APIs directly. The batch() context manager automatically takes care of this restriction and will issue multiple batch requests if needed.

                  这篇关于使用 Google Cloud Storage python 客户端的批处理请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Is there a way of group by month in Pandas starting at specific day number?( pandas 有从特定日期开始的按月分组的方式吗?)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  <legend id='d1yZg'><style id='d1yZg'><dir id='d1yZg'><q id='d1yZg'></q></dir></style></legend>
                      <tbody id='d1yZg'></tbody>

                    <tfoot id='d1yZg'></tfoot>

                      <small id='d1yZg'></small><noframes id='d1yZg'>

                      <i id='d1yZg'><tr id='d1yZg'><dt id='d1yZg'><q id='d1yZg'><span id='d1yZg'><b id='d1yZg'><form id='d1yZg'><ins id='d1yZg'></ins><ul id='d1yZg'></ul><sub id='d1yZg'></sub></form><legend id='d1yZg'></legend><bdo id='d1yZg'><pre id='d1yZg'><center id='d1yZg'></center></pre></bdo></b><th id='d1yZg'></th></span></q></dt></tr></i><div id='d1yZg'><tfoot id='d1yZg'></tfoot><dl id='d1yZg'><fieldset id='d1yZg'></fieldset></dl></div>
                            <bdo id='d1yZg'></bdo><ul id='d1yZg'></ul>