(task, data)
| 139 | |
| 140 | |
| 141 | def service_data_decoder(task, data): |
| 142 | if CustomDecoder.get(task) is not None: |
| 143 | return CustomDecoder[task](data) |
| 144 | input_data = data.decode('utf-8') |
| 145 | input_type = TASK_INPUTS[task] |
| 146 | if isinstance(input_type, list): |
| 147 | input_type = input_type[0] |
| 148 | if input_type == InputType.IMAGE: |
| 149 | return decode_base64_to_image(input_data) |
| 150 | elif input_type == InputType.AUDIO: |
| 151 | return decode_base64_to_binary(input_data)[0] |
| 152 | elif input_type == InputType.TEXT: |
| 153 | return input_data |
| 154 | elif isinstance(input_type, dict): |
| 155 | input_data = {} |
| 156 | data = json.loads(data) |
| 157 | for key, val in input_type.items(): |
| 158 | if val == InputType.IMAGE: |
| 159 | input_data[key] = decode_base64_to_image(data[key]) |
| 160 | elif val == InputType.AUDIO: |
| 161 | input_data[key] = decode_base64_to_binary(data[key])[0] |
| 162 | elif val == InputType.TEXT: |
| 163 | input_data[key] = data[key] |
| 164 | else: |
| 165 | return data |
| 166 | |
| 167 | return input_data |
| 168 | |
| 169 | |
| 170 | def service_data_encoder(task, data): |
nothing calls this directly
no test coverage detected
searching dependent graphs…