Skip to content

Commit

Permalink
minor fixes to result attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
kessler-frost committed Dec 13, 2023
1 parent bfecfcd commit 8fed857
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions covalent/_serialize/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ def deserialize_asset(data: bytes, data_type: AssetType) -> Any:
elif data_type == AssetType.JSONABLE:
return json.loads(data.decode("utf-8"))
elif data_type == AssetType.TEXT:
return data.decode("utf-8")
try:
return data.decode("utf-8")
except UnicodeDecodeError:
return cloudpickle.loads(data)
elif data_type == AssetType.BYTES:
return data
else:
Expand Down Expand Up @@ -170,6 +173,9 @@ def load_asset(asset_meta: AssetSchema, data_type: AssetType) -> Any:

path = uri[len(scheme_prefix) :] if uri.startswith(scheme_prefix) else uri

with open(path, "rb") as f:
data = f.read()
try:
with open(path, "rb") as f:
data = f.read()
except FileNotFoundError:
data = "".encode("utf-8")
return deserialize_asset(data, data_type)

0 comments on commit 8fed857

Please sign in to comment.