Skip to content

Commit 771805a

Browse files
committed
tests: workaround for missing basin feature data
1 parent 0985b6c commit 771805a

1 file changed

Lines changed: 24 additions & 11 deletions

File tree

ckanext/dc_serve/jobs.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
import pathlib
33
import tempfile
4+
import time
45
import traceback
56
import warnings
67

@@ -232,17 +233,29 @@ def _get_intra_dataset_upstream_basins(res_dict, ds) -> list[dict]:
232233
# get the actual features available for this basin
233234
ds_s3_res = s3cc.get_s3_dc_handle(u_rid, "resource")
234235
basin_feats = ds_s3_res.features_innate
235-
try:
236-
ds_s3_con = s3cc.get_s3_dc_handle(u_rid, "condensed")
237-
except BaseException:
238-
logger.warning(
239-
f"Condensed resource {u_rid} not accessible, not "
240-
f"extracting available features for intra-dataset "
241-
f"basin; traceback follows.")
242-
logger.warning(traceback.format_exc())
243-
else:
244-
basin_feats = list(set(
245-
basin_feats + ds_s3_con.features_innate))
236+
for ii in range(10):
237+
# Workaround. I experienced AttributeErrors during
238+
# testing ('S3File' object has no attribute 'seek'),
239+
# possibly due to MinIO not having finalized the
240+
# upload. In this case, simply try again.
241+
try:
242+
ds_s3_con = s3cc.get_s3_dc_handle(u_rid,
243+
"condensed")
244+
except AttributeError:
245+
time.sleep(1)
246+
logger.warning(
247+
f"Workaround for attribute error, try: {ii}")
248+
continue
249+
except BaseException:
250+
logger.warning(
251+
f"Condensed resource {u_rid} not accessible, "
252+
f"not extracting available features for "
253+
f"intra-dataset basin; traceback follows.")
254+
logger.warning(traceback.format_exc())
255+
else:
256+
basin_feats = list(set(
257+
basin_feats + ds_s3_con.features_innate))
258+
break
246259

247260
# Add DCOR basin
248261
u_dcor_url = f"{site_url}/api/3/action/dcserv?id={u_rid}"

0 commit comments

Comments
 (0)