|
1 | 1 | import logging |
2 | 2 | import pathlib |
3 | 3 | import tempfile |
| 4 | +import time |
4 | 5 | import traceback |
5 | 6 | import warnings |
6 | 7 |
|
@@ -232,17 +233,29 @@ def _get_intra_dataset_upstream_basins(res_dict, ds) -> list[dict]: |
232 | 233 | # get the actual features available for this basin |
233 | 234 | ds_s3_res = s3cc.get_s3_dc_handle(u_rid, "resource") |
234 | 235 | 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 |
246 | 259 |
|
247 | 260 | # Add DCOR basin |
248 | 261 | u_dcor_url = f"{site_url}/api/3/action/dcserv?id={u_rid}" |
|
0 commit comments