classiq 0.92.0__py3-none-any.whl → 0.99.0__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.
- classiq/__init__.py +11 -19
- classiq/_analyzer_extras/_ipywidgets_async_extension.py +7 -7
- classiq/_analyzer_extras/interactive_hardware.py +19 -12
- classiq/_internals/api_wrapper.py +31 -142
- classiq/_internals/async_utils.py +4 -7
- classiq/_internals/authentication/auth0.py +41 -15
- classiq/_internals/authentication/authorization_code.py +9 -0
- classiq/_internals/authentication/authorization_flow.py +41 -0
- classiq/_internals/authentication/device.py +33 -52
- classiq/_internals/authentication/hybrid_flow.py +19 -0
- classiq/_internals/authentication/password_manager.py +13 -13
- classiq/_internals/authentication/token_manager.py +9 -9
- classiq/_internals/client.py +17 -44
- classiq/_internals/config.py +19 -5
- classiq/_internals/help.py +1 -2
- classiq/_internals/host_checker.py +3 -3
- classiq/_internals/jobs.py +14 -14
- classiq/_internals/type_validation.py +3 -3
- classiq/analyzer/analyzer.py +18 -18
- classiq/analyzer/rb.py +17 -8
- classiq/analyzer/show_interactive_hack.py +1 -1
- classiq/applications/__init__.py +2 -2
- classiq/applications/chemistry/__init__.py +0 -30
- classiq/applications/chemistry/op_utils.py +4 -4
- classiq/applications/chemistry/problems.py +3 -3
- classiq/applications/chemistry/ucc.py +1 -2
- classiq/applications/chemistry/z2_symmetries.py +4 -4
- classiq/applications/combinatorial_helpers/allowed_constraints.py +1 -3
- classiq/applications/combinatorial_helpers/arithmetic/arithmetic_expression.py +2 -1
- classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +2 -2
- classiq/applications/combinatorial_helpers/encoding_mapping.py +2 -3
- classiq/applications/combinatorial_helpers/encoding_utils.py +2 -2
- classiq/applications/combinatorial_helpers/optimization_model.py +3 -4
- classiq/applications/combinatorial_helpers/pauli_helpers/pauli_sparsing.py +2 -2
- classiq/applications/combinatorial_helpers/pyomo_utils.py +8 -8
- classiq/applications/combinatorial_helpers/sympy_utils.py +1 -3
- classiq/applications/combinatorial_helpers/transformations/encoding.py +3 -3
- classiq/applications/combinatorial_helpers/transformations/fixed_variables.py +1 -2
- classiq/applications/combinatorial_optimization/combinatorial_optimization_config.py +2 -3
- classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +4 -6
- classiq/applications/combinatorial_optimization/combinatorial_problem.py +15 -10
- classiq/applications/hamiltonian/pauli_decomposition.py +6 -4
- classiq/applications/iqae/iqae.py +14 -11
- classiq/applications/qnn/datasets/dataset_base_classes.py +6 -6
- classiq/applications/qnn/datasets/dataset_parity.py +6 -6
- classiq/applications/qnn/gradients/simple_quantum_gradient.py +1 -1
- classiq/applications/qnn/qlayer.py +9 -8
- classiq/applications/qnn/torch_utils.py +5 -6
- classiq/applications/qnn/types.py +2 -1
- classiq/applications/qsp/__init__.py +20 -2
- classiq/applications/qsp/qsp.py +239 -11
- classiq/applications/qsvm/qsvm_data_generation.py +1 -2
- classiq/evaluators/classical_expression.py +0 -4
- classiq/evaluators/parameter_types.py +20 -12
- classiq/evaluators/qmod_annotated_expression.py +31 -26
- classiq/evaluators/qmod_expression_visitors/qmod_expression_evaluator.py +14 -14
- classiq/evaluators/qmod_expression_visitors/qmod_expression_simplifier.py +2 -1
- classiq/evaluators/qmod_expression_visitors/sympy_wrappers.py +8 -8
- classiq/evaluators/qmod_node_evaluators/binary_op_evaluation.py +4 -4
- classiq/evaluators/qmod_node_evaluators/classical_function_evaluation.py +14 -4
- classiq/evaluators/qmod_node_evaluators/list_evaluation.py +2 -2
- classiq/evaluators/qmod_node_evaluators/numeric_attrs_utils.py +3 -3
- classiq/evaluators/qmod_node_evaluators/subscript_evaluation.py +9 -9
- classiq/evaluators/qmod_node_evaluators/utils.py +6 -6
- classiq/evaluators/qmod_type_inference/classical_type_inference.py +9 -10
- classiq/evaluators/qmod_type_inference/quantum_type_inference.py +5 -5
- classiq/execution/__init__.py +0 -3
- classiq/execution/execution_session.py +28 -21
- classiq/execution/jobs.py +26 -26
- classiq/execution/qnn.py +1 -2
- classiq/execution/user_budgets.py +71 -37
- classiq/executor.py +1 -3
- classiq/interface/_version.py +1 -1
- classiq/interface/analyzer/analysis_params.py +4 -4
- classiq/interface/analyzer/cytoscape_graph.py +3 -3
- classiq/interface/analyzer/result.py +4 -4
- classiq/interface/ast_node.py +3 -3
- classiq/interface/backend/backend_preferences.py +26 -50
- classiq/interface/backend/ionq/ionq_quantum_program.py +5 -5
- classiq/interface/backend/provider_config/__init__.py +0 -0
- classiq/interface/backend/provider_config/provider_config.py +8 -0
- classiq/interface/backend/provider_config/providers/__init__.py +0 -0
- classiq/interface/backend/provider_config/providers/alice_bob.py +47 -0
- classiq/interface/backend/provider_config/providers/aqt.py +16 -0
- classiq/interface/backend/provider_config/providers/azure.py +37 -0
- classiq/interface/backend/provider_config/providers/braket.py +39 -0
- classiq/interface/backend/provider_config/providers/ibm.py +26 -0
- classiq/interface/backend/provider_config/providers/ionq.py +22 -0
- classiq/interface/backend/quantum_backend_providers.py +20 -2
- classiq/interface/chemistry/ansatz_library.py +3 -5
- classiq/interface/chemistry/operator.py +3 -3
- classiq/interface/combinatorial_optimization/examples/knapsack.py +2 -4
- classiq/interface/combinatorial_optimization/examples/tsp_digraph.py +1 -2
- classiq/interface/compression_utils.py +2 -3
- classiq/interface/debug_info/debug_info.py +8 -7
- classiq/interface/exceptions.py +10 -7
- classiq/interface/execution/primitives.py +6 -6
- classiq/interface/executor/estimate_cost.py +1 -1
- classiq/interface/executor/execution_preferences.py +3 -5
- classiq/interface/executor/execution_request.py +10 -10
- classiq/interface/executor/execution_result.py +1 -2
- classiq/interface/executor/quantum_code.py +8 -8
- classiq/interface/executor/result.py +28 -18
- classiq/interface/executor/user_budget.py +25 -17
- classiq/interface/executor/vqe_result.py +5 -6
- classiq/interface/generator/ansatz_library.py +6 -8
- classiq/interface/generator/application_apis/__init__.py +0 -3
- classiq/interface/generator/arith/arithmetic.py +2 -2
- classiq/interface/generator/arith/arithmetic_arg_type_validator.py +2 -3
- classiq/interface/generator/arith/arithmetic_expression_abc.py +4 -5
- classiq/interface/generator/arith/arithmetic_expression_parser.py +11 -4
- classiq/interface/generator/arith/arithmetic_expression_validator.py +12 -15
- classiq/interface/generator/arith/arithmetic_operations.py +4 -6
- classiq/interface/generator/arith/arithmetic_param_getters.py +70 -107
- classiq/interface/generator/arith/arithmetic_result_builder.py +4 -4
- classiq/interface/generator/arith/ast_node_rewrite.py +8 -4
- classiq/interface/generator/arith/binary_ops.py +15 -40
- classiq/interface/generator/arith/logical_ops.py +2 -3
- classiq/interface/generator/arith/number_utils.py +2 -2
- classiq/interface/generator/arith/register_user_input.py +3 -3
- classiq/interface/generator/arith/unary_ops.py +2 -2
- classiq/interface/generator/circuit_code/circuit_code.py +8 -10
- classiq/interface/generator/circuit_code/types_and_constants.py +1 -1
- classiq/interface/generator/complex_type.py +2 -2
- classiq/interface/generator/copy.py +1 -3
- classiq/interface/generator/expressions/atomic_expression_functions.py +0 -5
- classiq/interface/generator/expressions/evaluated_expression.py +2 -3
- classiq/interface/generator/expressions/expression.py +2 -2
- classiq/interface/generator/expressions/proxies/classical/classical_array_proxy.py +4 -7
- classiq/interface/generator/function_param_list.py +0 -40
- classiq/interface/generator/function_params.py +5 -6
- classiq/interface/generator/functions/classical_function_declaration.py +2 -2
- classiq/interface/generator/functions/classical_type.py +3 -3
- classiq/interface/generator/functions/type_modifier.py +0 -15
- classiq/interface/generator/functions/type_name.py +2 -2
- classiq/interface/generator/generated_circuit_data.py +14 -18
- classiq/interface/generator/hamiltonian_evolution/exponentiation.py +2 -4
- classiq/interface/generator/hardware/hardware_data.py +8 -8
- classiq/interface/generator/hardware_efficient_ansatz.py +9 -9
- classiq/interface/generator/mcu.py +3 -3
- classiq/interface/generator/mcx.py +3 -3
- classiq/interface/generator/model/constraints.py +34 -5
- classiq/interface/generator/model/preferences/preferences.py +15 -21
- classiq/interface/generator/model/quantum_register.py +7 -10
- classiq/interface/generator/noise_properties.py +3 -7
- classiq/interface/generator/parameters.py +1 -1
- classiq/interface/generator/partitioned_register.py +1 -2
- classiq/interface/generator/preferences/qasm_to_qmod_params.py +11 -0
- classiq/interface/generator/quantum_function_call.py +9 -12
- classiq/interface/generator/quantum_program.py +10 -23
- classiq/interface/generator/range_types.py +3 -3
- classiq/interface/generator/slice_parsing_utils.py +4 -5
- classiq/interface/generator/standard_gates/standard_gates.py +2 -4
- classiq/interface/generator/synthesis_execution_parameter.py +1 -3
- classiq/interface/generator/synthesis_metadata/synthesis_duration.py +9 -0
- classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py +2 -3
- classiq/interface/generator/transpiler_basis_gates.py +12 -4
- classiq/interface/generator/types/builtin_enum_declarations.py +0 -145
- classiq/interface/generator/types/compilation_metadata.py +12 -1
- classiq/interface/generator/types/enum_declaration.py +2 -1
- classiq/interface/generator/validations/flow_graph.py +3 -3
- classiq/interface/generator/visitor.py +10 -12
- classiq/interface/hardware.py +2 -3
- classiq/interface/helpers/classproperty.py +2 -2
- classiq/interface/helpers/custom_encoders.py +2 -1
- classiq/interface/helpers/custom_pydantic_types.py +1 -1
- classiq/interface/helpers/text_utils.py +1 -4
- classiq/interface/ide/visual_model.py +6 -5
- classiq/interface/interface_version.py +1 -1
- classiq/interface/jobs.py +3 -3
- classiq/interface/model/allocate.py +4 -4
- classiq/interface/model/block.py +6 -2
- classiq/interface/model/bounds.py +3 -3
- classiq/interface/model/classical_if.py +4 -0
- classiq/interface/model/control.py +8 -1
- classiq/interface/model/inplace_binary_operation.py +2 -2
- classiq/interface/model/invert.py +4 -0
- classiq/interface/model/model.py +4 -4
- classiq/interface/model/model_visitor.py +40 -1
- classiq/interface/model/parameter.py +1 -3
- classiq/interface/model/port_declaration.py +1 -1
- classiq/interface/model/power.py +4 -0
- classiq/interface/model/quantum_expressions/quantum_expression.py +1 -2
- classiq/interface/model/quantum_function_call.py +3 -6
- classiq/interface/model/quantum_function_declaration.py +1 -0
- classiq/interface/model/quantum_lambda_function.py +4 -4
- classiq/interface/model/quantum_statement.py +11 -4
- classiq/interface/model/quantum_type.py +14 -14
- classiq/interface/model/repeat.py +4 -0
- classiq/interface/model/skip_control.py +4 -0
- classiq/interface/model/validation_handle.py +2 -3
- classiq/interface/model/variable_declaration_statement.py +2 -2
- classiq/interface/model/within_apply_operation.py +4 -0
- classiq/interface/pretty_print/expression_to_qmod.py +3 -4
- classiq/interface/server/routes.py +0 -16
- classiq/interface/source_reference.py +3 -4
- classiq/model_expansions/arithmetic.py +11 -7
- classiq/model_expansions/arithmetic_compute_result_attrs.py +30 -27
- classiq/model_expansions/capturing/captured_vars.py +3 -3
- classiq/model_expansions/capturing/mangling_utils.py +1 -2
- classiq/model_expansions/closure.py +12 -11
- classiq/model_expansions/function_builder.py +14 -6
- classiq/model_expansions/generative_functions.py +7 -12
- classiq/model_expansions/interpreters/base_interpreter.py +3 -7
- classiq/model_expansions/interpreters/frontend_generative_interpreter.py +2 -1
- classiq/model_expansions/interpreters/generative_interpreter.py +8 -4
- classiq/model_expansions/quantum_operations/allocate.py +4 -4
- classiq/model_expansions/quantum_operations/assignment_result_processor.py +8 -4
- classiq/model_expansions/quantum_operations/call_emitter.py +31 -37
- classiq/model_expansions/quantum_operations/declarative_call_emitter.py +2 -2
- classiq/model_expansions/quantum_operations/emitter.py +3 -5
- classiq/model_expansions/quantum_operations/expression_evaluator.py +3 -3
- classiq/model_expansions/quantum_operations/skip_control_verifier.py +1 -2
- classiq/model_expansions/quantum_operations/variable_decleration.py +61 -29
- classiq/model_expansions/scope.py +7 -7
- classiq/model_expansions/scope_initialization.py +4 -0
- classiq/model_expansions/visitors/symbolic_param_inference.py +6 -6
- classiq/model_expansions/visitors/uncomputation_signature_inference.py +328 -0
- classiq/model_expansions/visitors/variable_references.py +15 -14
- classiq/open_library/functions/__init__.py +28 -11
- classiq/open_library/functions/amplitude_loading.py +81 -0
- classiq/open_library/functions/discrete_sine_cosine_transform.py +19 -14
- classiq/open_library/functions/grover.py +8 -10
- classiq/open_library/functions/lcu.py +47 -18
- classiq/open_library/functions/modular_exponentiation.py +93 -8
- classiq/open_library/functions/qsvt.py +66 -79
- classiq/open_library/functions/qsvt_temp.py +536 -0
- classiq/open_library/functions/state_preparation.py +130 -27
- classiq/qmod/__init__.py +6 -4
- classiq/qmod/builtins/classical_execution_primitives.py +4 -23
- classiq/qmod/builtins/classical_functions.py +1 -42
- classiq/qmod/builtins/enums.py +15 -153
- classiq/qmod/builtins/functions/__init__.py +9 -18
- classiq/qmod/builtins/functions/allocation.py +25 -4
- classiq/qmod/builtins/functions/arithmetic.py +22 -27
- classiq/qmod/builtins/functions/exponentiation.py +51 -2
- classiq/qmod/builtins/functions/mcx_func.py +7 -0
- classiq/qmod/builtins/functions/standard_gates.py +46 -27
- classiq/qmod/builtins/operations.py +173 -79
- classiq/qmod/builtins/structs.py +24 -91
- classiq/qmod/cfunc.py +3 -2
- classiq/qmod/classical_function.py +2 -1
- classiq/qmod/classical_variable.py +4 -2
- classiq/qmod/cparam.py +2 -8
- classiq/qmod/create_model_function.py +7 -7
- classiq/qmod/declaration_inferrer.py +33 -30
- classiq/qmod/expression_query.py +7 -4
- classiq/qmod/model_state_container.py +2 -2
- classiq/qmod/native/pretty_printer.py +25 -14
- classiq/qmod/pretty_print/expression_to_python.py +5 -3
- classiq/qmod/pretty_print/pretty_printer.py +39 -17
- classiq/qmod/python_classical_type.py +40 -13
- classiq/qmod/qfunc.py +124 -19
- classiq/qmod/qmod_constant.py +2 -2
- classiq/qmod/qmod_parameter.py +5 -2
- classiq/qmod/qmod_variable.py +47 -46
- classiq/qmod/quantum_callable.py +18 -13
- classiq/qmod/quantum_expandable.py +33 -26
- classiq/qmod/quantum_function.py +84 -36
- classiq/qmod/semantics/annotation/call_annotation.py +5 -5
- classiq/qmod/semantics/error_manager.py +12 -14
- classiq/qmod/semantics/lambdas.py +1 -2
- classiq/qmod/semantics/validation/types_validation.py +1 -2
- classiq/qmod/symbolic.py +2 -4
- classiq/qmod/symbolic_expr.py +12 -4
- classiq/qmod/utilities.py +13 -20
- classiq/qmod/write_qmod.py +3 -4
- classiq/quantum_program.py +1 -3
- classiq/synthesis.py +11 -7
- {classiq-0.92.0.dist-info → classiq-0.99.0.dist-info}/METADATA +38 -37
- {classiq-0.92.0.dist-info → classiq-0.99.0.dist-info}/RECORD +273 -300
- classiq-0.99.0.dist-info/WHEEL +4 -0
- classiq-0.99.0.dist-info/licenses/LICENSE.txt +27 -0
- classiq/applications/chemistry/ansatz_parameters.py +0 -29
- classiq/applications/chemistry/chemistry_execution_parameters.py +0 -16
- classiq/applications/chemistry/chemistry_model_constructor.py +0 -532
- classiq/applications/chemistry/ground_state_problem.py +0 -42
- classiq/applications/qsvm/__init__.py +0 -8
- classiq/applications/qsvm/qsvm.py +0 -11
- classiq/evaluators/qmod_expression_visitors/qmod_expression_bwc.py +0 -129
- classiq/execution/iqcc.py +0 -128
- classiq/interface/applications/qsvm.py +0 -117
- classiq/interface/chemistry/elements.py +0 -120
- classiq/interface/chemistry/fermionic_operator.py +0 -208
- classiq/interface/chemistry/ground_state_problem.py +0 -132
- classiq/interface/chemistry/ground_state_result.py +0 -8
- classiq/interface/chemistry/molecule.py +0 -71
- classiq/interface/execution/iqcc.py +0 -44
- classiq/interface/generator/application_apis/chemistry_declarations.py +0 -69
- classiq/interface/generator/application_apis/entangler_declarations.py +0 -29
- classiq/interface/generator/application_apis/qsvm_declarations.py +0 -6
- classiq/interface/generator/chemistry_function_params.py +0 -50
- classiq/interface/generator/entangler_params.py +0 -72
- classiq/interface/generator/entanglers.py +0 -14
- classiq/interface/generator/hamiltonian_evolution/qdrift.py +0 -27
- classiq/interface/generator/hartree_fock.py +0 -26
- classiq/interface/generator/hva.py +0 -22
- classiq/interface/generator/linear_pauli_rotations.py +0 -92
- classiq/interface/generator/qft.py +0 -37
- classiq/interface/generator/qsvm.py +0 -96
- classiq/interface/generator/state_preparation/__init__.py +0 -14
- classiq/interface/generator/state_preparation/bell_state_preparation.py +0 -27
- classiq/interface/generator/state_preparation/computational_basis_state_preparation.py +0 -28
- classiq/interface/generator/state_preparation/distributions.py +0 -53
- classiq/interface/generator/state_preparation/exponential_state_preparation.py +0 -14
- classiq/interface/generator/state_preparation/ghz_state_preparation.py +0 -14
- classiq/interface/generator/state_preparation/metrics.py +0 -41
- classiq/interface/generator/state_preparation/state_preparation.py +0 -113
- classiq/interface/generator/state_preparation/state_preparation_abc.py +0 -24
- classiq/interface/generator/state_preparation/uniform_distibution_state_preparation.py +0 -13
- classiq/interface/generator/state_preparation/w_state_preparation.py +0 -13
- classiq/interface/generator/ucc.py +0 -74
- classiq/interface/helpers/backward_compatibility.py +0 -9
- classiq/model_expansions/transformers/type_modifier_inference.py +0 -392
- classiq/open_library/functions/lookup_table.py +0 -58
- classiq/qmod/builtins/functions/chemistry.py +0 -123
- classiq/qmod/builtins/functions/qsvm.py +0 -24
- classiq-0.92.0.dist-info/WHEEL +0 -4
classiq/__init__.py
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
"""Classiq SDK."""
|
|
2
2
|
|
|
3
|
-
import sys
|
|
4
|
-
import warnings
|
|
5
|
-
|
|
6
|
-
from classiq.interface.exceptions import ClassiqDeprecationWarning
|
|
7
|
-
|
|
8
|
-
if sys.version_info[0:2] <= (3, 9):
|
|
9
|
-
warnings.warn(
|
|
10
|
-
"Python version 3.9 will no longer be supported starting on 2025-10-01 "
|
|
11
|
-
"at the earliest",
|
|
12
|
-
ClassiqDeprecationWarning,
|
|
13
|
-
stacklevel=2,
|
|
14
|
-
)
|
|
15
|
-
|
|
16
3
|
from classiq.interface._version import VERSION as _VERSION
|
|
4
|
+
from classiq.interface.backend.quantum_backend_providers import (
|
|
5
|
+
ProviderVendor,
|
|
6
|
+
__all__ as _be_all,
|
|
7
|
+
)
|
|
8
|
+
from classiq.interface.exceptions import ClassiqDeprecationWarning
|
|
17
9
|
from classiq.interface.generator.application_apis import * # noqa: F403
|
|
18
10
|
from classiq.interface.generator.arith.register_user_input import (
|
|
19
11
|
RegisterArithmeticInfo,
|
|
@@ -36,10 +28,6 @@ from classiq._internals.client import configure
|
|
|
36
28
|
from classiq._internals.config import Configuration
|
|
37
29
|
from classiq._internals.help import open_help
|
|
38
30
|
from classiq.analyzer import Analyzer
|
|
39
|
-
from classiq.applications.chemistry import (
|
|
40
|
-
construct_chemistry_model,
|
|
41
|
-
molecule_problem_to_qmod,
|
|
42
|
-
)
|
|
43
31
|
from classiq.applications.combinatorial_optimization import (
|
|
44
32
|
CombinatorialProblem,
|
|
45
33
|
compute_qaoa_initial_point,
|
|
@@ -51,6 +39,7 @@ from classiq.applications.hamiltonian.pauli_decomposition import (
|
|
|
51
39
|
hamiltonian_to_matrix,
|
|
52
40
|
matrix_to_hamiltonian,
|
|
53
41
|
matrix_to_pauli_operator,
|
|
42
|
+
pauli_operator_to_matrix,
|
|
54
43
|
)
|
|
55
44
|
from classiq.execution import * # noqa: F403
|
|
56
45
|
from classiq.execution import __all__ as _execution_all
|
|
@@ -65,6 +54,7 @@ from classiq.qmod import * # noqa: F403
|
|
|
65
54
|
from classiq.qmod import __all__ as _qmod_all
|
|
66
55
|
from classiq.quantum_program import ExecutionParams, assign_parameters, transpile
|
|
67
56
|
from classiq.synthesis import (
|
|
57
|
+
QmodFormat,
|
|
68
58
|
qasm_to_qmod,
|
|
69
59
|
quantum_program_from_qasm,
|
|
70
60
|
quantum_program_from_qasm_async,
|
|
@@ -81,8 +71,6 @@ from classiq.synthesis import (
|
|
|
81
71
|
|
|
82
72
|
_application_constructors_all = [
|
|
83
73
|
"construct_combinatorial_optimization_model",
|
|
84
|
-
"construct_chemistry_model",
|
|
85
|
-
"molecule_problem_to_qmod",
|
|
86
74
|
]
|
|
87
75
|
|
|
88
76
|
__version__ = _VERSION
|
|
@@ -113,6 +101,7 @@ __all__ = (
|
|
|
113
101
|
"synthesize_async",
|
|
114
102
|
"execute",
|
|
115
103
|
"execute_async",
|
|
104
|
+
"qasm_to_qmod",
|
|
116
105
|
"set_preferences",
|
|
117
106
|
"set_constraints",
|
|
118
107
|
"set_execution_preferences",
|
|
@@ -125,8 +114,10 @@ __all__ = (
|
|
|
125
114
|
"hamiltonian_to_matrix",
|
|
126
115
|
"matrix_to_hamiltonian",
|
|
127
116
|
"matrix_to_pauli_operator",
|
|
117
|
+
"pauli_operator_to_matrix",
|
|
128
118
|
"quantum_program_from_qasm",
|
|
129
119
|
"quantum_program_from_qasm_async",
|
|
120
|
+
"QmodFormat",
|
|
130
121
|
]
|
|
131
122
|
+ _md_all
|
|
132
123
|
+ _sub_modules
|
|
@@ -134,6 +125,7 @@ __all__ = (
|
|
|
134
125
|
+ _qmod_all
|
|
135
126
|
+ _execution_all
|
|
136
127
|
+ _open_library_all
|
|
128
|
+
+ _be_all
|
|
137
129
|
)
|
|
138
130
|
|
|
139
131
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
-
from collections.abc import Awaitable
|
|
2
|
+
from collections.abc import Awaitable, Callable
|
|
3
3
|
from functools import wraps
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
5
|
-
|
|
6
|
-
from ipywidgets import widgets # type: ignore[import]
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
7
5
|
|
|
8
6
|
if TYPE_CHECKING:
|
|
7
|
+
from ipywidgets import widgets # type: ignore[import]
|
|
8
|
+
|
|
9
9
|
from classiq._analyzer_extras.interactive_hardware import InteractiveHardware
|
|
10
10
|
|
|
11
11
|
WidgetName = str
|
|
@@ -30,7 +30,7 @@ def widget_callback(widget_name: WidgetName) -> Callable[[WidgetFunc], Callable]
|
|
|
30
30
|
def decorator(function: WidgetFunc) -> Callable:
|
|
31
31
|
@wraps(function)
|
|
32
32
|
async def wrapper(self: "InteractiveHardware", **kwargs: WidgetValue) -> None:
|
|
33
|
-
widget: widgets = getattr(self, widget_name)
|
|
33
|
+
widget: "widgets" = getattr(self, widget_name)
|
|
34
34
|
interactive_loop = _create_interactive_loop_async(
|
|
35
35
|
function=function, self=self, widget=widget
|
|
36
36
|
)
|
|
@@ -43,7 +43,7 @@ def widget_callback(widget_name: WidgetName) -> Callable[[WidgetFunc], Callable]
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
async def _create_interactive_loop_async(
|
|
46
|
-
function: WidgetFunc, self: "InteractiveHardware", widget: widgets
|
|
46
|
+
function: WidgetFunc, self: "InteractiveHardware", widget: "widgets"
|
|
47
47
|
) -> None:
|
|
48
48
|
while True:
|
|
49
49
|
value: WidgetValue = await _wait_for_change(widget=widget)
|
|
@@ -51,7 +51,7 @@ async def _create_interactive_loop_async(
|
|
|
51
51
|
await function(self, value)
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
def _wait_for_change(widget: widgets) -> asyncio.Future:
|
|
54
|
+
def _wait_for_change(widget: "widgets") -> asyncio.Future:
|
|
55
55
|
future: asyncio.Future = asyncio.Future()
|
|
56
56
|
|
|
57
57
|
def _get_value(change) -> None: # type: ignore[no-untyped-def]
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from typing import
|
|
3
|
-
|
|
4
|
-
import plotly.graph_objects as go
|
|
5
|
-
from ipywidgets import Combobox, HBox, VBox # type: ignore[import]
|
|
2
|
+
from typing import TYPE_CHECKING
|
|
6
3
|
|
|
7
4
|
from classiq.interface.analyzer import analysis_params
|
|
8
5
|
from classiq.interface.backend.quantum_backend_providers import AnalyzerProviderVendor
|
|
@@ -17,6 +14,10 @@ from classiq.analyzer.analyzer_utilities import (
|
|
|
17
14
|
ProviderNameEnum,
|
|
18
15
|
)
|
|
19
16
|
|
|
17
|
+
if TYPE_CHECKING:
|
|
18
|
+
import plotly.graph_objects as go
|
|
19
|
+
from ipywidgets import Combobox, VBox # type: ignore[import]
|
|
20
|
+
|
|
20
21
|
|
|
21
22
|
class InteractiveHardware(AnalyzerUtilities):
|
|
22
23
|
def __init__(
|
|
@@ -31,7 +32,9 @@ class InteractiveHardware(AnalyzerUtilities):
|
|
|
31
32
|
self.devices_combobox = self._initialize_devices_combobox()
|
|
32
33
|
self.hardware_graph = self._initialize_hardware_graph()
|
|
33
34
|
|
|
34
|
-
def show_interactive_graph(self) -> VBox:
|
|
35
|
+
def show_interactive_graph(self) -> "VBox":
|
|
36
|
+
from ipywidgets import HBox, VBox
|
|
37
|
+
|
|
35
38
|
combobox_layout = HBox([self.providers_combobox, self.devices_combobox])
|
|
36
39
|
return VBox([combobox_layout, self.hardware_graph])
|
|
37
40
|
|
|
@@ -40,7 +43,9 @@ class InteractiveHardware(AnalyzerUtilities):
|
|
|
40
43
|
await self._device_selection_response_async()
|
|
41
44
|
|
|
42
45
|
@staticmethod
|
|
43
|
-
def _initialize_providers_combobox() -> Combobox:
|
|
46
|
+
def _initialize_providers_combobox() -> "Combobox":
|
|
47
|
+
from ipywidgets import Combobox
|
|
48
|
+
|
|
44
49
|
combobox = Combobox(
|
|
45
50
|
placeholder="Choose provider",
|
|
46
51
|
options=list(AnalyzerProviderVendor),
|
|
@@ -51,7 +56,9 @@ class InteractiveHardware(AnalyzerUtilities):
|
|
|
51
56
|
return combobox
|
|
52
57
|
|
|
53
58
|
@staticmethod
|
|
54
|
-
def _initialize_devices_combobox() -> Combobox:
|
|
59
|
+
def _initialize_devices_combobox() -> "Combobox":
|
|
60
|
+
from ipywidgets import Combobox
|
|
61
|
+
|
|
55
62
|
combobox = Combobox(
|
|
56
63
|
placeholder="Choose first provider",
|
|
57
64
|
description="devices:",
|
|
@@ -61,12 +68,14 @@ class InteractiveHardware(AnalyzerUtilities):
|
|
|
61
68
|
return combobox
|
|
62
69
|
|
|
63
70
|
@staticmethod
|
|
64
|
-
def _initialize_hardware_graph() -> go.FigureWidget:
|
|
71
|
+
def _initialize_hardware_graph() -> "go.FigureWidget":
|
|
72
|
+
import plotly.graph_objects as go
|
|
73
|
+
|
|
65
74
|
return go.FigureWidget()
|
|
66
75
|
|
|
67
76
|
@widget_callback(widget_name="providers_combobox")
|
|
68
77
|
async def _provider_selection_response_async(
|
|
69
|
-
self, provider:
|
|
78
|
+
self, provider: ProviderNameEnum | None
|
|
70
79
|
) -> None:
|
|
71
80
|
if not provider:
|
|
72
81
|
return
|
|
@@ -76,9 +85,7 @@ class InteractiveHardware(AnalyzerUtilities):
|
|
|
76
85
|
self.devices_combobox.placeholder = "Choose device"
|
|
77
86
|
|
|
78
87
|
@widget_callback(widget_name="devices_combobox")
|
|
79
|
-
async def _device_selection_response_async(
|
|
80
|
-
self, device: Optional[DeviceName]
|
|
81
|
-
) -> None:
|
|
88
|
+
async def _device_selection_response_async(self, device: DeviceName | None) -> None:
|
|
82
89
|
provider = self.providers_combobox.value
|
|
83
90
|
if not device or not provider:
|
|
84
91
|
return
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from typing import Any,
|
|
2
|
+
from typing import Any, Protocol, TypeVar
|
|
3
3
|
|
|
4
4
|
import httpx
|
|
5
5
|
import pydantic
|
|
@@ -10,18 +10,8 @@ import classiq.interface.pyomo_extension
|
|
|
10
10
|
from classiq.interface.analyzer import analysis_params, result as analysis_result
|
|
11
11
|
from classiq.interface.analyzer.analysis_params import AnalysisRBParams
|
|
12
12
|
from classiq.interface.analyzer.result import GraphStatus, QmodCode
|
|
13
|
-
from classiq.interface.chemistry import ground_state_problem, operator
|
|
14
13
|
from classiq.interface.enum_utils import StrEnum
|
|
15
14
|
from classiq.interface.exceptions import ClassiqAPIError, ClassiqValueError
|
|
16
|
-
from classiq.interface.execution.iqcc import (
|
|
17
|
-
IQCCAuthItemsDetails,
|
|
18
|
-
IQCCInitAuthData,
|
|
19
|
-
IQCCInitAuthResponse,
|
|
20
|
-
IQCCListAuthMethods,
|
|
21
|
-
IQCCListAuthTargets,
|
|
22
|
-
IQCCProbeAuthData,
|
|
23
|
-
IQCCProbeAuthResponse,
|
|
24
|
-
)
|
|
25
15
|
from classiq.interface.execution.primitives import PrimitivesInput
|
|
26
16
|
from classiq.interface.executor import execution_request
|
|
27
17
|
from classiq.interface.executor.quantum_program_params import (
|
|
@@ -75,8 +65,8 @@ class ApiWrapper:
|
|
|
75
65
|
url: str,
|
|
76
66
|
model: pydantic.BaseModel,
|
|
77
67
|
use_versioned_url: bool = True,
|
|
78
|
-
http_client:
|
|
79
|
-
exclude:
|
|
68
|
+
http_client: httpx.AsyncClient | None = None,
|
|
69
|
+
exclude: IncEx | None = None,
|
|
80
70
|
) -> dict:
|
|
81
71
|
# TODO: we can't use model.dict() - it doesn't serialize complex class.
|
|
82
72
|
# This was added because JSON serializer doesn't serialize complex type, and pydantic does.
|
|
@@ -95,12 +85,12 @@ class ApiWrapper:
|
|
|
95
85
|
cls,
|
|
96
86
|
http_method: str,
|
|
97
87
|
url: str,
|
|
98
|
-
body:
|
|
99
|
-
params:
|
|
88
|
+
body: dict | None = None,
|
|
89
|
+
params: dict | None = None,
|
|
100
90
|
use_versioned_url: bool = True,
|
|
101
|
-
headers:
|
|
91
|
+
headers: dict[str, str] | None = None,
|
|
102
92
|
allow_none: bool = False,
|
|
103
|
-
http_client:
|
|
93
|
+
http_client: httpx.AsyncClient | None = None,
|
|
104
94
|
) -> dict:
|
|
105
95
|
res: Any = await client().call_api(
|
|
106
96
|
http_method=http_method,
|
|
@@ -123,7 +113,7 @@ class ApiWrapper:
|
|
|
123
113
|
url: str,
|
|
124
114
|
job_input: pydantic.BaseModel,
|
|
125
115
|
result_type: type[ResultType],
|
|
126
|
-
http_client:
|
|
116
|
+
http_client: httpx.AsyncClient | None,
|
|
127
117
|
) -> ResultType:
|
|
128
118
|
poller = JobPoller(base_url=url)
|
|
129
119
|
result = await poller.run_pydantic(
|
|
@@ -135,7 +125,7 @@ class ApiWrapper:
|
|
|
135
125
|
async def call_generation_task(
|
|
136
126
|
cls,
|
|
137
127
|
model: Model,
|
|
138
|
-
http_client:
|
|
128
|
+
http_client: httpx.AsyncClient | None = None,
|
|
139
129
|
) -> generator_result.QuantumProgram:
|
|
140
130
|
return await cls._call_job_and_poll(
|
|
141
131
|
routes.TASKS_GENERATE_FULL_PATH,
|
|
@@ -148,7 +138,7 @@ class ApiWrapper:
|
|
|
148
138
|
async def call_transpilation_task(
|
|
149
139
|
cls,
|
|
150
140
|
params: TranspilationParams,
|
|
151
|
-
http_client:
|
|
141
|
+
http_client: httpx.AsyncClient | None = None,
|
|
152
142
|
) -> generator_result.QuantumProgram:
|
|
153
143
|
return await cls._call_job_and_poll(
|
|
154
144
|
routes.TRANSPILATION_FULL_PATH,
|
|
@@ -161,7 +151,7 @@ class ApiWrapper:
|
|
|
161
151
|
async def call_assign_parameters_task(
|
|
162
152
|
cls,
|
|
163
153
|
params: ParameterAssignmentsParams,
|
|
164
|
-
http_client:
|
|
154
|
+
http_client: httpx.AsyncClient | None = None,
|
|
165
155
|
) -> generator_result.QuantumProgram:
|
|
166
156
|
return await cls._call_job_and_poll(
|
|
167
157
|
routes.ASSIGN_PARAMETERS_FULL_PATH,
|
|
@@ -174,7 +164,7 @@ class ApiWrapper:
|
|
|
174
164
|
async def call_qasm_to_qmod_task(
|
|
175
165
|
cls,
|
|
176
166
|
params: QasmToQmodParams,
|
|
177
|
-
http_client:
|
|
167
|
+
http_client: httpx.AsyncClient | None = None,
|
|
178
168
|
) -> QmodCode:
|
|
179
169
|
return await cls._call_job_and_poll(
|
|
180
170
|
routes.QASM_TO_QMOD_FULL_PATH,
|
|
@@ -187,7 +177,7 @@ class ApiWrapper:
|
|
|
187
177
|
async def call_get_visual_model(
|
|
188
178
|
cls,
|
|
189
179
|
program_id: str,
|
|
190
|
-
http_client:
|
|
180
|
+
http_client: httpx.AsyncClient | None = None,
|
|
191
181
|
) -> ProgramVisualModel:
|
|
192
182
|
raw_result = await cls._call_task(
|
|
193
183
|
http_method=HTTPMethod.GET,
|
|
@@ -200,7 +190,7 @@ class ApiWrapper:
|
|
|
200
190
|
async def call_visualization_task(
|
|
201
191
|
cls,
|
|
202
192
|
circuit: generator_result.QuantumProgram,
|
|
203
|
-
http_client:
|
|
193
|
+
http_client: httpx.AsyncClient | None = None,
|
|
204
194
|
) -> ProgramVisualModel:
|
|
205
195
|
return await cls._call_job_and_poll(
|
|
206
196
|
routes.TASKS_VISUAL_MODEL_FULL_PATH,
|
|
@@ -213,7 +203,7 @@ class ApiWrapper:
|
|
|
213
203
|
async def call_create_execution_session(
|
|
214
204
|
cls,
|
|
215
205
|
circuit: generator_result.QuantumProgram,
|
|
216
|
-
http_client:
|
|
206
|
+
http_client: httpx.AsyncClient | None = None,
|
|
217
207
|
) -> str:
|
|
218
208
|
raw_result = await cls._call_task_pydantic(
|
|
219
209
|
http_method=HTTPMethod.POST,
|
|
@@ -229,7 +219,7 @@ class ApiWrapper:
|
|
|
229
219
|
cls,
|
|
230
220
|
session_id: str,
|
|
231
221
|
primitives_input: PrimitivesInput,
|
|
232
|
-
http_client:
|
|
222
|
+
http_client: httpx.AsyncClient | None = None,
|
|
233
223
|
) -> execution_request.ExecutionJobDetails:
|
|
234
224
|
data = await cls._call_task_pydantic(
|
|
235
225
|
http_method=HTTPMethod.POST,
|
|
@@ -243,7 +233,7 @@ class ApiWrapper:
|
|
|
243
233
|
async def call_convert_quantum_program(
|
|
244
234
|
cls,
|
|
245
235
|
circuit: generator_result.QuantumProgram,
|
|
246
|
-
http_client:
|
|
236
|
+
http_client: httpx.AsyncClient | None = None,
|
|
247
237
|
) -> dict:
|
|
248
238
|
return await cls._call_task_pydantic(
|
|
249
239
|
http_method=HTTPMethod.POST,
|
|
@@ -257,7 +247,7 @@ class ApiWrapper:
|
|
|
257
247
|
async def call_execute_execution_input(
|
|
258
248
|
cls,
|
|
259
249
|
execution_input: dict,
|
|
260
|
-
http_client:
|
|
250
|
+
http_client: httpx.AsyncClient | None = None,
|
|
261
251
|
) -> execution_request.ExecutionJobDetails:
|
|
262
252
|
data = await cls._call_task(
|
|
263
253
|
http_method=HTTPMethod.POST,
|
|
@@ -271,7 +261,7 @@ class ApiWrapper:
|
|
|
271
261
|
async def call_get_execution_job_details(
|
|
272
262
|
cls,
|
|
273
263
|
job_id: JobID,
|
|
274
|
-
http_client:
|
|
264
|
+
http_client: httpx.AsyncClient | None = None,
|
|
275
265
|
) -> execution_request.ExecutionJobDetails:
|
|
276
266
|
data = await cls._call_task(
|
|
277
267
|
http_method=HTTPMethod.GET,
|
|
@@ -284,7 +274,7 @@ class ApiWrapper:
|
|
|
284
274
|
async def call_get_execution_job_result(
|
|
285
275
|
cls,
|
|
286
276
|
job_id: JobID,
|
|
287
|
-
http_client:
|
|
277
|
+
http_client: httpx.AsyncClient | None = None,
|
|
288
278
|
) -> classiq.interface.executor.execution_result.ExecuteGeneratedCircuitResults:
|
|
289
279
|
data = await cls._call_task(
|
|
290
280
|
http_method=HTTPMethod.GET,
|
|
@@ -300,7 +290,7 @@ class ApiWrapper:
|
|
|
300
290
|
cls,
|
|
301
291
|
job_id: JobID,
|
|
302
292
|
name: str,
|
|
303
|
-
http_client:
|
|
293
|
+
http_client: httpx.AsyncClient | None = None,
|
|
304
294
|
) -> execution_request.ExecutionJobDetails:
|
|
305
295
|
data = await cls._call_task(
|
|
306
296
|
http_method=HTTPMethod.PATCH,
|
|
@@ -316,7 +306,7 @@ class ApiWrapper:
|
|
|
316
306
|
async def call_cancel_execution_job(
|
|
317
307
|
cls,
|
|
318
308
|
job_id: JobID,
|
|
319
|
-
http_client:
|
|
309
|
+
http_client: httpx.AsyncClient | None = None,
|
|
320
310
|
) -> None:
|
|
321
311
|
await cls._call_task(
|
|
322
312
|
http_method=HTTPMethod.PUT,
|
|
@@ -330,7 +320,7 @@ class ApiWrapper:
|
|
|
330
320
|
cls,
|
|
331
321
|
offset: int,
|
|
332
322
|
limit: int,
|
|
333
|
-
http_client:
|
|
323
|
+
http_client: httpx.AsyncClient | None = None,
|
|
334
324
|
) -> execution_request.ExecutionJobsQueryResults:
|
|
335
325
|
data = await cls._call_task(
|
|
336
326
|
http_method=HTTPMethod.GET,
|
|
@@ -347,7 +337,7 @@ class ApiWrapper:
|
|
|
347
337
|
async def call_analysis_task(
|
|
348
338
|
cls,
|
|
349
339
|
params: analysis_params.AnalysisParams,
|
|
350
|
-
http_client:
|
|
340
|
+
http_client: httpx.AsyncClient | None = None,
|
|
351
341
|
) -> analysis_result.Analysis:
|
|
352
342
|
data = await cls._call_task_pydantic(
|
|
353
343
|
http_method=HTTPMethod.POST,
|
|
@@ -358,25 +348,11 @@ class ApiWrapper:
|
|
|
358
348
|
|
|
359
349
|
return analysis_result.Analysis.model_validate(data)
|
|
360
350
|
|
|
361
|
-
@classmethod
|
|
362
|
-
async def call_analyzer_app(
|
|
363
|
-
cls,
|
|
364
|
-
params: generator_result.QuantumProgram,
|
|
365
|
-
http_client: Optional[httpx.AsyncClient] = None,
|
|
366
|
-
) -> analysis_result.DataID:
|
|
367
|
-
data = await cls._call_task_pydantic(
|
|
368
|
-
http_method=HTTPMethod.POST,
|
|
369
|
-
url=routes.ANALYZER_DATA_FULL_PATH,
|
|
370
|
-
model=params,
|
|
371
|
-
http_client=http_client,
|
|
372
|
-
)
|
|
373
|
-
return analysis_result.DataID.model_validate(data)
|
|
374
|
-
|
|
375
351
|
@classmethod
|
|
376
352
|
async def get_generated_circuit_from_qasm(
|
|
377
353
|
cls,
|
|
378
354
|
params: analysis_result.QasmCode,
|
|
379
|
-
http_client:
|
|
355
|
+
http_client: httpx.AsyncClient | None = None,
|
|
380
356
|
) -> generator_result.QuantumProgram:
|
|
381
357
|
data = await cls._call_task_pydantic(
|
|
382
358
|
http_method=HTTPMethod.POST,
|
|
@@ -390,7 +366,7 @@ class ApiWrapper:
|
|
|
390
366
|
async def get_analyzer_app_data(
|
|
391
367
|
cls,
|
|
392
368
|
params: analysis_result.DataID,
|
|
393
|
-
http_client:
|
|
369
|
+
http_client: httpx.AsyncClient | None = None,
|
|
394
370
|
) -> generator_result.QuantumProgram:
|
|
395
371
|
data = await cls._call_task(
|
|
396
372
|
http_method=HTTPMethod.GET,
|
|
@@ -403,7 +379,7 @@ class ApiWrapper:
|
|
|
403
379
|
async def call_rb_analysis_task(
|
|
404
380
|
cls,
|
|
405
381
|
params: AnalysisRBParams,
|
|
406
|
-
http_client:
|
|
382
|
+
http_client: httpx.AsyncClient | None = None,
|
|
407
383
|
) -> analysis_result.RbResults:
|
|
408
384
|
data = await cls._call_task(
|
|
409
385
|
http_method=HTTPMethod.POST,
|
|
@@ -418,7 +394,7 @@ class ApiWrapper:
|
|
|
418
394
|
async def call_hardware_connectivity_task(
|
|
419
395
|
cls,
|
|
420
396
|
params: analysis_params.AnalysisHardwareParams,
|
|
421
|
-
http_client:
|
|
397
|
+
http_client: httpx.AsyncClient | None = None,
|
|
422
398
|
) -> analysis_result.GraphResult:
|
|
423
399
|
data = await cls._call_task_pydantic(
|
|
424
400
|
http_method=HTTPMethod.POST,
|
|
@@ -432,7 +408,7 @@ class ApiWrapper:
|
|
|
432
408
|
async def call_table_graphs_task(
|
|
433
409
|
cls,
|
|
434
410
|
params: analysis_params.AnalysisHardwareListParams,
|
|
435
|
-
http_client:
|
|
411
|
+
http_client: httpx.AsyncClient | None = None,
|
|
436
412
|
) -> analysis_result.GraphResult:
|
|
437
413
|
return await cls._call_job_and_poll(
|
|
438
414
|
routes.ANALYZER_HC_TABLE_GRAPH_FULL_PATH,
|
|
@@ -445,7 +421,7 @@ class ApiWrapper:
|
|
|
445
421
|
async def call_available_devices_task(
|
|
446
422
|
cls,
|
|
447
423
|
params: analysis_params.AnalysisOptionalDevicesParams,
|
|
448
|
-
http_client:
|
|
424
|
+
http_client: httpx.AsyncClient | None = None,
|
|
449
425
|
) -> analysis_result.DevicesResult:
|
|
450
426
|
hardware_info = await cls.call_get_all_hardware_devices(http_client=http_client)
|
|
451
427
|
return cls._get_devices_from_hardware_info(hardware_info, params)
|
|
@@ -477,7 +453,7 @@ class ApiWrapper:
|
|
|
477
453
|
@classmethod
|
|
478
454
|
async def call_get_all_hardware_devices(
|
|
479
455
|
cls,
|
|
480
|
-
http_client:
|
|
456
|
+
http_client: httpx.AsyncClient | None = None,
|
|
481
457
|
) -> list[HardwareInformation]:
|
|
482
458
|
data = await client().call_api(
|
|
483
459
|
http_method=HTTPMethod.GET,
|
|
@@ -489,93 +465,6 @@ class ApiWrapper:
|
|
|
489
465
|
raise ClassiqAPIError(f"Unexpected value: {data}")
|
|
490
466
|
return [HardwareInformation.model_validate(info) for info in data]
|
|
491
467
|
|
|
492
|
-
@classmethod
|
|
493
|
-
async def call_generate_hamiltonian_task(
|
|
494
|
-
cls,
|
|
495
|
-
problem: ground_state_problem.CHEMISTRY_PROBLEMS_TYPE,
|
|
496
|
-
http_client: Optional[httpx.AsyncClient] = None,
|
|
497
|
-
) -> operator.PauliOperator:
|
|
498
|
-
return await cls._call_job_and_poll(
|
|
499
|
-
routes.GENERATE_HAMILTONIAN_FULL_PATH,
|
|
500
|
-
problem,
|
|
501
|
-
operator.PauliOperator,
|
|
502
|
-
http_client,
|
|
503
|
-
)
|
|
504
|
-
|
|
505
|
-
@classmethod
|
|
506
|
-
async def call_iqcc_init_auth(
|
|
507
|
-
cls,
|
|
508
|
-
data: IQCCInitAuthData,
|
|
509
|
-
http_client: Optional[httpx.AsyncClient] = None,
|
|
510
|
-
) -> IQCCInitAuthResponse:
|
|
511
|
-
response = await cls._call_task_pydantic(
|
|
512
|
-
http_method=HTTPMethod.PUT,
|
|
513
|
-
url=f"{routes.IQCC_INIT_AUTH_FULL_PATH}",
|
|
514
|
-
model=data,
|
|
515
|
-
http_client=http_client,
|
|
516
|
-
)
|
|
517
|
-
return IQCCInitAuthResponse.model_validate(response)
|
|
518
|
-
|
|
519
|
-
@classmethod
|
|
520
|
-
async def call_iqcc_probe_auth(
|
|
521
|
-
cls,
|
|
522
|
-
data: IQCCProbeAuthData,
|
|
523
|
-
http_client: Optional[httpx.AsyncClient] = None,
|
|
524
|
-
) -> Optional[IQCCProbeAuthResponse]:
|
|
525
|
-
try:
|
|
526
|
-
response = await cls._call_task_pydantic(
|
|
527
|
-
http_method=HTTPMethod.PUT,
|
|
528
|
-
url=f"{routes.IQCC_PROBE_AUTH_FULL_PATH}",
|
|
529
|
-
model=data,
|
|
530
|
-
http_client=http_client,
|
|
531
|
-
)
|
|
532
|
-
except ClassiqAPIError as ex:
|
|
533
|
-
if ex.status_code == 418:
|
|
534
|
-
return None
|
|
535
|
-
raise
|
|
536
|
-
|
|
537
|
-
return IQCCProbeAuthResponse.model_validate(response)
|
|
538
|
-
|
|
539
|
-
@classmethod
|
|
540
|
-
async def call_iqcc_list_auth_scopes(
|
|
541
|
-
cls,
|
|
542
|
-
http_client: Optional[httpx.AsyncClient] = None,
|
|
543
|
-
) -> IQCCAuthItemsDetails:
|
|
544
|
-
response = await cls._call_task(
|
|
545
|
-
http_method=HTTPMethod.GET,
|
|
546
|
-
url=routes.IQCC_LIST_AUTH_SCOPES_FULL_PATH,
|
|
547
|
-
http_client=http_client,
|
|
548
|
-
)
|
|
549
|
-
return IQCCAuthItemsDetails.model_validate(response)
|
|
550
|
-
|
|
551
|
-
@classmethod
|
|
552
|
-
async def call_iqcc_list_auth_methods(
|
|
553
|
-
cls,
|
|
554
|
-
data: IQCCListAuthMethods,
|
|
555
|
-
http_client: Optional[httpx.AsyncClient] = None,
|
|
556
|
-
) -> IQCCAuthItemsDetails:
|
|
557
|
-
response = await cls._call_task_pydantic(
|
|
558
|
-
http_method=HTTPMethod.PUT,
|
|
559
|
-
url=routes.IQCC_LIST_AUTH_METHODS_FULL_PATH,
|
|
560
|
-
model=data,
|
|
561
|
-
http_client=http_client,
|
|
562
|
-
)
|
|
563
|
-
return IQCCAuthItemsDetails.model_validate(response)
|
|
564
|
-
|
|
565
|
-
@classmethod
|
|
566
|
-
async def call_iqcc_list_auth_targets(
|
|
567
|
-
cls,
|
|
568
|
-
data: IQCCListAuthTargets,
|
|
569
|
-
http_client: Optional[httpx.AsyncClient] = None,
|
|
570
|
-
) -> IQCCAuthItemsDetails:
|
|
571
|
-
response = await cls._call_task_pydantic(
|
|
572
|
-
http_method=HTTPMethod.PUT,
|
|
573
|
-
url=routes.IQCC_LIST_AUTH_TARGETS_FULL_PATH,
|
|
574
|
-
model=data,
|
|
575
|
-
http_client=http_client,
|
|
576
|
-
)
|
|
577
|
-
return IQCCAuthItemsDetails.model_validate(response)
|
|
578
|
-
|
|
579
468
|
@classmethod
|
|
580
469
|
async def call_get_all_budgets(cls) -> list[UserBudget]:
|
|
581
470
|
data = await client().call_api(
|
|
@@ -3,14 +3,11 @@ import functools
|
|
|
3
3
|
import itertools
|
|
4
4
|
import logging
|
|
5
5
|
import time
|
|
6
|
-
from collections.abc import AsyncGenerator, Awaitable, Iterable
|
|
6
|
+
from collections.abc import AsyncGenerator, Awaitable, Callable, Iterable
|
|
7
7
|
from typing import (
|
|
8
8
|
Any,
|
|
9
|
-
Callable,
|
|
10
|
-
Optional,
|
|
11
9
|
SupportsFloat,
|
|
12
10
|
TypeVar,
|
|
13
|
-
Union,
|
|
14
11
|
)
|
|
15
12
|
|
|
16
13
|
T = TypeVar("T")
|
|
@@ -58,7 +55,7 @@ def enable_jupyter_notebook() -> None:
|
|
|
58
55
|
|
|
59
56
|
|
|
60
57
|
def _make_iterable_interval(
|
|
61
|
-
interval_sec:
|
|
58
|
+
interval_sec: SupportsFloat | Iterable[SupportsFloat],
|
|
62
59
|
) -> Iterable[float]:
|
|
63
60
|
if isinstance(interval_sec, Iterable):
|
|
64
61
|
return map(float, interval_sec)
|
|
@@ -67,8 +64,8 @@ def _make_iterable_interval(
|
|
|
67
64
|
|
|
68
65
|
async def poll_for(
|
|
69
66
|
poller: Callable[..., Awaitable[T]],
|
|
70
|
-
timeout_sec:
|
|
71
|
-
interval_sec:
|
|
67
|
+
timeout_sec: float | None,
|
|
68
|
+
interval_sec: float | Iterable[float],
|
|
72
69
|
) -> AsyncGenerator[T, None]:
|
|
73
70
|
if timeout_sec is not None:
|
|
74
71
|
end_time = time.perf_counter() + timeout_sec
|