luna-quantum 0.0.16__py3-none-any.whl → 0.0.29__py3-none-any.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-0.0.16.dist-info → luna_quantum-0.0.29.dist-info}/METADATA +2 -1
- {luna_quantum-0.0.16.dist-info → luna_quantum-0.0.29.dist-info}/RECORD +57 -53
- luna_sdk/controllers/custom_login_client.py +8 -3
- luna_sdk/controllers/luna_platform_client.py +9 -9
- luna_sdk/controllers/luna_q.py +7 -10
- luna_sdk/controllers/luna_solve.py +8 -15
- luna_sdk/controllers/luna_transform.py +9 -16
- luna_sdk/interfaces/circuit_repo_i.py +18 -12
- luna_sdk/interfaces/cplex_repo_i.py +25 -10
- luna_sdk/interfaces/info_repo_i.py +10 -3
- luna_sdk/interfaces/lp_repo_i.py +20 -8
- luna_sdk/interfaces/optimization_repo_i.py +31 -57
- luna_sdk/interfaces/qpu_token_repo_i.py +24 -28
- luna_sdk/interfaces/solutions_repo_i.py +44 -24
- luna_sdk/repositories/circuit_repo.py +11 -44
- luna_sdk/repositories/cplex_repo.py +32 -20
- luna_sdk/repositories/info_repo.py +4 -7
- luna_sdk/repositories/lp_repo.py +21 -15
- luna_sdk/repositories/optimization_repo.py +25 -200
- luna_sdk/repositories/qpu_token_repo.py +28 -120
- luna_sdk/repositories/solutions_repo.py +109 -181
- luna_sdk/schemas/create/solution.py +2 -2
- luna_sdk/schemas/optimization.py +9 -11
- luna_sdk/schemas/pretty_base.py +10 -3
- luna_sdk/schemas/qpu_token.py +3 -0
- luna_sdk/schemas/solution.py +7 -6
- luna_sdk/schemas/solver_info.py +31 -1
- luna_sdk/schemas/solver_parameters/aws/optimizer_params.py +40 -0
- luna_sdk/schemas/solver_parameters/aws/qaoa.py +36 -4
- luna_sdk/schemas/solver_parameters/base_parameter.py +5 -0
- luna_sdk/schemas/solver_parameters/dwave/base.py +15 -14
- luna_sdk/schemas/solver_parameters/dwave/dialectic_search.py +3 -2
- luna_sdk/schemas/solver_parameters/dwave/kerberos.py +2 -3
- luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_bqm.py +2 -2
- luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_cqm.py +2 -2
- luna_sdk/schemas/solver_parameters/dwave/parallel_tempering.py +2 -3
- luna_sdk/schemas/solver_parameters/dwave/parallel_tempering_qpu.py +2 -3
- luna_sdk/schemas/solver_parameters/dwave/population_annealing.py +2 -3
- luna_sdk/schemas/solver_parameters/dwave/population_annealing_qpu.py +2 -1
- luna_sdk/schemas/solver_parameters/dwave/qaga.py +4 -2
- luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_qpu.py +2 -3
- luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_simulated_annealing.py +2 -3
- luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_tabu_search.py +2 -3
- luna_sdk/schemas/solver_parameters/dwave/quantum_annealing.py +2 -3
- luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_quantum_annealing.py +4 -2
- luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_simulated_annealing.py +3 -2
- luna_sdk/schemas/solver_parameters/dwave/saga.py +1 -1
- luna_sdk/schemas/solver_parameters/dwave/tabu_search.py +3 -1
- luna_sdk/schemas/solver_parameters/fujitsu/base.py +5 -4
- luna_sdk/schemas/solver_parameters/fujitsu/partial_config.py +7 -5
- luna_sdk/schemas/solver_parameters/ibm/standard_parameters.py +121 -7
- luna_sdk/schemas/solver_parameters/qctrl/qaoa.py +2 -2
- luna_sdk/schemas/wrappers/__init__.py +1 -0
- luna_sdk/schemas/wrappers/datetime_wrapper.py +31 -0
- luna_sdk/utils/parameter_finder.py +90 -0
- luna_sdk/constants.py +0 -1
- {luna_quantum-0.0.16.dist-info → luna_quantum-0.0.29.dist-info}/LICENSE +0 -0
- {luna_quantum-0.0.16.dist-info → luna_quantum-0.0.29.dist-info}/WHEEL +0 -0
luna_sdk/interfaces/lp_repo_i.py
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
2
|
from functools import partial
|
|
3
|
-
from typing import
|
|
3
|
+
from typing import Any, Dict, List, Tuple
|
|
4
4
|
|
|
5
5
|
import dimod
|
|
6
6
|
from dimod import ConstrainedQuadraticModel
|
|
7
7
|
from dimod.constrained.constrained import CQMToBQMInverter
|
|
8
|
-
from docplex.mp.model import Model as DOCplexModel
|
|
8
|
+
from docplex.mp.model import Model as DOCplexModel
|
|
9
9
|
from qiskit_optimization import QuadraticProgram
|
|
10
10
|
|
|
11
|
-
from luna_sdk.interfaces import IRepository
|
|
11
|
+
from luna_sdk.interfaces import IRepository
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class ILPRepo(IRepository, ABC):
|
|
@@ -19,7 +19,7 @@ class ILPRepo(IRepository, ABC):
|
|
|
19
19
|
return inverter_bqm(var_sample)
|
|
20
20
|
|
|
21
21
|
@abstractmethod
|
|
22
|
-
def to_qubo_qiskit(self, lp_string: str) -> QuadraticProgram:
|
|
22
|
+
def to_qubo_qiskit(self, lp_string: str, **kwargs) -> QuadraticProgram:
|
|
23
23
|
"""
|
|
24
24
|
Transform LP to QUBO Qiskit
|
|
25
25
|
|
|
@@ -27,6 +27,8 @@ class ILPRepo(IRepository, ABC):
|
|
|
27
27
|
----------
|
|
28
28
|
lp_string: str
|
|
29
29
|
LP problem description
|
|
30
|
+
**kwargs
|
|
31
|
+
Parameters to pass to `httpx.request`.
|
|
30
32
|
|
|
31
33
|
Returns
|
|
32
34
|
-------
|
|
@@ -36,7 +38,7 @@ class ILPRepo(IRepository, ABC):
|
|
|
36
38
|
raise NotImplementedError
|
|
37
39
|
|
|
38
40
|
@abstractmethod
|
|
39
|
-
def to_docplex(self, lp_string: str) -> DOCplexModel:
|
|
41
|
+
def to_docplex(self, lp_string: str, **kwargs) -> DOCplexModel:
|
|
40
42
|
"""
|
|
41
43
|
Transform LP to DOCplex
|
|
42
44
|
|
|
@@ -44,6 +46,8 @@ class ILPRepo(IRepository, ABC):
|
|
|
44
46
|
----------
|
|
45
47
|
lp_string: str
|
|
46
48
|
LP problem description
|
|
49
|
+
**kwargs
|
|
50
|
+
Parameters to pass to `httpx.request`.
|
|
47
51
|
|
|
48
52
|
Returns
|
|
49
53
|
-------
|
|
@@ -53,7 +57,9 @@ class ILPRepo(IRepository, ABC):
|
|
|
53
57
|
raise NotImplementedError
|
|
54
58
|
|
|
55
59
|
@abstractmethod
|
|
56
|
-
def to_qubo_matrix(
|
|
60
|
+
def to_qubo_matrix(
|
|
61
|
+
self, lp_string: str, **kwargs
|
|
62
|
+
) -> Tuple[List[List[float]], partial]:
|
|
57
63
|
"""
|
|
58
64
|
Transform LP to QUBO matrix
|
|
59
65
|
|
|
@@ -61,6 +67,8 @@ class ILPRepo(IRepository, ABC):
|
|
|
61
67
|
----------
|
|
62
68
|
lp_string: str
|
|
63
69
|
LP problem description
|
|
70
|
+
**kwargs
|
|
71
|
+
Parameters to pass to `httpx.request`.
|
|
64
72
|
|
|
65
73
|
Returns
|
|
66
74
|
-------
|
|
@@ -71,7 +79,7 @@ class ILPRepo(IRepository, ABC):
|
|
|
71
79
|
|
|
72
80
|
@abstractmethod
|
|
73
81
|
def to_bqm(
|
|
74
|
-
self, lp_string: str
|
|
82
|
+
self, lp_string: str, **kwargs
|
|
75
83
|
) -> Tuple[dimod.BinaryQuadraticModel, CQMToBQMInverter]:
|
|
76
84
|
"""
|
|
77
85
|
Transform LP to BQM model
|
|
@@ -80,6 +88,8 @@ class ILPRepo(IRepository, ABC):
|
|
|
80
88
|
----------
|
|
81
89
|
lp_string: str
|
|
82
90
|
LP problem description
|
|
91
|
+
**kwargs
|
|
92
|
+
Parameters to pass to `httpx.request`.
|
|
83
93
|
|
|
84
94
|
Returns
|
|
85
95
|
-------
|
|
@@ -89,7 +99,7 @@ class ILPRepo(IRepository, ABC):
|
|
|
89
99
|
raise NotImplementedError
|
|
90
100
|
|
|
91
101
|
@abstractmethod
|
|
92
|
-
def to_cqm(self, lp_string: str) -> ConstrainedQuadraticModel:
|
|
102
|
+
def to_cqm(self, lp_string: str, **kwargs) -> ConstrainedQuadraticModel:
|
|
93
103
|
"""
|
|
94
104
|
Transform LP to CQM model
|
|
95
105
|
|
|
@@ -97,6 +107,8 @@ class ILPRepo(IRepository, ABC):
|
|
|
97
107
|
----------
|
|
98
108
|
lp_string: str
|
|
99
109
|
LP problem description
|
|
110
|
+
**kwargs
|
|
111
|
+
Parameters to pass to `httpx.request`.
|
|
100
112
|
|
|
101
113
|
Returns
|
|
102
114
|
-------
|
|
@@ -7,18 +7,13 @@ from dimod import BinaryQuadraticModel, ConstrainedQuadraticModel
|
|
|
7
7
|
from luna_sdk.interfaces.repository_i import IRepository
|
|
8
8
|
from luna_sdk.schemas.enums.optimization import InputType
|
|
9
9
|
from luna_sdk.schemas.enums.timeframe import TimeframeEnum
|
|
10
|
-
from luna_sdk.schemas.optimization import
|
|
11
|
-
Optimization,
|
|
12
|
-
)
|
|
10
|
+
from luna_sdk.schemas.optimization import Optimization
|
|
13
11
|
from luna_sdk.schemas.use_cases import UseCase
|
|
14
12
|
|
|
15
13
|
|
|
16
14
|
class IOptimizationRepo(IRepository, ABC):
|
|
17
15
|
@abstractmethod
|
|
18
|
-
def get(
|
|
19
|
-
self,
|
|
20
|
-
optimization_id: str,
|
|
21
|
-
) -> Optimization:
|
|
16
|
+
def get(self, optimization_id: str, **kwargs) -> Optimization:
|
|
22
17
|
"""
|
|
23
18
|
Retrieve a optimization by id.
|
|
24
19
|
|
|
@@ -26,6 +21,8 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
26
21
|
----------
|
|
27
22
|
optimization_id: str
|
|
28
23
|
Id of the optimization to be retrieved.
|
|
24
|
+
**kwargs
|
|
25
|
+
Parameters to pass to `httpx.request`.
|
|
29
26
|
|
|
30
27
|
Returns
|
|
31
28
|
-------
|
|
@@ -41,6 +38,7 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
41
38
|
input_type: Optional[InputType] = None,
|
|
42
39
|
limit: int = 50,
|
|
43
40
|
offset: int = 0,
|
|
41
|
+
**kwargs,
|
|
44
42
|
) -> List[Optimization]:
|
|
45
43
|
"""
|
|
46
44
|
Retrieve a list of optimizations.
|
|
@@ -56,6 +54,8 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
56
54
|
Limit the number of optimizations to be returned. Default value 50.
|
|
57
55
|
offset:
|
|
58
56
|
Offset the list of optimizations by this amount. Default value 0.
|
|
57
|
+
**kwargs
|
|
58
|
+
Parameters to pass to `httpx.request`.
|
|
59
59
|
|
|
60
60
|
Returns
|
|
61
61
|
-------
|
|
@@ -66,10 +66,7 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
66
66
|
|
|
67
67
|
@abstractmethod
|
|
68
68
|
def create_from_qubo(
|
|
69
|
-
self,
|
|
70
|
-
name: str,
|
|
71
|
-
matrix: List[List[float]],
|
|
72
|
-
timeout: Optional[float] = 10.0,
|
|
69
|
+
self, name: str, matrix: List[List[float]], **kwargs
|
|
73
70
|
) -> Optimization:
|
|
74
71
|
"""
|
|
75
72
|
Create an optimization from a QUBO matrix.
|
|
@@ -80,10 +77,8 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
80
77
|
Name of the optimization to be created.
|
|
81
78
|
matrix: List[List[float]]
|
|
82
79
|
QUBO matrix.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
there won't be any timeout. Increase or disable the timeout if you face
|
|
86
|
-
issues uploading big QUBO matrices.
|
|
80
|
+
**kwargs
|
|
81
|
+
Parameters to pass to `httpx.request`.
|
|
87
82
|
|
|
88
83
|
Returns
|
|
89
84
|
-------
|
|
@@ -94,10 +89,7 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
94
89
|
|
|
95
90
|
@abstractmethod
|
|
96
91
|
def create_from_use_case(
|
|
97
|
-
self,
|
|
98
|
-
name: str,
|
|
99
|
-
use_case: UseCase,
|
|
100
|
-
timeout: Optional[float] = 10.0,
|
|
92
|
+
self, name: str, use_case: UseCase, **kwargs
|
|
101
93
|
) -> Optimization:
|
|
102
94
|
"""
|
|
103
95
|
Create an optimization from a use case.
|
|
@@ -108,10 +100,8 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
108
100
|
Name of the optimization to be created.
|
|
109
101
|
use_case: UseCase
|
|
110
102
|
Use case.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
there won't be any timeout. Increase or disable the timeout if you face
|
|
114
|
-
issues uploading big Problems.
|
|
103
|
+
**kwargs
|
|
104
|
+
Parameters to pass to `httpx.request`.
|
|
115
105
|
|
|
116
106
|
Returns
|
|
117
107
|
-------
|
|
@@ -122,10 +112,7 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
122
112
|
|
|
123
113
|
@abstractmethod
|
|
124
114
|
def create_from_bqm(
|
|
125
|
-
self,
|
|
126
|
-
name: str,
|
|
127
|
-
bqm: BinaryQuadraticModel,
|
|
128
|
-
timeout: Optional[float] = 10.0,
|
|
115
|
+
self, name: str, bqm: BinaryQuadraticModel, **kwargs
|
|
129
116
|
) -> Optimization:
|
|
130
117
|
"""
|
|
131
118
|
Create an optimization from BQM.
|
|
@@ -136,10 +123,8 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
136
123
|
Name of the optimization to be created.
|
|
137
124
|
bqm: BinaryQuadraticModel
|
|
138
125
|
QUBO in dimod BQM format.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
there won't be any timeout. Increase or disable the timeout if you face
|
|
142
|
-
issues uploading big Problems.
|
|
126
|
+
**kwargs
|
|
127
|
+
Parameters to pass to `httpx.request`.
|
|
143
128
|
|
|
144
129
|
Returns
|
|
145
130
|
-------
|
|
@@ -150,10 +135,7 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
150
135
|
|
|
151
136
|
@abstractmethod
|
|
152
137
|
def create_from_cqm(
|
|
153
|
-
self,
|
|
154
|
-
name: str,
|
|
155
|
-
cqm: ConstrainedQuadraticModel,
|
|
156
|
-
timeout: Optional[float] = 10.0,
|
|
138
|
+
self, name: str, cqm: ConstrainedQuadraticModel, **kwargs
|
|
157
139
|
) -> Optimization:
|
|
158
140
|
"""
|
|
159
141
|
Create an optimization from CQM.
|
|
@@ -164,7 +146,8 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
164
146
|
Name of the optimization to be created.
|
|
165
147
|
cqm: ConstrainedQuadraticModel
|
|
166
148
|
in dimod CQM format.
|
|
167
|
-
|
|
149
|
+
**kwargs
|
|
150
|
+
Parameters to pass to `httpx.request`.
|
|
168
151
|
|
|
169
152
|
Returns
|
|
170
153
|
-------
|
|
@@ -175,10 +158,7 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
175
158
|
|
|
176
159
|
@abstractmethod
|
|
177
160
|
def create_from_lp_file(
|
|
178
|
-
self,
|
|
179
|
-
name: str,
|
|
180
|
-
lp_file: BufferedReader,
|
|
181
|
-
timeout: Optional[float] = 10.0,
|
|
161
|
+
self, name: str, lp_file: BufferedReader, **kwargs
|
|
182
162
|
) -> Optimization:
|
|
183
163
|
"""
|
|
184
164
|
Create an optimization from LP file.
|
|
@@ -188,10 +168,8 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
188
168
|
name: str
|
|
189
169
|
Name of the optimization to be created.
|
|
190
170
|
lp_file: buffer reader.
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
there won't be any timeout. Increase or disable the timeout if you face
|
|
194
|
-
issues uploading big Problems.
|
|
171
|
+
**kwargs
|
|
172
|
+
Parameters to pass to `httpx.request`.
|
|
195
173
|
|
|
196
174
|
Returns
|
|
197
175
|
-------
|
|
@@ -202,10 +180,7 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
202
180
|
|
|
203
181
|
@abstractmethod
|
|
204
182
|
def create_from_lp_string(
|
|
205
|
-
self,
|
|
206
|
-
name: str,
|
|
207
|
-
lp_string: str,
|
|
208
|
-
timeout: Optional[float] = 10.0,
|
|
183
|
+
self, name: str, lp_string: str, **kwargs
|
|
209
184
|
) -> Optimization:
|
|
210
185
|
"""
|
|
211
186
|
Create an optimization from LP file.
|
|
@@ -215,10 +190,8 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
215
190
|
name: str
|
|
216
191
|
Name of the optimization to be created.
|
|
217
192
|
lp_string: string.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
there won't be any timeout. Increase or disable the timeout if you face
|
|
221
|
-
issues uploading big Problems.
|
|
193
|
+
**kwargs
|
|
194
|
+
Parameters to pass to `httpx.request`.
|
|
222
195
|
|
|
223
196
|
Returns
|
|
224
197
|
-------
|
|
@@ -228,7 +201,7 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
228
201
|
raise NotImplementedError
|
|
229
202
|
|
|
230
203
|
@abstractmethod
|
|
231
|
-
def rename(self, optimization_id: str, name: str) -> Optimization:
|
|
204
|
+
def rename(self, optimization_id: str, name: str, **kwargs) -> Optimization:
|
|
232
205
|
"""
|
|
233
206
|
Update the name of the optimization
|
|
234
207
|
|
|
@@ -238,6 +211,8 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
238
211
|
Id of the optimization to be updated.
|
|
239
212
|
name: str
|
|
240
213
|
New name of the optimization
|
|
214
|
+
**kwargs
|
|
215
|
+
Parameters to pass to `httpx.request`.
|
|
241
216
|
|
|
242
217
|
Returns
|
|
243
218
|
-------
|
|
@@ -247,10 +222,7 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
247
222
|
raise NotImplementedError
|
|
248
223
|
|
|
249
224
|
@abstractmethod
|
|
250
|
-
def delete(
|
|
251
|
-
self,
|
|
252
|
-
optimization_id: str,
|
|
253
|
-
) -> None:
|
|
225
|
+
def delete(self, optimization_id: str, **kwargs) -> None:
|
|
254
226
|
"""
|
|
255
227
|
Delete an optimization by id.
|
|
256
228
|
|
|
@@ -258,5 +230,7 @@ class IOptimizationRepo(IRepository, ABC):
|
|
|
258
230
|
----------
|
|
259
231
|
optimization_id: str
|
|
260
232
|
Id of the optimization to be deleted.
|
|
233
|
+
**kwargs
|
|
234
|
+
Parameters to pass to `httpx.request`.
|
|
261
235
|
"""
|
|
262
236
|
raise NotImplementedError
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
|
-
from typing import Dict, List,
|
|
2
|
+
from typing import Dict, List, Optional
|
|
3
3
|
|
|
4
4
|
from luna_sdk.interfaces.repository_i import IRepository
|
|
5
5
|
from luna_sdk.schemas import QpuTokenOut
|
|
@@ -13,8 +13,9 @@ class IQpuTokenRepo(IRepository, ABC):
|
|
|
13
13
|
name: str,
|
|
14
14
|
provider: str,
|
|
15
15
|
token: str,
|
|
16
|
-
token_type: QpuTokenTypeEnum
|
|
16
|
+
token_type: QpuTokenTypeEnum,
|
|
17
17
|
encryption_key: Optional[str] = None,
|
|
18
|
+
**kwargs,
|
|
18
19
|
) -> QpuTokenOut:
|
|
19
20
|
"""
|
|
20
21
|
Create organization QPU token
|
|
@@ -23,17 +24,19 @@ class IQpuTokenRepo(IRepository, ABC):
|
|
|
23
24
|
----------
|
|
24
25
|
name: str
|
|
25
26
|
Name of the QPU token
|
|
26
|
-
provider:
|
|
27
|
+
provider: str
|
|
27
28
|
Name of provider
|
|
28
29
|
token: str
|
|
29
30
|
Token
|
|
30
31
|
token_type: QpuTokenTypeEnum
|
|
31
32
|
There are two types of QPU tokens: PERSONAL and ORGANIZATION.
|
|
32
|
-
The default value is PERSONAL.
|
|
33
33
|
All users of an organization can use organization QPU tokens.
|
|
34
34
|
User QPU tokens can only be used by the user who created them.
|
|
35
35
|
encryption_key: Optional[str]
|
|
36
36
|
Encryption key to be used for encryption of QPU tokens.
|
|
37
|
+
**kwargs
|
|
38
|
+
Parameters to pass to `httpx.request`.
|
|
39
|
+
|
|
37
40
|
Returns
|
|
38
41
|
-------
|
|
39
42
|
QpuTokenOut
|
|
@@ -47,6 +50,7 @@ class IQpuTokenRepo(IRepository, ABC):
|
|
|
47
50
|
filter_provider: Optional[str] = None,
|
|
48
51
|
name: Optional[str] = None,
|
|
49
52
|
token_type: Optional[QpuTokenTypeEnum] = None,
|
|
53
|
+
**kwargs,
|
|
50
54
|
) -> Dict[QpuTokenTypeEnum, List[QpuTokenOut]]:
|
|
51
55
|
"""
|
|
52
56
|
Retrieve a list of QPU tokens.
|
|
@@ -60,6 +64,9 @@ class IQpuTokenRepo(IRepository, ABC):
|
|
|
60
64
|
token_type: Optional[QpuTokenTypeEnum]
|
|
61
65
|
If you want to retrieve only user or organization QPU tokens
|
|
62
66
|
otherwise all QPU tokens will be retrieved
|
|
67
|
+
**kwargs
|
|
68
|
+
Parameters to pass to `httpx.request`.
|
|
69
|
+
|
|
63
70
|
Returns
|
|
64
71
|
-------
|
|
65
72
|
Dict[QpuTokenTypeEnum, List[QpuTokenOut]]
|
|
@@ -68,24 +75,20 @@ class IQpuTokenRepo(IRepository, ABC):
|
|
|
68
75
|
raise NotImplementedError
|
|
69
76
|
|
|
70
77
|
@abstractmethod
|
|
71
|
-
def get(
|
|
72
|
-
self,
|
|
73
|
-
name: str,
|
|
74
|
-
token_type: QpuTokenTypeEnum = QpuTokenTypeEnum.PERSONAL,
|
|
75
|
-
) -> QpuTokenOut:
|
|
78
|
+
def get(self, name: str, token_type: QpuTokenTypeEnum, **kwargs) -> QpuTokenOut:
|
|
76
79
|
"""
|
|
77
|
-
Retrieve user QPU token by id
|
|
80
|
+
Retrieve user QPU token by id.
|
|
78
81
|
|
|
79
82
|
Parameters
|
|
80
83
|
----------
|
|
81
84
|
name: str
|
|
82
85
|
Name of the QPU token that should be retrieved
|
|
83
|
-
|
|
84
86
|
token_type: QpuTokenTypeEnum
|
|
85
87
|
There are two types of QPU tokens: PERSONAL and ORGANIZATION.
|
|
86
|
-
The default value is PERSONAL.
|
|
87
88
|
All users of an organization can use organization QPU tokens.
|
|
88
89
|
User QPU tokens can only be used by the user who created them.
|
|
90
|
+
**kwargs
|
|
91
|
+
Parameters to pass to `httpx.request`.
|
|
89
92
|
|
|
90
93
|
Returns
|
|
91
94
|
-------
|
|
@@ -99,10 +102,11 @@ class IQpuTokenRepo(IRepository, ABC):
|
|
|
99
102
|
self,
|
|
100
103
|
name: str,
|
|
101
104
|
new_name: str,
|
|
102
|
-
token_type: QpuTokenTypeEnum
|
|
105
|
+
token_type: QpuTokenTypeEnum,
|
|
106
|
+
**kwargs,
|
|
103
107
|
) -> QpuTokenOut:
|
|
104
108
|
"""
|
|
105
|
-
Update organization QPU token by id
|
|
109
|
+
Update organization QPU token by id.
|
|
106
110
|
|
|
107
111
|
Parameters
|
|
108
112
|
----------
|
|
@@ -110,13 +114,12 @@ class IQpuTokenRepo(IRepository, ABC):
|
|
|
110
114
|
Current name of the QPU token that should be updated
|
|
111
115
|
new_name: str
|
|
112
116
|
The new name
|
|
113
|
-
|
|
114
117
|
token_type: QpuTokenTypeEnum
|
|
115
118
|
There are two types of QPU tokens: PERSONAL and ORGANIZATION.
|
|
116
|
-
The default value is PERSONAL.
|
|
117
119
|
All users of an organization can use organization QPU tokens.
|
|
118
120
|
User QPU tokens can only be used by the user who created them.
|
|
119
|
-
|
|
121
|
+
**kwargs
|
|
122
|
+
Parameters to pass to `httpx.request`.
|
|
120
123
|
|
|
121
124
|
Returns
|
|
122
125
|
-------
|
|
@@ -126,26 +129,19 @@ class IQpuTokenRepo(IRepository, ABC):
|
|
|
126
129
|
raise NotImplementedError
|
|
127
130
|
|
|
128
131
|
@abstractmethod
|
|
129
|
-
def delete(
|
|
130
|
-
self,
|
|
131
|
-
name: str,
|
|
132
|
-
token_type: QpuTokenTypeEnum = QpuTokenTypeEnum.PERSONAL,
|
|
133
|
-
) -> None:
|
|
132
|
+
def delete(self, name: str, token_type: QpuTokenTypeEnum, **kwargs) -> None:
|
|
134
133
|
"""
|
|
135
|
-
Delete organization QPU token by
|
|
134
|
+
Delete organization QPU token by name.
|
|
136
135
|
|
|
137
136
|
Parameters
|
|
138
137
|
----------
|
|
139
138
|
name: str
|
|
140
139
|
Name of the QPU token that should be deleted
|
|
141
|
-
|
|
142
140
|
token_type: QpuTokenTypeEnum
|
|
143
141
|
There are two types of QPU tokens: PERSONAL and ORGANIZATION.
|
|
144
|
-
The default value is PERSONAL.
|
|
145
142
|
All users of an organization can use organization QPU tokens.
|
|
146
143
|
User QPU tokens can only be used by the user who created them.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
-------
|
|
144
|
+
**kwargs
|
|
145
|
+
Parameters to pass to `httpx.request`.
|
|
150
146
|
"""
|
|
151
147
|
raise NotImplementedError
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
|
-
from typing import Dict, List, Optional, Union
|
|
2
|
+
from typing import Any, Dict, List, Optional, Union
|
|
3
3
|
|
|
4
4
|
from pydantic import BaseModel
|
|
5
5
|
|
|
@@ -22,6 +22,7 @@ class ISolutionsRepo(IRepository, ABC):
|
|
|
22
22
|
limit: int = 50,
|
|
23
23
|
offset: int = 0,
|
|
24
24
|
optimization_id: Optional[str] = None,
|
|
25
|
+
**kwargs,
|
|
25
26
|
) -> List[Solution]:
|
|
26
27
|
"""
|
|
27
28
|
Get list of available optimizations.
|
|
@@ -36,6 +37,8 @@ class ISolutionsRepo(IRepository, ABC):
|
|
|
36
37
|
Offset the list of solutions by this amount. Default value 0.
|
|
37
38
|
optimization_id: Optional[str]
|
|
38
39
|
Show solutions for only this optimization id. Default None.
|
|
40
|
+
**kwargs
|
|
41
|
+
Parameters to pass to `httpx.request`.
|
|
39
42
|
|
|
40
43
|
Returns
|
|
41
44
|
-------
|
|
@@ -45,14 +48,16 @@ class ISolutionsRepo(IRepository, ABC):
|
|
|
45
48
|
raise NotImplementedError
|
|
46
49
|
|
|
47
50
|
@abstractmethod
|
|
48
|
-
def get(self, solution_id: str) -> Solution:
|
|
51
|
+
def get(self, solution_id: str, **kwargs) -> Solution:
|
|
49
52
|
"""
|
|
50
53
|
Retrieve one optimization by id.
|
|
51
54
|
|
|
52
55
|
Parameters
|
|
53
56
|
----------
|
|
54
57
|
solution_id: str
|
|
55
|
-
Id of the solution that should be retrieved
|
|
58
|
+
Id of the solution that should be retrieved.
|
|
59
|
+
**kwargs
|
|
60
|
+
Parameters to pass to `httpx.request`.
|
|
56
61
|
|
|
57
62
|
Returns
|
|
58
63
|
-------
|
|
@@ -62,14 +67,18 @@ class ISolutionsRepo(IRepository, ABC):
|
|
|
62
67
|
raise NotImplementedError
|
|
63
68
|
|
|
64
69
|
@abstractmethod
|
|
65
|
-
def get_use_case_representation(
|
|
70
|
+
def get_use_case_representation(
|
|
71
|
+
self, solution_id: str, **kwargs
|
|
72
|
+
) -> UseCaseRepresentation:
|
|
66
73
|
"""
|
|
67
74
|
Get the use-case-specific representation of a solution.
|
|
68
75
|
|
|
69
76
|
Parameters
|
|
70
77
|
----------
|
|
71
78
|
solution_id: str
|
|
72
|
-
Id of the solution that should be retrieved
|
|
79
|
+
Id of the solution that should be retrieved.
|
|
80
|
+
**kwargs
|
|
81
|
+
Parameters to pass to `httpx.request`.
|
|
73
82
|
|
|
74
83
|
Returns
|
|
75
84
|
-------
|
|
@@ -78,17 +87,16 @@ class ISolutionsRepo(IRepository, ABC):
|
|
|
78
87
|
"""
|
|
79
88
|
|
|
80
89
|
@abstractmethod
|
|
81
|
-
def delete(self, solution_id: str) -> None:
|
|
90
|
+
def delete(self, solution_id: str, **kwargs) -> None:
|
|
82
91
|
"""
|
|
83
92
|
Delete one optimization by id.
|
|
84
93
|
|
|
85
94
|
Parameters
|
|
86
95
|
----------
|
|
87
96
|
solution_id: str
|
|
88
|
-
Id of the optimization that should be deleted
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
-------
|
|
97
|
+
Id of the optimization that should be deleted.
|
|
98
|
+
**kwargs
|
|
99
|
+
Parameters to pass to `httpx.request`.
|
|
92
100
|
"""
|
|
93
101
|
raise NotImplementedError
|
|
94
102
|
|
|
@@ -99,34 +107,40 @@ class ISolutionsRepo(IRepository, ABC):
|
|
|
99
107
|
solver_name: str,
|
|
100
108
|
provider: str,
|
|
101
109
|
qpu_tokens: Optional[TokenProvider] = None,
|
|
102
|
-
solver_parameters: Optional[Union[Dict, BaseModel]] = None,
|
|
110
|
+
solver_parameters: Optional[Union[Dict[str, Any], BaseModel]] = None,
|
|
103
111
|
encryption_key: Optional[str] = None,
|
|
104
112
|
name: Optional[str] = None,
|
|
113
|
+
fail_on_invalid_params: bool = True,
|
|
114
|
+
**kwargs,
|
|
105
115
|
) -> Solution:
|
|
106
116
|
"""
|
|
107
|
-
Create a solution for optimization
|
|
117
|
+
Create a solution for optimization.
|
|
108
118
|
|
|
109
119
|
Parameters
|
|
110
120
|
----------
|
|
111
121
|
optimization_id: str
|
|
112
|
-
The id of the optimization for which solution should be created
|
|
122
|
+
The id of the optimization for which solution should be created.
|
|
113
123
|
solver_name: str
|
|
114
124
|
The name of the solver to use.
|
|
115
125
|
provider: str
|
|
116
126
|
The name of the provider to use.
|
|
117
127
|
qpu_tokens: Optional[TokenProvider]
|
|
118
128
|
The tokens to be used for the QPU.
|
|
119
|
-
solver_parameters: Optional[Union[Dict, BaseModel]]
|
|
129
|
+
solver_parameters: Optional[Union[Dict[str, Any], BaseModel]]
|
|
120
130
|
Parameters to be passed to the solver.
|
|
121
131
|
encryption_key: Optional[str]
|
|
122
132
|
Encryption key to be used for encryption of QPU tokens.
|
|
123
133
|
name: Optional[str]
|
|
124
134
|
Default: None, The name of the solution to create.
|
|
135
|
+
fail_on_invalid_params: bool
|
|
136
|
+
Default: true. Disable the local solver parameter validation.
|
|
137
|
+
**kwargs
|
|
138
|
+
Parameters to pass to `httpx.request`.
|
|
125
139
|
|
|
126
140
|
Returns
|
|
127
141
|
-------
|
|
128
142
|
SolutionOut
|
|
129
|
-
|
|
143
|
+
The location where the solution can be found once solving is complete.
|
|
130
144
|
"""
|
|
131
145
|
raise NotImplementedError
|
|
132
146
|
|
|
@@ -137,12 +151,14 @@ class ISolutionsRepo(IRepository, ABC):
|
|
|
137
151
|
solver_name: str,
|
|
138
152
|
provider: str,
|
|
139
153
|
qpu_tokens: Optional[TokenProvider] = None,
|
|
140
|
-
solver_parameters: Optional[Union[Dict, BaseModel]] = None,
|
|
154
|
+
solver_parameters: Optional[Union[Dict[str, Any], BaseModel]] = None,
|
|
141
155
|
sleep_time_max: float = 60.0,
|
|
142
156
|
sleep_time_increment: float = 5.0,
|
|
143
157
|
sleep_time_initial: float = 5.0,
|
|
144
158
|
encryption_key: Optional[str] = None,
|
|
145
159
|
name: Optional[str] = None,
|
|
160
|
+
fail_on_invalid_params: bool = True,
|
|
161
|
+
**kwargs,
|
|
146
162
|
) -> Solution:
|
|
147
163
|
"""
|
|
148
164
|
Create a solution for optimization. This method will block your code until the solution is ready.
|
|
@@ -151,16 +167,15 @@ class ISolutionsRepo(IRepository, ABC):
|
|
|
151
167
|
Parameters
|
|
152
168
|
----------
|
|
153
169
|
optimization_id: str
|
|
154
|
-
The id of the optimization for which solution should be created
|
|
170
|
+
The id of the optimization for which solution should be created.
|
|
155
171
|
solver_name: str
|
|
156
172
|
The name of the solver to use.
|
|
157
173
|
provider: str
|
|
158
174
|
The name of the provider to use.
|
|
159
175
|
qpu_tokens: Optional[TokenProvider] = None
|
|
160
176
|
The tokens to be used for the QPU.
|
|
161
|
-
solver_parameters: Optional[Union[Dict, BaseModel]]
|
|
177
|
+
solver_parameters: Optional[Union[Dict[str, Any], BaseModel]]
|
|
162
178
|
Parameters to be passed to the solver.
|
|
163
|
-
|
|
164
179
|
sleep_time_max: float
|
|
165
180
|
Maximum time to sleep between requests.
|
|
166
181
|
sleep_time_increment: float
|
|
@@ -171,10 +186,15 @@ class ISolutionsRepo(IRepository, ABC):
|
|
|
171
186
|
Encryption key to be used for encryption of QPU tokens.
|
|
172
187
|
name: Optional[str]
|
|
173
188
|
Default: None, The name of the solution to create.
|
|
189
|
+
fail_on_invalid_params: bool
|
|
190
|
+
Default: true. Disable the local solver parameter validation.
|
|
191
|
+
**kwargs
|
|
192
|
+
Parameters to pass to `httpx.request`.
|
|
193
|
+
|
|
174
194
|
Returns
|
|
175
195
|
-------
|
|
176
196
|
SolutionOut
|
|
177
|
-
|
|
197
|
+
The location where the solution can be found once solving is complete.
|
|
178
198
|
"""
|
|
179
199
|
raise NotImplementedError
|
|
180
200
|
|
|
@@ -186,14 +206,14 @@ class ISolutionsRepo(IRepository, ABC):
|
|
|
186
206
|
Parameters
|
|
187
207
|
----------
|
|
188
208
|
solution : Solution
|
|
189
|
-
The solution received via
|
|
209
|
+
The solution received via `solutions.get` or `solutions.get_all`.
|
|
190
210
|
|
|
191
211
|
Returns
|
|
192
212
|
-------
|
|
193
|
-
Result
|
|
213
|
+
Optional[Result]
|
|
194
214
|
The best result of the solution. If there are several best solutions with
|
|
195
215
|
the same objective value, return only the first. If the solution results are
|
|
196
|
-
not (yet) available
|
|
216
|
+
not (yet) available or the solution sense is `None`, `None` is returned.
|
|
197
217
|
"""
|
|
198
218
|
raise NotImplementedError
|
|
199
219
|
|
|
@@ -214,6 +234,6 @@ class ISolutionsRepo(IRepository, ABC):
|
|
|
214
234
|
UseCaseResult | None
|
|
215
235
|
The best result of the solution. If there are several best solutions with
|
|
216
236
|
the same objective value, return only the first. If the solution results are
|
|
217
|
-
not (yet) available or
|
|
237
|
+
not (yet) available or the solution sense is `None`, `None` is returned.
|
|
218
238
|
"""
|
|
219
239
|
raise NotImplementedError
|