luna-quantum 1.0.2rc1__cp313-cp313-macosx_11_0_arm64.whl → 1.0.3rc2__cp313-cp313-macosx_11_0_arm64.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=ZlnHGE4Mo7ps1v16zvcAfrDnL3ds3Klm21sZZ52w3vY,104
3
- luna_quantum-1.0.2rc1.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
4
- luna_quantum-1.0.2rc1.dist-info/licenses/NOTICE,sha256=noPOS8eDj5XoyRO8ZrCxIOh5fSjk0RildIrrqxQlepY,588
5
- luna_quantum/__init__.py,sha256=VVqJBFKl8ET7gJmebXVnTsD33sIFfhxKm7_eB12YVkU,3170
6
- luna_quantum/__init__.pyi,sha256=dG3-NeEI8ApxHUcVq-Ov9Pa9D3Px_5yWUWkxhLsfL80,1608
7
- luna_quantum/_core.cpython-313-darwin.so,sha256=b9pLsdrV42afW1bmK2Ul9IgPBxtg34E9ItUXONGSSck,4122496
8
- luna_quantum/_core.pyi,sha256=dVgYQVxIfHdWQEYLYAkVUDulGlXQ9ktBdln_V7NnmNc,104258
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=ZlnHGE4Mo7ps1v16zvcAfrDnL3ds3Klm21sZZ52w3vY,104
3
+ luna_quantum-1.0.3rc2.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
4
+ luna_quantum-1.0.3rc2.dist-info/licenses/NOTICE,sha256=noPOS8eDj5XoyRO8ZrCxIOh5fSjk0RildIrrqxQlepY,588
5
+ luna_quantum/__init__.py,sha256=RV92O-Th8ktm0S9kcpfRfECkeeORP-tbDKfpa4u1CiY,3223
6
+ luna_quantum/__init__.pyi,sha256=tcM9H4ZAKxgt8KYnFmKH5OHSJZ0zv7J8dMdYMZp6m3s,1661
7
+ luna_quantum/_core.cpython-313-darwin.so,sha256=Dn_vF0Ek30xTTazg1NPSGQd8h_jYrZQyLLVRoxT3Lx0,4139168
8
+ luna_quantum/_core.pyi,sha256=7HL0LZHypfEWlrnjzk3dT0kG3K92v3FkPylQmc9EITs,105472
9
9
  luna_quantum/algorithms/__init__.py,sha256=IX9ZpzY3Do3mTgKqto5vAWwdYrZrM-RemYSf64yxefg,69
10
10
  luna_quantum/aqm_overwrites/__init__.py,sha256=rteObr5JHDnTnRime0Euq9Qy2iDIp6VMpFNHTGVNBe0,46
11
11
  luna_quantum/aqm_overwrites/model.py,sha256=La5mh-aS2LNLaQFp_B1EnhrKUXVRRmIqGnIvX66uc8Y,6099
@@ -13,7 +13,7 @@ luna_quantum/backends/__init__.py,sha256=OaE9cTpXP07x2mhJ_kLFaHPYZJBzdEQhlP_ztnq
13
13
  luna_quantum/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  luna_quantum/client/controllers/__init__.py,sha256=yG8Gwatlm6f-OH2p3WLTyAsNePUER84eBxx67pkRi4A,156
15
15
  luna_quantum/client/controllers/luna_http_client.py,sha256=Siwtm0wQzdRZXw0ilkUmFXbD8tbRuJI7cEceWwfXos4,1057
16
- luna_quantum/client/controllers/luna_platform_client.py,sha256=IqkI3BKbwrtoCZk4pE_lTPFshMyWPEeKkkEm3C6Slvc,5158
16
+ luna_quantum/client/controllers/luna_platform_client.py,sha256=-X16kNpuvmFmVZl_QE9y-Qyek8XB90M2uXDqHYCefss,5216
17
17
  luna_quantum/client/controllers/luna_q.py,sha256=S8-Uvv9TYKC-yRo67T-g0kwIlDoEmluoAQlAl4otrQ4,1930
18
18
  luna_quantum/client/controllers/luna_solve.py,sha256=oqG_dR_82ccysm5Q4Gp9x7vQBb1xvCb9-mRA8qD8xzE,3399
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=tfd-JKBLr-0FwVEGKJFfvY1y
80
80
  luna_quantum/client/schemas/wrappers/datetime_wrapper.py,sha256=8K2jexTarxGCgD1ukgVUW5TCroYGWXGfzDfjLcJfYlk,768
81
81
  luna_quantum/client/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
82
82
  luna_quantum/client/utils/qpu_token_utils.py,sha256=xeWIKcBwXGSQ0INfUY3NMTu6H90T03jkT85yHs2QXmk,4768
83
+ luna_quantum/config.py,sha256=xx7DnjAvOeLUMlXvbXqQ4_EBAy53bjPYU1-QQO6I2lY,217
83
84
  luna_quantum/errors.py,sha256=yjeXB3i07LlTuuJ18IKgwsC5wmtJElN8cDwlg3JkcEs,1424
84
- luna_quantum/errors.pyi,sha256=sB9AKnafl1-duUZQPJNGDGBqE41QFhk1BX1jgBkqW6A,8745
85
+ luna_quantum/errors.pyi,sha256=daGAwiOdpgHPILYVSUy360AZQilRb-vdwh2pwAAn3CU,8900
85
86
  luna_quantum/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
86
87
  luna_quantum/exceptions/base_luna_quantum_error.py,sha256=qC712QkF04FiY_qwQ5HlIYVhg5P6WzXJ_chJDVTpWXI,89
87
88
  luna_quantum/exceptions/patch_class_field_exists_error.py,sha256=3TGKb-MNyjwntrJkbRaBKEvlsj68ROTwCltDt6Zg7Gg,398
@@ -245,14 +246,14 @@ luna_quantum/solve/usecases/solve_job_get_result_usecase.py,sha256=dk6LSjInOfH5d
245
246
  luna_quantum/transformations.py,sha256=AZtGBaJ0PTWsr4mpONoJq5BpNOXPcM85CnWDhPgXx_I,902
246
247
  luna_quantum/transformations.pyi,sha256=D71bSXST8vfib-jSez0s5sg8NJpN5obja4Y0BXoqUjA,7795
247
248
  luna_quantum/translator.py,sha256=xi5eiIRNv8ATz69GYpUY5kbEIUmQEtK6_dF5t2Mwpec,1134
248
- luna_quantum/translator.pyi,sha256=1kQyDBUWKV6vTyydC_f2K1aQzbW6_8sdcpgxCZJVaM4,26329
249
+ luna_quantum/translator.pyi,sha256=edLGrIFl6do9LaCH4znjnOD8Zb3va-9nBGq-H3XQHso,26478
249
250
  luna_quantum/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
250
251
  luna_quantum/util/active_waiting.py,sha256=MkLL7UEtWh8jU1Zwd9rYqfcReYPGB7FJLUjQe2v9_Tg,3029
251
252
  luna_quantum/util/class_patcher.py,sha256=-vD_7Auh1dQTOJXOKv-4sTQ5EzH3n6I0EsHDFQ_ZPOY,5456
252
253
  luna_quantum/util/debug_info.py,sha256=UjMcmX5waYEEH51cK8REUOdjpNX0D6HWSR0ns7yQp54,1755
253
- luna_quantum/util/log_utils.py,sha256=M8Gbt0Pb2CsQsG3fGyuKeT-rl264laEGGXcPCGfBhaQ,4918
254
+ luna_quantum/util/log_utils.py,sha256=8WK0ivN3Dq3QntIYu-eGRBrGyiBoFnZkRiX_GCc-IHQ,5471
254
255
  luna_quantum/util/pretty_base.py,sha256=Vv3dYpMsydOPYFOm-0lCCuJIe-62oYkI64Zy_bahl3s,2115
255
256
  luna_quantum/util/pydantic_utils.py,sha256=nhl_SdLJVAizrtLVHvnbco84g8CdBVdVxN_jlXiv82w,1263
256
257
  luna_quantum/utils.py,sha256=pBOkGXNJXlOzxAwTJv8nCj32Q6WNeh3t6Ka3lmTgy9c,134
257
258
  luna_quantum/utils.pyi,sha256=afjDJhGiM9KmN2zqVkd6agP8JAsbwUxJBW9tEyiFrdY,1941
258
- luna_quantum-1.0.2rc1.dist-info/RECORD,,
259
+ luna_quantum-1.0.3rc2.dist-info/RECORD,,