Skip to content

Commit 33e5382

Browse files
author
Saul Frank
committed
Update pandas_redis_store.py
1 parent 3716e4b commit 33e5382

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/dataplane/pipelinerun/data_persist/pandas_redis_store.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ def RedisCheck(r):
1616
DataFrame: Pandas dataframe to pass
1717
Expire: Expires the data if true.
1818
ExpireDuration: If expires is true, how much time to expire. Default 15 mins
19+
Compression: "gzip", "bz2", 'zstd', 'tar', "zip", None
1920
"""
20-
def pipeline_pandas_redis_store(StoreKey, DataFrame, Redis, Expire=True, ExpireDuration=timedelta(minutes=15)):
21+
def pipeline_pandas_redis_store(StoreKey, DataFrame, Redis, Expire=True, ExpireDuration=timedelta(minutes=15), Compression="gzip"):
2122

2223
import os
2324
import io
@@ -33,7 +34,7 @@ def pipeline_pandas_redis_store(StoreKey, DataFrame, Redis, Expire=True, ExpireD
3334
raise Exception("Redis connection failed.")
3435

3536
buffer = io.BytesIO()
36-
DataFrame.to_pickle(buffer, compression='gzip')
37+
DataFrame.to_pickle(buffer, compression=Compression)
3738
buffer.seek(0) # re-set the pointer to the beginning after reading
3839

3940
if Expire:
@@ -50,7 +51,7 @@ def pipeline_pandas_redis_store(StoreKey, DataFrame, Redis, Expire=True, ExpireD
5051
StoreKey: is the key to look up for retrieval (set with RedisStore).
5152
Redis: e.g. Redis = redis.Redis(host='redis-service', port=6379, db=0)
5253
"""
53-
def pipeline_pandas_redis_get(StoreKey, Redis):
54+
def pipeline_pandas_redis_get(StoreKey, Redis, Compression="gzip"):
5455

5556
import os
5657
import io
@@ -69,7 +70,7 @@ def pipeline_pandas_redis_get(StoreKey, Redis):
6970
buffer = io.BytesIO(Redis.get(InsertKey))
7071
buffer.seek(0)
7172
import pandas as pd
72-
df = pd.read_pickle(buffer,compression='gzip')
73+
df = pd.read_pickle(buffer,compression=Compression)
7374

7475
duration = datetime.now() - start
7576

0 commit comments

Comments
 (0)