Metadata-Version: 2.4
Name: quapp-qiskit
Version: 1.0.13.dev23
Summary: Quapp common library supporting Quapp Platform for Quantum Computing
Author-email: "CITYNOW Co. Ltd. " <corp@citynow.vn>
License: The MIT License (MIT)
        Copyright © CITYNOW Co. Ltd. All rights reserved.
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project-URL: Homepage, https://quapp.cloud/
Keywords: quapp,quapp-qiskit,quantum
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: <3.11,>=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: oqc-qcaas-client==3.4.0
Requires-Dist: quapp-common==0.0.14.dev6
Requires-Dist: qiskit-aer==0.16.1
Requires-Dist: qiskit-ibm-runtime==0.35.0
Requires-Dist: qiskit==1.4.2
Requires-Dist: qudora-sdk==1.1.3
Provides-Extra: dev
Requires-Dist: black; extra == "dev"
Requires-Dist: bumpver; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: pip-tools; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Dynamic: license-file

# quapp-qiskit

Quapp qiskit library supporting Quapp Platform for Quantum Computing.

## Overview

`quapp-qiskit` provides the providers, devices, factories, and tasks to
run quantum circuits via Qiskit within the Quapp Platform. It integrates with
IBM Quantum, IBM Cloud, OQC Cloud, and Qiskit simulators (Aer), with a strong
focus on clean, consistent logging, robust error handling, and standardized
header management using project/workspace context to improve maintainability and
clarity.

## Features

- Provider and device factories for IBM Quantum, IBM Cloud, OQC Cloud, and
  Qiskit Aer simulators.
- Circuit export and transpilation pipeline with asynchronous job submission.
- Consistent, context-rich logging across provider/device creation,
  transpilation, job submission, and job fetching.
- Standardized header handling using project and workspace headers for backend
  invocations.
- Improved error handling and diagnostics in critical execution paths.

## Installation

Install via pip:

```bash
pip install quapp-qiskit
```

## Recently Changes Highlights

### 1.0.13.dev21

- **fix(log)**: 6 provider gọi `job_logger('IbmQuantumProvider')` — tham số đầu
  của `job_logger()` là **job_id**, không phải tên component. Chúng đang đặt một
  job_id giả, và vì `_inject_job_context` của `quapp-common` chỉ điền key nào
  đang `None`, giá trị giả **thắng** job_id thật. Hệ quả: Grafana filter theo
  `jobId` mất toàn bộ dòng log của provider, và index có 6 giá trị `jobId` rác.

  Đã đổi sang `logger.bind(context='IbmQuantumProvider')` — `context` là field
  dành cho tên component, và text sink đã hiển thị nó trong prefix.

  Đo trước/sau với một job thật:

  | | `jobId` trên dòng log của provider |
  |---|---|
  | trước | `IbmQuantumProvider` |
  | sau | `job_REAL_123` |

- **fix(log)**: `QiskitHandlerFactory.create_handler()` đọc job id bằng
  `getattr(event.json(), 'jobId', None)`. `event.json()` trả về **dict** nên
  `getattr` luôn cho `None` — job_id không bao giờ được bind ở đây. Nay đọc bằng
  `request_data.get('jobId')`.

- **test**: Thêm `tests/test_log_context_binding.py` — khoá hồi quy ở hai mức:
  quét AST bắt `job_logger()` nhận chuỗi literal, và test hành vi khi chạy thật
  để đảm bảo dòng log của provider mang job_id của job đang chạy.

### 1.0.13.dev20

- **feat(error)**: Thêm `quapp_qiskit/error_rules.py` — 22 rule phân loại lỗi đặc
  thù Qiskit, đăng ký vào classifier của `quapp-common` khi package được import.
  Nhờ đó lỗi Qiskit có `category` / `code` / hướng xử lý cụ thể trong Job Log thay
  vì rơi về fallback chung theo phase (`COMPILATION_FAILED`,
  `PROVIDER_INVOCATION_FAILED`):

  | Nhóm | Mã tiêu biểu |
  |---|---|
  | Authentication | `IBMQ_TOKEN_INVALID`, `IBMQ_ACCOUNT_INVALID`, `RIKEN_TOKEN_MISSING`, `IBMQ_LICENSE_NOT_ACCEPTED` |
  | Device | `QISKIT_BACKEND_NOT_FOUND`, `QISKIT_DEVICE_UNSUPPORTED`, `IBMQ_JOB_FAILED`, `IBMQ_JOB_NOT_FOUND` |
  | Input của user | `QISKIT_CIRCUIT_TOO_WIDE`, `QISKIT_QASM_INVALID`, `IBMQ_INPUT_INVALID`, `IBMQ_BACKEND_OPTION_INVALID` |
  | Code của user | `QISKIT_INVALID_CIRCUIT_TYPE`, `QISKIT_CIRCUIT_INVALID` |
  | SDK / device | `QISKIT_TRANSPILE_FAILED`, `QISKIT_AER_ERROR`, `QISKIT_BACKEND_CONFIG_ERROR`, `QISKIT_SDK_ERROR` |
  | Retry được | `IBMQ_JOB_TIMEOUT` (120s), `IBMQ_API_UNAVAILABLE` (120s), `IBMQ_BACKEND_ERROR` (180s) |

  Rule match theo **tên class dạng string** và `error_rules.py` **không import**
  `qiskit`, `qiskit_ibm_runtime`, `qiskit_aer` hay `qcaas_client`. Đây là ràng
  buộc cứng: image C/C++ native cài `quapp-qiskit --no-deps` và block các SDK đó,
  nên `import quapp_qiskit` không được đòi vendor SDK — xem
  `tests/test_lazy_provider_imports.py`.

  Vài điểm phân loại đáng chú ý:
  - `CircuitTooWideForTarget` → `INVALID_INPUT` chứ không phải `SDK_RUNTIME`:
    circuit nhiều qubit hơn device là thứ user sửa được.
  - `IBMBackendValueError` tách theo message — `not found` là lỗi device, còn lại
    là sai option.
  - Lỗi HTTP của RIKEN (`requests` + `raise_for_status()`, bọc trong
    `RuntimeError`) vẫn ra `PROVIDER_AUTH_FAILED` nhờ classifier đi hết cause
    chain, nên không cần rule riêng.

- **test**: Thêm `tests/test_error_rules.py` — 26 case, dựng exception thật từ
  `qiskit==1.4.2` / `qiskit-ibm-runtime==0.35.0` để test vỡ khi upstream đổi tên
  exception. Có một case quét AST của `error_rules.py` để chặn việc ai đó thêm
  import vendor SDK vào đó.

- **build**: Bump version lên `1.0.13.dev20`.

- refactor: Remove unused timing logs and import from InvocationHandler.
- refactor: Replace set/map usage with set comprehension and enhance logging for
  unsupported devices.
- refactor: Add support for project and workspace headers in backend invocation.
- refactor: Update logging to handle missing jobId gracefully.
- refactor: Improve logging across device and provider classes, enhance error
  handling in key methods.
- chore: Bump a library version and update quapp-common dependency to the latest
  development release.

For detailed usage and API references, please refer to the in-code documentation
or contact the maintainers.
