def dump(self, object, name): ''' dump(object, name) ''' s = encode(object) if s: s = b64encode(s) self.redis.set(_resultname(name), s)
def dump(self, obj, name): ''' dump(object, name) ''' s = encode(obj) sblob = self.bucket.blob(self.storage_key(name)) sblob.upload_from_string(s, content_type=None) self.redis.set(self.redis_result_key(name), self.storage_key(name))
def test_decompress_stream_seek(): s = encode(range(33)) st = decompress_stream(StringIO(s)) first = st.read(6) st.seek(-6, 1) second = st.read(6) assert first == second st = decompress_stream(StringIO(s)) first = st.read(6) st.seek(-6, 1) second = st.read(8) assert first == second[:6]
def test_decompress_stream_seek(): s = encode(list(range(33))) st = decompress_stream(BytesIO(s)) first = st.read(6) st.seek(-6, 1) second = st.read(6) assert first == second st = decompress_stream(BytesIO(s)) first = st.read(6) st.seek(-6, 1) second = st.read(8) assert first == second[:6] st = decompress_stream(BytesIO(s)) st.seek(6, 1) st.seek(-6, 1) second = st.read(8) assert first == second[:6]
def test_encode(): assert decode(encode(None)) is None assert decode(encode([])) == [] assert decode(encode(list(range(33)))) == list(range(33))
def test_numpy_derived(): a = Derived([1, 2, 3]) assert type(decode(encode(a))) == type(a)
def test_numpy(): assert np.all(decode(encode(np.arange(33))) == np.arange(33))
def test_encode(): assert decode(encode(None)) is None assert decode(encode([])) == [] assert decode(encode(range(33))) == range(33)
def test_numpy_derived(): a = Derived([1,2,3]) assert type(decode(encode(a))) == type(a)
def test_numpy(): assert np.all(decode(encode(np.arange(33))) == np.arange(33)) x = decode(encode({'res': np.arange(1024 * 1024)})) assert np.all(x['res'] == np.arange(1024 * 1024))
def test_encode(): assert decode(encode(None)) is None assert decode(encode([])) == [] assert decode(encode(range(33))) == range(33) assert np.all(decode(encode(np.arange(33))) == np.arange(33))