DataTree.from_dict with file clean-up.
(groups_dict: Mapping[str, Dataset])
| 274 | |
| 275 | |
| 276 | def datatree_from_dict_with_io_cleanup(groups_dict: Mapping[str, Dataset]) -> DataTree: |
| 277 | """DataTree.from_dict with file clean-up.""" |
| 278 | try: |
| 279 | tree = DataTree.from_dict(groups_dict) |
| 280 | except Exception: |
| 281 | for ds in groups_dict.values(): |
| 282 | ds.close() |
| 283 | raise |
| 284 | for path, ds in groups_dict.items(): |
| 285 | tree[path].set_close(ds._close) |
| 286 | return tree |
| 287 | |
| 288 | |
| 289 | def robust_getitem(array, key, catch=Exception, max_retries=6, initial_delay=500): |
no test coverage detected
searching dependent graphs…