qoro-divi 0.3.1b0__py3-none-any.whl → 0.3.3__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 qoro-divi might be problematic. Click here for more details.

divi/reporter.py ADDED
@@ -0,0 +1,90 @@
1
+ # SPDX-FileCopyrightText: 2025 Qoro Quantum Ltd <divi@qoroquantum.de>
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ import logging
6
+ from abc import ABC, abstractmethod
7
+ from queue import Queue
8
+
9
+ logger = logging.getLogger(__name__)
10
+
11
+
12
+ class ProgressReporter(ABC):
13
+ """An abstract base class for reporting progress of a quantum program."""
14
+
15
+ @abstractmethod
16
+ def update(self, **kwargs):
17
+ """Provides a progress update."""
18
+ pass
19
+
20
+ @abstractmethod
21
+ def info(self, message: str, **kwargs):
22
+ """
23
+ Provides a simple informational message.
24
+ No changes to progress or state.
25
+ """
26
+ pass
27
+
28
+
29
+ class QueueProgressReporter(ProgressReporter):
30
+ """Reports progress by putting structured dictionaries onto a Queue."""
31
+
32
+ def __init__(
33
+ self, job_id: str, progress_queue: Queue, has_final_computation: bool = False
34
+ ):
35
+ self._job_id = job_id
36
+ self._queue = progress_queue
37
+ self.has_final_computation = has_final_computation
38
+
39
+ def update(self, **kwargs):
40
+ payload = {"job_id": self._job_id, "progress": 1}
41
+ self._queue.put(payload)
42
+
43
+ def info(self, message: str, **kwargs):
44
+ payload = {"job_id": self._job_id, "progress": 0, "message": message}
45
+
46
+ # Determine if this message indicates the job is truly finished.
47
+ is_final_step = "Computed Final Solution" in message or (
48
+ "Finished Optimization" in message and not self.has_final_computation
49
+ )
50
+
51
+ if is_final_step:
52
+ payload["final_status"] = "Success"
53
+ elif "poll_attempt" in kwargs:
54
+ # For polling, remove the message key so the last message persists.
55
+ del payload["message"]
56
+ payload["poll_attempt"] = kwargs["poll_attempt"]
57
+ payload["max_retries"] = kwargs["max_retries"]
58
+ payload["service_job_id"] = kwargs["service_job_id"]
59
+ payload["job_status"] = kwargs["job_status"]
60
+
61
+ self._queue.put(payload)
62
+
63
+
64
+ class LoggingProgressReporter(ProgressReporter):
65
+ """Reports progress by logging messages to the console."""
66
+
67
+ # Define ANSI color codes
68
+ CYAN = "\033[36m"
69
+ RESET = "\033[0m"
70
+
71
+ def update(self, **kwargs):
72
+ # You can decide how to format the update for logging
73
+ logger.info(f"Finished Iteration #{kwargs['iteration']}\r\n")
74
+
75
+ def info(self, message: str, **kwargs):
76
+ # A special check for iteration updates to mimic old behavior
77
+ if "poll_attempt" in kwargs:
78
+ logger.info(
79
+ f"Job {self.CYAN}{kwargs['service_job_id'].split('-')[0]}{self.RESET} is {kwargs['job_status']}. Polling attempt {kwargs['poll_attempt']} / {kwargs['max_retries']}\r",
80
+ extra={"append": True},
81
+ )
82
+ return
83
+
84
+ if "iteration" in kwargs:
85
+ logger.info(
86
+ f"Running Iteration #{kwargs['iteration'] + 1} circuits: {message}\r"
87
+ )
88
+ return
89
+
90
+ logger.info(message)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qoro-divi
3
- Version: 0.3.1b0
3
+ Version: 0.3.3
4
4
  Summary: A Python library to automate generating, parallelizing, and executing quantum programs.
5
5
  Author: Ahmed Darwish
6
6
  Author-email: ahmed@qoroquantum.de
@@ -14,14 +14,14 @@ Requires-Dist: dwave-hybrid (>=0.6.14,<0.7.0)
14
14
  Requires-Dist: matplotlib (>=3.10.3,<4.0.0)
15
15
  Requires-Dist: mitiq (>=0.46,<0.47)
16
16
  Requires-Dist: networkx (>=3.5,<4.0)
17
- Requires-Dist: pennylane (>=0.40,<0.41)
17
+ Requires-Dist: pennylane (>=0.42.3,<0.43.0)
18
18
  Requires-Dist: ply (>=3.11,<4.0)
19
19
  Requires-Dist: pymetis (>=2025.1.1,<2026.0.0)
20
20
  Requires-Dist: python-dotenv (>=1.1.1,<2.0.0)
21
21
  Requires-Dist: qiskit (<2.0)
22
22
  Requires-Dist: qiskit-aer (>=0.17.1,<0.18.0)
23
23
  Requires-Dist: qiskit-ibm-runtime (>=0.37,<0.38)
24
- Requires-Dist: qiskit-optimization (>=0.6.1,<0.7.0)
24
+ Requires-Dist: qiskit-optimization[cplex] (>=0.7.0,<0.8.0)
25
25
  Requires-Dist: requests (>=2.32.4,<3.0.0)
26
26
  Requires-Dist: rich (>=14.0.0,<15.0.0)
27
27
  Requires-Dist: scikit-learn (>=1.7.0,<2.0.0)
@@ -1,12 +1,12 @@
1
1
  divi/__init__.py,sha256=WNAlzdjio0M5la_NTGk4-0AFqItI6HEBExRs6ck9j0Y,203
2
- divi/_pbar.py,sha256=M6FQByH63bWwzsKtedW49Hm7hFsnb1X5AlFfCZFSvuU,2019
2
+ divi/_pbar.py,sha256=I8AWI93mpcJXIXTIvsa3JghazO65Pmrq-bW2bJTf2Ik,2131
3
3
  divi/circuits.py,sha256=OKcwTMXIvCIjvpLvdeQBWGYElcVUNNyA3z8yXnxUXeo,4476
4
- divi/exp/cirq/__init__.py,sha256=4wd5rEiNgsPVSK8uLYdJMf54B1ITdtKfMJtdnRpfwTE,350
4
+ divi/exp/cirq/__init__.py,sha256=6NjP3TlQn_oNkg8VrKvEIoYQxB5Bx0mLLFOT3SXReTc,371
5
5
  divi/exp/cirq/_lexer.py,sha256=x5UArrnN_JEyiq7E02ikq0wdmqZ2vEQ3_FADL1LIhQI,3187
6
6
  divi/exp/cirq/_parser.py,sha256=z_bSn4m03-sfRlN8eL99Mo4LnjY-zmR-Xt6UrjzstZc,29279
7
7
  divi/exp/cirq/_qasm_export.py,sha256=8C5xLYvIIkQTWWAAYo7ZjwtQjvYXNSflbf5UyUx6YUE,1024
8
8
  divi/exp/cirq/_qasm_import.py,sha256=HbehrgfLl3iDdRyWr4o26Bek3ZpN-_dvNVSexl5-aVE,969
9
- divi/exp/cirq/_validator.py,sha256=nYbJdT_0hCVUgZA0YiKZ8G1oDgwmcqEiy-LZH41EgUw,20481
9
+ divi/exp/cirq/_validator.py,sha256=552fiXRpiuXc6aoNNXjnv6SWWCAdBAKieQEOTfCQy1s,20484
10
10
  divi/exp/cirq/exception.py,sha256=w1w2vSubOGMRmyKBFqXejxfeIAzkPZ6V7gSrDX_ap4A,765
11
11
  divi/exp/scipy/_cobyla.py,sha256=cnCf5AsOM8JWIMiujuUbWMNOgmUr3ZET9y04hUyumHs,10937
12
12
  divi/exp/scipy/pyprima/LICENCE.txt,sha256=mXN5ssG_U6OR0v0yldznW_PJTtKNZIgu3jDRtRjLDdY,1533
@@ -40,22 +40,23 @@ divi/interfaces.py,sha256=P-8lekQIGwbhHv4ewfMFtKYIjmQHu7nmscwAmxsx72U,594
40
40
  divi/parallel_simulator.py,sha256=2JCwmootXLtDplplEqtykKc8HiYe6G0zKWemIb-IIdE,8947
41
41
  divi/qasm.py,sha256=lfWky4E9qetotVo8BII58svutVVZEV14BntoC14bo40,7384
42
42
  divi/qem.py,sha256=o6rMPUcxLuCBitBb8-QcxveUiKZVsP3HMamxyVFLi6M,6805
43
- divi/qlogger.py,sha256=VaCnw-u8VkR7JukjOp39r0V89wO-SSpDj5l50ejnHUg,3801
44
- divi/qoro_service.py,sha256=sv94S_xdY4k4YYSK3PgX4sgvgldFMkjJ3wtQO1a_2Yc,13557
45
- divi/qprog/__init__.py,sha256=quz1zEdrY71TuNVXUHq9u92sORgPmmNq8y6ozMiYnTI,507
46
- divi/qprog/_graph_partitioning.py,sha256=ZVDKc5--YB9EmuA7Qsyc0Rc5P-eojWpglO-XqoMmbZk,23620
47
- divi/qprog/_qaoa.py,sha256=FCO3s0mA6rlrymqUjvpfY640DoLLIFP8tqi8z7UAamM,16129
48
- divi/qprog/_qubo_partitioning.py,sha256=7MxeUfZ5PDkfzPprcXh_1omdvUuCK_I4qh1915XAVhk,7388
49
- divi/qprog/_vqe.py,sha256=0MNSZA9wb6CKhLIT5SpM_J2ncW-p1frKBp8k0ipOYwQ,9985
50
- divi/qprog/_vqe_sweep.py,sha256=lTWPG7vwtVS91Piqc5-_tlhglO8RFkMhlatCTz-8PZg,17214
51
- divi/qprog/batch.py,sha256=UWiDsABFWNggvR136jBnTg6r5OUuHHh3nOCGL1keAy8,9654
52
- divi/qprog/optimizers.py,sha256=l19zIyt1l0IhUbLofEXlwE9XnsILk7ANlwACi3KKN4w,2034
53
- divi/qprog/quantum_program.py,sha256=hJ5uraX9ZNicfoJu3X0aAe8KTJUzndgX5GyoHZ1GOB8,16921
43
+ divi/qlogger.py,sha256=TcZMaNZXDHguKJGLD6t2bEmP25rkRQVaSS8FLs9U-lI,3822
44
+ divi/qoro_service.py,sha256=CASWEE6ySlFeQ6pHeOZJUUuwnldEVsPakn_4jTFPnX0,14087
45
+ divi/qprog/__init__.py,sha256=av3I0i3VldwblycfQjcXcJHGVY1m05rnsZ0R5iGMCwk,546
46
+ divi/qprog/_graph_partitioning.py,sha256=cYeHQ2VJAeOzooO43dPfWdXjRZPF_UmHR_H2D7VIpnU,23666
47
+ divi/qprog/_qaoa.py,sha256=Cq1AnaS386iGEv8OiHhSkyGkMG1MwfX3_mq2jBXavgI,15950
48
+ divi/qprog/_qubo_partitioning.py,sha256=h2QPDm1pzNYzsrvw0WZ04fb-nOzj8xFqf5YZqOU5FHk,7470
49
+ divi/qprog/_vqe.py,sha256=21KVvf40UGwxuJQ0OJ1YuiFctvEVbJRklilpxgopnkA,10069
50
+ divi/qprog/_vqe_sweep.py,sha256=T5tXVOENn4VlzwUxSR0SGbv1EWVRdy4H9m1M_sLElCk,17286
51
+ divi/qprog/batch.py,sha256=jxeOO5xFecCCmA82GDAtg3mA8PeW_c5O5ooqEcb2-Bg,10093
52
+ divi/qprog/optimizers.py,sha256=sbOxd9VgMroZn1llN5wyIMLEM-a4x_YKJpt34ApaKX8,6453
53
+ divi/qprog/quantum_program.py,sha256=D2L1zjvW_G3O0oNgty3Y_QhIGrJz0V4rzcz6VSoXFME,14779
54
54
  divi/qpu_system.py,sha256=teVeG18ukyzMFgbPSr4BLx4MJUHVK382RqZMOy2voFk,374
55
+ divi/reporter.py,sha256=AgB2Mno1sIXF-VhOi8i-LGuWG5FMG1HelMw5cMc84HM,2977
55
56
  divi/utils.py,sha256=EEyGakoz33AvU0Rq7iijL8AULMg4FGcGBtmOlpSw-tY,3603
56
- qoro_divi-0.3.1b0.dist-info/LICENSE,sha256=NS4JlQrgNwg1bvB3kE5shE-P4cJgnntgl-kClbOpG_Q,10760
57
- qoro_divi-0.3.1b0.dist-info/LICENSES/.license-header,sha256=2jN_xtJscqP8LG-NaveY2KHUkfRCC543Y_XjOyKEfWY,105
58
- qoro_divi-0.3.1b0.dist-info/LICENSES/Apache-2.0.txt,sha256=yoILHpvVuguUBpk8UwMnzJbcHUUyst9iGNNuEwUtWVc,10270
59
- qoro_divi-0.3.1b0.dist-info/METADATA,sha256=NMSrA8Dko7m626atJX0Cpkp1QaauZBozWFLyNeGQBNQ,2419
60
- qoro_divi-0.3.1b0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
61
- qoro_divi-0.3.1b0.dist-info/RECORD,,
57
+ qoro_divi-0.3.3.dist-info/LICENSE,sha256=NS4JlQrgNwg1bvB3kE5shE-P4cJgnntgl-kClbOpG_Q,10760
58
+ qoro_divi-0.3.3.dist-info/LICENSES/.license-header,sha256=2jN_xtJscqP8LG-NaveY2KHUkfRCC543Y_XjOyKEfWY,105
59
+ qoro_divi-0.3.3.dist-info/LICENSES/Apache-2.0.txt,sha256=yoILHpvVuguUBpk8UwMnzJbcHUUyst9iGNNuEwUtWVc,10270
60
+ qoro_divi-0.3.3.dist-info/METADATA,sha256=txN4vgtVVbI_PuH1vtN70jRHY21S7WL35Bj1eFOxgBA,2428
61
+ qoro_divi-0.3.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
62
+ qoro_divi-0.3.3.dist-info/RECORD,,