qcanvas-sdk 1.0.2__tar.gz
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.
- qcanvas_sdk-1.0.2/LICENSE +53 -0
- qcanvas_sdk-1.0.2/PKG-INFO +468 -0
- qcanvas_sdk-1.0.2/README.md +436 -0
- qcanvas_sdk-1.0.2/pyproject.toml +50 -0
- qcanvas_sdk-1.0.2/qcanvas/__init__.py +15 -0
- qcanvas_sdk-1.0.2/qcanvas/core.py +315 -0
- qcanvas_sdk-1.0.2/qcanvas/qsim.py +177 -0
- qcanvas_sdk-1.0.2/qcanvas/result.py +167 -0
- qcanvas_sdk-1.0.2/qcanvas/sandbox.py +541 -0
- qcanvas_sdk-1.0.2/qcanvas_sdk.egg-info/PKG-INFO +468 -0
- qcanvas_sdk-1.0.2/qcanvas_sdk.egg-info/SOURCES.txt +46 -0
- qcanvas_sdk-1.0.2/qcanvas_sdk.egg-info/dependency_links.txt +1 -0
- qcanvas_sdk-1.0.2/qcanvas_sdk.egg-info/requires.txt +26 -0
- qcanvas_sdk-1.0.2/qcanvas_sdk.egg-info/top_level.txt +2 -0
- qcanvas_sdk-1.0.2/quantum_converters/__init__.py +24 -0
- qcanvas_sdk-1.0.2/quantum_converters/base/ConversionResult.py +72 -0
- qcanvas_sdk-1.0.2/quantum_converters/base/__init__.py +1 -0
- qcanvas_sdk-1.0.2/quantum_converters/base/abstract_converter.py +63 -0
- qcanvas_sdk-1.0.2/quantum_converters/base/circuit_ast.py +220 -0
- qcanvas_sdk-1.0.2/quantum_converters/base/openqasm_generator.py +34 -0
- qcanvas_sdk-1.0.2/quantum_converters/base/qasm3_builder.py +800 -0
- qcanvas_sdk-1.0.2/quantum_converters/base/qasm3_expression.py +436 -0
- qcanvas_sdk-1.0.2/quantum_converters/base/qasm3_gates.py +430 -0
- qcanvas_sdk-1.0.2/quantum_converters/config/__init__.py +33 -0
- qcanvas_sdk-1.0.2/quantum_converters/config/config.py +12 -0
- qcanvas_sdk-1.0.2/quantum_converters/config/mappings.py +207 -0
- qcanvas_sdk-1.0.2/quantum_converters/config/schemas.py +80 -0
- qcanvas_sdk-1.0.2/quantum_converters/converters/__init__.py +19 -0
- qcanvas_sdk-1.0.2/quantum_converters/converters/cirq_to_qasm.py +884 -0
- qcanvas_sdk-1.0.2/quantum_converters/converters/pennylane_to_qasm.py +874 -0
- qcanvas_sdk-1.0.2/quantum_converters/converters/qiskit_to_qasm.py +835 -0
- qcanvas_sdk-1.0.2/quantum_converters/optimizers/__init__.py +1 -0
- qcanvas_sdk-1.0.2/quantum_converters/optimizers/circuit_optimizer.py +36 -0
- qcanvas_sdk-1.0.2/quantum_converters/optimizers/gate_fusion.py +37 -0
- qcanvas_sdk-1.0.2/quantum_converters/parsers/__init__.py +1 -0
- qcanvas_sdk-1.0.2/quantum_converters/parsers/braket_parser.py +36 -0
- qcanvas_sdk-1.0.2/quantum_converters/parsers/cirq_parser.py +1444 -0
- qcanvas_sdk-1.0.2/quantum_converters/parsers/pennylane_parser.py +1096 -0
- qcanvas_sdk-1.0.2/quantum_converters/parsers/qiskit_parser.py +1411 -0
- qcanvas_sdk-1.0.2/quantum_converters/utils/__init__.py +1 -0
- qcanvas_sdk-1.0.2/quantum_converters/utils/circuit_utils.py +35 -0
- qcanvas_sdk-1.0.2/quantum_converters/utils/gate_mappings.py +35 -0
- qcanvas_sdk-1.0.2/quantum_converters/utils/qasm_formatter.py +35 -0
- qcanvas_sdk-1.0.2/quantum_converters/validators/__init__.py +1 -0
- qcanvas_sdk-1.0.2/quantum_converters/validators/semantic_validator.py +37 -0
- qcanvas_sdk-1.0.2/quantum_converters/validators/syntax_validator.py +36 -0
- qcanvas_sdk-1.0.2/setup.cfg +4 -0
- qcanvas_sdk-1.0.2/tests/test_security.py +42 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
Open Quantum Workbench Proprietary License
|
|
2
|
+
==========================================
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2025 Open Quantum Workbench.
|
|
5
|
+
All rights reserved.
|
|
6
|
+
|
|
7
|
+
1. Grant of Limited Rights
|
|
8
|
+
--------------------------
|
|
9
|
+
Open Quantum Workbench (“Licensor”) grants you a non-transferable,
|
|
10
|
+
non-exclusive, revocable license to install and use this repository
|
|
11
|
+
(“Software”) solely for personal evaluation, academic review, or internal
|
|
12
|
+
research. Any other use is strictly prohibited.
|
|
13
|
+
|
|
14
|
+
2. Prohibited Activities
|
|
15
|
+
------------------------
|
|
16
|
+
You may NOT, under any circumstance, do any of the following:
|
|
17
|
+
|
|
18
|
+
- Copy, reproduce, or redistribute the Software or any derivative work.
|
|
19
|
+
- Modify, fork, translate, adapt, or otherwise create derivative works.
|
|
20
|
+
- Sell, sublicense, rent, lease, lend, or otherwise commercialize the Software.
|
|
21
|
+
- Use the Software to build competing products or services.
|
|
22
|
+
- Remove, obscure, or alter any proprietary notices.
|
|
23
|
+
|
|
24
|
+
3. Ownership
|
|
25
|
+
------------
|
|
26
|
+
The Software is licensed, not sold. All rights, title, and interest—including
|
|
27
|
+
all intellectual property rights—remain exclusively with Open Quantum Workbench
|
|
28
|
+
and its contributors.
|
|
29
|
+
|
|
30
|
+
4. Termination
|
|
31
|
+
--------------
|
|
32
|
+
Licensor reserves the right to terminate this license at any time. Upon
|
|
33
|
+
termination you must cease all use, destroy all copies, and certify
|
|
34
|
+
destruction to Licensor.
|
|
35
|
+
|
|
36
|
+
5. Disclaimer of Warranty
|
|
37
|
+
-------------------------
|
|
38
|
+
THE SOFTWARE IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS
|
|
39
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
40
|
+
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
|
41
|
+
|
|
42
|
+
6. Limitation of Liability
|
|
43
|
+
--------------------------
|
|
44
|
+
IN NO EVENT SHALL OPEN QUANTUM WORKBENCH OR ITS CONTRIBUTORS BE LIABLE FOR ANY
|
|
45
|
+
CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR
|
|
46
|
+
OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
47
|
+
OR OTHER DEALINGS IN THE SOFTWARE.
|
|
48
|
+
|
|
49
|
+
7. Acceptance
|
|
50
|
+
-------------
|
|
51
|
+
By accessing or using the Software, you acknowledge that you have read,
|
|
52
|
+
understood, and agree to be bound by the terms of this license. If you do not
|
|
53
|
+
agree, do not use the Software.
|
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qcanvas-sdk
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: A package for compiling quantum circuit code from Cirq, Qiskit, and PennyLane to OpenQASM 3.0.
|
|
5
|
+
Author: QCanvas Team
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: antlr4-python3-runtime>=4.13.2
|
|
11
|
+
Requires-Dist: numpy>=1.24.0
|
|
12
|
+
Requires-Dist: pydantic>=2.0.0
|
|
13
|
+
Provides-Extra: cirq
|
|
14
|
+
Requires-Dist: cirq>=1.5.0; extra == "cirq"
|
|
15
|
+
Provides-Extra: qiskit
|
|
16
|
+
Requires-Dist: qiskit>=2.1.2; extra == "qiskit"
|
|
17
|
+
Requires-Dist: qiskit-aer>=0.17.2; extra == "qiskit"
|
|
18
|
+
Provides-Extra: pennylane
|
|
19
|
+
Requires-Dist: pennylane>=0.42.3; extra == "pennylane"
|
|
20
|
+
Requires-Dist: pennylane-lightning>=0.42.0; extra == "pennylane"
|
|
21
|
+
Provides-Extra: qsim
|
|
22
|
+
Requires-Dist: qsim; extra == "qsim"
|
|
23
|
+
Provides-Extra: all
|
|
24
|
+
Requires-Dist: cirq>=1.5.0; extra == "all"
|
|
25
|
+
Requires-Dist: qiskit>=2.1.2; extra == "all"
|
|
26
|
+
Requires-Dist: qiskit-aer>=0.17.2; extra == "all"
|
|
27
|
+
Requires-Dist: pennylane>=0.42.3; extra == "all"
|
|
28
|
+
Requires-Dist: pennylane-lightning>=0.42.0; extra == "all"
|
|
29
|
+
Requires-Dist: openqasm3>=1.0.1; extra == "all"
|
|
30
|
+
Requires-Dist: pyqasm>=0.5.0; extra == "all"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# Quantum Unified Simulator (QCanvas)
|
|
34
|
+
|
|
35
|
+
A comprehensive quantum computing platform that provides unified simulation, circuit conversion, and visualization capabilities across multiple quantum frameworks using a hybrid Next.js and FastAPI architecture.
|
|
36
|
+
|
|
37
|
+
## 🚀 Overview
|
|
38
|
+
|
|
39
|
+
QCanvas is a modern, web-based quantum computing platform that bridges the gap between different quantum computing frameworks. It provides a unified interface for simulating quantum circuits, converting between different quantum programming languages, and visualizing quantum states and operations.
|
|
40
|
+
|
|
41
|
+
### Key Features
|
|
42
|
+
|
|
43
|
+
- **Multi-Framework Support**: Convert circuits between Cirq, Qiskit, and PennyLane
|
|
44
|
+
- **Hybrid CPU–QPU Model**: QCanvas orchestrates; QSim executes (simulator-first, pluggable QPU later)
|
|
45
|
+
- **Real-Time Simulation**: Execute quantum circuits with statevector, density matrix, or stabilizer backends
|
|
46
|
+
- **OpenQASM 3.0 (Rosetta Stone)**: Universal intermediate representation across frameworks
|
|
47
|
+
- **Smart Conversion Engine**: AST-based parsing, intelligent gate mapping, built-in validation, instant analytics
|
|
48
|
+
- **Interactive Visualization**: Circuit rendering, histograms, and results analysis
|
|
49
|
+
- **Shared TypeScript Types**: Type safety across frontend and backend services
|
|
50
|
+
- **Extensible Architecture**: Plugin-based system for adding new frameworks
|
|
51
|
+
|
|
52
|
+
## 🏗️ Architecture
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
QCanvas/
|
|
56
|
+
├── frontend/ # Next.js-based web interface
|
|
57
|
+
│ ├── app/ # App Router pages and layouts
|
|
58
|
+
│ ├── components/ # Reusable UI components
|
|
59
|
+
│ ├── lib/ # Utility functions and state management
|
|
60
|
+
│ └── public/ # Static assets (images, icons)
|
|
61
|
+
│
|
|
62
|
+
├── backend/ # FastAPI REST API and WebSocket server
|
|
63
|
+
│ ├── app/ # Main application logic
|
|
64
|
+
│ │ ├── api/ # API routes and endpoints
|
|
65
|
+
│ │ ├── models/ # Database models and Pydantic schemas
|
|
66
|
+
│ │ └── services/ # Business logic services
|
|
67
|
+
│ └── alembic/ # Database migration scripts
|
|
68
|
+
│
|
|
69
|
+
├── quantum_converters/ # Framework conversion modules
|
|
70
|
+
│ ├── qiskit/ # Qiskit to OpenQASM converters
|
|
71
|
+
│ ├── cirq/ # Cirq to OpenQASM converters
|
|
72
|
+
│ └── pennylane/ # PennyLane to OpenQASM converters
|
|
73
|
+
│
|
|
74
|
+
├── quantum_simulator/ # Quantum simulation engine
|
|
75
|
+
│ ├── backends/ # Simulation backends (statevector, density matrix)
|
|
76
|
+
│ └── core/ # Core simulation logic
|
|
77
|
+
│
|
|
78
|
+
├── examples/ # Sample circuits and tutorials
|
|
79
|
+
│
|
|
80
|
+
├── docs/ # Project documentation
|
|
81
|
+
│
|
|
82
|
+
├── tests/ # Comprehensive test suite
|
|
83
|
+
│
|
|
84
|
+
└── scripts/ # Helper scripts for setup and maintenance
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Core Components
|
|
88
|
+
|
|
89
|
+
1. **QCanvas (Compilation/Orchestration)**: AST parsing, QASM generation, validation, hybrid scheduling
|
|
90
|
+
2. **QSim (Execution)**: High-performance simulation backends and result aggregation
|
|
91
|
+
3. **Next.js Frontend**: UI components, routing, and simple operations
|
|
92
|
+
4. **FastAPI Backend**: API, WebSockets, and heavy computations
|
|
93
|
+
5. **Shared TypeScript Types**: Type safety across frontend and backend
|
|
94
|
+
|
|
95
|
+
## 🛠️ Installation
|
|
96
|
+
|
|
97
|
+
### Prerequisites
|
|
98
|
+
|
|
99
|
+
- Python 3.9+
|
|
100
|
+
- Node.js 18+ (for Next.js)
|
|
101
|
+
- Docker Engine with **Compose V2** (`docker compose` CLI)
|
|
102
|
+
- Git
|
|
103
|
+
|
|
104
|
+
## Docker and Docker Compose
|
|
105
|
+
|
|
106
|
+
The repo includes [`docker-compose.yml`](docker-compose.yml) for **PostgreSQL**, **Redis**, **QCanvas FastAPI backend**, **Cirq-RAG-Code-Assistant** (Cirq AI / Bedrock), and optionally **SonarQube** (metrics profile).
|
|
107
|
+
|
|
108
|
+
The **Next.js frontend is not in Compose**; run it locally with `npm run dev` in `frontend/` (see below).
|
|
109
|
+
|
|
110
|
+
### Service overview
|
|
111
|
+
|
|
112
|
+
| Service | Container name | Host port | Notes |
|
|
113
|
+
|--------|----------------|-----------|--------|
|
|
114
|
+
| PostgreSQL | `qcanvas_postgres` | **5433** → 5432 | Database for QCanvas |
|
|
115
|
+
| Redis | `qcanvas_redis` | **6379** | Caching |
|
|
116
|
+
| Cirq AI | `qcanvas_cirq_agent` | **8001** → 8000 | Bedrock/RAG; internal URL `http://cirq_agent:8000` |
|
|
117
|
+
| QCanvas API | `qcanvas_backend` | **8000** | Sets `CIRQ_AGENT_URL=http://cirq_agent:8000` |
|
|
118
|
+
| SonarQube | `qcanvas_sonarqube` | **9000** | Only with `--profile metrics` |
|
|
119
|
+
|
|
120
|
+
Each container can use port **8000 internally** without conflict; they are isolated. Only **host** ports must be unique (**8000** vs **8001**).
|
|
121
|
+
|
|
122
|
+
### Environment file (project root)
|
|
123
|
+
|
|
124
|
+
Create a **`.env`** in the repository root (Compose loads it automatically). Minimum for the database:
|
|
125
|
+
|
|
126
|
+
```env
|
|
127
|
+
POSTGRES_USER=postgres
|
|
128
|
+
POSTGRES_PASSWORD=postgres
|
|
129
|
+
POSTGRES_DB=qcanvas_db
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
For **Cirq AI** inside Docker, add the same variables you use for Bedrock (see [`Cirq-RAG-Code-Assistant/.env.example`](Cirq-RAG-Code-Assistant/.env.example)):
|
|
133
|
+
|
|
134
|
+
```env
|
|
135
|
+
AWS_ACCESS_KEY_ID=...
|
|
136
|
+
AWS_SECRET_ACCESS_KEY=...
|
|
137
|
+
AWS_DEFAULT_REGION=us-east-1
|
|
138
|
+
BEDROCK_INFERENCE_PROFILE_ARN_DESIGNER=...
|
|
139
|
+
BEDROCK_INFERENCE_PROFILE_ARN_OPTIMIZER=...
|
|
140
|
+
BEDROCK_INFERENCE_PROFILE_ARN_VALIDATOR=...
|
|
141
|
+
BEDROCK_INFERENCE_PROFILE_ARN_EDUCATIONAL=...
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Put AWS keys in **`Cirq-RAG-Code-Assistant/.env`** when using Docker: that file is bind-mounted into the `cirq_agent` container as `/app/.env`. The Compose file does **not** set `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` to empty defaults anymore—empty values used to block `python-dotenv` from applying the mounted file.
|
|
145
|
+
|
|
146
|
+
### Commands (run from the repo root)
|
|
147
|
+
|
|
148
|
+
**Build images and start the default stack** (postgres, redis, cirq_agent, backend):
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
docker compose up -d --build
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Start or restart without rebuilding images:**
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
docker compose up -d
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Include SonarQube** (metrics profile):
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
docker compose --profile metrics up -d --build
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Rebuild only specific services** (e.g. after changing a `Dockerfile`):
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
docker compose build cirq_agent backend
|
|
170
|
+
docker compose up -d
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**Force a clean rebuild** (slower; use when dependencies change):
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
docker compose build --no-cache cirq_agent backend
|
|
177
|
+
docker compose up -d
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**View running services:**
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
docker compose ps
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Follow logs** (all services or one):
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
docker compose logs -f
|
|
190
|
+
docker compose logs -f backend
|
|
191
|
+
docker compose logs -f cirq_agent
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Stop containers** (keeps named volumes such as database data):
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
docker compose stop
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Stop and remove containers** (keeps volumes unless you add `-v`):
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
docker compose down
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Stop and remove containers and volumes** (⚠️ deletes Postgres/Redis/SonarQube data):
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
docker compose down -v
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Run a one-off command in the backend container** (example: open a shell):
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
docker compose exec backend bash
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### After Docker is up
|
|
219
|
+
|
|
220
|
+
- **API:** http://localhost:8000 — docs: http://localhost:8000/docs
|
|
221
|
+
- **Health:** http://localhost:8000/api/health
|
|
222
|
+
- **Cirq AI (direct):** http://localhost:8001/docs
|
|
223
|
+
|
|
224
|
+
Run **database migrations** against the Dockerized Postgres (from host, with venv and `PYTHONPATH` set, or `exec` into `backend`):
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# Example from host (Windows PowerShell); adjust path and venv
|
|
228
|
+
$env:PYTHONPATH = "D:\path\to\QCanvas\backend"
|
|
229
|
+
$env:DATABASE_URL = "postgresql://postgres:postgres@127.0.0.1:5433/qcanvas_db"
|
|
230
|
+
python -m alembic -c backend/alembic.ini upgrade head
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Then start the **frontend**:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
cd frontend
|
|
237
|
+
npm install
|
|
238
|
+
npm run dev
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Open http://localhost:3000
|
|
242
|
+
|
|
243
|
+
### Windows Setup (Recommended for Development)
|
|
244
|
+
|
|
245
|
+
#### 1. Clone Repository
|
|
246
|
+
```bash
|
|
247
|
+
git clone https://github.com/Umer-Farooq-CS/QCanvas.git
|
|
248
|
+
cd QCanvas
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
#### 2. Create Virtual Environment
|
|
252
|
+
```bash
|
|
253
|
+
python -m venv qcanvas_env
|
|
254
|
+
.\qcanvas_env\Scripts\activate
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
#### 3. Install Dependencies
|
|
258
|
+
```bash
|
|
259
|
+
pip install -r requirements.txt
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
#### 4. Start Docker Services
|
|
263
|
+
|
|
264
|
+
Use **Docker Compose** as described in [Docker and Docker Compose](#docker-and-docker-compose) (e.g. `docker compose up -d --build`). For SonarQube, add `--profile metrics`.
|
|
265
|
+
|
|
266
|
+
#### 5. Set Up Database Schema
|
|
267
|
+
```powershell
|
|
268
|
+
# From repo root; set path to your clone
|
|
269
|
+
$env:PYTHONPATH = "D:\path\to\QCanvas\backend"
|
|
270
|
+
# If Postgres is the Docker Compose service (mapped to host 5433):
|
|
271
|
+
$env:DATABASE_URL = "postgresql://postgres:postgres@127.0.0.1:5433/qcanvas_db"
|
|
272
|
+
|
|
273
|
+
python -m alembic -c backend/alembic.ini upgrade head
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
#### 6. Create Admin User (Optional)
|
|
277
|
+
```bash
|
|
278
|
+
python backend/create_user.py
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Follow prompts to create an admin account.
|
|
282
|
+
|
|
283
|
+
#### 7. Create Demo Account (Optional)
|
|
284
|
+
```bash
|
|
285
|
+
python backend/create_demo_account.py
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
This creates a demo account (`demo@qcanvas.dev` / `demo123`) for testing. Demo data is cleared on logout.
|
|
289
|
+
|
|
290
|
+
#### 8. Verify Database
|
|
291
|
+
```bash
|
|
292
|
+
python backend/verify_database.py
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
📚 **For detailed information about database architecture, security (CIA principles), and troubleshooting, see [docs/db_setup.md](docs/db_setup.md)**
|
|
296
|
+
|
|
297
|
+
#### 9. Start Backend Server
|
|
298
|
+
|
|
299
|
+
If you already use **Docker Compose** for the API, **skip this step** (backend is on http://localhost:8000).
|
|
300
|
+
|
|
301
|
+
```powershell
|
|
302
|
+
$env:PYTHONPATH="d:\path\to\QCanvas\backend"
|
|
303
|
+
python backend/start.py
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Backend will run on `http://localhost:8000`
|
|
307
|
+
- API Docs: `http://localhost:8000/docs`
|
|
308
|
+
- Health Check: `http://localhost:8000/api/health`
|
|
309
|
+
|
|
310
|
+
**Cirq AI assistant (optional):** The IDE can proxy to [Cirq-RAG-Code-Assistant](Cirq-RAG-Code-Assistant/QCANVAS_INTEGRATION_GUIDE.md). Run the Cirq service on **port 8001** (QCanvas already uses **8000**). Set `CIRQ_AGENT_URL` in the QCanvas backend environment (defaults to `http://127.0.0.1:8001`). The frontend calls `{QCanvas API}/api/cirq-agent/api/v1/...`. For local UI-only testing without the QCanvas API proxy, set `NEXT_PUBLIC_CIRQ_USE_NEXT_REWRITE=true` and optionally `CIRQ_REWRITE_TARGET` (Next.js rewrites `/cirq-api/*` to the Cirq server).
|
|
311
|
+
|
|
312
|
+
#### 10. Start Frontend (New Terminal)
|
|
313
|
+
```bash
|
|
314
|
+
cd frontend
|
|
315
|
+
npm install
|
|
316
|
+
npm run dev
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Frontend will run on `http://localhost:3000`
|
|
320
|
+
|
|
321
|
+
### Linux Quick Setup (Recommended)
|
|
322
|
+
|
|
323
|
+
For a fresh Linux machine, you can install all requirements and start QCanvas using the provided scripts:
|
|
324
|
+
|
|
325
|
+
1. **Clone the repository**
|
|
326
|
+
```bash
|
|
327
|
+
git clone https://github.com/Umer-Farooq-CS/QCanvas.git
|
|
328
|
+
cd QCanvas
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
2. **Run first‑time setup**
|
|
332
|
+
```bash
|
|
333
|
+
# Installs system packages, creates venv, installs backend + frontend deps
|
|
334
|
+
bash setup.sh
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
3. **Configure environment**
|
|
338
|
+
```bash
|
|
339
|
+
cp environment.env.example environment.env
|
|
340
|
+
# Edit environment.env with your configuration
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
4. **Start/stop QCanvas in the background**
|
|
344
|
+
```bash
|
|
345
|
+
# Start Next.js frontend and FastAPI backend in background
|
|
346
|
+
./run.sh start
|
|
347
|
+
|
|
348
|
+
# Stop all QCanvas services (kills node/next/uvicorn and clears PID files)
|
|
349
|
+
./run.sh stop
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
- Background logs are written to `logs/frontend.log` and `logs/backend.log`.
|
|
353
|
+
- PID files `frontend.pid` and `backend.pid` are used to avoid double‑starting services.
|
|
354
|
+
|
|
355
|
+
## 📡 API Usage
|
|
356
|
+
|
|
357
|
+
### Conversion API
|
|
358
|
+
|
|
359
|
+
**Endpoint:** `POST /api/converter/convert`
|
|
360
|
+
|
|
361
|
+
Convert quantum circuit code from a specific framework to OpenQASM 3.0.
|
|
362
|
+
|
|
363
|
+
```json
|
|
364
|
+
{
|
|
365
|
+
"source_code": "from qiskit import QuantumCircuit\nqc = QuantumCircuit(2)\nqc.h(0)\nqc.cx(0, 1)",
|
|
366
|
+
"source_framework": "qiskit",
|
|
367
|
+
"conversion_type": "classic"
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**Response:**
|
|
372
|
+
```json
|
|
373
|
+
{
|
|
374
|
+
"success": true,
|
|
375
|
+
"qasm_code": "OPENQASM 3.0;...",
|
|
376
|
+
"framework": "qiskit",
|
|
377
|
+
"conversion_stats": { ... }
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Simulation API (QSim)
|
|
382
|
+
|
|
383
|
+
**Endpoint:** `POST /api/simulator/execute`
|
|
384
|
+
|
|
385
|
+
Execute OpenQASM 3.0 code using the QSim engine with various backends.
|
|
386
|
+
|
|
387
|
+
```json
|
|
388
|
+
{
|
|
389
|
+
"qasm_code": "OPENQASM 3.0; include \"stdgates.inc\"; qubit[2] q; bit[2] c; h q[0]; cx q[0], q[1]; c = measure q;",
|
|
390
|
+
"backend": "cirq", // Options: "cirq", "qiskit", "pennylane"
|
|
391
|
+
"shots": 1024
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**Response:**
|
|
396
|
+
```json
|
|
397
|
+
{
|
|
398
|
+
"success": true,
|
|
399
|
+
"counts": { "00": 512, "11": 512 },
|
|
400
|
+
"metadata": { ... }
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
## 🔧 Configuration
|
|
405
|
+
|
|
406
|
+
### Environment Variables
|
|
407
|
+
|
|
408
|
+
- `DATABASE_URL`: PostgreSQL connection string
|
|
409
|
+
- `REDIS_URL`: Redis connection string for caching
|
|
410
|
+
- `SECRET_KEY`: Application secret key
|
|
411
|
+
- `DEBUG`: Enable debug mode (True/False)
|
|
412
|
+
- `ALLOWED_HOSTS`: Comma-separated list of allowed hosts
|
|
413
|
+
- `NEXT_PUBLIC_API_URL` / `NEXT_PUBLIC_API_BASE`: Frontend API endpoint for Next.js
|
|
414
|
+
- `CIRQ_AGENT_URL`: QCanvas backend proxy target for Cirq AI (Compose sets `http://cirq_agent:8000` inside Docker; locally often `http://127.0.0.1:8001`)
|
|
415
|
+
|
|
416
|
+
## 🧪 Testing
|
|
417
|
+
|
|
418
|
+
### Run Tests
|
|
419
|
+
|
|
420
|
+
```bash
|
|
421
|
+
# Run all tests
|
|
422
|
+
pytest
|
|
423
|
+
|
|
424
|
+
# Run specific test categories
|
|
425
|
+
pytest tests/unit/
|
|
426
|
+
pytest tests/integration/
|
|
427
|
+
pytest tests/e2e/
|
|
428
|
+
|
|
429
|
+
# Run frontend tests
|
|
430
|
+
cd frontend
|
|
431
|
+
npm test
|
|
432
|
+
|
|
433
|
+
# Run with coverage
|
|
434
|
+
pytest --cov=quantum_converters --cov=quantum_simulator --cov=backend
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
## 📚 Documentation
|
|
438
|
+
|
|
439
|
+
- [API Documentation](docs/api/)
|
|
440
|
+
- [User Guide](docs/user-guide/)
|
|
441
|
+
- [Developer Guide](docs/developer/)
|
|
442
|
+
- [Deployment Guide](docs/deployment/)
|
|
443
|
+
|
|
444
|
+
## 🤝 Contributing
|
|
445
|
+
|
|
446
|
+
We welcome contributions! Please see our [Contributing Guide](docs/developer/contributing.md) for details.
|
|
447
|
+
|
|
448
|
+
## 📄 License
|
|
449
|
+
|
|
450
|
+
This project is licensed under the **Open Quantum Workbench Proprietary License**. See the [LICENSE](LICENSE) file for details.
|
|
451
|
+
|
|
452
|
+
## 👥 Teams
|
|
453
|
+
|
|
454
|
+
### QCanvas Team
|
|
455
|
+
- Umer Farooq
|
|
456
|
+
- Hussan Waseem Syed
|
|
457
|
+
- Muhammad Irtaza Khan
|
|
458
|
+
|
|
459
|
+
### QSim Team
|
|
460
|
+
- Aneeq Ahmed Malik
|
|
461
|
+
- Abeer Noor
|
|
462
|
+
- Abdullah Mehmood
|
|
463
|
+
|
|
464
|
+
### Supervisors
|
|
465
|
+
- Dr. Imran Ashraf (Project Supervisor)
|
|
466
|
+
- Dr. Muhammad Nouman Noor (Co-Supervisor)
|
|
467
|
+
|
|
468
|
+
**Built under Open Quantum Workbench: A FAST University Initiative**
|