Decode binary-ref answer.
(msg: dict, ref_resolver: abc.Callable)
| 421 | |
| 422 | |
| 423 | def decode_binary_ref(msg: dict, ref_resolver: abc.Callable) -> dict: |
| 424 | """Decode binary-ref answer.""" |
| 425 | |
| 426 | answer = msg['answer'] |
| 427 | if answer['format'] != 'binary-ref': |
| 428 | raise ValueError(f"Unsupported answer format: {answer['format']}") |
| 429 | if 'auth_method' not in answer or 'url' not in answer: |
| 430 | raise ValueError("Incomplete binary-ref answer") |
| 431 | |
| 432 | result = { |
| 433 | 'problem_type': msg['type'], |
| 434 | 'timing': answer.get('timing', {}), |
| 435 | 'shape': answer.get('shape', {}), |
| 436 | 'answer': ref_resolver(auth_method=answer['auth_method'], url=answer['url']) |
| 437 | } |
| 438 | return result |
| 439 | |
| 440 | |
| 441 | def bqm_as_file(bqm, **options): |