luna-quantum 1.0.2rc1__cp311-cp311-win_amd64.whl → 1.0.3rc2__cp311-cp311-win_amd64.whl

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.

Potentially problematic release.


This version of luna-quantum might be problematic. Click here for more details.

luna_quantum/__init__.py CHANGED
@@ -1,6 +1,7 @@
1
1
  from luna_quantum._core import __luna_quantum_version__
2
2
  from luna_quantum.aqm_overwrites.model import Model
3
3
  from luna_quantum.client.controllers import LunaQ, LunaSolve
4
+ from luna_quantum.config import config
4
5
  from luna_quantum.factories.luna_solve_client_factory import LunaSolveClientFactory
5
6
  from luna_quantum.factories.usecase_factory import UseCaseFactory
6
7
  from luna_quantum.solve import DefaultToken
@@ -107,6 +108,7 @@ __all__ = [
107
108
  "__version__",
108
109
  "algorithms",
109
110
  "backends",
111
+ "config",
110
112
  "constants",
111
113
  "debug_info",
112
114
  "errors",
luna_quantum/__init__.pyi CHANGED
@@ -33,6 +33,7 @@ from .utils import quicksum
33
33
  from luna_quantum._core import __luna_quantum_version__
34
34
  from luna_quantum.aqm_overwrites.model import Model
35
35
  from luna_quantum.client.controllers import LunaQ, LunaSolve
36
+ from luna_quantum.config import config
36
37
  from luna_quantum.solve import DefaultToken
37
38
  from luna_quantum.solve.parameters import algorithms, backends, constants
38
39
  from luna_quantum.util.debug_info import debug_info
@@ -73,6 +74,7 @@ __all__ = [
73
74
  "__version__",
74
75
  "algorithms",
75
76
  "backends",
77
+ "config",
76
78
  "constants",
77
79
  "debug_info",
78
80
  "errors",
Binary file
luna_quantum/_core.pyi CHANGED
@@ -2355,6 +2355,20 @@ class Model:
2355
2355
  """
2356
2356
  ...
2357
2357
 
2358
+ def equal_contents(self, other: Model, /) -> bool:
2359
+ """
2360
+ Check whether this model has equal contents as `other`.
2361
+
2362
+ Parameters
2363
+ ----------
2364
+ other : Model
2365
+
2366
+ Returns
2367
+ -------
2368
+ bool
2369
+ """
2370
+ ...
2371
+
2358
2372
  def __str__(self, /) -> str: ...
2359
2373
  def __repr__(self, /) -> str: ...
2360
2374
  def __hash__(self, /) -> int: ...
@@ -3641,10 +3655,30 @@ class Constraints:
3641
3655
  """
3642
3656
  ...
3643
3657
 
3658
+ @overload
3659
+ def get(self, item: str, /) -> Constraint: ...
3660
+ @overload
3661
+ def get(self, item: int, /) -> Constraint: ...
3662
+ def get(self, item: (int | str), /) -> Constraint:
3663
+ """Get a constraint for its name or index."""
3664
+ ...
3665
+
3666
+ @overload
3667
+ def remove(self, item: str, /) -> Constraint: ...
3668
+ @overload
3669
+ def remove(self, item: int, /) -> Constraint: ...
3670
+ def remove(self, item: (int | str), /) -> Constraint:
3671
+ """Remove a constraint for its name or index."""
3672
+ ...
3673
+
3644
3674
  def __eq__(self, other: Constraints, /) -> bool: ...
3645
3675
  def __str__(self, /) -> str: ...
3646
3676
  def __repr__(self, /) -> str: ...
3677
+ @overload
3678
+ def __getitem__(self, item: str, /) -> Constraint: ...
3679
+ @overload
3647
3680
  def __getitem__(self, item: int, /) -> Constraint: ...
3681
+ def __getitem__(self, item: (int | str), /) -> Constraint: ...
3648
3682
  def __len__(self, /) -> int:
3649
3683
  """
3650
3684
  Get the number of constraints.
@@ -3656,6 +3690,20 @@ class Constraints:
3656
3690
  """
3657
3691
  ...
3658
3692
 
3693
+ def equal_contents(self, other: Constraints, /) -> bool:
3694
+ """
3695
+ Check whether this constraints has equal contents as `other`.
3696
+
3697
+ Parameters
3698
+ ----------
3699
+ other : Constraints
3700
+
3701
+ Returns
3702
+ -------
3703
+ bool
3704
+ """
3705
+ ...
3706
+
3659
3707
  __version__: str
3660
3708
  __aq_model_version__: str
3661
3709
  __luna_quantum_version__: str
@@ -48,7 +48,7 @@ class APIKeyAuth(httpx.Auth):
48
48
  def __init__(self, token: str) -> None:
49
49
  self.token = token
50
50
 
51
- def auth_flow(self, request: Request) -> Generator[Request, Response, None]:
51
+ def auth_flow(self, request: Request) -> Generator[Request, Response]:
52
52
  """
53
53
  Authenticate a request to Luna platform.
54
54
 
@@ -89,7 +89,7 @@ class LunaPlatformClient(IService):
89
89
  self,
90
90
  api: LunaPrefixEnum,
91
91
  api_key: str | None = None,
92
- base_url: str = os.getenv("LUNA_BASE_URL", "https://api.aqarios.com"),
92
+ base_url: str | None = None,
93
93
  timeout: float | None = 240.0,
94
94
  ) -> None:
95
95
  """
@@ -116,6 +116,8 @@ class LunaPlatformClient(IService):
116
116
  itself will time out after 240 seconds.
117
117
  Default: 240.0
118
118
  """
119
+ if base_url is None:
120
+ base_url = os.getenv("LUNA_BASE_URL", "https://api.aqarios.com")
119
121
  if os.getenv("LUNA_DISABLE_SUFFIX", "false").lower() == "true":
120
122
  self._base_url = f"{base_url}/api/v1"
121
123
  else:
luna_quantum/config.py ADDED
@@ -0,0 +1,11 @@
1
+ from pydantic_settings import BaseSettings
2
+
3
+
4
+ class Config(BaseSettings):
5
+ """Class for all config values."""
6
+
7
+ LUNA_LOG_DEFAULT_LEVEL: str = "INFO"
8
+ LUNA_LOG_DISABLE_SPINNER: bool = False
9
+
10
+
11
+ config = Config()
luna_quantum/errors.pyi CHANGED
@@ -236,6 +236,9 @@ class StartCannotBeInferredError(TypeError):
236
236
 
237
237
  def __str__(self, /) -> str: ...
238
238
 
239
+ class NoConstraintForKeyError(IndexError):
240
+ """Raised getting a constraint from the constraints that does not exist."""
241
+
239
242
  __all__ = [
240
243
  "ComputationError",
241
244
  "ComputationError",
@@ -250,6 +253,7 @@ __all__ = [
250
253
  "ModelVtypeError",
251
254
  "MultipleActiveEnvironmentsError",
252
255
  "NoActiveEnvironmentFoundError",
256
+ "NoConstraintForKeyError",
253
257
  "SampleIncompatibleVtypeError",
254
258
  "SampleIncorrectLengthError",
255
259
  "SampleUnexpectedVariableError",
@@ -616,6 +616,9 @@ class DwaveTranslator:
616
616
  SampleIncorrectLengthError
617
617
  If a solution's sample has a different number of variables than the model
618
618
  environment passed to the translator.
619
+ SampleUnexpectedVariableError
620
+ If the sample_set contains variables that are not contained in the passed
621
+ environment.
619
622
  ModelVtypeError
620
623
  If the result's variable types are incompatible with the model environment's
621
624
  variable types.
@@ -3,13 +3,15 @@ from __future__ import annotations
3
3
  import logging
4
4
  from contextlib import contextmanager
5
5
  from functools import wraps
6
- from typing import TYPE_CHECKING, ClassVar, ParamSpec, TypeVar
6
+ from typing import TYPE_CHECKING, ParamSpec, TypeVar
7
7
 
8
8
  from rich.console import Console
9
9
  from rich.logging import RichHandler
10
10
  from rich.progress import Progress, SpinnerColumn, TaskID, TextColumn
11
11
  from rich.theme import Theme
12
12
 
13
+ from luna_quantum.config import config
14
+
13
15
  if TYPE_CHECKING:
14
16
  from collections.abc import Callable, Generator
15
17
 
@@ -27,7 +29,20 @@ class Logging:
27
29
  - Manage consistent logging behavior across the SDK
28
30
  """
29
31
 
30
- _log_level: ClassVar[int] = logging.INFO
32
+ @staticmethod
33
+ def is_process_bar_shown() -> bool:
34
+ """
35
+ Return whether to use a process bar for progress bars.
36
+
37
+ Returns
38
+ -------
39
+ bool
40
+ Returns whether to use a process bar for progress bars.
41
+ """
42
+ return (
43
+ not config.LUNA_LOG_DISABLE_SPINNER
44
+ and Logging.get_level() != logging.NOTSET
45
+ )
31
46
 
32
47
  @staticmethod
33
48
  def set_level(log_level: int) -> None:
@@ -38,12 +53,12 @@ class Logging:
38
53
  log_level : int
39
54
  Logging level to set (e.g., logging.DEBUG, logging.INFO)
40
55
  """
56
+ config.LUNA_LOG_DEFAULT_LEVEL = logging.getLevelName(log_level)
57
+
41
58
  for logger_name in logging.root.manager.loggerDict:
42
59
  if logger_name.startswith("luna_quantum"): # Only modify SDK loggers
43
60
  logging.getLogger(logger_name).setLevel(log_level)
44
61
 
45
- Logging._log_level = log_level
46
-
47
62
  @staticmethod
48
63
  def get_level() -> int:
49
64
  """Return the current logging level for the SDK.
@@ -54,7 +69,7 @@ class Logging:
54
69
  Current logging level as defined in the logging module
55
70
  (e.g., logging.DEBUG, logging.INFO, etc.)
56
71
  """
57
- return Logging._log_level
72
+ return logging._nameToLevel.get(config.LUNA_LOG_DEFAULT_LEVEL, logging.INFO) # noqa: SLF001 #No other way to map these log levels.
58
73
 
59
74
  @staticmethod
60
75
  def get_console() -> Console:
@@ -85,7 +100,7 @@ class Logging:
85
100
  Configured logger instance with appropriate handlers
86
101
  """
87
102
  logger = logging.getLogger(name)
88
- logger.setLevel(Logging._log_level)
103
+ logger.setLevel(Logging.get_level())
89
104
  logger.propagate = False
90
105
 
91
106
  if logger.hasHandlers():
@@ -107,7 +122,7 @@ class Logging:
107
122
  @contextmanager
108
123
  def progress_bar(
109
124
  total: int | None, desc: str = "", unit: str = "steps"
110
- ) -> Generator[tuple[Progress, TaskID], None, None]:
125
+ ) -> Generator[tuple[Progress, TaskID]]:
111
126
  """Create a progress bar using Rich as a context manager.
112
127
 
113
128
  Parameters
@@ -136,6 +151,7 @@ def progress_bar(
136
151
  )
137
152
  ),
138
153
  transient=True,
154
+ disable=not Logging.is_process_bar_shown(),
139
155
  ) as progress:
140
156
  task = progress.add_task(f"[blue]{desc}", total=total, unit=unit)
141
157
  yield progress, task # Yield both progress and task for updates
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: luna-quantum
3
- Version: 1.0.2rc1
3
+ Version: 1.0.3rc2
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: License :: OSI Approved :: Apache Software License
6
6
  Classifier: Operating System :: OS Independent
7
7
  Classifier: Topic :: Scientific/Engineering
8
8
  Requires-Dist: httpx>=0.28.1,<0.29
9
9
  Requires-Dist: numpy>=1
10
+ Requires-Dist: pydantic-settings>=2.10.1
10
11
  Requires-Dist: pydantic[email]>=2.11.3,<3
11
12
  Requires-Dist: python-dateutil>=2.9.0,<3
12
13
  Requires-Dist: rich>=14.0.0
@@ -1,11 +1,11 @@
1
- luna_quantum-1.0.2rc1.dist-info/METADATA,sha256=hs54VddogdgUbN6j3OQMGP4yN-g7hBmlzQXoUYx7miQ,1533
2
- luna_quantum-1.0.2rc1.dist-info/WHEEL,sha256=auo2gA2SV-bvS4ssY6DIG7dtu3SpmB5FcBkwIwO6YZk,96
3
- luna_quantum-1.0.2rc1.dist-info/licenses/LICENSE,sha256=bR2Wj7Il7KNny38LiDGrASo12StUfpReF--OewXD5cw,10349
4
- luna_quantum-1.0.2rc1.dist-info/licenses/NOTICE,sha256=GHZYA5H4QFAhbhXliAi2SjWWXLjxl4hrHdEPyUbC0r0,601
5
- luna_quantum/__init__.py,sha256=1nYCHMAMTshDawN7U9FiO3XRUkClk-wcNNR0KQBfeZs,3287
6
- luna_quantum/__init__.pyi,sha256=nqAu05_nRij1xlcbADzyjUSQhvUIvvb8ElnWYE9ZkS8,1691
7
- luna_quantum/_core.cp311-win_amd64.pyd,sha256=ZVi8noFKJl93UbIPfZIMDAYyHHrmIhmKQDxdyibczcg,4616704
8
- luna_quantum/_core.pyi,sha256=d2zeUCc3CYz-CRRhwnzKOJXvn65uNbF0IieiBZp1b-4,107948
1
+ luna_quantum-1.0.3rc2.dist-info/METADATA,sha256=uf6_KnE34UPfQi9K-5gwJ6aMAhyMK0_wooFkWDnX-UQ,1574
2
+ luna_quantum-1.0.3rc2.dist-info/WHEEL,sha256=auo2gA2SV-bvS4ssY6DIG7dtu3SpmB5FcBkwIwO6YZk,96
3
+ luna_quantum-1.0.3rc2.dist-info/licenses/LICENSE,sha256=bR2Wj7Il7KNny38LiDGrASo12StUfpReF--OewXD5cw,10349
4
+ luna_quantum-1.0.3rc2.dist-info/licenses/NOTICE,sha256=GHZYA5H4QFAhbhXliAi2SjWWXLjxl4hrHdEPyUbC0r0,601
5
+ luna_quantum/__init__.py,sha256=9Dpk-wfL5fR_R74c-JsFKZmUy7OUfe4hj4ZXEJaPAt4,3342
6
+ luna_quantum/__init__.pyi,sha256=hDTZ1lJV4kd104FvjVmMbMn0jNt9V3LqTvDDssJGwQU,1746
7
+ luna_quantum/_core.cp311-win_amd64.pyd,sha256=j2bSN2R-zZMVSZifst9B7mZYeuqge_w4ffnyPOckPGk,4632576
8
+ luna_quantum/_core.pyi,sha256=tzzycPQ6d7Ec_ptRIDlBKt4QhFtfplBeXHQWoZ72_q0,109210
9
9
  luna_quantum/algorithms/__init__.py,sha256=EoTNO0FXXjPrhpYfN7q9c_nUhmVHk2nEZsbhaVOBh_g,70
10
10
  luna_quantum/aqm_overwrites/__init__.py,sha256=ieIVhfslOwrznbvwqu3vNzU_nFIHS1hyeUgIV097WdQ,49
11
11
  luna_quantum/aqm_overwrites/model.py,sha256=stqMo97W0nzDLoWmTqwefdu7xgtPAWS46dsxOcJDHpU,6283
@@ -13,7 +13,7 @@ luna_quantum/backends/__init__.py,sha256=jBbtXn6u196zFHqOv-Yh1-S1otbYssGPPsEHTT3
13
13
  luna_quantum/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  luna_quantum/client/controllers/__init__.py,sha256=0HavZV2mfk4Inuv5KnEZo5OmCtl6orm1flUfx9bnT4o,160
15
15
  luna_quantum/client/controllers/luna_http_client.py,sha256=bwBn_d-JWkEmy6JX-vMo8qFhRAu9eteqCD8rBFl5wKo,1094
16
- luna_quantum/client/controllers/luna_platform_client.py,sha256=iZRaBf_SSNJMgEMOtuuY0xOHslZ-UNTrb0d4EalsI4w,5311
16
+ luna_quantum/client/controllers/luna_platform_client.py,sha256=BGkBnIoNtISHRnTtPv6Z5quV1QQY564einW1UDZI2vM,5371
17
17
  luna_quantum/client/controllers/luna_q.py,sha256=2Wh47dJ3W6SjlwUtEUVKlpY-2OBDVFVeqooJBXq2Vr8,1992
18
18
  luna_quantum/client/controllers/luna_solve.py,sha256=pbGBrPnbCA_kG9Rq34lTZfc78WekD-m3ksFgMrARxOY,3524
19
19
  luna_quantum/client/error/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -80,8 +80,9 @@ luna_quantum/client/schemas/wrappers/__init__.py,sha256=sAIRzd1LmugZkyZ4ND3XJUt1
80
80
  luna_quantum/client/schemas/wrappers/datetime_wrapper.py,sha256=11KmaftPtKoafhcgn4nuCjL1NfV_afSRJHlcSuyW55o,800
81
81
  luna_quantum/client/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
82
82
  luna_quantum/client/utils/qpu_token_utils.py,sha256=goq4nwmxKz0GTqLep01ydoopqHb336FPv6CXGGtR260,4915
83
+ luna_quantum/config.py,sha256=a5UgYn6TIT2pFfdprvDy0RzyI4eAI_OFSdFSxpjQr2M,228
83
84
  luna_quantum/errors.py,sha256=9qeMJY-hI1qlBqrWjaESVGx3ujEQuFdqONGgIl107kk,1458
84
- luna_quantum/errors.pyi,sha256=Ve2bky1TWT7SeCXaueyogyR2SYlAnMRdjmcfEOLJUX0,9009
85
+ luna_quantum/errors.pyi,sha256=xKHr2YcetOKgMKD-JwS5bkfamcRVhYjjo6NfDAQBNUk,9168
85
86
  luna_quantum/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
86
87
  luna_quantum/exceptions/base_luna_quantum_error.py,sha256=Gl65slQxbNJoo8Kgnqif-slshlluCke0O0ow2r5PZE0,91
87
88
  luna_quantum/exceptions/patch_class_field_exists_error.py,sha256=4nmnGlPXp-SjuNX72PETXQ4eZzVpMTxH0eYs1IVDUPQ,408
@@ -245,14 +246,14 @@ luna_quantum/solve/usecases/solve_job_get_result_usecase.py,sha256=_62COwl-I1iGa
245
246
  luna_quantum/transformations.py,sha256=A00BqmKpZz1Ixrb77a_ynpuqtB7w-AlVshg-QHp2UwM,920
246
247
  luna_quantum/transformations.pyi,sha256=ZuTF6cCy6vAcsqYuy7rBfNjHuYGay4vukrL-Zvobq7s,8053
247
248
  luna_quantum/translator.py,sha256=5RDTzFzd5sw3JzxFQsHdZQWhz2KDl03nzik5dUHebHI,1157
248
- luna_quantum/translator.pyi,sha256=kT-w2xtAP7HQm7ZtAZd1_9MiIc-skyKoc3Olo9F_KRA,27195
249
+ luna_quantum/translator.pyi,sha256=RcePKY4Ztw-uv0Dfyx2DTw1TBMyem_SWts1MmzYZfn0,27347
249
250
  luna_quantum/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
250
251
  luna_quantum/util/active_waiting.py,sha256=hmwUiav3woWy1q6KJckYmHTIIFPI4MnQ4QF1LwqPrKY,3108
251
252
  luna_quantum/util/class_patcher.py,sha256=rQRjnUgAXq0NnFY7lvfNZu4r-4VWvke0sV18i67DfTI,5620
252
253
  luna_quantum/util/debug_info.py,sha256=--Ef5EIgo3oWdUc5vn8TKFHNmcflBmc5-bexTSUlBJQ,1807
253
- luna_quantum/util/log_utils.py,sha256=2eiF3A48fBcgLSbqXIqeVV6deoFJNK3rw8GvdIdG-fI,5089
254
+ luna_quantum/util/log_utils.py,sha256=0-ARoGkp7xyTvw1i-pRJoq1ylDKNC4eDoVY2DG05DS8,5658
254
255
  luna_quantum/util/pretty_base.py,sha256=rJy28OKfNdB1j5xdzOmFrCdbw-Gb-JJ5Dcz3NvOpIcQ,2182
255
256
  luna_quantum/util/pydantic_utils.py,sha256=KipyyVaajjFB-krdPl_j5BLogaiPqn0L8mrJuLwZtic,1301
256
257
  luna_quantum/utils.py,sha256=RlF0LFK0qXavL22BSjMuNcGBGJrEL8mde_rAPX66qhw,137
257
258
  luna_quantum/utils.pyi,sha256=JbBq1V2SpGy4IbwqCQQKoJUM17LiTD35Wv8Im1YY1pw,2008
258
- luna_quantum-1.0.2rc1.dist-info/RECORD,,
259
+ luna_quantum-1.0.3rc2.dist-info/RECORD,,