Get function result as an unstructured Python primitive.
(
self,
parent_name: str,
parent_state: Mapping[str, Any],
name: str,
raw_inputs: Mapping[str, Any],
)
| 346 | return result |
| 347 | |
| 348 | async def get_result( |
| 349 | self, |
| 350 | parent_name: str, |
| 351 | parent_state: Mapping[str, Any], |
| 352 | name: str, |
| 353 | raw_inputs: Mapping[str, Any], |
| 354 | ) -> Any: |
| 355 | """Get function result as an unstructured Python primitive.""" |
| 356 | result, fn = await self.get_structured_result( |
| 357 | parent_name, |
| 358 | parent_state, |
| 359 | name, |
| 360 | raw_inputs, |
| 361 | ) |
| 362 | if fn.return_type is not None: |
| 363 | try: |
| 364 | return await self.unstructure(result, fn.return_type) |
| 365 | except Exception as e: |
| 366 | log_exception_only(e, "Invalid result from function") |
| 367 | msg = transform_error( |
| 368 | e, |
| 369 | origin=getattr(fn, "wrapped", None), |
| 370 | typ=fn.return_type, |
| 371 | ) |
| 372 | msg += ( |
| 373 | "\n" |
| 374 | "Please check if the returned value at runtime matches " |
| 375 | "the function's declared return type." |
| 376 | ) |
| 377 | raise InvalidResultError(msg) from e |
| 378 | return None |
| 379 | |
| 380 | async def get_structured_result( |
| 381 | self, |