Commit 5549a7d6 authored by Tiago Peixoto's avatar Tiago Peixoto

Raise exception if zstandard module is not available

parent a405ceb3
...@@ -2869,7 +2869,7 @@ class Graph(object): ...@@ -2869,7 +2869,7 @@ class Graph(object):
try: try:
cctx = zstandard.ZstdDecompressor() cctx = zstandard.ZstdDecompressor()
except NameError: except NameError:
raise NotImplementedError("zstandard module not installed") raise NotImplementedError("zstandard module not installed, but it's required for decompression")
fctx = contextlib.ExitStack() fctx = contextlib.ExitStack()
f = open(file_name, mode="rb") f = open(file_name, mode="rb")
fctx.enter_context(f) fctx.enter_context(f)
...@@ -2963,7 +2963,7 @@ class Graph(object): ...@@ -2963,7 +2963,7 @@ class Graph(object):
try: try:
cctx = zstandard.ZstdCompressor(level=19) cctx = zstandard.ZstdCompressor(level=19)
except NameError: except NameError:
raise NotImplementedError("zstandard module not installed") raise NotImplementedError("zstandard module not installed, but it's required for compression")
fctx = contextlib.ExitStack() fctx = contextlib.ExitStack()
f = open(file_name, mode="wb") f = open(file_name, mode="wb")
fctx.enter_context(f) fctx.enter_context(f)
......
...@@ -64,7 +64,10 @@ def get_ns_network(k, token=None): ...@@ -64,7 +64,10 @@ def get_ns_network(k, token=None):
url = f"{url_prefix}/net/{k[0]}/files/{k[1]}.gt.zst" url = f"{url_prefix}/net/{k[0]}/files/{k[1]}.gt.zst"
with open_ns_file(url, token) as f: with open_ns_file(url, token) as f:
cctx = zstandard.ZstdDecompressor() try:
cctx = zstandard.ZstdDecompressor()
except NameError:
raise NotImplementedError("zstandard module not installed, but it's required for zstd de-compression")
with cctx.stream_reader(f) as fc: with cctx.stream_reader(f) as fc:
g = load_graph(fc, fmt="gt") g = load_graph(fc, fmt="gt")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment