Retrieve binary-ref answer data.
(self,
answer: models.UnstructuredProblemAnswerBinaryRef,
output: Optional[io.IOBase] = None,
)
| 290 | |
| 291 | @accepts(media_type='application/octet-stream') |
| 292 | def get_answer_data(self, |
| 293 | answer: models.UnstructuredProblemAnswerBinaryRef, |
| 294 | output: Optional[io.IOBase] = None, |
| 295 | ) -> io.IOBase: |
| 296 | """Retrieve binary-ref answer data.""" |
| 297 | if answer.auth_method != constants.BinaryRefAuthMethod.SAPI_TOKEN: |
| 298 | raise ValueError(f"Authentication method {answer.auth_method!r} not supported.") |
| 299 | |
| 300 | if output is None: |
| 301 | output = io.BytesIO() |
| 302 | |
| 303 | for chunk in self.session.get(answer.url, stream=True).iter_content(chunk_size=8192): |
| 304 | output.write(chunk) |
| 305 | |
| 306 | output.seek(0) |
| 307 | |
| 308 | return output |
| 309 | |
| 310 | @accepts(media_type='application/vnd.dwave.sapi.problem-message+json', |
| 311 | version='>=2.1,<4', ask_version='3.0.0') |