(self)
| 55 | attr_name = '_lazy_' + fn.__name__ |
| 56 | |
| 57 | def _get_data_loader(self): |
| 58 | try: |
| 59 | value = getattr(self, attr_name) |
| 60 | except AttributeError: |
| 61 | try: |
| 62 | value = fn(self) # Lazy evaluation, done only once. |
| 63 | if ( |
| 64 | value is not None and |
| 65 | not isinstance(value, list) and |
| 66 | fn.__name__ in ['test_dataloader', 'val_dataloader'] |
| 67 | ): |
| 68 | value = [value] |
| 69 | except AttributeError as e: |
| 70 | # Guard against AttributeError suppression. (Issue #142) |
| 71 | traceback.print_exc() |
| 72 | error = f'{fn.__name__}: An AttributeError was encountered: ' + str(e) |
| 73 | raise RuntimeError(error) from e |
| 74 | setattr(self, attr_name, value) # Memoize evaluation. |
| 75 | return value |
| 76 | |
| 77 | return _get_data_loader |
| 78 |
nothing calls this directly
no outgoing calls
no test coverage detected