MCPcopy Create free account
hub / github.com/dwavesystems/dwave-cloud-client / _load_result

Method _load_result

dwave/cloud/computation.py:921–954  ·  view source on GitHub ↗

Get the result, waiting and decoding as needed.

(self)

Source from the content-addressed store, hash-verified

919 return self._result[key]
920
921 def _load_result(self):
922 """Get the result, waiting and decoding as needed."""
923 if self._result is None:
924 # Wait for the query response
925 self.wait(timeout=None)
926
927 # Check for other error conditions
928 if self._exception is not None:
929 raise self._exception
930
931 with self._result_write_lock:
932 # If someone else took care of decoding while we were waiting
933 if self._result is not None:
934 return self._result
935
936 # extract results from the response
937 # note: decoding might mutate `self._message`, so it should be only called once
938 self._decode()
939
940 # signal answer data downloaded
941 if 'answer' in self._result:
942 self._answer_data_ready_event.set()
943
944 # create a direct reference to sampleset if already available in response
945 # NB: in this case we don't actually need a weakref (strong ref is fine),
946 # but we use it for consistency
947 if 'sampleset' in self._result:
948 # add common problem info
949 sampleset = self._result['sampleset']
950 sampleset.info.update(self._get_problem_info())
951
952 self._sampleset = weakref.ref(sampleset)
953
954 return self._result
955
956 def _get_problem_info(self):
957 """Return problem metadata (id, label) to be included in `sampleset.info`."""

Callers 3

resultMethod · 0.95
wait_samplesetMethod · 0.95
__getitem__Method · 0.95

Calls 4

waitMethod · 0.95
_decodeMethod · 0.95
_get_problem_infoMethod · 0.95
setMethod · 0.80

Tested by

no test coverage detected