(
self, fn_index: int, predictions: List[Any], state: Dict[int, Any]
)
| 894 | return processed_input |
| 895 | |
| 896 | def postprocess_data( |
| 897 | self, fn_index: int, predictions: List[Any], state: Dict[int, Any] |
| 898 | ): |
| 899 | block_fn = self.fns[fn_index] |
| 900 | dependency = self.dependencies[fn_index] |
| 901 | batch = dependency["batch"] |
| 902 | |
| 903 | if type(predictions) is dict and len(predictions) > 0: |
| 904 | predictions = convert_component_dict_to_list( |
| 905 | dependency["outputs"], predictions |
| 906 | ) |
| 907 | |
| 908 | if len(dependency["outputs"]) == 1 and not (batch): |
| 909 | predictions = (predictions,) |
| 910 | |
| 911 | output = [] |
| 912 | for i, output_id in enumerate(dependency["outputs"]): |
| 913 | if predictions[i] is components._Keywords.FINISHED_ITERATING: |
| 914 | output.append(None) |
| 915 | continue |
| 916 | block = self.blocks[output_id] |
| 917 | if getattr(block, "stateful", False): |
| 918 | if not utils.is_update(predictions[i]): |
| 919 | state[output_id] = predictions[i] |
| 920 | output.append(None) |
| 921 | else: |
| 922 | prediction_value = predictions[i] |
| 923 | if utils.is_update(prediction_value): |
| 924 | prediction_value = postprocess_update_dict( |
| 925 | block=block, |
| 926 | update_dict=prediction_value, |
| 927 | postprocess=block_fn.postprocess, |
| 928 | ) |
| 929 | elif block_fn.postprocess: |
| 930 | prediction_value = block.postprocess(prediction_value) |
| 931 | output.append(prediction_value) |
| 932 | return output |
| 933 | |
| 934 | async def process_api( |
| 935 | self, |
no test coverage detected