qpanda3-runtime 1.0.1__cp314-none-win_amd64.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.
Files changed (63) hide show
  1. qpanda3_runtime/__init__.py +59 -0
  2. qpanda3_runtime/access_service/__init__.py +3 -0
  3. qpanda3_runtime/access_service/channel/__init__.py +5 -0
  4. qpanda3_runtime/access_service/channel/default_channel.py +11 -0
  5. qpanda3_runtime/access_service/network/__init__.py +39 -0
  6. qpanda3_runtime/access_service/network/http_client.py +223 -0
  7. qpanda3_runtime/access_service/network/query_task_tcp.py +639 -0
  8. qpanda3_runtime/access_service/network/tcp_client/__init__.py +47 -0
  9. qpanda3_runtime/access_service/network/tcp_client/application_processor.py +230 -0
  10. qpanda3_runtime/access_service/network/tcp_client/est.py +184 -0
  11. qpanda3_runtime/access_service/network/tcp_client/heart_beat.py +408 -0
  12. qpanda3_runtime/access_service/network/tcp_client/memory_pool.py +299 -0
  13. qpanda3_runtime/access_service/network/tcp_client/task_querier.py +80 -0
  14. qpanda3_runtime/access_service/network/tcp_client/tcp_data_client.py +194 -0
  15. qpanda3_runtime/access_service/remote_request/__init__.py +27 -0
  16. qpanda3_runtime/access_service/remote_request/chip_task_msg.py +392 -0
  17. qpanda3_runtime/access_service/remote_request/remote_request_worker.py +455 -0
  18. qpanda3_runtime/cli.py +51 -0
  19. qpanda3_runtime/device/__init__.py +73 -0
  20. qpanda3_runtime/device/device_abc.py +52 -0
  21. qpanda3_runtime/device/fake_backend.py +975 -0
  22. qpanda3_runtime/device/qdevice.py +607 -0
  23. qpanda3_runtime/runtime_service.py +1419 -0
  24. qpanda3_runtime/task/__init__.py +60 -0
  25. qpanda3_runtime/task/program_set/__init__.py +54 -0
  26. qpanda3_runtime/task/program_set/gate_params_bind_rule.py +453 -0
  27. qpanda3_runtime/task/program_set/observable_bind_rule.py +695 -0
  28. qpanda3_runtime/task/qtask_info.py +513 -0
  29. qpanda3_runtime/task/qtask_manager.py +757 -0
  30. qpanda3_runtime/task/session/__init__.py +27 -0
  31. qpanda3_runtime/task/session/fake_vqsession.py +139 -0
  32. qpanda3_runtime/task/session/vqsession.py +126 -0
  33. qpanda3_runtime/task/session/vqsession_abc.py +161 -0
  34. qpanda3_runtime/task/utils/__init__.py +3 -0
  35. qpanda3_runtime/toolbox/__init__.py +49 -0
  36. qpanda3_runtime/toolbox/checkpoint.py +259 -0
  37. qpanda3_runtime/toolbox/client_task_id_generator.py +442 -0
  38. qpanda3_runtime/toolbox/failure_orchestrator/__init__.py +49 -0
  39. qpanda3_runtime/toolbox/failure_orchestrator/failure_orchestrator.py +366 -0
  40. qpanda3_runtime/toolbox/tracker/__init__.py +41 -0
  41. qpanda3_runtime/toolbox/tracker/tools/__init__.py +5 -0
  42. qpanda3_runtime/toolbox/tracker/tools/trace_debugger.py +891 -0
  43. qpanda3_runtime/toolbox/tracker/trace_analyzer.py +125 -0
  44. qpanda3_runtime/toolbox/tracker/tracker_system.py +171 -0
  45. qpanda3_runtime/toolbox/tracker/tracker_trace.py +1257 -0
  46. qpanda3_runtime/toolbox/tracker/tracker_ui.py +341 -0
  47. qpanda3_runtime/toolbox/tracker/tracking_rule.py +201 -0
  48. qpanda3_runtime/toolbox/tracker/tracking_rules/__init__.py +6 -0
  49. qpanda3_runtime/toolbox/tracker/tracking_rules/default_tracking_rule.py +50 -0
  50. qpanda3_runtime/toolbox/tracker/tracking_rules/qtask_failure_rule.py +50 -0
  51. qpanda3_runtime/utils/__init__.py +63 -0
  52. qpanda3_runtime/utils/convert_json_bytes.py +155 -0
  53. qpanda3_runtime/utils/convert_json_ndarray.py +167 -0
  54. qpanda3_runtime/utils/exception/__init__.py +40 -0
  55. qpanda3_runtime/utils/exception/response_error.py +321 -0
  56. qpanda3_runtime/utils/union_type.py +200 -0
  57. qpanda3_runtime/version.py +20 -0
  58. qpanda3_runtime-1.0.1.dist-info/METADATA +26 -0
  59. qpanda3_runtime-1.0.1.dist-info/RECORD +63 -0
  60. qpanda3_runtime-1.0.1.dist-info/WHEEL +5 -0
  61. qpanda3_runtime-1.0.1.dist-info/entry_points.txt +3 -0
  62. qpanda3_runtime-1.0.1.dist-info/licenses/LICENSE.txt +202 -0
  63. qpanda3_runtime-1.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,59 @@
1
+ # SPDX-FileCopyrightText: 2026 Origin Quantum
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ """
6
+ QPanda3 Runtime Client Package.
7
+
8
+ This package provides the client-side interface for QPanda3 quantum computing runtime services.
9
+ It includes modules for quantum device management, task execution, and runtime service interaction.
10
+
11
+ Modules
12
+ -------
13
+ runtime_service : RuntimeService
14
+ Main client manager class for quantum runtime services.
15
+ access_service : Access service modules
16
+ Network communication and channel management.
17
+ device : Quantum device modules
18
+ Quantum device interfaces and fake backends.
19
+ toolbox : Utility tools
20
+ Checkpointing, tracking, and debugging utilities.
21
+ task : Task management
22
+ Quantum task execution and session management.
23
+ utils : Utility functions
24
+ Helper functions and exception handling.
25
+
26
+ Examples
27
+ --------
28
+ >>> from qpanda3_runtime import RuntimeService
29
+ >>> service = RuntimeService('https://localhost:8080')
30
+ >>> device = service.get_device('quantum_backend')
31
+ >>> task = device.run(circuit, shots=1000)
32
+
33
+ See Also
34
+ --------
35
+ qpanda3_runtime_server : Server-side package for QPanda3 runtime services.
36
+ pyqpanda3 : Core quantum computing library.
37
+
38
+ Notes
39
+ -----
40
+ - This package requires a running QPanda3 runtime server.
41
+ - Authentication tokens are managed automatically by the RuntimeService.
42
+ - All quantum operations are tracked for debugging and monitoring.
43
+ """
44
+
45
+ from .version import __version__
46
+ from .runtime_service import RuntimeService
47
+ from .access_service.channel import default_channel
48
+ from .device.qdevice import QDevice
49
+ from .device.fake_backend import FakeBackend
50
+ from .toolbox.checkpoint import CheckPoint
51
+ from .toolbox.tracker import Tracker,tracker,TraceAnalyzer,TrackerRef
52
+ from .task.qtask_manager import QTaskManager
53
+ from .task.session.vqsession import VQSession
54
+ from .task.session import FakeVQSession
55
+ from .task.program_set.gate_params_bind_rule import AnsatzParamsBinding
56
+ from .task.program_set.observable_bind_rule import CircuitObservableBinding,AnsatzObservableBinding
57
+
58
+
59
+
@@ -0,0 +1,3 @@
1
+ # SPDX-FileCopyrightText: 2026 Origin Quantum
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
@@ -0,0 +1,5 @@
1
+ # SPDX-FileCopyrightText: 2026 Origin Quantum
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ from .default_channel import default_channel
@@ -0,0 +1,11 @@
1
+ # SPDX-FileCopyrightText: 2026 Origin Quantum
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ import os
6
+
7
+ setting = os.environ.get('DEFAULT_CHANNEL')
8
+ if setting and setting != '':
9
+ default_channel = setting
10
+ else:
11
+ default_channel = 'qcloud'
@@ -0,0 +1,39 @@
1
+ # SPDX-FileCopyrightText: 2026 Origin Quantum
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ """
6
+ Network communication module for quantum computing runtime service.
7
+
8
+ This module provides HTTP and TCP client implementations for communicating with
9
+ quantum computing backend services. It supports both synchronous and asynchronous
10
+ communication patterns.
11
+
12
+ Modules
13
+ -------
14
+ http_client : HTTPClient
15
+ Asynchronous HTTP client for REST API communication with quantum backend.
16
+ query_task_tcp : TCPQueryTask
17
+ TCP-based client for querying quantum task execution results.
18
+
19
+ Notes
20
+ -----
21
+ - The HTTP client supports SSL/TLS with certificate verification disabled for
22
+ development environments.
23
+ - The TCP client implements custom binary protocol for efficient data transfer.
24
+ - Both clients are designed for high-throughput quantum task management.
25
+
26
+ Examples
27
+ --------
28
+ >>> from .http_client import HTTPClient
29
+ >>> client = HTTPClient(base_url='http://localhost:8080')
30
+ >>> result = client.get_request('/api/status')
31
+
32
+ >>> from .query_task_tcp import TCPQueryTask
33
+ >>> result = TCPQueryTask.query_task_tcp('localhost', 8080, 'task-123')
34
+ """
35
+
36
+ from .http_client import HTTPClient
37
+ from .query_task_tcp import TCPQueryTask
38
+
39
+ __all__ = ['HTTPClient', 'TCPQueryTask']
@@ -0,0 +1,223 @@
1
+ # SPDX-FileCopyrightText: 2026 Origin Quantum
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ import json
6
+ import os.path
7
+ import ssl
8
+
9
+ import aiohttp
10
+ import asyncio
11
+ from typing import Union
12
+
13
+
14
+ class HTTPClient:
15
+ """
16
+ Asynchronous HTTP client for quantum computing backend communication.
17
+
18
+ Provides synchronous and asynchronous methods for making HTTP requests
19
+ to quantum computing backend services. Supports request logging and
20
+ SSL/TLS configuration.
21
+
22
+ Parameters
23
+ ----------
24
+ base_url : str, optional
25
+ Base URL for all HTTP requests (default: 'http://localhost:8080').
26
+ outbound_raw_requests_logfile : Union[str, None], optional
27
+ Path to log file for recording outbound request data.
28
+ If provided, all request payloads will be logged to this file.
29
+
30
+ Attributes
31
+ ----------
32
+ _base_url : str
33
+ Base URL for HTTP requests.
34
+ _outbound_raw_requests_logfile : Union[str, None]
35
+ Path to request logging file.
36
+
37
+ Notes
38
+ -----
39
+ - SSL certificate verification is disabled for development environments.
40
+ - All requests use JSON format for both request and response.
41
+ - Timeout handling is managed by aiohttp default settings.
42
+
43
+ Examples
44
+ --------
45
+ >>> client = HTTPClient(base_url='http://quantum-backend:8080')
46
+ >>> result = client.get_request('/api/status')
47
+ >>> async_result = await client.post_request_async('/api/task', {'task_id': '123'})
48
+ """
49
+
50
+ def __init__(self, base_url='http://localhost:8080', outbound_raw_requests_logfile: Union[str, None] = None):
51
+ self._base_url = base_url
52
+ self._outbound_raw_requests_logfile = outbound_raw_requests_logfile
53
+
54
+ async def _make_request(self, method, endpoint, data=None):
55
+ """
56
+ Internal method to make HTTP requests asynchronously.
57
+
58
+ Handles request logging, SSL configuration, and response processing.
59
+ All exceptions are propagated to the caller.
60
+
61
+ Parameters
62
+ ----------
63
+ method : str
64
+ HTTP method (GET, POST, PUT, DELETE).
65
+ endpoint : str
66
+ API endpoint path relative to base URL.
67
+ data : dict, optional
68
+ JSON-serializable data for POST/PUT requests.
69
+
70
+ Returns
71
+ -------
72
+ dict
73
+ Parsed JSON response from the server.
74
+
75
+ Raises
76
+ ------
77
+ RuntimeError
78
+ If server returns non-2xx status code.
79
+ aiohttp.ClientError
80
+ For network or connection errors.
81
+
82
+ Notes
83
+ -----
84
+ - Request data is logged to file if outbound_raw_requests_logfile is set.
85
+ - SSL verification is disabled for development compatibility.
86
+ - Only status codes 200 and 201 are considered successful.
87
+ """
88
+ if self._outbound_raw_requests_logfile is not None and os.path.exists(self._outbound_raw_requests_logfile):
89
+ with open(self._outbound_raw_requests_logfile, mode='at', encoding='utf8') as file:
90
+ json_str = json.dumps(data)
91
+ file.write(json_str)
92
+ file.write('\n')
93
+ file.flush()
94
+
95
+ url = f"{self._base_url}{endpoint}"
96
+ ssl_context = ssl.create_default_context()
97
+ ssl_context.check_hostname = False
98
+ ssl_context.verify_mode = ssl.CERT_NONE
99
+
100
+ connector = aiohttp.TCPConnector(ssl=ssl_context)
101
+
102
+ try:
103
+ async with aiohttp.ClientSession(connector=connector) as session:
104
+ async with session.request(
105
+ method=method,
106
+ url=url,
107
+ json=data if data else None,
108
+ headers={'Content-Type': 'application/json'}
109
+ ) as response:
110
+
111
+ if response.status in [200, 201]:
112
+ response_data = await response.json()
113
+ return response_data
114
+ else:
115
+ error_text = await response.text()
116
+ help_info = 'Possible causes and corresponding solutions:\n'
117
+ if response.status in [404]:
118
+ help_info += f'\t 1> Maybe channel {data["channel"]} is error or unreachable, \n' \
119
+ '\t\t 1>>please check if channel string meets the expectations.\n' \
120
+ '\t\t 2>> or please connect to qpanda3_runtime service provider to get help.\n'
121
+
122
+ raise RuntimeError(
123
+ f'request/target url:{url}, response code:{response.status}, '
124
+ f'response info:{error_text}, {help_info}')
125
+
126
+ except aiohttp.ClientError as e:
127
+ raise e
128
+ except RuntimeError as e:
129
+ raise e
130
+
131
+ def get_request(self, endpoint):
132
+ """
133
+ Synchronous GET request.
134
+
135
+ Parameters
136
+ ----------
137
+ endpoint : str
138
+ API endpoint path.
139
+
140
+ Returns
141
+ -------
142
+ dict
143
+ Parsed JSON response.
144
+
145
+ See Also
146
+ --------
147
+ _make_request : Internal request implementation.
148
+ """
149
+ return asyncio.run(self._make_request('GET', endpoint))
150
+
151
+ def post_request(self, endpoint, data):
152
+ """
153
+ Synchronous POST request.
154
+
155
+ Parameters
156
+ ----------
157
+ endpoint : str
158
+ API endpoint path.
159
+ data : dict
160
+ JSON-serializable request data.
161
+
162
+ Returns
163
+ -------
164
+ dict
165
+ Parsed JSON response.
166
+ """
167
+ return asyncio.run(self._make_request('POST', endpoint, data))
168
+
169
+ async def post_request_async(self, endpoint, data):
170
+ """
171
+ Asynchronous POST request.
172
+
173
+ Parameters
174
+ ----------
175
+ endpoint : str
176
+ API endpoint path.
177
+ data : dict
178
+ JSON-serializable request data.
179
+
180
+ Returns
181
+ -------
182
+ dict
183
+ Parsed JSON response.
184
+
185
+ Notes
186
+ -----
187
+ Use this method in async contexts to avoid blocking.
188
+ """
189
+ return await self._make_request('POST', endpoint, data)
190
+
191
+ def put_request(self, endpoint, data):
192
+ """
193
+ Synchronous PUT request.
194
+
195
+ Parameters
196
+ ----------
197
+ endpoint : str
198
+ API endpoint path.
199
+ data : dict
200
+ JSON-serializable request data.
201
+
202
+ Returns
203
+ -------
204
+ dict
205
+ Parsed JSON response.
206
+ """
207
+ return asyncio.run(self._make_request('PUT', endpoint, data))
208
+
209
+ def delete_request(self, endpoint):
210
+ """
211
+ Synchronous DELETE request.
212
+
213
+ Parameters
214
+ ----------
215
+ endpoint : str
216
+ API endpoint path.
217
+
218
+ Returns
219
+ -------
220
+ dict
221
+ Parsed JSON response.
222
+ """
223
+ return asyncio.run(self._make_request('DELETE', endpoint))