luna-quantum 0.0.16__py3-none-any.whl → 0.0.33__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.

Files changed (66) hide show
  1. {luna_quantum-0.0.16.dist-info → luna_quantum-0.0.33.dist-info}/METADATA +2 -1
  2. {luna_quantum-0.0.16.dist-info → luna_quantum-0.0.33.dist-info}/RECORD +64 -58
  3. luna_sdk/controllers/luna_http_client.py +27 -0
  4. luna_sdk/controllers/luna_platform_client.py +41 -23
  5. luna_sdk/controllers/luna_q.py +11 -16
  6. luna_sdk/controllers/luna_solve.py +12 -17
  7. luna_sdk/controllers/luna_transform.py +14 -15
  8. luna_sdk/error/http_error_utils.py +10 -3
  9. luna_sdk/interfaces/circuit_repo_i.py +18 -12
  10. luna_sdk/interfaces/cplex_repo_i.py +25 -10
  11. luna_sdk/interfaces/info_repo_i.py +10 -3
  12. luna_sdk/interfaces/lp_repo_i.py +20 -8
  13. luna_sdk/interfaces/optimization_repo_i.py +35 -60
  14. luna_sdk/interfaces/qpu_token_repo_i.py +40 -38
  15. luna_sdk/interfaces/solutions_repo_i.py +44 -24
  16. luna_sdk/repositories/circuit_repo.py +11 -44
  17. luna_sdk/repositories/cplex_repo.py +32 -20
  18. luna_sdk/repositories/info_repo.py +4 -7
  19. luna_sdk/repositories/lp_repo.py +21 -15
  20. luna_sdk/repositories/optimization_repo.py +36 -210
  21. luna_sdk/repositories/qpu_token_repo.py +52 -128
  22. luna_sdk/repositories/solutions_repo.py +109 -181
  23. luna_sdk/schemas/create/solution.py +2 -2
  24. luna_sdk/schemas/enums/optimization.py +8 -7
  25. luna_sdk/schemas/enums/qpu_token_type.py +1 -1
  26. luna_sdk/schemas/optimization.py +15 -24
  27. luna_sdk/schemas/optimization_formats/qubo.py +8 -0
  28. luna_sdk/schemas/pretty_base.py +10 -3
  29. luna_sdk/schemas/qpu_token.py +4 -5
  30. luna_sdk/schemas/rest/qpu_token/qpu_token_source.py +18 -0
  31. luna_sdk/schemas/rest/qpu_token/token_provider.py +47 -15
  32. luna_sdk/schemas/solution.py +7 -6
  33. luna_sdk/schemas/solver_info.py +31 -1
  34. luna_sdk/schemas/solver_parameters/aws/optimizer_params.py +40 -0
  35. luna_sdk/schemas/solver_parameters/aws/qaoa.py +36 -4
  36. luna_sdk/schemas/solver_parameters/base_parameter.py +5 -0
  37. luna_sdk/schemas/solver_parameters/dwave/base.py +15 -14
  38. luna_sdk/schemas/solver_parameters/dwave/dialectic_search.py +3 -2
  39. luna_sdk/schemas/solver_parameters/dwave/kerberos.py +2 -3
  40. luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_bqm.py +2 -2
  41. luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_cqm.py +2 -2
  42. luna_sdk/schemas/solver_parameters/dwave/parallel_tempering.py +2 -3
  43. luna_sdk/schemas/solver_parameters/dwave/parallel_tempering_qpu.py +2 -3
  44. luna_sdk/schemas/solver_parameters/dwave/population_annealing.py +2 -3
  45. luna_sdk/schemas/solver_parameters/dwave/population_annealing_qpu.py +2 -1
  46. luna_sdk/schemas/solver_parameters/dwave/qaga.py +4 -2
  47. luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_qpu.py +2 -3
  48. luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_simulated_annealing.py +2 -3
  49. luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_tabu_search.py +2 -3
  50. luna_sdk/schemas/solver_parameters/dwave/quantum_annealing.py +2 -3
  51. luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_quantum_annealing.py +4 -2
  52. luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_simulated_annealing.py +3 -2
  53. luna_sdk/schemas/solver_parameters/dwave/saga.py +1 -1
  54. luna_sdk/schemas/solver_parameters/dwave/tabu_search.py +3 -1
  55. luna_sdk/schemas/solver_parameters/fujitsu/base.py +5 -4
  56. luna_sdk/schemas/solver_parameters/fujitsu/partial_config.py +7 -5
  57. luna_sdk/schemas/solver_parameters/ibm/standard_parameters.py +121 -7
  58. luna_sdk/schemas/solver_parameters/qctrl/qaoa.py +2 -2
  59. luna_sdk/schemas/wrappers/__init__.py +1 -0
  60. luna_sdk/schemas/wrappers/datetime_wrapper.py +31 -0
  61. luna_sdk/utils/parameter_finder.py +90 -0
  62. luna_sdk/utils/qpu_tokens.py +14 -13
  63. luna_sdk/constants.py +0 -1
  64. luna_sdk/controllers/custom_login_client.py +0 -61
  65. {luna_quantum-0.0.16.dist-info → luna_quantum-0.0.33.dist-info}/LICENSE +0 -0
  66. {luna_quantum-0.0.16.dist-info → luna_quantum-0.0.33.dist-info}/WHEEL +0 -0
@@ -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(self, solution_id: str) -> UseCaseRepresentation:
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
- Returns
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
- Returns the location where the solution can be found once solving is complete.
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
- Returns the location where the solution can be found once solving is complete.
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 a `solutions.get` or `solutions.get_all`.
209
+ The solution received via `solutions.get` or `solutions.get_all`.
190
210
 
191
211
  Returns
192
212
  -------
193
- Result | None
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, return `None`.
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 no the solution sense is `None`, return `None`.
237
+ not (yet) available or the solution sense is `None`, `None` is returned.
218
238
  """
219
239
  raise NotImplementedError
@@ -6,7 +6,7 @@ from luna_sdk.interfaces.circuit_repo_i import ICircuitRepo
6
6
  from luna_sdk.schemas.circuit import CircuitJob, CircuitResult
7
7
  from luna_sdk.schemas.create.circuit import CircuitIn
8
8
  from luna_sdk.schemas.enums.circuit import CircuitProviderEnum
9
- from luna_sdk.schemas.qpu_token import TokenProvider, QpuToken, QpuTokenSource
9
+ from luna_sdk.schemas.qpu_token import TokenProvider
10
10
  from luna_sdk.schemas.rest.qpu_token.token_provider import RestAPITokenProvider
11
11
  from luna_sdk.utils.qpu_tokens import extract_qpu_tokens_from_env
12
12
 
@@ -20,35 +20,13 @@ class CircuitRepo(ICircuitRepo):
20
20
  provider: CircuitProviderEnum,
21
21
  params: Dict[str, Any] = {},
22
22
  qpu_tokens: Optional[TokenProvider] = None,
23
- timeout: Optional[float] = 10800.0,
24
23
  encryption_key: Optional[str] = None,
24
+ **kwargs,
25
25
  ) -> CircuitJob:
26
- """
27
- Create a circuit solution.
28
-
29
- Parameters
30
- ----------
31
- circuit: str
32
- The circuit which to create a solution for.
33
- provider: CircuitProviderEnum
34
- Which provider to use to solve the circuit.
35
- params: Dict[str, Any]
36
- Additional parameters of the circuit.
37
- qpu_tokens: Optional[TokenProvider]
38
- The tokens to be used for the QPU.
39
- timeout: Optional[float]
40
- Default = 10800.0. Timeout for the api request. If set to None,
41
- there won't be any timeout. Increase or disable the timeout if you face
42
- issues uploading big Problems.
43
- encryption_key: Optional[str]
44
- Encryption key to be used for encryption of QPU tokens.
45
- Returns
46
- -------
47
- CircuitJob
48
- The created circuit job.
49
- """
50
26
  if qpu_tokens is not None:
51
- rest_qpu_tokens = RestAPITokenProvider.from_sdk_token_provider(qpu_tokens)
27
+ rest_qpu_tokens = RestAPITokenProvider.from_sdk_token_provider(
28
+ TokenProvider.model_validate(qpu_tokens)
29
+ )
52
30
  else:
53
31
  rest_qpu_tokens = None
54
32
 
@@ -68,29 +46,18 @@ class CircuitRepo(ICircuitRepo):
68
46
  )
69
47
 
70
48
  response = self._client.post(
71
- self._endpoint, content=circuit_in.model_dump_json(), timeout=timeout
49
+ self._endpoint, content=circuit_in.model_dump_json(), **kwargs
72
50
  )
73
51
 
74
52
  response.raise_for_status()
75
53
  return CircuitJob(id=response.json(), provider=provider, params=params)
76
54
 
77
55
  def get(
78
- self, job: CircuitJob, encryption_key: Optional[str] = None
56
+ self,
57
+ job: CircuitJob,
58
+ encryption_key: Optional[str] = None,
59
+ **kwargs,
79
60
  ) -> CircuitResult:
80
- """
81
- Retrieve a circuit result from a job.
82
-
83
- Parameters
84
- ----------
85
- job: CircuitJob
86
- The job received upon circuit creation.
87
- encryption_key: Optional[str]
88
- The encryption key to be used for the QPU.
89
- Returns
90
- -------
91
- CircuitResult
92
- The result of solving the circuit.
93
- """
94
61
  url = f"{self._endpoint}/{job.id}/{job.provider.value}"
95
62
  encryption_key = encryption_key or os.environ.get("LUNA_ENCRYPTION_KEY")
96
63
  if encryption_key is None:
@@ -98,7 +65,7 @@ class CircuitRepo(ICircuitRepo):
98
65
  if job.params is None:
99
66
  job.params = {}
100
67
  job.params["encryption_key"] = encryption_key
101
- response = self._client.get(url, params=job.params, timeout=60)
68
+ response = self._client.get(url, params=job.params, **kwargs)
102
69
 
103
70
  response.raise_for_status()
104
71
  return CircuitResult.model_validate(response.json())
@@ -2,7 +2,7 @@ import os
2
2
  import pickle
3
3
  import tempfile
4
4
  from functools import partial
5
- from typing import Tuple, List, Dict
5
+ from typing import Dict, List, Tuple
6
6
 
7
7
  import dimod
8
8
  from dimod import ConstrainedQuadraticModel
@@ -12,7 +12,7 @@ from qiskit_optimization import QuadraticProgram
12
12
 
13
13
  from luna_sdk.exceptions.transformation import TransformationException
14
14
  from luna_sdk.interfaces.cplex_repo_i import ICplexRepo
15
- from luna_sdk.schemas.transformations.bqm import BQMResultSchema, BQMSchema
15
+ from luna_sdk.schemas.transformations.bqm import BQMResultSchema
16
16
  from luna_sdk.schemas.transformations.matrix import MatrixSchema
17
17
 
18
18
 
@@ -20,12 +20,14 @@ class CplexRepo(ICplexRepo):
20
20
  _endpoint = "/transformations/docplex"
21
21
 
22
22
  def _send_request_with_pickle_file_response(
23
- self, docplex_model: DOCplexModel, endpoint: str
23
+ self, docplex_model: DOCplexModel, endpoint: str, **kwargs
24
24
  ):
25
25
  file = tempfile.NamedTemporaryFile(delete=False)
26
26
  with open(file.name, "wb") as tmp:
27
27
  pickle.dump(docplex_model, tmp)
28
- response = self._client.post(endpoint, files={"file": (file.name, file.file)})
28
+ response = self._client.post(
29
+ endpoint, files={"file": (file.name, file.file)}, **kwargs
30
+ )
29
31
  os.remove(file.name)
30
32
  try:
31
33
  parsed_model = pickle.loads(response.content)
@@ -33,9 +35,9 @@ class CplexRepo(ICplexRepo):
33
35
  raise TransformationException()
34
36
  return parsed_model
35
37
 
36
- def to_qubo_qiskit(self, docplex_model: DOCplexModel) -> QuadraticProgram:
38
+ def to_qubo_qiskit(self, docplex_model: DOCplexModel, **kwargs) -> QuadraticProgram:
37
39
  qubo_qiskit_model = self._send_request_with_pickle_file_response(
38
- docplex_model, f"{self._endpoint}/to-qubo-qiskit"
40
+ docplex_model, f"{self._endpoint}/to-qubo-qiskit", **kwargs
39
41
  )
40
42
  try:
41
43
  assert isinstance(qubo_qiskit_model, QuadraticProgram)
@@ -43,51 +45,59 @@ class CplexRepo(ICplexRepo):
43
45
  raise TransformationException()
44
46
  return qubo_qiskit_model
45
47
 
46
- def to_lp_file(self, docplex_model: DOCplexModel, filepath: str) -> None:
48
+ def to_lp_file(self, docplex_model: DOCplexModel, filepath: str, **kwargs) -> None:
47
49
  file = tempfile.NamedTemporaryFile(delete=False)
48
50
  with open(file.name, "wb") as tmp:
49
51
  pickle.dump(docplex_model, tmp)
50
52
  response = self._client.post(
51
- f"{self._endpoint}/to-lp-file", files={"file": (file.name, file.file)}
53
+ f"{self._endpoint}/to-lp-file",
54
+ files={"file": (file.name, file.file)},
55
+ **kwargs,
52
56
  )
53
57
  with open(filepath, "w") as file: # type: ignore
54
58
  file.write(response.content.decode("utf-8")) # type: ignore
55
59
 
56
- def to_lp_string(self, docplex_model: DOCplexModel) -> str:
60
+ def to_lp_string(self, docplex_model: DOCplexModel, **kwargs) -> str:
57
61
  file = tempfile.NamedTemporaryFile(delete=False)
58
62
  with open(file.name, "wb") as tmp:
59
63
  pickle.dump(docplex_model, tmp)
60
64
  response = self._client.post(
61
- f"{self._endpoint}/to-lp-file", files={"file": (file.name, file.file)}
65
+ f"{self._endpoint}/to-lp-file",
66
+ files={"file": (file.name, file.file)},
67
+ **kwargs,
62
68
  )
63
69
  return response.content.decode("utf-8")
64
70
 
65
71
  def to_qubo_matrix(
66
- self, docplex_model: DOCplexModel
72
+ self, docplex_model: DOCplexModel, **kwargs
67
73
  ) -> Tuple[List[List[float]], partial]:
68
74
  file = tempfile.NamedTemporaryFile(delete=False)
69
75
  with open(file.name, "wb") as tmp:
70
76
  pickle.dump(docplex_model, tmp)
71
77
  response = self._client.post(
72
- f"{self._endpoint}/to-qubo-matrix", files={"file": (file.name, file.file)}
78
+ f"{self._endpoint}/to-qubo-matrix",
79
+ files={"file": (file.name, file.file)},
80
+ **kwargs,
73
81
  )
74
- retrieved_matrix = MatrixSchema.validate(response.json())
82
+ retrieved_matrix = MatrixSchema.model_validate(response.json())
75
83
  return retrieved_matrix.matrix, partial(
76
84
  self.inverter,
77
85
  var_indices=retrieved_matrix.variable_indices,
78
- inverter_bqm=CQMToBQMInverter.from_dict(retrieved_matrix.inverter.dict()),
86
+ inverter_bqm=CQMToBQMInverter.from_dict(
87
+ retrieved_matrix.inverter.model_dump()
88
+ ),
79
89
  )
80
90
 
81
91
  def to_bqm(
82
- self, docplex_model: DOCplexModel
92
+ self, docplex_model: DOCplexModel, **kwargs
83
93
  ) -> Tuple[dimod.BinaryQuadraticModel, CQMToBQMInverter]:
84
94
  file = tempfile.NamedTemporaryFile(delete=False)
85
95
  with open(file.name, "wb") as tmp:
86
96
  pickle.dump(docplex_model, tmp)
87
97
  response = self._client.post(
88
- f"{self._endpoint}/to-bqm", files={"file": (file.name, file.file)}
98
+ f"{self._endpoint}/to-bqm", files={"file": (file.name, file.file)}, **kwargs
89
99
  )
90
- retrieved_bqm = BQMResultSchema.validate(response.json())
100
+ retrieved_bqm = BQMResultSchema.model_validate(response.json())
91
101
 
92
102
  quadratic: Dict[Tuple[str, str], float] = {}
93
103
  for key, value in retrieved_bqm.bqm.quadratic.items():
@@ -104,15 +114,17 @@ class CplexRepo(ICplexRepo):
104
114
  )
105
115
  except Exception:
106
116
  raise TransformationException()
107
- inverter = CQMToBQMInverter.from_dict(retrieved_bqm.inverter.dict())
117
+ inverter = CQMToBQMInverter.from_dict(retrieved_bqm.inverter.model_dump())
108
118
  return bqm, inverter
109
119
 
110
- def to_cqm(self, docplex_model: DOCplexModel) -> ConstrainedQuadraticModel:
120
+ def to_cqm(
121
+ self, docplex_model: DOCplexModel, **kwargs
122
+ ) -> ConstrainedQuadraticModel:
111
123
  file = tempfile.NamedTemporaryFile(delete=False)
112
124
  with open(file.name, "wb") as tmp:
113
125
  pickle.dump(docplex_model, tmp)
114
126
  response = self._client.post(
115
- f"{self._endpoint}/to-cqm", files={"file": (file.name, file.file)}
127
+ f"{self._endpoint}/to-cqm", files={"file": (file.name, file.file)}, **kwargs
116
128
  )
117
129
  cqm = ConstrainedQuadraticModel.from_file(response.content)
118
130
  return cqm
@@ -11,15 +11,14 @@ class InfoRepo(IInfoRepo):
11
11
  _endpoint_providers = "/providers"
12
12
 
13
13
  def solvers_available(
14
- self, solver_name: Optional[str] = None
14
+ self, solver_name: Optional[str] = None, **kwargs
15
15
  ) -> Dict[str, Dict[str, SolverInfo]]:
16
16
  params = {}
17
17
  if solver_name:
18
18
  params["solver_name"] = solver_name
19
19
 
20
20
  response = self._client.get(
21
- f"{self._endpoint_solvers}/available",
22
- params=params,
21
+ f"{self._endpoint_solvers}/available", params=params, **kwargs
23
22
  )
24
23
 
25
24
  response.raise_for_status()
@@ -35,10 +34,8 @@ class InfoRepo(IInfoRepo):
35
34
 
36
35
  return to_return
37
36
 
38
- def providers_available(self) -> List[str]:
39
- response = self._client.get(
40
- f"{self._endpoint_providers}/available",
41
- )
37
+ def providers_available(self, **kwargs) -> List[str]:
38
+ response = self._client.get(f"{self._endpoint_providers}/available", **kwargs)
42
39
 
43
40
  response.raise_for_status()
44
41
 
@@ -2,7 +2,7 @@ import os
2
2
  import pickle
3
3
  import tempfile
4
4
  from functools import partial
5
- from typing import Tuple, List, Dict
5
+ from typing import Dict, List, Tuple
6
6
 
7
7
  import dimod
8
8
  from dimod import ConstrainedQuadraticModel
@@ -12,7 +12,7 @@ from qiskit_optimization import QuadraticProgram
12
12
 
13
13
  from luna_sdk.exceptions.transformation import TransformationException
14
14
  from luna_sdk.interfaces.lp_repo_i import ILPRepo
15
- from luna_sdk.schemas.transformations.bqm import BQMResultSchema, BQMSchema
15
+ from luna_sdk.schemas.transformations.bqm import BQMResultSchema
16
16
  from luna_sdk.schemas.transformations.matrix import MatrixSchema
17
17
 
18
18
 
@@ -31,9 +31,9 @@ class LPRepo(ILPRepo):
31
31
  raise TransformationException()
32
32
  return parsed_model
33
33
 
34
- def to_qubo_qiskit(self, lp_string: str) -> QuadraticProgram:
34
+ def to_qubo_qiskit(self, lp_string: str, **kwargs) -> QuadraticProgram:
35
35
  qubo_qiskit_model = self._send_request_with_pickle_file_response(
36
- lp_string, f"{self._endpoint}/to-qubo-qiskit"
36
+ lp_string, f"{self._endpoint}/to-qubo-qiskit", **kwargs
37
37
  )
38
38
  try:
39
39
  assert isinstance(qubo_qiskit_model, QuadraticProgram)
@@ -41,9 +41,9 @@ class LPRepo(ILPRepo):
41
41
  raise TransformationException()
42
42
  return qubo_qiskit_model
43
43
 
44
- def to_docplex(self, lp_string: str) -> DOCplexModel:
44
+ def to_docplex(self, lp_string: str, **kwargs) -> DOCplexModel:
45
45
  docplex_model = self._send_request_with_pickle_file_response(
46
- lp_string, f"{self._endpoint}/to-docplex"
46
+ lp_string, f"{self._endpoint}/to-docplex", **kwargs
47
47
  )
48
48
  try:
49
49
  assert isinstance(docplex_model, DOCplexModel)
@@ -51,30 +51,36 @@ class LPRepo(ILPRepo):
51
51
  raise TransformationException()
52
52
  return docplex_model
53
53
 
54
- def to_qubo_matrix(self, lp_string: str) -> Tuple[List[List[float]], partial]:
54
+ def to_qubo_matrix(
55
+ self, lp_string: str, **kwargs
56
+ ) -> Tuple[List[List[float]], partial]:
55
57
  file = tempfile.NamedTemporaryFile(delete=False, suffix=".lp")
56
58
  with open(file.name, "w") as tmp:
57
59
  tmp.write(lp_string)
58
60
  response = self._client.post(
59
- f"{self._endpoint}/to-qubo-matrix", files={"file": (file.name, file.file)}
61
+ f"{self._endpoint}/to-qubo-matrix",
62
+ files={"file": (file.name, file.file)},
63
+ **kwargs,
60
64
  )
61
- retrieved_matrix = MatrixSchema.validate(response.json())
65
+ retrieved_matrix = MatrixSchema.model_validate(response.json())
62
66
  return retrieved_matrix.matrix, partial(
63
67
  self.inverter,
64
68
  var_indices=retrieved_matrix.variable_indices,
65
- inverter_bqm=CQMToBQMInverter.from_dict(retrieved_matrix.inverter.dict()),
69
+ inverter_bqm=CQMToBQMInverter.from_dict(
70
+ retrieved_matrix.inverter.model_dump()
71
+ ),
66
72
  )
67
73
 
68
74
  def to_bqm(
69
- self, lp_string: str
75
+ self, lp_string: str, **kwargs
70
76
  ) -> Tuple[dimod.BinaryQuadraticModel, CQMToBQMInverter]:
71
77
  file = tempfile.NamedTemporaryFile(delete=False, suffix=".lp")
72
78
  with open(file.name, "w") as tmp:
73
79
  tmp.write(lp_string)
74
80
  response = self._client.post(
75
- f"{self._endpoint}/to-bqm", files={"file": (file.name, file.file)}
81
+ f"{self._endpoint}/to-bqm", files={"file": (file.name, file.file)}, **kwargs
76
82
  )
77
- retrieved_bqm = BQMResultSchema.validate(response.json())
83
+ retrieved_bqm = BQMResultSchema.model_validate(response.json())
78
84
 
79
85
  quadratic: Dict[Tuple[str, str], float] = {}
80
86
  for key, value in retrieved_bqm.bqm.quadratic.items():
@@ -94,12 +100,12 @@ class LPRepo(ILPRepo):
94
100
  inverter = CQMToBQMInverter.from_dict(retrieved_bqm.inverter.dict())
95
101
  return bqm, inverter
96
102
 
97
- def to_cqm(self, lp_string: str) -> ConstrainedQuadraticModel:
103
+ def to_cqm(self, lp_string: str, **kwargs) -> ConstrainedQuadraticModel:
98
104
  file = tempfile.NamedTemporaryFile(delete=False, suffix=".lp")
99
105
  with open(file.name, "w") as tmp:
100
106
  tmp.write(lp_string)
101
107
  response = self._client.post(
102
- f"{self._endpoint}/to-cqm", files={"file": (file.name, file.file)}
108
+ f"{self._endpoint}/to-cqm", files={"file": (file.name, file.file)}, **kwargs
103
109
  )
104
110
  cqm = ConstrainedQuadraticModel.from_file(response.content)
105
111
  return cqm