Load the dagger.Module instance via the main object entry point.
()
| 52 | |
| 53 | |
| 54 | def load_module() -> Module: |
| 55 | """Load the dagger.Module instance via the main object entry point.""" |
| 56 | ep = get_entry_point() |
| 57 | try: |
| 58 | cls = ep.load() |
| 59 | except Exception as e: |
| 60 | logger.exception( |
| 61 | "Error while importing Python module '%s' with Dagger functions", |
| 62 | ep.module, |
| 63 | ) |
| 64 | raise ModuleLoadError(str(e)) from e |
| 65 | try: |
| 66 | return cls.__dagger_module__ |
| 67 | except AttributeError: |
| 68 | msg = ( |
| 69 | "The main object must be a class decorated with @dagger.object_type, " |
| 70 | f"found '{type(cls)}'" |
| 71 | ) |
| 72 | raise ModuleLoadError(msg) from None |
| 73 | |
| 74 | |
| 75 | def get_entry_point() -> importlib.metadata.EntryPoint: |
no test coverage detected