def poll_layer_publishing(ctx, asset_id):
  @retries((180 * 60) / 10, delay=30, backoff=1)
  def poll(ctx, asset_id):
    response = ctx.service().layers().get(id=asset_id).execute()
    if response['publishingStatus'] == 'published':
      return response
    else:
      raise Exception("Layer publishing status is '%s'" % (response["publishingStatus"]))

  start_time = time.time()
  response = poll(ctx, asset_id)
  ctx.log("Publishing complete (%s mins)" % (round((time.time() - start_time) / 60, 2)))
  return response
Poll a given layer until its publishing stage has completed.
dataset/ETHPy150Open keithmoss/Hodor/hodor/gme.py/poll_layer_publishing