Skip to content

Commit

Permalink
Raise an exception when 0-file
Browse files Browse the repository at this point in the history
  • Loading branch information
alexamici committed Mar 23, 2024
1 parent aeb27b9 commit b77b29a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion xarray_ecmwf/client_polytope.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import hashlib
import logging
import os
from typing import Any

import attrs
Expand All @@ -22,5 +23,9 @@ def get_filename(self, result: Any) -> str:
return result["target"] # type: ignore

def download(self, result: Any, target: str | None = None) -> str:
assert target is not None
client = polytope.api.Client(**CLIENT_KWARGS_DEFAULTS | self.client_kwargs)
return client.retrieve("destination-earth", result["request"], target) # type: ignore
client.retrieve("destination-earth", result["request"], target)
if os.stat(target).st_size == 0:
raise TypeError(f"polytope returned an empty file: {target}")
return target

0 comments on commit b77b29a

Please sign in to comment.