qbraid-cli 0.9.6__tar.gz → 0.9.7__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.
Potentially problematic release.
This version of qbraid-cli might be problematic. Click here for more details.
- qbraid_cli-0.9.7/.github/dependabot.yml +15 -0
- qbraid_cli-0.9.7/.github/workflows/ci-pr-target.yml +81 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/.github/workflows/main.yml +5 -4
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/PKG-INFO +20 -5
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/README.md +19 -4
- qbraid_cli-0.9.7/docs/requirements.txt +7 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/pyproject.toml +1 -1
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/_version.py +2 -2
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/admin/app.py +4 -8
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/admin/headers.py +46 -29
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/admin/validation.py +1 -8
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/configure/app.py +1 -1
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli.egg-info/PKG-INFO +20 -5
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli.egg-info/SOURCES.txt +2 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/admin/test_headers.py +67 -50
- qbraid_cli-0.9.6/docs/requirements.txt +0 -7
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/.env.example +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/.github/workflows/bump-version.yml +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/.github/workflows/docs-pr.yml +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/.github/workflows/docs.yml +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/.github/workflows/format.yml +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/.github/workflows/pre-release.yml +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/.github/workflows/publish.yml +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/.github/workflows/tag-on-merge.yml +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/.gitignore +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/.readthedocs.yml +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/CONTRIBUTING.md +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/LICENSE +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/MANIFEST.IN +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/Makefile +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/docs/Makefile +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/docs/_static/favicon.ico +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/docs/_static/logo.png +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/docs/_static/style/custom.css +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/docs/_static/style/s4defs-roles.css +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/docs/conf.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/docs/index.rst +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/docs/make.bat +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/account/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/account/app.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/admin/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/chat/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/chat/app.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/configure/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/configure/actions.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/devices/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/devices/app.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/devices/validation.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/envs/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/envs/activate.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/envs/app.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/envs/create.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/envs/data_handling.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/exceptions.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/files/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/files/app.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/handlers.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/jobs/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/jobs/app.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/jobs/toggle_braket.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/jobs/validation.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/kernels/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/kernels/app.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/main.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/pip/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/pip/app.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/pip/hooks.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli/py.typed +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli.egg-info/dependency_links.txt +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli.egg-info/entry_points.txt +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli.egg-info/requires.txt +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/qbraid_cli.egg-info/top_level.txt +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/setup.cfg +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/account/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/account/test_account_credits.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/configure/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/configure/test_configure_commands.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/configure/test_configure_prompt_for_config.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/configure/test_configure_set.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/configure/test_configure_validate_input.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/conftest.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/devices/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/devices/test_devices_list.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/devices/test_devices_validations.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/envs/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/envs/test_envs_activate.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/envs/test_envs_activate_find_shell_rc.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/envs/test_envs_activate_print_command.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/envs/test_envs_activate_pyenv.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/envs/test_envs_create_from_yaml.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/envs/test_envs_list.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/envs/test_envs_remove.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/files/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/files/test_files_commands.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/jobs/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/jobs/test_jobs_disable.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/jobs/test_jobs_enable.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/jobs/test_jobs_list.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/jobs/test_jobs_state.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/jobs/test_jobs_toggle_braket_confirm.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/jobs/test_jobs_toggle_braket_disable.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/jobs/test_jobs_toggle_braket_enable.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/jobs/test_jobs_toggle_braket_get_data.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/jobs/test_jobs_validate_get_state.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/jobs/test_jobs_validate_handle_state.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/jobs/test_jobs_validate_library.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/kernels/__init__.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/kernels/test_kernels_list.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/resources/envs/correct.yaml +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/resources/envs/icon.png +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tests/resources/envs/incorrect.yaml +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tools/bump_version.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tools/create_dev_build.sh +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tools/install_wheel_extras.sh +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tools/split_md.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tools/split_rst.py +0 -0
- {qbraid_cli-0.9.6 → qbraid_cli-0.9.7}/tools/stamp_pre_release.py +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "pip" # See documentation for possible values
|
|
9
|
+
directory: "/" # Location of package manifests
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "weekly"
|
|
12
|
+
- package-ecosystem: "github-actions"
|
|
13
|
+
directory: "/"
|
|
14
|
+
schedule:
|
|
15
|
+
interval: "weekly"
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
name: CI (PR Target)
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request_target:
|
|
5
|
+
branches: ['main']
|
|
6
|
+
types: [opened, reopened, ready_for_review, synchronize]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
if: github.event.pull_request.draft == false && github.event.pull_request.user.login == 'dependabot[bot]'
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ['3.11']
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
19
|
+
uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: ${{ matrix.python-version }}
|
|
22
|
+
cache: pip
|
|
23
|
+
- name: Upgrade pip and install build tools
|
|
24
|
+
run: |
|
|
25
|
+
pip install --upgrade pip
|
|
26
|
+
pip install setuptools wheel build
|
|
27
|
+
- name: Build the package
|
|
28
|
+
run: |
|
|
29
|
+
python -m build
|
|
30
|
+
- name: Upload built package
|
|
31
|
+
uses: actions/upload-artifact@v4
|
|
32
|
+
with:
|
|
33
|
+
name: built-package
|
|
34
|
+
path: dist/*.whl
|
|
35
|
+
|
|
36
|
+
test:
|
|
37
|
+
if: github.event.pull_request.draft == false && github.event.pull_request.user.login == 'dependabot[bot]'
|
|
38
|
+
needs: build
|
|
39
|
+
runs-on: ${{ matrix.os }}
|
|
40
|
+
strategy:
|
|
41
|
+
matrix:
|
|
42
|
+
os: [ubuntu-latest, windows-latest]
|
|
43
|
+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
|
|
44
|
+
fail-fast: true
|
|
45
|
+
|
|
46
|
+
steps:
|
|
47
|
+
- uses: actions/checkout@v4
|
|
48
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
49
|
+
uses: actions/setup-python@v5
|
|
50
|
+
with:
|
|
51
|
+
python-version: ${{ matrix.python-version }}
|
|
52
|
+
cache: pip
|
|
53
|
+
- name: Download built package
|
|
54
|
+
uses: actions/download-artifact@v4
|
|
55
|
+
with:
|
|
56
|
+
name: built-package
|
|
57
|
+
path: dist
|
|
58
|
+
- name: Install package
|
|
59
|
+
run: |
|
|
60
|
+
if ($env:RUNNER_OS -eq "Windows") {
|
|
61
|
+
Get-ChildItem dist/*.whl | ForEach-Object { pip install $_.FullName }
|
|
62
|
+
} else {
|
|
63
|
+
pip install dist/*.whl
|
|
64
|
+
}
|
|
65
|
+
shell: pwsh
|
|
66
|
+
- name: Install testing dependencies
|
|
67
|
+
run: |
|
|
68
|
+
pip install pytest pytest-cov qbraid-core[environments]
|
|
69
|
+
- name: Run tests with pytest
|
|
70
|
+
run: |
|
|
71
|
+
pytest --cov=qbraid_cli tests/ --cov-report=html --cov-report=xml --cov-report=term --cov-config=pyproject.toml
|
|
72
|
+
env:
|
|
73
|
+
QBRAID_API_KEY: ${{ secrets.QBRAID_API_KEY }}
|
|
74
|
+
- name: Upload coverage to Codecov
|
|
75
|
+
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
|
|
76
|
+
uses: codecov/codecov-action@v5.1.2
|
|
77
|
+
with:
|
|
78
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
79
|
+
fail_ci_if_error: false
|
|
80
|
+
files: ./build/coverage/coverage.xml
|
|
81
|
+
verbose: true
|
|
@@ -10,7 +10,7 @@ on:
|
|
|
10
10
|
|
|
11
11
|
jobs:
|
|
12
12
|
build:
|
|
13
|
-
if: github.event.pull_request.draft == false
|
|
13
|
+
if: github.event.pull_request.draft == false && github.event.pull_request.user.login != 'dependabot[bot]'
|
|
14
14
|
runs-on: ubuntu-latest
|
|
15
15
|
strategy:
|
|
16
16
|
matrix:
|
|
@@ -37,13 +37,14 @@ jobs:
|
|
|
37
37
|
path: dist/*.whl
|
|
38
38
|
|
|
39
39
|
test:
|
|
40
|
-
if: github.event.pull_request.draft == false
|
|
40
|
+
if: github.event.pull_request.draft == false && github.event.pull_request.user.login != 'dependabot[bot]'
|
|
41
41
|
needs: build
|
|
42
42
|
runs-on: ${{ matrix.os }}
|
|
43
43
|
strategy:
|
|
44
44
|
matrix:
|
|
45
45
|
os: [ubuntu-latest, windows-latest]
|
|
46
|
-
python-version: ['3.9', '3.10', '3.11', '3.12']
|
|
46
|
+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
|
|
47
|
+
fail-fast: true
|
|
47
48
|
|
|
48
49
|
steps:
|
|
49
50
|
- uses: actions/checkout@v4
|
|
@@ -75,7 +76,7 @@ jobs:
|
|
|
75
76
|
QBRAID_API_KEY: ${{ secrets.QBRAID_API_KEY }}
|
|
76
77
|
- name: Upload coverage to Codecov
|
|
77
78
|
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
|
|
78
|
-
uses: codecov/codecov-action@
|
|
79
|
+
uses: codecov/codecov-action@v5.1.2
|
|
79
80
|
with:
|
|
80
81
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
81
82
|
fail_ci_if_error: false
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: qbraid-cli
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.7
|
|
4
4
|
Summary: Command Line Interface for interacting with all parts of the qBraid platform.
|
|
5
5
|
Author-email: qBraid Development Team <contact@qbraid.com>
|
|
6
6
|
License: Proprietary
|
|
@@ -52,7 +52,11 @@ Requires-Dist: pytest-cov; extra == "dev"
|
|
|
52
52
|
|
|
53
53
|
Command Line Interface for interacting with all parts of the qBraid platform.
|
|
54
54
|
|
|
55
|
-
The **qBraid CLI** is a versatile command-line interface tool designed for seamless interaction with qBraid cloud services and quantum software management tools. Initially exclusive to the [qBraid Lab](https://docs.qbraid.com/lab/user-guide/overview) platform, the CLI now supports local installations as well. This enhancement broadens access to features like [qBraid Quantum Jobs](https://docs.qbraid.com/cli/user-guide/quantum-jobs), enabling direct
|
|
55
|
+
The **qBraid CLI** is a versatile command-line interface tool designed for seamless interaction with qBraid cloud services and quantum software management tools. Initially exclusive to the [qBraid Lab](https://docs.qbraid.com/lab/user-guide/overview) platform, the CLI now supports local installations as well. This enhancement broadens access to features like [qBraid Quantum Jobs](https://docs.qbraid.com/cli/user-guide/quantum-jobs), enabling direct, pre-configured access to QPUs from IonQ, Oxford Quantum Circuits, QuEra, Rigetti, and IQM, as well as on-demand simulators from qBraid, AWS, IonQ, QuEra, and NEC. See [pricing](https://docs.qbraid.com/home/pricing) for more.
|
|
56
|
+
|
|
57
|
+
*Resources*:
|
|
58
|
+
- [User Guide](https://docs.qbraid.com/cli/user-guide/overview)
|
|
59
|
+
- [API Reference](https://docs.qbraid.com/cli/api-reference/qbraid)
|
|
56
60
|
|
|
57
61
|
## Getting Started
|
|
58
62
|
|
|
@@ -69,6 +73,12 @@ You can also install the qBraid-CLI from PyPI with:
|
|
|
69
73
|
pip install qbraid-cli
|
|
70
74
|
```
|
|
71
75
|
|
|
76
|
+
To manage qBraid [environments](https://docs.qbraid.com/lab/user-guide/environments) using the CLI, you must also install the `envs` extra:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install 'qbraid-cli[envs]'
|
|
80
|
+
```
|
|
81
|
+
|
|
72
82
|
## Local configuration
|
|
73
83
|
|
|
74
84
|
After installation, you must configure your account credentials to use the CLI locally:
|
|
@@ -83,6 +93,8 @@ After installation, you must configure your account credentials to use the CLI l
|
|
|
83
93
|
$ qbraid configure
|
|
84
94
|
```
|
|
85
95
|
|
|
96
|
+
For more on API keys, see [documentation](https://docs.qbraid.com/home/account#api-keys).
|
|
97
|
+
|
|
86
98
|
## Basic Commands
|
|
87
99
|
|
|
88
100
|
```bash
|
|
@@ -142,12 +154,17 @@ Options
|
|
|
142
154
|
--help Show this message and exit.
|
|
143
155
|
|
|
144
156
|
Commands
|
|
157
|
+
account Manage qBraid account
|
|
158
|
+
admin CI/CD commands for qBraid maintainers.
|
|
145
159
|
configure Configure qBraid CLI options.
|
|
146
160
|
account Manage qBraid account.
|
|
161
|
+
chat Interact with qBraid AI chat service.
|
|
147
162
|
devices Manage qBraid quantum devices.
|
|
148
163
|
envs Manage qBraid environments.
|
|
164
|
+
files Manage qBraid cloud storage files.
|
|
149
165
|
jobs Manage qBraid quantum jobs.
|
|
150
166
|
kernels Manage qBraid kernels.
|
|
167
|
+
pip Run pip command in active qBraid environment.
|
|
151
168
|
```
|
|
152
169
|
|
|
153
170
|
To get the version of the qBraid CLI:
|
|
@@ -173,7 +190,5 @@ In [1]: %load_ext qbraid_magic
|
|
|
173
190
|
Now you can continue to use the qBraid-CLI as normal from within your Jupyter notebook using the magic ``%`` operator, e.g.
|
|
174
191
|
|
|
175
192
|
```python
|
|
176
|
-
In [2]: %qbraid
|
|
177
|
-
|
|
178
|
-
In [3]: %qbraid jobs enable braket -y
|
|
193
|
+
In [2]: %qbraid chat -f code -p "Write a Qiskit bell circuit"
|
|
179
194
|
```
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
|
|
10
10
|
Command Line Interface for interacting with all parts of the qBraid platform.
|
|
11
11
|
|
|
12
|
-
The **qBraid CLI** is a versatile command-line interface tool designed for seamless interaction with qBraid cloud services and quantum software management tools. Initially exclusive to the [qBraid Lab](https://docs.qbraid.com/lab/user-guide/overview) platform, the CLI now supports local installations as well. This enhancement broadens access to features like [qBraid Quantum Jobs](https://docs.qbraid.com/cli/user-guide/quantum-jobs), enabling direct
|
|
12
|
+
The **qBraid CLI** is a versatile command-line interface tool designed for seamless interaction with qBraid cloud services and quantum software management tools. Initially exclusive to the [qBraid Lab](https://docs.qbraid.com/lab/user-guide/overview) platform, the CLI now supports local installations as well. This enhancement broadens access to features like [qBraid Quantum Jobs](https://docs.qbraid.com/cli/user-guide/quantum-jobs), enabling direct, pre-configured access to QPUs from IonQ, Oxford Quantum Circuits, QuEra, Rigetti, and IQM, as well as on-demand simulators from qBraid, AWS, IonQ, QuEra, and NEC. See [pricing](https://docs.qbraid.com/home/pricing) for more.
|
|
13
|
+
|
|
14
|
+
*Resources*:
|
|
15
|
+
- [User Guide](https://docs.qbraid.com/cli/user-guide/overview)
|
|
16
|
+
- [API Reference](https://docs.qbraid.com/cli/api-reference/qbraid)
|
|
13
17
|
|
|
14
18
|
## Getting Started
|
|
15
19
|
|
|
@@ -26,6 +30,12 @@ You can also install the qBraid-CLI from PyPI with:
|
|
|
26
30
|
pip install qbraid-cli
|
|
27
31
|
```
|
|
28
32
|
|
|
33
|
+
To manage qBraid [environments](https://docs.qbraid.com/lab/user-guide/environments) using the CLI, you must also install the `envs` extra:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install 'qbraid-cli[envs]'
|
|
37
|
+
```
|
|
38
|
+
|
|
29
39
|
## Local configuration
|
|
30
40
|
|
|
31
41
|
After installation, you must configure your account credentials to use the CLI locally:
|
|
@@ -40,6 +50,8 @@ After installation, you must configure your account credentials to use the CLI l
|
|
|
40
50
|
$ qbraid configure
|
|
41
51
|
```
|
|
42
52
|
|
|
53
|
+
For more on API keys, see [documentation](https://docs.qbraid.com/home/account#api-keys).
|
|
54
|
+
|
|
43
55
|
## Basic Commands
|
|
44
56
|
|
|
45
57
|
```bash
|
|
@@ -99,12 +111,17 @@ Options
|
|
|
99
111
|
--help Show this message and exit.
|
|
100
112
|
|
|
101
113
|
Commands
|
|
114
|
+
account Manage qBraid account
|
|
115
|
+
admin CI/CD commands for qBraid maintainers.
|
|
102
116
|
configure Configure qBraid CLI options.
|
|
103
117
|
account Manage qBraid account.
|
|
118
|
+
chat Interact with qBraid AI chat service.
|
|
104
119
|
devices Manage qBraid quantum devices.
|
|
105
120
|
envs Manage qBraid environments.
|
|
121
|
+
files Manage qBraid cloud storage files.
|
|
106
122
|
jobs Manage qBraid quantum jobs.
|
|
107
123
|
kernels Manage qBraid kernels.
|
|
124
|
+
pip Run pip command in active qBraid environment.
|
|
108
125
|
```
|
|
109
126
|
|
|
110
127
|
To get the version of the qBraid CLI:
|
|
@@ -130,7 +147,5 @@ In [1]: %load_ext qbraid_magic
|
|
|
130
147
|
Now you can continue to use the qBraid-CLI as normal from within your Jupyter notebook using the magic ``%`` operator, e.g.
|
|
131
148
|
|
|
132
149
|
```python
|
|
133
|
-
In [2]: %qbraid
|
|
134
|
-
|
|
135
|
-
In [3]: %qbraid jobs enable braket -y
|
|
150
|
+
In [2]: %qbraid chat -f code -p "Write a Qiskit bell circuit"
|
|
136
151
|
```
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "qbraid-cli"
|
|
7
|
-
version = "0.9.
|
|
7
|
+
version = "0.9.7"
|
|
8
8
|
description = "Command Line Interface for interacting with all parts of the qBraid platform."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "qBraid Development Team", email = "contact@qbraid.com" }]
|
|
@@ -12,5 +12,5 @@ __version__: str
|
|
|
12
12
|
__version_tuple__: VERSION_TUPLE
|
|
13
13
|
version_tuple: VERSION_TUPLE
|
|
14
14
|
|
|
15
|
-
__version__ = version = '0.1.dev1+
|
|
16
|
-
__version_tuple__ = version_tuple = (0, 1, 'dev1', '
|
|
15
|
+
__version__ = version = '0.1.dev1+g51fd097'
|
|
16
|
+
__version_tuple__ = version_tuple = (0, 1, 'dev1', 'g51fd097')
|
|
@@ -10,8 +10,8 @@ from typing import Optional
|
|
|
10
10
|
|
|
11
11
|
import typer
|
|
12
12
|
|
|
13
|
-
from qbraid_cli.admin.headers import check_and_fix_headers
|
|
14
|
-
from qbraid_cli.admin.validation import
|
|
13
|
+
from qbraid_cli.admin.headers import HeaderType, check_and_fix_headers
|
|
14
|
+
from qbraid_cli.admin.validation import validate_paths_exist
|
|
15
15
|
|
|
16
16
|
admin_app = typer.Typer(
|
|
17
17
|
help="CI/CD commands for qBraid maintainers.",
|
|
@@ -25,12 +25,8 @@ def admin_headers(
|
|
|
25
25
|
src_paths: list[str] = typer.Argument(
|
|
26
26
|
..., help="Source file or directory paths to verify.", callback=validate_paths_exist
|
|
27
27
|
),
|
|
28
|
-
header_type:
|
|
29
|
-
"default",
|
|
30
|
-
"--type",
|
|
31
|
-
"-t",
|
|
32
|
-
help="Type of header to use ('default' or 'gpl').",
|
|
33
|
-
callback=validate_header_type,
|
|
28
|
+
header_type: HeaderType = typer.Option(
|
|
29
|
+
"default", "--type", "-t", help="Type of header to use."
|
|
34
30
|
),
|
|
35
31
|
skip_files: list[str] = typer.Option(
|
|
36
32
|
[], "--skip", "-s", help="Files to skip during verification.", callback=validate_paths_exist
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Copyright (c) 2024, qBraid Development Team
|
|
2
2
|
# All rights reserved.
|
|
3
3
|
|
|
4
|
+
# pylint: disable=too-many-branches,too-many-statements
|
|
5
|
+
|
|
4
6
|
"""
|
|
5
7
|
Script to verify qBraid copyright file headers
|
|
6
8
|
|
|
@@ -8,6 +10,8 @@ Script to verify qBraid copyright file headers
|
|
|
8
10
|
|
|
9
11
|
import datetime
|
|
10
12
|
import os
|
|
13
|
+
from enum import Enum
|
|
14
|
+
from pathlib import Path
|
|
11
15
|
from typing import Optional
|
|
12
16
|
|
|
13
17
|
import typer
|
|
@@ -15,36 +19,47 @@ from rich.console import Console
|
|
|
15
19
|
|
|
16
20
|
from qbraid_cli.handlers import handle_error
|
|
17
21
|
|
|
18
|
-
# pylint: disable=too-many-branches,too-many-statements
|
|
19
22
|
CURR_YEAR = datetime.datetime.now().year
|
|
20
23
|
PREV_YEAR = CURR_YEAR - 1
|
|
21
|
-
VALID_EXTS = (".py", ".js", ".ts")
|
|
22
24
|
|
|
25
|
+
COMMENT_MARKER = {
|
|
26
|
+
".py": "#",
|
|
27
|
+
".js": "//",
|
|
28
|
+
".ts": "//",
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
VALID_EXTS = tuple(COMMENT_MARKER.keys())
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class HeaderType(Enum):
|
|
35
|
+
"""Type of header to use."""
|
|
36
|
+
|
|
37
|
+
default = "default" # pylint: disable=invalid-name
|
|
38
|
+
gpl = "gpl" # pylint: disable=invalid-name
|
|
23
39
|
|
|
24
|
-
|
|
40
|
+
|
|
41
|
+
DEFAULT_HEADER = f"""# Copyright (c) {CURR_YEAR}, qBraid Development Team
|
|
25
42
|
# All rights reserved.
|
|
26
43
|
"""
|
|
27
44
|
|
|
28
|
-
DEFAULT_HEADER_GPL = (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
# This file is part of {project_name}
|
|
45
|
+
DEFAULT_HEADER_GPL = f"""# Copyright (C) {CURR_YEAR} qBraid
|
|
46
|
+
#
|
|
47
|
+
# This file is part of {{project_name}}
|
|
32
48
|
#
|
|
33
|
-
# {project_name_start} is free software released under the GNU General Public License v3
|
|
49
|
+
# {{project_name_start}} is free software released under the GNU General Public License v3
|
|
34
50
|
# or later. You can redistribute and/or modify it under the terms of the GPL v3.
|
|
35
51
|
# See the LICENSE file in the project root or <https://www.gnu.org/licenses/gpl-3.0.html>.
|
|
36
52
|
#
|
|
37
|
-
# THERE IS NO WARRANTY for {project_name}, as per Section 15 of the GPL v3.
|
|
53
|
+
# THERE IS NO WARRANTY for {{project_name}}, as per Section 15 of the GPL v3.
|
|
38
54
|
"""
|
|
39
|
-
)
|
|
40
55
|
|
|
41
56
|
HEADER_TYPES = {
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
HeaderType.default: DEFAULT_HEADER,
|
|
58
|
+
HeaderType.gpl: DEFAULT_HEADER_GPL,
|
|
44
59
|
}
|
|
45
60
|
|
|
46
61
|
|
|
47
|
-
def get_formatted_header(header_type:
|
|
62
|
+
def get_formatted_header(header_type: HeaderType, project_name: str) -> str:
|
|
48
63
|
"""Get the formatted header based on the header type
|
|
49
64
|
|
|
50
65
|
Args:
|
|
@@ -56,16 +71,24 @@ def get_formatted_header(header_type: str, project_name: str) -> str:
|
|
|
56
71
|
"""
|
|
57
72
|
|
|
58
73
|
header = HEADER_TYPES[header_type]
|
|
59
|
-
if header_type ==
|
|
60
|
-
|
|
61
|
-
project_name=
|
|
62
|
-
|
|
74
|
+
if header_type == HeaderType.gpl:
|
|
75
|
+
if project_name.split(" ")[0].lower() == "the":
|
|
76
|
+
project_name = project_name[:1].lower() + project_name[1:]
|
|
77
|
+
project_name_start = project_name[:1].upper() + project_name[1:]
|
|
78
|
+
else:
|
|
79
|
+
project_name_start = project_name
|
|
80
|
+
return header.format(project_name=project_name, project_name_start=project_name_start)
|
|
63
81
|
return header
|
|
64
82
|
|
|
65
83
|
|
|
84
|
+
def _get_comment_marker(file_path: str, default: Optional[str] = None) -> str:
|
|
85
|
+
file_ext = Path(file_path).suffix
|
|
86
|
+
return COMMENT_MARKER.get(file_ext, default)
|
|
87
|
+
|
|
88
|
+
|
|
66
89
|
def check_and_fix_headers(
|
|
67
90
|
src_paths: list[str],
|
|
68
|
-
header_type:
|
|
91
|
+
header_type: HeaderType = HeaderType.default,
|
|
69
92
|
skip_files: Optional[list[str]] = None,
|
|
70
93
|
fix: bool = False,
|
|
71
94
|
project_name: Optional[str] = None,
|
|
@@ -74,11 +97,10 @@ def check_and_fix_headers(
|
|
|
74
97
|
try:
|
|
75
98
|
header = get_formatted_header(header_type, project_name)
|
|
76
99
|
except KeyError:
|
|
100
|
+
members = HeaderType._member_names_ # pylint: disable=no-member,protected-access
|
|
77
101
|
handle_error(
|
|
78
102
|
error_type="ValueError",
|
|
79
|
-
message=(
|
|
80
|
-
f"Invalid header type: {HEADER_TYPES}. Expected one of {list(HEADER_TYPES.keys())}"
|
|
81
|
-
),
|
|
103
|
+
message=(f"Invalid header type: {HEADER_TYPES}. Expected one of {members}"),
|
|
82
104
|
)
|
|
83
105
|
|
|
84
106
|
for path in src_paths:
|
|
@@ -101,7 +123,8 @@ def check_and_fix_headers(
|
|
|
101
123
|
if os.path.basename(file_path) == "__init__.py":
|
|
102
124
|
return not content.strip()
|
|
103
125
|
|
|
104
|
-
|
|
126
|
+
comment_marker = _get_comment_marker(file_path)
|
|
127
|
+
skip_header_tag = f"{comment_marker} qbraid: skip-header"
|
|
105
128
|
line_number = 0
|
|
106
129
|
|
|
107
130
|
for line in content.splitlines():
|
|
@@ -117,13 +140,7 @@ def check_and_fix_headers(
|
|
|
117
140
|
with open(file_path, "r", encoding="ISO-8859-1") as f:
|
|
118
141
|
content = f.read()
|
|
119
142
|
|
|
120
|
-
|
|
121
|
-
file_ext = os.path.splitext(file_path)[1]
|
|
122
|
-
|
|
123
|
-
if file_ext == ".py":
|
|
124
|
-
comment_marker = "#"
|
|
125
|
-
elif file_ext in (".js", ".ts"):
|
|
126
|
-
comment_marker = "//"
|
|
143
|
+
comment_marker = _get_comment_marker(file_path)
|
|
127
144
|
|
|
128
145
|
# This finds the start of the actual content after skipping initial whitespace and comments.
|
|
129
146
|
lines = content.splitlines()
|
|
@@ -10,14 +10,7 @@ import os
|
|
|
10
10
|
|
|
11
11
|
import typer
|
|
12
12
|
|
|
13
|
-
from qbraid_cli.
|
|
14
|
-
from qbraid_cli.handlers import _format_list_items, validate_item
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def validate_header_type(value: str) -> str:
|
|
18
|
-
"""Validate header type."""
|
|
19
|
-
header_types = list(HEADER_TYPES.keys())
|
|
20
|
-
return validate_item(value, header_types, "Header type")
|
|
13
|
+
from qbraid_cli.handlers import _format_list_items
|
|
21
14
|
|
|
22
15
|
|
|
23
16
|
def validate_paths_exist(paths: list[str]) -> list[str]:
|
|
@@ -79,7 +79,7 @@ def configure_get(
|
|
|
79
79
|
|
|
80
80
|
@configure_app.command(name="list")
|
|
81
81
|
def configure_list():
|
|
82
|
-
"""List all configuration values in
|
|
82
|
+
"""List all configuration values in qbraidrc."""
|
|
83
83
|
# pylint: disable-next=import-outside-toplevel
|
|
84
84
|
from qbraid_core.config import load_config
|
|
85
85
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: qbraid-cli
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.7
|
|
4
4
|
Summary: Command Line Interface for interacting with all parts of the qBraid platform.
|
|
5
5
|
Author-email: qBraid Development Team <contact@qbraid.com>
|
|
6
6
|
License: Proprietary
|
|
@@ -52,7 +52,11 @@ Requires-Dist: pytest-cov; extra == "dev"
|
|
|
52
52
|
|
|
53
53
|
Command Line Interface for interacting with all parts of the qBraid platform.
|
|
54
54
|
|
|
55
|
-
The **qBraid CLI** is a versatile command-line interface tool designed for seamless interaction with qBraid cloud services and quantum software management tools. Initially exclusive to the [qBraid Lab](https://docs.qbraid.com/lab/user-guide/overview) platform, the CLI now supports local installations as well. This enhancement broadens access to features like [qBraid Quantum Jobs](https://docs.qbraid.com/cli/user-guide/quantum-jobs), enabling direct
|
|
55
|
+
The **qBraid CLI** is a versatile command-line interface tool designed for seamless interaction with qBraid cloud services and quantum software management tools. Initially exclusive to the [qBraid Lab](https://docs.qbraid.com/lab/user-guide/overview) platform, the CLI now supports local installations as well. This enhancement broadens access to features like [qBraid Quantum Jobs](https://docs.qbraid.com/cli/user-guide/quantum-jobs), enabling direct, pre-configured access to QPUs from IonQ, Oxford Quantum Circuits, QuEra, Rigetti, and IQM, as well as on-demand simulators from qBraid, AWS, IonQ, QuEra, and NEC. See [pricing](https://docs.qbraid.com/home/pricing) for more.
|
|
56
|
+
|
|
57
|
+
*Resources*:
|
|
58
|
+
- [User Guide](https://docs.qbraid.com/cli/user-guide/overview)
|
|
59
|
+
- [API Reference](https://docs.qbraid.com/cli/api-reference/qbraid)
|
|
56
60
|
|
|
57
61
|
## Getting Started
|
|
58
62
|
|
|
@@ -69,6 +73,12 @@ You can also install the qBraid-CLI from PyPI with:
|
|
|
69
73
|
pip install qbraid-cli
|
|
70
74
|
```
|
|
71
75
|
|
|
76
|
+
To manage qBraid [environments](https://docs.qbraid.com/lab/user-guide/environments) using the CLI, you must also install the `envs` extra:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install 'qbraid-cli[envs]'
|
|
80
|
+
```
|
|
81
|
+
|
|
72
82
|
## Local configuration
|
|
73
83
|
|
|
74
84
|
After installation, you must configure your account credentials to use the CLI locally:
|
|
@@ -83,6 +93,8 @@ After installation, you must configure your account credentials to use the CLI l
|
|
|
83
93
|
$ qbraid configure
|
|
84
94
|
```
|
|
85
95
|
|
|
96
|
+
For more on API keys, see [documentation](https://docs.qbraid.com/home/account#api-keys).
|
|
97
|
+
|
|
86
98
|
## Basic Commands
|
|
87
99
|
|
|
88
100
|
```bash
|
|
@@ -142,12 +154,17 @@ Options
|
|
|
142
154
|
--help Show this message and exit.
|
|
143
155
|
|
|
144
156
|
Commands
|
|
157
|
+
account Manage qBraid account
|
|
158
|
+
admin CI/CD commands for qBraid maintainers.
|
|
145
159
|
configure Configure qBraid CLI options.
|
|
146
160
|
account Manage qBraid account.
|
|
161
|
+
chat Interact with qBraid AI chat service.
|
|
147
162
|
devices Manage qBraid quantum devices.
|
|
148
163
|
envs Manage qBraid environments.
|
|
164
|
+
files Manage qBraid cloud storage files.
|
|
149
165
|
jobs Manage qBraid quantum jobs.
|
|
150
166
|
kernels Manage qBraid kernels.
|
|
167
|
+
pip Run pip command in active qBraid environment.
|
|
151
168
|
```
|
|
152
169
|
|
|
153
170
|
To get the version of the qBraid CLI:
|
|
@@ -173,7 +190,5 @@ In [1]: %load_ext qbraid_magic
|
|
|
173
190
|
Now you can continue to use the qBraid-CLI as normal from within your Jupyter notebook using the magic ``%`` operator, e.g.
|
|
174
191
|
|
|
175
192
|
```python
|
|
176
|
-
In [2]: %qbraid
|
|
177
|
-
|
|
178
|
-
In [3]: %qbraid jobs enable braket -y
|
|
193
|
+
In [2]: %qbraid chat -f code -p "Write a Qiskit bell circuit"
|
|
179
194
|
```
|
|
@@ -8,9 +8,11 @@ Makefile
|
|
|
8
8
|
README.md
|
|
9
9
|
pyproject.toml
|
|
10
10
|
.github/PULL_REQUEST_TEMPLATE.md
|
|
11
|
+
.github/dependabot.yml
|
|
11
12
|
.github/ISSUE_TEMPLATE/bug_report.yml
|
|
12
13
|
.github/ISSUE_TEMPLATE/feature_request.yml
|
|
13
14
|
.github/workflows/bump-version.yml
|
|
15
|
+
.github/workflows/ci-pr-target.yml
|
|
14
16
|
.github/workflows/docs-pr.yml
|
|
15
17
|
.github/workflows/docs.yml
|
|
16
18
|
.github/workflows/format.yml
|
|
@@ -13,7 +13,7 @@ import pytest
|
|
|
13
13
|
from typer.testing import CliRunner
|
|
14
14
|
|
|
15
15
|
from qbraid_cli.admin.app import admin_app
|
|
16
|
-
from qbraid_cli.admin.headers import DEFAULT_HEADER, VALID_EXTS, get_formatted_header
|
|
16
|
+
from qbraid_cli.admin.headers import DEFAULT_HEADER, VALID_EXTS, HeaderType, get_formatted_header
|
|
17
17
|
|
|
18
18
|
runner = CliRunner()
|
|
19
19
|
|
|
@@ -49,17 +49,20 @@ def _get_test_file(test_type: str, ext: str = ".py") -> str:
|
|
|
49
49
|
return file_path
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def
|
|
52
|
+
def remove_test_file(test_type: str, ext: str = ".py") -> None:
|
|
53
|
+
"""Remove the test file."""
|
|
53
54
|
file_path = _get_test_file_path(test_type, ext)
|
|
54
55
|
os.remove(file_path)
|
|
55
56
|
|
|
56
57
|
|
|
57
58
|
def strip_ansi_codes(text):
|
|
59
|
+
"""Remove ANSI escape codes from text."""
|
|
58
60
|
ansi_escape = re.compile(r"\x1B[@-_][0-?]*[ -/]*[@-~]")
|
|
59
61
|
return ansi_escape.sub("", text)
|
|
60
62
|
|
|
61
63
|
|
|
62
|
-
def
|
|
64
|
+
def verify_test_result(result, expected_exit_code: int, expected_output: str):
|
|
65
|
+
"""Verify the test result."""
|
|
63
66
|
assert expected_output in strip_ansi_codes(result.stdout)
|
|
64
67
|
assert result.exit_code == expected_exit_code
|
|
65
68
|
|
|
@@ -72,13 +75,15 @@ def test_header_fix_for_file_with_correct_header(ext):
|
|
|
72
75
|
|
|
73
76
|
result = runner.invoke(admin_app, [file_path, "--fix"])
|
|
74
77
|
|
|
75
|
-
|
|
78
|
+
verify_test_result(result, 0, "1 file left unchanged")
|
|
76
79
|
|
|
77
80
|
# assert that the file has not been changed
|
|
78
81
|
with open(file_path, "r") as f:
|
|
79
|
-
|
|
82
|
+
passed = f.read() == original_content
|
|
80
83
|
|
|
81
|
-
|
|
84
|
+
remove_test_file("correct_header", ext)
|
|
85
|
+
|
|
86
|
+
assert passed
|
|
82
87
|
|
|
83
88
|
|
|
84
89
|
@pytest.mark.parametrize("ext", VALID_EXTS)
|
|
@@ -88,17 +93,19 @@ def test_header_fix_for_file_with_no_header(ext):
|
|
|
88
93
|
|
|
89
94
|
result = runner.invoke(admin_app, [file_path, "--fix"])
|
|
90
95
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
comment_marker = "#" if ext == ".py" else "//"
|
|
96
|
+
try:
|
|
97
|
+
verify_test_result(result, 0, "1 file fixed")
|
|
94
98
|
|
|
95
|
-
|
|
96
|
-
with open(file_path, "r") as f:
|
|
97
|
-
assert (
|
|
98
|
-
f.read() == DEFAULT_HEADER.replace("#", comment_marker) + "\n" + "print('hello world')"
|
|
99
|
-
)
|
|
99
|
+
comment_marker = "#" if ext == ".py" else "//"
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
# assert that the file has the new header
|
|
102
|
+
with open(file_path, "r") as f:
|
|
103
|
+
assert (
|
|
104
|
+
f.read()
|
|
105
|
+
== DEFAULT_HEADER.replace("#", comment_marker) + "\n" + "print('hello world')"
|
|
106
|
+
)
|
|
107
|
+
finally:
|
|
108
|
+
remove_test_file("no_header", ext)
|
|
102
109
|
|
|
103
110
|
|
|
104
111
|
@pytest.mark.parametrize("ext", VALID_EXTS)
|
|
@@ -108,20 +115,21 @@ def test_header_update_for_file_with_old_header(ext):
|
|
|
108
115
|
|
|
109
116
|
result = runner.invoke(admin_app, [file_path, "--fix", "-t", "gpl", "-p", "test_project"])
|
|
110
117
|
|
|
111
|
-
|
|
118
|
+
try:
|
|
119
|
+
verify_test_result(result, 0, "1 file fixed")
|
|
112
120
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
# assert that the file has the new header
|
|
116
|
-
with open(file_path, "r") as f:
|
|
117
|
-
assert (
|
|
118
|
-
f.read()
|
|
119
|
-
== get_formatted_header("gpl", "test_project").replace("#", comment_marker)
|
|
120
|
-
+ "\n"
|
|
121
|
-
+ "print('hello world')"
|
|
122
|
-
)
|
|
121
|
+
comment_marker = "#" if ext == ".py" else "//"
|
|
123
122
|
|
|
124
|
-
|
|
123
|
+
# assert that the file has the new header
|
|
124
|
+
with open(file_path, "r") as f:
|
|
125
|
+
assert (
|
|
126
|
+
f.read()
|
|
127
|
+
== get_formatted_header(HeaderType.gpl, "test_project").replace("#", comment_marker)
|
|
128
|
+
+ "\n"
|
|
129
|
+
+ "print('hello world')"
|
|
130
|
+
)
|
|
131
|
+
finally:
|
|
132
|
+
remove_test_file("old_header", ext)
|
|
125
133
|
|
|
126
134
|
|
|
127
135
|
def test_current_year_header_for_new_file():
|
|
@@ -130,13 +138,15 @@ def test_current_year_header_for_new_file():
|
|
|
130
138
|
|
|
131
139
|
result = runner.invoke(admin_app, [file_path, "--fix"])
|
|
132
140
|
|
|
133
|
-
|
|
141
|
+
try:
|
|
142
|
+
verify_test_result(result, 0, "1 file fixed")
|
|
134
143
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
144
|
+
# assert that the file has the new header with the current year
|
|
145
|
+
with open(file_path, "r") as f:
|
|
146
|
+
assert str(datetime.datetime.now().year) in f.read()
|
|
138
147
|
|
|
139
|
-
|
|
148
|
+
finally:
|
|
149
|
+
remove_test_file("no_header")
|
|
140
150
|
|
|
141
151
|
|
|
142
152
|
def test_no_header_update_for_file_with_last_year_header():
|
|
@@ -146,13 +156,15 @@ def test_no_header_update_for_file_with_last_year_header():
|
|
|
146
156
|
|
|
147
157
|
result = runner.invoke(admin_app, [file_path, "--fix"])
|
|
148
158
|
|
|
149
|
-
|
|
159
|
+
try:
|
|
160
|
+
verify_test_result(result, 0, "1 file left unchanged")
|
|
150
161
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
162
|
+
# assert that the file has not been changed
|
|
163
|
+
with open(file_path, "r") as f:
|
|
164
|
+
assert f.read() == original_content
|
|
154
165
|
|
|
155
|
-
|
|
166
|
+
finally:
|
|
167
|
+
remove_test_file("last_year")
|
|
156
168
|
|
|
157
169
|
|
|
158
170
|
def test_files_in_directory():
|
|
@@ -162,10 +174,11 @@ def test_files_in_directory():
|
|
|
162
174
|
|
|
163
175
|
result = runner.invoke(admin_app, [os.path.dirname(__file__), "--fix"])
|
|
164
176
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
177
|
+
try:
|
|
178
|
+
verify_test_result(result, 0, "2 files fixed")
|
|
179
|
+
finally:
|
|
180
|
+
for test_file in test_files:
|
|
181
|
+
remove_test_file(test_file)
|
|
169
182
|
|
|
170
183
|
|
|
171
184
|
def test_invalid_path():
|
|
@@ -174,7 +187,7 @@ def test_invalid_path():
|
|
|
174
187
|
|
|
175
188
|
result = runner.invoke(admin_app, [file_path, "--fix"])
|
|
176
189
|
|
|
177
|
-
|
|
190
|
+
verify_test_result(result, 2, f"Path '{file_path}' does not exist")
|
|
178
191
|
|
|
179
192
|
|
|
180
193
|
def test_invalid_header_types():
|
|
@@ -182,8 +195,10 @@ def test_invalid_header_types():
|
|
|
182
195
|
file_path = _get_test_file("no_header")
|
|
183
196
|
|
|
184
197
|
result = runner.invoke(admin_app, [file_path, "--fix", "-t", "invalid_header"])
|
|
185
|
-
|
|
186
|
-
|
|
198
|
+
try:
|
|
199
|
+
verify_test_result(result, 2, "Invalid value for '--type' / '-t'")
|
|
200
|
+
finally:
|
|
201
|
+
remove_test_file("no_header")
|
|
187
202
|
|
|
188
203
|
|
|
189
204
|
def test_correct_identification_of_bad_headers():
|
|
@@ -192,9 +207,10 @@ def test_correct_identification_of_bad_headers():
|
|
|
192
207
|
|
|
193
208
|
result = runner.invoke(admin_app, [file_path])
|
|
194
209
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
210
|
+
try:
|
|
211
|
+
verify_test_result(result, 1, "would fix")
|
|
212
|
+
finally:
|
|
213
|
+
remove_test_file("old_header")
|
|
198
214
|
|
|
199
215
|
|
|
200
216
|
def test_non_supported_extensions_are_untouched():
|
|
@@ -206,6 +222,7 @@ def test_non_supported_extensions_are_untouched():
|
|
|
206
222
|
|
|
207
223
|
result = runner.invoke(admin_app, [non_python_file_path, "--fix"])
|
|
208
224
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
225
|
+
try:
|
|
226
|
+
verify_test_result(result, 0, f"No {VALID_EXTS} files present. Nothing to do")
|
|
227
|
+
finally:
|
|
228
|
+
os.remove(non_python_file_path)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|