TransformationError原因get_serving_url / Images API [英] TransformationError Reasons get_serving_url / Images API

查看:151
本文介绍了TransformationError原因get_serving_url / Images API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  Traceback(最新版本)调用最后一个):
文件/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py,第570行,发送
返回方法( * args,** kwargs)
文件/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py,第1087行,在synctasklet_wrapper
return taskletfunc(* args,** kwds).get_result()
文件/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py ,第1057行,在tasklet_wrapper
result = func(* args,** kwds)
文件/base/data/home/apps/e~tileserve20171207t210519.406056180994857717/blob_upload.py,第70行,在后
bf.put_async()
文件/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/model.py,第3473行,在_put_async
self._pre_put_ho ok()
文件/base/data/home/apps/e~tileserve/20171207t210519.406056180994857717/blob_files.py,第124行,在_pre_put_hook
中打印images.get_serving_url(None,filename =' / gs'+'/tileserve.appspot.com/user2test4test4RGB20170927.tif')
文件/ base / data / home / runtimes / python27 / python27_lib / versions / 1 / google / appengine / api / images / __ init__。 py,第1868行,在get_serving_url
返回rpc.get_result()
文件/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py ,line 613,in get_result
return self .__ get_result_hook(self)
文件/ base / data / home / runtimes / python27 / python27_lib / versions / 1 / google / appengine / api / images / __ init__ .py,第1972行,in get_serving_url_hook
raise _ToImagesError(e,readable_blob_key)
TransformationError

当我将图片上传到我的存储桶时,它可以工作,但是当我通过处理创建图像时,应通过get_s erving_url我得到了TransformationError。



我尝试了两种服务图片变体:

  test = blobstore.create_gs_key('/ gs'+'/ path2object')
images.get_serving_url(test,secure_url = True)

images.get_serving_url(None,filename ='/ gs'+'/'+< bucket name> +'/'+< object name>)

我还设置了存储桶对象ACM权限和IAM App Engine应用默认服务帐户权限(存储管理员)。这两个变体都没有改变,但是为了访问桶的对象是很重要的。



有人遇到过这个问题吗?什么可能是错误?我不明白为什么它在我上传图片时起作用,但不能处理通过处理生成的图片。

解决方案

回溯表明您可能正尝试调用 images.get_serving_url()异步操作可能仍在进行中。如果该操作实际上是将转换后的图像保存在GCS中,那么它可以解释失败: get_serving_url() include 检查文件是否为有效图像,如果文件尚未保存,则该文件将失败并显示 TransformationError



如果是这样 - 您可以通过以下两种方式解决问题:


  • 切换到保存图像的同步版本

  • 等待保存图像完成(如果在此期间还有其他工作要做) - 在调用<$之前获取同步调用的结果c $ c> get_serving_url()

  • 在捕获 get_serving_url() > TransformationError ,直到它不再以这种方式失败。如果 TransformationError 由于保存图像不完整等原因而被引发,则这会有点冒险,因为它可能会在无限循环中结束。


I'm running into the following error using get_serving_url in order to serve images from my bucket.

Traceback (most recent call last):
 File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
   return method(*args, **kwargs)
 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1087, in synctasklet_wrapper
   return taskletfunc(*args, **kwds).get_result()
 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1057, in tasklet_wrapper
   result = func(*args, **kwds)
 File "/base/data/home/apps/e~tileserve20171207t210519.406056180994857717/blob_upload.py", line 70, in post
   bf.put_async()
 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/model.py", line 3473, in _put_async
   self._pre_put_hook()
 File "/base/data/home/apps/e~tileserve/20171207t210519.406056180994857717/blob_files.py", line 124, in _pre_put_hook
   print images.get_serving_url(None, filename='/gs' + '/tileserve.appspot.com/user2test4test4RGB20170927.tif')
 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/images/__init__.py", line 1868, in get_serving_url
   return rpc.get_result()
 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 613, in get_result
   return self.__get_result_hook(self)
 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/images/__init__.py", line 1972, in get_serving_url_hook
   raise _ToImagesError(e, readable_blob_key)
 TransformationError

When I upload an image to my bucket then it works but when I create an image through processing which should be exposed through get_serving_url I get TransformationError.

I tried two variants for serving images:

test = blobstore.create_gs_key('/gs' + '/path2object')
images.get_serving_url(test, secure_url=True)

images.get_serving_url(None, filename='/gs' + '/' + <bucket name>+  '/'+ <object name>)

I also set the bucket object ACM permissions and the IAM App Engine app default service account permissions (storage admin). Both variants changed nothing but are important in order to access objects of a bucket.

Did somebody experience this issue ? What could be the error? I do not understand why it works when I upload an image but not for images which are generated through processing.

解决方案

The traceback suggests you may be trying to call images.get_serving_url() while an async operation may still be in progress.

If that op is actually saving the transformed image in GCS then it could explain the failure: get_serving_url() includes a check of the file being a valid image, which would fail with TransformationError if the file is not yet saved.

If so - you can fix the problem by either:

  • switching to the sync version of saving the image
  • waiting until saving the image completes (in case you have some other stuff to do in the meantime) - get the result of the sync call before invoking get_serving_url()
  • repeatedly trying get_serving_url() while catching TransformationError until it no longer fails that way. This is a bit risky as it can end up in an infinite loop if TransformationError is raised for reasons other than simply saving the image being incomplete.

这篇关于TransformationError原因get_serving_url / Images API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆