dwave-cloud-client 0.13.4__tar.gz → 0.13.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/PKG-INFO +1 -1
  2. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/api/client.py +65 -18
  3. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/cli.py +9 -4
  4. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/client/base.py +16 -2
  5. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/computation.py +19 -0
  6. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/package_info.py +1 -1
  7. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/solver.py +13 -6
  8. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/utils/http.py +26 -5
  9. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave_cloud_client.egg-info/PKG-INFO +1 -1
  10. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave_cloud_client.egg-info/SOURCES.txt +0 -1
  11. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/setup.py +2 -2
  12. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_cli.py +49 -39
  13. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_mock_submission.py +84 -1
  14. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_mock_unstructured_submission.py +24 -15
  15. dwave_cloud_client-0.13.4/dwave/__init__.py +0 -16
  16. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/LICENSE +0 -0
  17. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/README.rst +0 -0
  18. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/__init__.py +0 -0
  19. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/api/__init__.py +0 -0
  20. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/api/constants.py +0 -0
  21. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/api/exceptions.py +0 -0
  22. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/api/models.py +0 -0
  23. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/api/resources.py +0 -0
  24. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/auth/__init__.py +0 -0
  25. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/auth/_creds.py +0 -0
  26. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/auth/config.py +0 -0
  27. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/auth/creds.py +0 -0
  28. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/auth/flows.py +0 -0
  29. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/auth/server.py +0 -0
  30. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/client/__init__.py +0 -0
  31. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/client/hybrid.py +0 -0
  32. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/client/qpu.py +0 -0
  33. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/client/sw.py +0 -0
  34. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/coders.py +0 -0
  35. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/concurrency.py +0 -0
  36. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/config/__init__.py +0 -0
  37. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/config/constants.py +0 -0
  38. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/config/exceptions.py +0 -0
  39. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/config/loaders.py +0 -0
  40. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/config/models.py +0 -0
  41. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/events.py +0 -0
  42. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/exceptions.py +0 -0
  43. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/regions.py +0 -0
  44. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/testing/__init__.py +0 -0
  45. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/testing/mocks.py +0 -0
  46. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/upload.py +0 -0
  47. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/utils/__init__.py +0 -0
  48. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/utils/cli.py +0 -0
  49. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/utils/coders.py +0 -0
  50. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/utils/decorators.py +0 -0
  51. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/utils/dist.py +0 -0
  52. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/utils/exception.py +0 -0
  53. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/utils/logging.py +0 -0
  54. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/utils/qubo.py +0 -0
  55. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave/cloud/utils/time.py +0 -0
  56. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave_cloud_client.egg-info/dependency_links.txt +0 -0
  57. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave_cloud_client.egg-info/entry_points.txt +0 -0
  58. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave_cloud_client.egg-info/not-zip-safe +0 -0
  59. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave_cloud_client.egg-info/requires.txt +0 -0
  60. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/dwave_cloud_client.egg-info/top_level.txt +0 -0
  61. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/pyproject.toml +0 -0
  62. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/setup.cfg +0 -0
  63. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_client.py +0 -0
  64. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_coders.py +0 -0
  65. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_concurrency.py +0 -0
  66. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_config.py +0 -0
  67. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_events.py +0 -0
  68. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_exceptions.py +0 -0
  69. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_mock_solver_loading.py +0 -0
  70. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_regions.py +0 -0
  71. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_solver.py +0 -0
  72. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_solver_utils.py +0 -0
  73. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_testing.py +0 -0
  74. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_upload.py +0 -0
  75. {dwave_cloud_client-0.13.4 → dwave_cloud_client-0.13.6}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dwave-cloud-client
3
- Version: 0.13.4
3
+ Version: 0.13.6
4
4
  Summary: A minimal client for interacting with D-Wave cloud resources.
5
5
  Home-page: https://github.com/dwavesystems/dwave-cloud-client
6
6
  Author: D-Wave Systems Inc.
@@ -34,7 +34,7 @@ from packaging.specifiers import SpecifierSet
34
34
  import dwave.cloud.config
35
35
  from dwave.cloud.api import exceptions
36
36
  from dwave.cloud.utils.exception import is_caused_by
37
- from dwave.cloud.utils.http import PretimedHTTPAdapter, BaseUrlSession, default_user_agent
37
+ from dwave.cloud.utils.http import PretimedHTTPAdapter, BaseUrlSessionMixin, default_user_agent
38
38
  from dwave.cloud.utils.time import epochnow
39
39
 
40
40
  if TYPE_CHECKING:
@@ -45,7 +45,7 @@ __all__ = ['DWaveAPIClient', 'SolverAPIClient', 'MetadataAPIClient', 'LeapAPICli
45
45
  logger = logging.getLogger(__name__)
46
46
 
47
47
 
48
- class LoggingSession(BaseUrlSession):
48
+ class LoggingSessionMixin:
49
49
  """:class:`.BaseUrlSession` extended to unify timeout exceptions and to log
50
50
  all requests (and responses).
51
51
 
@@ -133,7 +133,19 @@ class LoggingSession(BaseUrlSession):
133
133
  return response
134
134
 
135
135
 
136
- class PayloadCompressingSession(LoggingSession):
136
+ class LoggingSession(LoggingSessionMixin, BaseUrlSessionMixin, requests.Session):
137
+ def __init__(self, *args, **kwargs):
138
+ # note: this deprecation warning is raised by all subclasses, up to and
139
+ # including `CachingSession`. The message adapts accordingly.
140
+ cls = type(self).__name__
141
+ warnings.warn(
142
+ f"`{cls}` is deprecated in favor of `{cls}Mixin` since "
143
+ f"dwave-cloud-client 0.13.6, and will be removed in 0.15.0.",
144
+ DeprecationWarning, stacklevel=2)
145
+ super().__init__(*args, **kwargs)
146
+
147
+
148
+ class PayloadCompressingSessionMixin:
137
149
  """A :class:`requests.Session` subclass (technically, a further specialized
138
150
  :class:`.LoggingSession`) that adds support for payload compression on the
139
151
  fly.
@@ -233,7 +245,11 @@ class PayloadCompressingSession(LoggingSession):
233
245
  return super().send(request, **kwargs)
234
246
 
235
247
 
236
- class VersionedAPISession(PayloadCompressingSession):
248
+ class PayloadCompressingSession(PayloadCompressingSessionMixin, LoggingSession):
249
+ pass
250
+
251
+
252
+ class VersionedAPISessionMixin:
237
253
  """A :class:`requests.Session` subclass (technically, further specialized
238
254
  :class:`.PayloadCompressingSession`) that enforces conformance of API response
239
255
  version with supported version range(s).
@@ -350,7 +366,11 @@ def _create_default_cache_store(**kwargs) -> abc.Mapping:
350
366
  return diskcache.Cache(directory=directory)
351
367
 
352
368
 
353
- class CachingSession(VersionedAPISession):
369
+ class VersionedAPISession(VersionedAPISessionMixin, PayloadCompressingSession):
370
+ pass
371
+
372
+
373
+ class CachingSessionMixin:
354
374
  """A :class:`requests.Session` subclass (technically, further specialized
355
375
  :class:`.VersionedAPISession`) that caches responses and uses conditional
356
376
  requests for smart cache updates.
@@ -533,19 +553,19 @@ class CachingSession(VersionedAPISession):
533
553
  res.raw = io.BytesIO(content)
534
554
  return res
535
555
 
536
- if not refresh and (meta := self._store.get(key_meta)):
556
+ meta = self._store.get(key_meta)
557
+ content = self._store.get(key_data)
558
+
559
+ if not refresh and meta and content:
537
560
  logger.debug("cache_read (meta): %r = %r", key_meta, meta)
561
+ logger.debug("cache_read (data): %r -> (%d bytes)", key_data, len(content))
562
+
538
563
  # respect max-age from response cache-control
539
564
  maxage = meta.get('maxage')
540
565
  if maxage is None:
541
566
  # but if cache-control was absent, client gets do decide
542
567
  maxage = default_maxage
543
568
 
544
- # note: by deferring this lookup, we could save a few ms in case
545
- # when upstream content was modified (but that doesn't happen often)
546
- content = self._store.get(key_data)
547
- logger.debug("cache_read (data): %r -> (%d bytes)", key_data, len(content))
548
-
549
569
  if epochnow() - meta['created'] < maxage:
550
570
  logger.debug('cache hit within maxage')
551
571
  return make_response(content)
@@ -576,6 +596,10 @@ class CachingSession(VersionedAPISession):
576
596
  return res
577
597
 
578
598
 
599
+ class CachingSession(CachingSessionMixin, VersionedAPISession):
600
+ pass
601
+
602
+
579
603
  class DWaveAPIClient:
580
604
  """Low-level client for D-Wave APIs. A thin wrapper around
581
605
  `requests.Session` that handles API specifics such as authentication,
@@ -596,7 +620,19 @@ class DWaveAPIClient:
596
620
 
597
621
  """
598
622
 
623
+ class DefaultSession(CachingSessionMixin,
624
+ VersionedAPISessionMixin,
625
+ PayloadCompressingSessionMixin,
626
+ LoggingSessionMixin,
627
+ BaseUrlSessionMixin,
628
+ requests.Session):
629
+ """Default session class is based on `requests.Session` extended with
630
+ base url, logging, compressing, API versioning and caching mixins.
631
+ """
632
+
599
633
  DEFAULTS = {
634
+ 'session_class': DefaultSession,
635
+
600
636
  'endpoint': None,
601
637
  'token': None,
602
638
  'cert': None,
@@ -748,14 +784,25 @@ class DWaveAPIClient:
748
784
  if not endpoint.endswith('/'):
749
785
  endpoint += '/'
750
786
 
787
+ session_class = config['session_class']
788
+
789
+ # build kwargs from mixins used
790
+ # note: we could automate param extraction with a metaclass, but let's kiss
791
+ session_kwargs = {}
792
+ if issubclass(session_class, BaseUrlSessionMixin):
793
+ session_kwargs.update(base_url=endpoint)
794
+ if issubclass(session_class, LoggingSessionMixin):
795
+ session_kwargs.update(history_size=config['history_size'])
796
+ if issubclass(session_class, PayloadCompressingSessionMixin):
797
+ session_kwargs.update(compress=config['compress'])
798
+ if issubclass(session_class, VersionedAPISessionMixin):
799
+ session_kwargs.update(strict_mode=config['version_strict_mode'])
800
+ if issubclass(session_class, CachingSessionMixin):
801
+ session_kwargs.update(cache=config['cache'])
802
+
803
+ session = session_class(**session_kwargs)
804
+
751
805
  # configure request timeout and retries
752
- session = CachingSession(
753
- base_url=endpoint,
754
- history_size=config['history_size'],
755
- compress=config['compress'],
756
- strict_mode=config['version_strict_mode'],
757
- cache=config['cache'],
758
- )
759
806
  timeout = config['timeout']
760
807
  retry = config['retry']
761
808
  session.mount('http://', PretimedHTTPAdapter(
@@ -374,8 +374,8 @@ def _get_client_solver(config, output=None):
374
374
  raise CLIError("Authentication error. Check credentials in your configuration file.", 2)
375
375
  except SolverNotFoundError:
376
376
  raise CLIError("Solver not available.", 6)
377
- except (InvalidAPIResponseError, UnsupportedSolverError):
378
- raise CLIError("Invalid or unexpected API response.", 3)
377
+ except (InvalidAPIResponseError, UnsupportedSolverError) as e:
378
+ raise CLIError(f"Invalid or unexpected API response: {e!s}", 3)
379
379
  except RequestTimeout:
380
380
  raise CLIError("API connection timed out.", 4)
381
381
  except requests.exceptions.SSLError as e:
@@ -408,8 +408,10 @@ def _sample(solver, problem, params, output):
408
408
  raise CLIError("API connection timed out.", 8)
409
409
  except PollingTimeout:
410
410
  raise CLIError("Polling timeout exceeded.", 9)
411
+ except InvalidAPIResponseError as e:
412
+ raise CLIError(f"Invalid or unexpected API response: {e!s}", 3)
411
413
  except Exception as e:
412
- raise CLIError("Sampling error: {!r}".format(e), 10)
414
+ raise CLIError(f"Sampling error: {e!s}", 10)
413
415
 
414
416
  return response
415
417
 
@@ -487,7 +489,10 @@ def standardized_output(fn):
487
489
  def ping(*, config_file, profile, endpoint, region, client_type, solver_def,
488
490
  sampling_params, request_timeout, polling_timeout, label, json_output,
489
491
  output):
490
- """Ping the QPU by submitting a single-qubit problem."""
492
+ """Ping a solver by submitting a single-qubit problem.
493
+
494
+ If solver is not specified, a QPU solver is selected by default.
495
+ """
491
496
 
492
497
  # parse params (TODO: move to click validator)
493
498
  params = {}
@@ -530,6 +530,9 @@ class Client(object):
530
530
  self._download_answer_executor = \
531
531
  ThreadPoolExecutor(self._DOWNLOAD_ANSWER_THREAD_COUNT)
532
532
 
533
+ class _Session(api.client.VersionedAPISessionMixin, BaseUrlSession):
534
+ pass
535
+
533
536
  def create_session(self):
534
537
  """Create a new requests session based on client's (self) params.
535
538
 
@@ -542,7 +545,7 @@ class Client(object):
542
545
  if not endpoint.endswith('/'):
543
546
  endpoint += '/'
544
547
 
545
- session = BaseUrlSession(base_url=endpoint)
548
+ session = self._Session(base_url=endpoint, strict_mode=True)
546
549
  session.mount('http://', PretimedHTTPAdapter(
547
550
  timeout=self.config.request_timeout,
548
551
  max_retries=self.config.request_retry.to_urllib3_retry()))
@@ -1268,6 +1271,8 @@ class Client(object):
1268
1271
  return []
1269
1272
 
1270
1273
  session = self.create_session()
1274
+ session.set_accept(media_type='application/vnd.dwave.sapi.problems+json',
1275
+ accept_version='>=2.1,<3')
1271
1276
  try:
1272
1277
  while True:
1273
1278
  # Pull as many problems as we can, block on the first one,
@@ -1443,6 +1448,8 @@ class Client(object):
1443
1448
  This method is always run inside of a daemon thread.
1444
1449
  """
1445
1450
  session = self.create_session()
1451
+ session.set_accept(media_type='application/vnd.dwave.sapi.problems+json',
1452
+ accept_version='>=2.1,<3')
1446
1453
  try:
1447
1454
  while True:
1448
1455
  # Pull as many problems as we can, block when none are available.
@@ -1541,6 +1548,8 @@ class Client(object):
1541
1548
  This method is always run inside of a daemon thread.
1542
1549
  """
1543
1550
  session = self.create_session()
1551
+ session.set_accept(media_type='application/vnd.dwave.sapi.problems+json',
1552
+ accept_version='>=2.1,<3')
1544
1553
  try:
1545
1554
  # grouped futures (all scheduled within _POLL_GROUP_TIMEFRAME)
1546
1555
  # and/or up to _STATUS_QUERY_SIZE (depending on strategy)
@@ -1622,7 +1631,7 @@ class Client(object):
1622
1631
 
1623
1632
  except SAPIError as exc:
1624
1633
  # assume 5xx errors are transient, and don't abort polling
1625
- if 500 <= exc.error_code < 600:
1634
+ if exc.error_code and 500 <= exc.error_code < 600:
1626
1635
  logger.warning(
1627
1636
  "Received an internal server error response on "
1628
1637
  "problem status polling request (%s). Assuming "
@@ -1678,6 +1687,8 @@ class Client(object):
1678
1687
  This method is always run inside of a daemon thread.
1679
1688
  """
1680
1689
  session = self.create_session()
1690
+ session.set_accept(media_type='application/vnd.dwave.sapi.problem+json',
1691
+ accept_version='>=2.1,<3')
1681
1692
  try:
1682
1693
  while True:
1683
1694
  # Select a problem
@@ -1807,6 +1818,9 @@ class Client(object):
1807
1818
  # execute request
1808
1819
  try:
1809
1820
  response = meth(*args, **kwargs)
1821
+ except api.exceptions.ResourceBadResponseError as e:
1822
+ # returned by VersionedAPISessionMixin; wrap for backwards-compatibility
1823
+ raise InvalidAPIResponseError(e) from e
1810
1824
  except Exception as exc:
1811
1825
  if is_caused_by(exc, (requests.exceptions.Timeout,
1812
1826
  urllib3.exceptions.TimeoutError)):
@@ -29,6 +29,7 @@ Some :class:`Future` methods are blocking.
29
29
  import io
30
30
  import time
31
31
  import threading
32
+ import typing
32
33
  import functools
33
34
  import weakref
34
35
 
@@ -115,6 +116,9 @@ class Future(object):
115
116
  #: The id the server will use to identify this problem, None until the id is actually known
116
117
  self.id = id_
117
118
 
119
+ #: Problem data ID, if problem is uploaded using multipart upload interface.
120
+ self._data_id = None
121
+
118
122
  #: Problem label, as (optionally) set on submission. None until parsed from a response.
119
123
  self.label = None
120
124
 
@@ -228,6 +232,19 @@ class Future(object):
228
232
  server_time = 0
229
233
  self.clock_diff = abs(server_time - localtime_of_response)
230
234
 
235
+ def _notify_uploaded(self, **metadata):
236
+ self._data_id = metadata.get('problem_data_id')
237
+
238
+ @property
239
+ def data_id(self) -> typing.Union[str, None]:
240
+ """Uploaded problem data id.
241
+
242
+ Note: only hybrid problems are currently uploaded separately from submit,
243
+ hence only they will have a data id associated. For QPU problems,
244
+ :meth:`.data_id` returns ``None``.
245
+ """
246
+ return self._data_id
247
+
231
248
  @staticmethod
232
249
  def wait_multiple(futures, min_done=None, timeout=None):
233
250
  """Wait for multiple :class:`Future` objects to complete.
@@ -943,6 +960,8 @@ class Future(object):
943
960
  problem_info.update(problem_id=self.id)
944
961
  if self.label is not None:
945
962
  problem_info.update(problem_label=self.label)
963
+ if (data_id := self.data_id) is not None:
964
+ problem_info.update(problem_data_id=data_id)
946
965
  return problem_info
947
966
 
948
967
  def _patch_offset(self):
@@ -14,7 +14,7 @@
14
14
 
15
15
  __packagename__ = 'dwave-cloud-client'
16
16
  __title__ = 'D-Wave Cloud Client'
17
- __version__ = '0.13.4'
17
+ __version__ = '0.13.6'
18
18
  __author__ = 'D-Wave Systems Inc.'
19
19
  __description__ = 'A minimal client for interacting with D-Wave cloud resources.'
20
20
  __url__ = 'https://github.com/dwavesystems/dwave-cloud-client'
@@ -432,7 +432,7 @@ class BaseUnstructuredSolver(BaseSolver):
432
432
 
433
433
  def _encode_problem_for_submission(self, *, problem, problem_type,
434
434
  upload_params=None, sample_params=None,
435
- label=None):
435
+ label=None, on_uploaded=None):
436
436
  """Encode `problem` for submitting in `ref` format. Upload the
437
437
  problem if it's not already uploaded.
438
438
 
@@ -452,6 +452,9 @@ class BaseUnstructuredSolver(BaseSolver):
452
452
  label (str, optional):
453
453
  Problem label.
454
454
 
455
+ on_uploaded (callable, optional):
456
+ Callback that's called when problem is uploaded.
457
+
455
458
  Returns:
456
459
  str:
457
460
  JSON-encoded problem submit body
@@ -469,6 +472,9 @@ class BaseUnstructuredSolver(BaseSolver):
469
472
  "we need to upload it first.")
470
473
  problem_id = self.upload_problem(problem, **upload_params).result()
471
474
 
475
+ if on_uploaded is not None:
476
+ on_uploaded(problem_data_id=problem_id)
477
+
472
478
  body = {
473
479
  'solver': self.id,
474
480
  'data': encode_problem_as_ref(problem_id),
@@ -515,15 +521,16 @@ class BaseUnstructuredSolver(BaseSolver):
515
521
  if problem_type is None:
516
522
  problem_type = next(iter(self._handled_problem_types))
517
523
 
524
+ # computation future holds a reference to the remote job
525
+ computation = Future(
526
+ solver=self, id_=None, return_matrix=self.return_matrix)
527
+
518
528
  # encode the request (body as future)
519
529
  body = self.client._encode_problem_executor.submit(
520
530
  self._encode_problem_for_submission,
521
531
  problem=problem, problem_type=problem_type, label=label,
522
- upload_params=upload_params, sample_params=sample_params)
523
-
524
- # computation future holds a reference to the remote job
525
- computation = Future(
526
- solver=self, id_=None, return_matrix=self.return_matrix)
532
+ upload_params=upload_params, sample_params=sample_params,
533
+ on_uploaded=computation._notify_uploaded)
527
534
 
528
535
  logger.debug("Submitting new problem to: %s", self.id)
529
536
  self.client._submit(body, computation)
@@ -69,26 +69,47 @@ class TimeoutingHTTPAdapter(PretimedHTTPAdapter):
69
69
  # If we later decide to use additional features from `requests-toolbelt`,
70
70
  # remove it from here.
71
71
 
72
- class BaseUrlSession(requests.Session):
73
- """A Session with a URL that all requests will use as a base."""
72
+ class BaseUrlSessionMixin:
73
+ """A :class:`~requests.Session` mixin that allows setting of a base URL for
74
+ all session requests.
74
75
 
76
+ See also :class:`.BaseUrlSession`.
77
+
78
+ Args:
79
+ base_url:
80
+ Base URL.
81
+
82
+ """
75
83
  base_url = None
76
84
 
77
- def __init__(self, base_url=None):
85
+ def __init__(self, base_url: Optional[str] = None):
78
86
  if base_url:
79
87
  self.base_url = base_url
80
88
  super().__init__()
81
89
 
82
- def request(self, method, url, *args, **kwargs):
90
+ def request(self, method: str, url: str, *args, **kwargs) -> requests.Response:
83
91
  """Send the request after generating the complete URL."""
84
92
  url = self.create_url(url)
85
93
  return super().request(method, url, *args, **kwargs)
86
94
 
87
- def create_url(self, url):
95
+ def create_url(self, url: str) -> str:
88
96
  """Create the URL based off this partial path."""
89
97
  return urljoin(self.base_url, url)
90
98
 
91
99
 
100
+ class BaseUrlSession(BaseUrlSessionMixin, requests.Session):
101
+ """A Session with a URL that all requests will use as a base.
102
+
103
+ See also :class:`.BaseUrlSessionMixin`.
104
+
105
+ Example::
106
+
107
+ session = BaseUrlSession(base_url='http://example.com/api/')
108
+ session.get('version')
109
+
110
+ """
111
+
112
+
92
113
  def user_agent(name: Optional[str] = None,
93
114
  version: Optional[str] = None,
94
115
  *,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dwave-cloud-client
3
- Version: 0.13.4
3
+ Version: 0.13.6
4
4
  Summary: A minimal client for interacting with D-Wave cloud resources.
5
5
  Home-page: https://github.com/dwavesystems/dwave-cloud-client
6
6
  Author: D-Wave Systems Inc.
@@ -3,7 +3,6 @@ README.rst
3
3
  pyproject.toml
4
4
  setup.cfg
5
5
  setup.py
6
- dwave/__init__.py
7
6
  dwave/cloud/__init__.py
8
7
  dwave/cloud/cli.py
9
8
  dwave/cloud/coders.py
@@ -1,6 +1,6 @@
1
1
  import os
2
2
  from io import open
3
- from setuptools import setup, find_packages
3
+ from setuptools import setup, find_namespace_packages
4
4
 
5
5
 
6
6
  # Load package info, without importing the package
@@ -44,7 +44,7 @@ extras_require = {
44
44
 
45
45
  # Packages provided. Only include packages under the 'dwave' namespace.
46
46
  # Do not include tests, benchmarks, etc.
47
- packages = [package for package in find_packages() if package.startswith('dwave')]
47
+ packages = find_namespace_packages(include=['dwave.*'])
48
48
 
49
49
  classifiers = [
50
50
  'License :: OSI Approved :: Apache Software License',