Metadata-Version: 2.4
Name: qbraid-core
Version: 0.6.61
Summary: Python library with core abstractions for software development in the qBraid ecosystem.
Author: qBraid Development Team
Author-email: contact@qbraid.com
License: Proprietary
Project-URL: Homepage, https://sdk.qbraid.com/qbraid-core/
Project-URL: Documentation, https://docs.qbraid.com/v2/core
Project-URL: Bug Tracker, https://github.com/qBraid/community/issues
Project-URL: Discord, https://discord.gg/KugF6Cnncm
Keywords: qbraid,quantum,cloud
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Typing :: Typed
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Requires-Dist: urllib3>=2
Requires-Dist: packaging>=22
Requires-Dist: psutil
Requires-Dist: tornado>=6.2
Requires-Dist: pydantic>=2.5
Requires-Dist: tomli; python_version < "3.11"
Provides-Extra: compute
Requires-Dist: websockets>=13.0; extra == "compute"
Provides-Extra: environments
Requires-Dist: jupyter_client>=7.1.0; extra == "environments"
Requires-Dist: ipython; extra == "environments"
Requires-Dist: ipykernel; extra == "environments"
Requires-Dist: pyyaml>6.0.0; extra == "environments"
Requires-Dist: zstandard; extra == "environments"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: pytest-asyncio; extra == "test"
Requires-Dist: pytest-timeout; extra == "test"
Requires-Dist: tomli; python_version < "3.11" and extra == "test"
Provides-Extra: docs
Requires-Dist: sphinx<8.3.0,>=7.2.6; extra == "docs"
Requires-Dist: sphinx-rtd-theme<3.1,>=1.3; extra == "docs"
Requires-Dist: sphinx-autodoc-typehints<3.2,>=1.24; extra == "docs"
Requires-Dist: docutils<0.23; extra == "docs"
Requires-Dist: sphinx-copybutton; extra == "docs"
Requires-Dist: sphinx-pydantic; extra == "docs"
Dynamic: license-file

# qbraid-core

[![Documentation](https://img.shields.io/badge/Documentation-DF0982)](https://qbraid.github.io/qbraid-core/)
[![codecov](https://codecov.io/gh/qBraid/qbraid-core/graph/badge.svg?token=vnZxySTsW2)](https://codecov.io/gh/qBraid/qbraid-core)
[![PyPI version](https://img.shields.io/pypi/v/qbraid-core.svg?color=blue)](https://pypi.org/project/qbraid-core/)
[![Python verions](https://img.shields.io/pypi/pyversions/qbraid-core.svg?color=blue)](https://pypi.org/project/qbraid-core/)
[![GitHub](https://img.shields.io/badge/issue_tracking-github-blue?logo=github)](https://github.com/qBraid/community/issues)

Python library providing core abstractions for software development within the qBraid ecosystem, and a low-level interface to a growing array of qBraid cloud services. The qbraid-core package forms the foundational base for the [qBraid CLI](https://pypi.org/project/qbraid-cli/), the [qBraid SDK](https://pypi.org/project/qbraid/), and [qBraid Lab](https://docs.qbraid.com/v2/lab/user-guide/overview).

You can find the latest, most up to date, documentation [here](https://qbraid.github.io/qbraid-core/), including a list of services that are supported.

*See also*: [`qbraid-core-js`](https://qbraid.github.io/qbraid-core-js/)

## Getting Started

You can install qbraid-core from PyPI with:

```bash
python -m pip install qbraid-core
```

### Local configuration

After installing qbraid-core, you must configure your account credentials:

1. Create a qBraid account or log in to your existing account by visiting
   [account.qbraid.com](https://account.qbraid.com/)
2. Navigate to **Account** > **API Keys** in the left-sidebar, and then click "Create API Key". See [API Key docs](https://docs.qbraid.com/v2/home/account#api-keys).
3. Save your API key from step 2 in local [configuration file](https://docs.qbraid.com/v2/cli/user-guide/config-files). On Linux and macOS, this file is located at `~/.qbraid/qbraidrc`, where `~` corresponds to your home (`$HOME`) directory. On Windows, the equivalent default location is `%USERPROFILE%\.qbraid\qbraidrc`.

```ini
[default]
api-key = YOUR_KEY
url = https://api-v2.qbraid.com/api/v1
```

Or generate your `~/.qbraid/qbraidrc` file via the qbraid-core Python interface:

```python
>>> from qbraid_core import QbraidSessionV1
>>> session = QbraidSessionV1(api_key='API_KEY')
>>> session.save_config()
>>> session.get_available_services()
['agents', 'compute', 'environments', 'projects', 'runtime', 'skills', 'storage']
```

Other credential configuration methods are available using the [qBraid-CLI](https://docs.qbraid.com/v2/cli/api-reference/qbraid_configure).

### Verify setup

After configuring your qBraid credentials, verify your setup by running the following from a Python interpreter:

```python
>>> import qbraid_core
>>> quantum_runtime_client = qbraid_core.client('runtime')
>>> devices = quantum_runtime_client.list_devices()
>>> for device in devices:
...     print(device.qrn, device.status)
```

## Contributing

Tests run on the machine you develop on, not on GitHub. Before asking for
review, run the full local checks:

```bash
tox -e format-check        # isort, black, mypy, ruff, headers (tox -e linters fixes most)
tox -e unit-tests          # pytest (adds jupyter-server for the Jupyter auth tests)
tox -e docs                # when you touch docstrings or docs/
```

Without tox: `pip install -e '.[test,environments,compute]' 'jupyter-server>=2,<3'
'jupyter-server-terminals>=0.5,<1' && pytest`.
With pytest-xdist, `pytest -n auto` sizes itself from the cgroup CPU/memory limits
(at most 6 workers, ~1 GiB each; `tests/_workers.py`); `-n N` overrides it.

When you touch `qbraid_core/services/agents/`, also run the agent contract
suite, in the offline sandbox that
[tests/agents_contract/README.md](tests/agents_contract/README.md) describes
(never from a shell inside a live agent session).

GitHub runs only Secret Scan and SAST on a PR. The heavy suite runs at
publish: Publish and Pre-release run the full test grid (Windows and every
supported Python), all seven agent contract jobs, the format check and the docs
build before anything is uploaded, and there is no CI on push to `main`.
Windows runs first, alone and fail-fast; Linux and the contracts start only
once it passes. Before a release, check the candidate on Windows alone: CI →
Run workflow with `full` and `platform: windows` (four jobs). If a
release fails there (most likely on Windows), fix everything in one PR, and
once it merges start the same workflow (Publish or Pre-release) again with Run
workflow on the updated `main` (Re-run jobs reuses the old commit).

To run CI on a PR into `main` anyway, add the `ci` label. It is one-shot: it
runs the suite once on that commit (Linux only, the newest pin of each agent).
The label comes off as the run starts, so later pushes run nothing; add it
again to re-run (adding it during a run replaces the run in flight). On a
stacked PR (into another branch) or a PR with merge conflicts, GitHub starts no
run and the label stays on: remove it, fix the base or the conflict, and add it
again. A Dependabot PR (or any PR from a `dependabot/` branch) runs without
secrets; still read the bump before you label it, since its new dependency runs
in the job. A fork's PR gets a read-only token, so its label stays on: remove
`ci` by hand. Whether a fork's run sees secrets is decided by the repository's
fork-PR settings, not by the workflow, which the fork can edit.

CI, Agent contract tests, Format, Docs, SAST and Secret Scan can also be
started from the Actions tab (Run workflow); CI and Agent contract tests take
`full` for the whole grid. The label workflow and the release tagging start
only from their events.

Windows runs only at publish, or on a manual CI run with `full`, so keep code
portable: build paths with
`pathlib` or `os.path`, never hard-code `/`, don't rely on file modes, symlinks
or case-sensitive names, and open text files with an explicit `encoding`.

## Community

- For feature requests and bug reports: [Submit an issue](https://github.com/qBraid/community/issues)
- For discussions and/or specific questions about qBraid services, [join our discord community](https://discord.gg/KugF6Cnncm)
- For questions that are more suited for a forum, post to [Stack Overflow](https://stackoverflow.com/) with the [`qbraid`](https://stackoverflow.com/questions/tagged/qbraid) tag.
