(self)
| 87 | return self.main_cls is other.cls |
| 88 | |
| 89 | async def serve(self): |
| 90 | if await dag.current_function_call().parent_name(): |
| 91 | result = await self.invoke() |
| 92 | else: |
| 93 | try: |
| 94 | result = await self._typedefs() |
| 95 | except TypeError as e: |
| 96 | raise RegistrationError(str(e)) from e |
| 97 | |
| 98 | try: |
| 99 | output = json.dumps(result) |
| 100 | except (TypeError, ValueError) as e: |
| 101 | # Not expected to happen because unstructuring should reduce |
| 102 | # Python complex types to primitive values that are easily |
| 103 | # serialized to JSON. If not, it's something that should be caught |
| 104 | # earlier. |
| 105 | msg = f"Failed to serialize final result as JSON: {e}" |
| 106 | raise InvalidResultError(msg) from e |
| 107 | |
| 108 | if logger.isEnabledFor(logging.DEBUG): |
| 109 | logger.debug( |
| 110 | "output => %s", |
| 111 | textwrap.shorten(repr(output), 144), |
| 112 | ) |
| 113 | |
| 114 | await dag.current_function_call().return_value(dagger.JSON(output)) |
| 115 | |
| 116 | async def register(self): |
| 117 | """Register the module and its types with the Dagger API.""" |
no test coverage detected