Skip to content

Commit

Permalink
Fix tests by allowing missing system:time_start IF wx:coordinate is a…
Browse files Browse the repository at this point in the history
…lready set
  • Loading branch information
aazuspan committed Aug 27, 2022
1 parent 7c44741 commit a5cdaf5
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions wxee/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,16 @@ def _get_download_id(self) -> ee.String:
"""
img = self._obj

original_id = _replace_if_null(img.get("system:id"), "null")
# Replace any invalid file path characters with underscores.
cleaned_id = ee.String(original_id).replace("([^a-z0-9]+)", "_", "gi")

date = _format_date(ee.Image(img).get("system:time_start"))
dimension = _replace_if_null(img.get("wx:dimension"), "time")
coordinate = _replace_if_null(img.get("wx:coordinate"), date)

try:
date = _format_date(ee.Image(img).get("system:time_start")).getInfo()
coordinate = coordinate.getInfo()
except ee.EEException as e:
if "Parameter 'value' is required" in str(e):
raise MissingPropertyError(
Expand All @@ -271,13 +279,6 @@ def _get_download_id(self) -> ee.String:
else:
raise e

original_id = _replace_if_null(img.get("system:id"), "null")
# Replace any invalid file path characters with underscores.
cleaned_id = ee.String(original_id).replace("([^a-z0-9]+)", "_", "gi")

dimension = _replace_if_null(img.get("wx:dimension"), "time")
coordinate = _replace_if_null(img.get("wx:coordinate"), date)

return ee.List([cleaned_id, dimension, coordinate]).join(".")

def _prefix_id(self, prefix: str) -> ee.Image:
Expand Down

0 comments on commit a5cdaf5

Please sign in to comment.