in source/client/python/api-v0.1/api/in_out_redis.py [0:0]
def __get_to_bytes(self, task_id, postfix):
try:
content = self.redis_cache.get(self.__get_full_key(task_id, postfix))
if content is None:
# cache miss
print('Cache miss for ' + task_id)
if self.bucket:
with (io.BytesIO()) as f_data:
self.bucket.download_fileobj(Key=self.__get_full_key(task_id, postfix), Fileobj=f_data)
data = f_data.getvalue()
if not data:
raise Exception("Can not retrieve from S3 {} ".format(task_id))
self.redis_cache.set(self.__get_full_key(task_id, postfix), data)
return data
else:
raise Exception("Cache miss for {}".format(task_id))
else:
return content
except Exception as e:
print(e)
raise e