qbraid-core 0.1.0.dev3__tar.gz → 0.1.0.dev4__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.
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/PKG-INFO +3 -1
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/README.md +2 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/pyproject.toml +1 -1
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/__init__.py +26 -9
- qbraid-core-0.1.0.dev3/qbraid_core/_warnings.py → qbraid-core-0.1.0.dev4/qbraid_core/_compat.py +4 -9
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/_version.py +2 -2
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/client.py +2 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/environments/create.py +2 -5
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/environments/paths.py +2 -5
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/environments/state.py +4 -7
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/quantum/proxy.py +0 -1
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/session.py +5 -3
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/system/executables.py +0 -1
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/system/packages.py +0 -1
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core.egg-info/PKG-INFO +3 -1
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core.egg-info/SOURCES.txt +2 -2
- qbraid-core-0.1.0.dev3/tests/test_warnings.py → qbraid-core-0.1.0.dev4/tests/test_compat.py +1 -1
- qbraid-core-0.1.0.dev4/tools/verify_headers.py +182 -0
- qbraid-core-0.1.0.dev3/tools/verify_headers.py +0 -173
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/.github/workflows/docs.yml +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/.github/workflows/format.yml +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/.github/workflows/main.yml +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/.github/workflows/publish.yml +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/.github/workflows/test-publish.yml +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/.gitignore +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/.readthedocs.yaml +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/LICENSE +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/MANIFEST.in +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/docs/Makefile +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/docs/_static/cards/jupyter.png +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/docs/_static/cards/python.png +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/docs/_static/cards/terminal.png +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/docs/_static/css/custom.css +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/docs/_static/css/s4defs-roles.css +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/docs/_static/favicon.ico +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/docs/_static/logo.png +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/docs/api/qbraid_core.rst +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/docs/api/qbraid_core.services.rst +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/docs/api/qbraid_core.system.rst +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/docs/conf.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/docs/index.rst +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/docs/make.bat +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/exceptions.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/registry.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/retry.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/__init__.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/environments/__init__.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/environments/client.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/environments/exceptions.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/environments/validate.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/quantum/__init__.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/quantum/adapter.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/quantum/client.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/quantum/exceptions.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/system/__init__.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/system/exceptions.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/system/generic.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/system/threader.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core.egg-info/dependency_links.txt +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core.egg-info/requires.txt +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core.egg-info/top_level.txt +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/setup.cfg +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/tests/__init__.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/tests/conftest.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/tests/fixtures/__init__.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/tests/fixtures/environments.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/tests/test_client.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/tests/test_environments.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/tests/test_session.py +0 -0
- {qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/tests/test_system.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: qbraid-core
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev4
|
|
4
4
|
Summary: Python library with core abstractions for software development in the qBraid ecosystem.
|
|
5
5
|
Author-email: qBraid Development Team <contact@qbraid.com>
|
|
6
6
|
License: Proprietary
|
|
@@ -80,6 +80,8 @@ Or generate your `~/.qbraid/qbraidrc` file via the qbraid-core Python interface:
|
|
|
80
80
|
>>> from qbraid_core import QbraidSession
|
|
81
81
|
>>> session = QbraidSession(api_key='API_KEY')
|
|
82
82
|
>>> session.save_config()
|
|
83
|
+
>>> session.get_available_services()
|
|
84
|
+
['environments', 'quantum']
|
|
83
85
|
```
|
|
84
86
|
|
|
85
87
|
Other credential configuration methods can be found [here](https://docs.qbraid.com/projects/cli/en/latest/tree/qbraid_configure.html).
|
|
@@ -41,6 +41,8 @@ Or generate your `~/.qbraid/qbraidrc` file via the qbraid-core Python interface:
|
|
|
41
41
|
>>> from qbraid_core import QbraidSession
|
|
42
42
|
>>> session = QbraidSession(api_key='API_KEY')
|
|
43
43
|
>>> session.save_config()
|
|
44
|
+
>>> session.get_available_services()
|
|
45
|
+
['environments', 'quantum']
|
|
44
46
|
```
|
|
45
47
|
|
|
46
48
|
Other credential configuration methods can be found [here](https://docs.qbraid.com/projects/cli/en/latest/tree/qbraid_configure.html).
|
|
@@ -24,8 +24,6 @@ Functions
|
|
|
24
24
|
:toctree: ../stubs/
|
|
25
25
|
|
|
26
26
|
client
|
|
27
|
-
register_client
|
|
28
|
-
discover_services
|
|
29
27
|
setup_default_session
|
|
30
28
|
|
|
31
29
|
Exceptions
|
|
@@ -38,9 +36,10 @@ Exceptions
|
|
|
38
36
|
AuthError
|
|
39
37
|
ConfigError
|
|
40
38
|
RequestsApiError
|
|
39
|
+
ResourceNotFoundError
|
|
40
|
+
UserNotFoundError
|
|
41
41
|
|
|
42
42
|
"""
|
|
43
|
-
from ._warnings import _check_version, _disable_urllib3
|
|
44
43
|
from .client import QbraidClient
|
|
45
44
|
from .exceptions import (
|
|
46
45
|
AuthError,
|
|
@@ -50,10 +49,15 @@ from .exceptions import (
|
|
|
50
49
|
ResourceNotFoundError,
|
|
51
50
|
UserNotFoundError,
|
|
52
51
|
)
|
|
53
|
-
from .registry import discover_services, register_client
|
|
54
52
|
from .retry import PostForcelistRetry
|
|
55
53
|
from .session import QbraidSession
|
|
56
54
|
|
|
55
|
+
try:
|
|
56
|
+
# Injected in _version.py during the build process.
|
|
57
|
+
from ._version import __version__
|
|
58
|
+
except ImportError:
|
|
59
|
+
__version__ = ""
|
|
60
|
+
|
|
57
61
|
# Hold the default session in a global variable, but don't initialize it yet.
|
|
58
62
|
_DEFAULT_SESSION = None
|
|
59
63
|
|
|
@@ -104,8 +108,21 @@ def client(*args, **kwargs):
|
|
|
104
108
|
Returns:
|
|
105
109
|
A service client instance.
|
|
106
110
|
"""
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
session = _get_default_session()
|
|
112
|
+
_ = session.get_available_services() # Ensure the session is initialized
|
|
113
|
+
return session.client(*args, **kwargs)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
__all__ = [
|
|
117
|
+
"QbraidClient",
|
|
118
|
+
"QbraidSession",
|
|
119
|
+
"PostForcelistRetry",
|
|
120
|
+
"client",
|
|
121
|
+
"setup_default_session",
|
|
122
|
+
"QbraidException",
|
|
123
|
+
"AuthError",
|
|
124
|
+
"ConfigError",
|
|
125
|
+
"RequestsApiError",
|
|
126
|
+
"ResourceNotFoundError",
|
|
127
|
+
"UserNotFoundError",
|
|
128
|
+
]
|
qbraid-core-0.1.0.dev3/qbraid_core/_warnings.py → qbraid-core-0.1.0.dev4/qbraid_core/_compat.py
RENAMED
|
@@ -7,8 +7,6 @@ Module for emitting and disabling warnings at top level.
|
|
|
7
7
|
"""
|
|
8
8
|
import warnings
|
|
9
9
|
|
|
10
|
-
import urllib3
|
|
11
|
-
|
|
12
10
|
from .exceptions import QbraidException
|
|
13
11
|
from .system import get_latest_package_version, get_local_package_version
|
|
14
12
|
|
|
@@ -16,13 +14,16 @@ from .system import get_latest_package_version, get_local_package_version
|
|
|
16
14
|
def _warn_new_version(local: str, latest: str) -> bool:
|
|
17
15
|
"""Returns True if you should warn user about updated package version,
|
|
18
16
|
False otherwise."""
|
|
17
|
+
if not local or not latest:
|
|
18
|
+
return False
|
|
19
|
+
|
|
19
20
|
installed_major, installed_minor = map(int, local.split(".")[:2])
|
|
20
21
|
latest_major, latest_minor = map(int, latest.split(".")[:2])
|
|
21
22
|
|
|
22
23
|
return (installed_major, installed_minor) < (latest_major, latest_minor)
|
|
23
24
|
|
|
24
25
|
|
|
25
|
-
def
|
|
26
|
+
def check_version(package: str) -> None:
|
|
26
27
|
"""Emits UserWarning if updated package version exists."""
|
|
27
28
|
try:
|
|
28
29
|
latest_version = get_latest_package_version(package)
|
|
@@ -37,9 +38,3 @@ def _check_version(package: str) -> None:
|
|
|
37
38
|
)
|
|
38
39
|
except QbraidException:
|
|
39
40
|
pass
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
# coverage: ignore
|
|
43
|
-
def _disable_urllib3() -> None:
|
|
44
|
-
"""Disables urllib3 InsecureRequestWarning warning."""
|
|
45
|
-
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
@@ -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+g2d79786'
|
|
16
|
+
__version_tuple__ = version_tuple = (0, 1, 'dev1', 'g2d79786')
|
|
@@ -10,6 +10,7 @@ import os
|
|
|
10
10
|
import re
|
|
11
11
|
from typing import Optional
|
|
12
12
|
|
|
13
|
+
from ._compat import check_version
|
|
13
14
|
from .exceptions import AuthError, RequestsApiError, ResourceNotFoundError, UserNotFoundError
|
|
14
15
|
from .session import QbraidSession
|
|
15
16
|
|
|
@@ -19,6 +20,7 @@ class QbraidClient:
|
|
|
19
20
|
|
|
20
21
|
def __init__(self, session: Optional[QbraidSession] = None):
|
|
21
22
|
self.session = session or QbraidSession()
|
|
23
|
+
check_version("qbraid-core")
|
|
22
24
|
|
|
23
25
|
@property
|
|
24
26
|
def session(self) -> QbraidSession:
|
{qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/environments/create.py
RENAMED
|
@@ -15,10 +15,7 @@ from qbraid_core.system import replace_str
|
|
|
15
15
|
|
|
16
16
|
from .state import update_install_status
|
|
17
17
|
|
|
18
|
-
logging.
|
|
19
|
-
level=logging.ERROR,
|
|
20
|
-
format="%(asctime)s - %(levelname)s - %(message)s",
|
|
21
|
-
)
|
|
18
|
+
logger = logging.getLogger(__name__)
|
|
22
19
|
|
|
23
20
|
|
|
24
21
|
def create_local_venv(slug_path: Union[str, Path], prompt: str) -> None:
|
|
@@ -43,5 +40,5 @@ def create_local_venv(slug_path: Union[str, Path], prompt: str) -> None:
|
|
|
43
40
|
|
|
44
41
|
update_install_status(slug_path, 1, 1)
|
|
45
42
|
except Exception as err: # pylint: disable=broad-exception-caught
|
|
46
|
-
|
|
43
|
+
logger.error("Error creating virtual environment: %s", err)
|
|
47
44
|
update_install_status(slug_path, 1, 0, message=str(err))
|
{qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/environments/paths.py
RENAMED
|
@@ -18,10 +18,7 @@ from qbraid_core.system import is_valid_python
|
|
|
18
18
|
|
|
19
19
|
from .validate import is_valid_slug
|
|
20
20
|
|
|
21
|
-
logging.
|
|
22
|
-
level=logging.ERROR,
|
|
23
|
-
format="%(asctime)s - %(levelname)s - %(message)s",
|
|
24
|
-
)
|
|
21
|
+
logger = logging.getLogger(__name__)
|
|
25
22
|
|
|
26
23
|
|
|
27
24
|
def get_default_envs_paths() -> List[Path]:
|
|
@@ -99,7 +96,7 @@ def which_python(slug: str) -> str:
|
|
|
99
96
|
if is_valid_python(python_path):
|
|
100
97
|
return str(python_path)
|
|
101
98
|
except Exception as err: # pylint: disable=broad-exception-caught
|
|
102
|
-
|
|
99
|
+
logger.error("Error determining Python path: %s", err)
|
|
103
100
|
|
|
104
101
|
return sys.executable
|
|
105
102
|
|
{qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/environments/state.py
RENAMED
|
@@ -13,10 +13,7 @@ from typing import Dict, Optional, Union
|
|
|
13
13
|
|
|
14
14
|
from .paths import get_env_path
|
|
15
15
|
|
|
16
|
-
logging.
|
|
17
|
-
level=logging.ERROR,
|
|
18
|
-
format="%(asctime)s - %(levelname)s - %(message)s",
|
|
19
|
-
)
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
20
17
|
|
|
21
18
|
|
|
22
19
|
def install_status_codes(slug: str) -> Dict[str, Union[int, str]]:
|
|
@@ -28,7 +25,7 @@ def install_status_codes(slug: str) -> Dict[str, Union[int, str]]:
|
|
|
28
25
|
json_data = json.load(file)
|
|
29
26
|
return json_data.get("install", {})
|
|
30
27
|
except (IOError, json.JSONDecodeError) as err:
|
|
31
|
-
|
|
28
|
+
logger.error("Error reading state.json: %s", err)
|
|
32
29
|
return {}
|
|
33
30
|
|
|
34
31
|
def read_from_txt(file_path: Path) -> Dict[str, Union[int, str]]:
|
|
@@ -43,7 +40,7 @@ def install_status_codes(slug: str) -> Dict[str, Union[int, str]]:
|
|
|
43
40
|
elif key == "message":
|
|
44
41
|
data[key] = value.strip()
|
|
45
42
|
except IOError as err:
|
|
46
|
-
|
|
43
|
+
logger.error("Error reading install_status.txt: %s", err)
|
|
47
44
|
return data
|
|
48
45
|
|
|
49
46
|
slug_path = get_env_path(slug)
|
|
@@ -83,7 +80,7 @@ def update_install_status(
|
|
|
83
80
|
file.seek(0) # Reset file position to the beginning
|
|
84
81
|
except json.JSONDecodeError as err:
|
|
85
82
|
# Keep default data if JSON is invalid
|
|
86
|
-
|
|
83
|
+
logger.error("Error opening state.json: %s", err)
|
|
87
84
|
|
|
88
85
|
# Update the data
|
|
89
86
|
data["install"]["complete"] = complete
|
|
@@ -10,6 +10,7 @@ import logging
|
|
|
10
10
|
import os
|
|
11
11
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
|
12
12
|
|
|
13
|
+
import urllib3
|
|
13
14
|
from requests import RequestException, Response, Session
|
|
14
15
|
from requests.adapters import HTTPAdapter
|
|
15
16
|
|
|
@@ -20,13 +21,14 @@ from .retry import STATUS_FORCELIST, PostForcelistRetry
|
|
|
20
21
|
if TYPE_CHECKING:
|
|
21
22
|
import qbraid_core
|
|
22
23
|
|
|
23
|
-
logging.basicConfig(level=logging.INFO)
|
|
24
24
|
logger = logging.getLogger(__name__)
|
|
25
25
|
|
|
26
26
|
DEFAULT_ENDPOINT_URL = "https://api.qbraid.com/api"
|
|
27
27
|
DEFAULT_CONFIG_PATH = os.path.join(os.path.expanduser("~"), ".qbraid", "qbraidrc")
|
|
28
28
|
DEFAULT_CONFIG_SECTION = "default"
|
|
29
29
|
|
|
30
|
+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
31
|
+
|
|
30
32
|
|
|
31
33
|
class QbraidSession(Session): # pylint: disable=too-many-instance-attributes
|
|
32
34
|
"""Custom session with handling of request urls and authentication.
|
|
@@ -258,8 +260,8 @@ class QbraidSession(Session): # pylint: disable=too-many-instance-attributes
|
|
|
258
260
|
"""
|
|
259
261
|
client_class = client_registry.get(service_name)
|
|
260
262
|
if not client_class:
|
|
261
|
-
raise ValueError(f"Service {service_name} not registered")
|
|
262
|
-
return client_class(
|
|
263
|
+
raise ValueError(f"Service '{service_name}' not registered")
|
|
264
|
+
return client_class(session=self)
|
|
263
265
|
|
|
264
266
|
def _initialize_retry(
|
|
265
267
|
self, retries_total: int, retries_connect: int, backoff_factor: float
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: qbraid-core
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev4
|
|
4
4
|
Summary: Python library with core abstractions for software development in the qBraid ecosystem.
|
|
5
5
|
Author-email: qBraid Development Team <contact@qbraid.com>
|
|
6
6
|
License: Proprietary
|
|
@@ -80,6 +80,8 @@ Or generate your `~/.qbraid/qbraidrc` file via the qbraid-core Python interface:
|
|
|
80
80
|
>>> from qbraid_core import QbraidSession
|
|
81
81
|
>>> session = QbraidSession(api_key='API_KEY')
|
|
82
82
|
>>> session.save_config()
|
|
83
|
+
>>> session.get_available_services()
|
|
84
|
+
['environments', 'quantum']
|
|
83
85
|
```
|
|
84
86
|
|
|
85
87
|
Other credential configuration methods can be found [here](https://docs.qbraid.com/projects/cli/en/latest/tree/qbraid_configure.html).
|
|
@@ -27,8 +27,8 @@ docs/api/qbraid_core.rst
|
|
|
27
27
|
docs/api/qbraid_core.services.rst
|
|
28
28
|
docs/api/qbraid_core.system.rst
|
|
29
29
|
qbraid_core/__init__.py
|
|
30
|
+
qbraid_core/_compat.py
|
|
30
31
|
qbraid_core/_version.py
|
|
31
|
-
qbraid_core/_warnings.py
|
|
32
32
|
qbraid_core/client.py
|
|
33
33
|
qbraid_core/exceptions.py
|
|
34
34
|
qbraid_core/registry.py
|
|
@@ -61,10 +61,10 @@ qbraid_core/system/threader.py
|
|
|
61
61
|
tests/__init__.py
|
|
62
62
|
tests/conftest.py
|
|
63
63
|
tests/test_client.py
|
|
64
|
+
tests/test_compat.py
|
|
64
65
|
tests/test_environments.py
|
|
65
66
|
tests/test_session.py
|
|
66
67
|
tests/test_system.py
|
|
67
|
-
tests/test_warnings.py
|
|
68
68
|
tests/fixtures/__init__.py
|
|
69
69
|
tests/fixtures/environments.py
|
|
70
70
|
tools/verify_headers.py
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Copyright (c) 2024, qBraid Development Team
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
|
|
4
|
+
# pylint: skip-file
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
Script to verify qBraid copyright file headers
|
|
8
|
+
|
|
9
|
+
"""
|
|
10
|
+
import os
|
|
11
|
+
import sys
|
|
12
|
+
from typing import List, Optional
|
|
13
|
+
|
|
14
|
+
# ANSI escape codes
|
|
15
|
+
BLUE = "\033[94m"
|
|
16
|
+
BOLD = "\033[1m"
|
|
17
|
+
RESET = "\033[0m"
|
|
18
|
+
|
|
19
|
+
DEFAULT_HEADER = """# Copyright (c) 2024, qBraid Development Team
|
|
20
|
+
# All rights reserved.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
DEFAULT_HEADER_GPL = """# Copyright (C) 2024 qBraid
|
|
24
|
+
#
|
|
25
|
+
# This file is part of the qBraid-SDK
|
|
26
|
+
#
|
|
27
|
+
# The qBraid-SDK is free software released under the GNU General Public License v3
|
|
28
|
+
# or later. You can redistribute and/or modify it under the terms of the GPL v3.
|
|
29
|
+
# See the LICENSE file in the project root or <https://www.gnu.org/licenses/gpl-3.0.html>.
|
|
30
|
+
#
|
|
31
|
+
# THERE IS NO WARRANTY for the qBraid-SDK, as per Section 15 of the GPL v3.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def verify_headers(
|
|
36
|
+
src_paths: List[str],
|
|
37
|
+
header_type: str = "default",
|
|
38
|
+
skip_files: Optional[List[str]] = None,
|
|
39
|
+
fix: bool = False,
|
|
40
|
+
) -> None:
|
|
41
|
+
if header_type == "default":
|
|
42
|
+
header = DEFAULT_HEADER
|
|
43
|
+
elif header_type == "gpl":
|
|
44
|
+
header = DEFAULT_HEADER_GPL
|
|
45
|
+
else:
|
|
46
|
+
raise ValueError("Invalid header type")
|
|
47
|
+
|
|
48
|
+
header_2023 = header.replace("2024", "2023")
|
|
49
|
+
|
|
50
|
+
skip_files = skip_files or []
|
|
51
|
+
|
|
52
|
+
failed_headers = []
|
|
53
|
+
fixed_headers = []
|
|
54
|
+
|
|
55
|
+
def should_skip(file_path: str, content: str) -> bool:
|
|
56
|
+
if file_path in skip_files:
|
|
57
|
+
return True
|
|
58
|
+
|
|
59
|
+
if os.path.basename(file_path) == "__init__.py":
|
|
60
|
+
return not content.strip()
|
|
61
|
+
|
|
62
|
+
skip_header_tag = "# qbraid: skip-header"
|
|
63
|
+
line_number = 0
|
|
64
|
+
|
|
65
|
+
for line in content.splitlines():
|
|
66
|
+
line_number += 1
|
|
67
|
+
if 5 <= line_number <= 30 and skip_header_tag in line:
|
|
68
|
+
return True
|
|
69
|
+
if line_number > 30:
|
|
70
|
+
break
|
|
71
|
+
|
|
72
|
+
return False
|
|
73
|
+
|
|
74
|
+
def replace_or_add_header(file_path: str, fix: bool = False) -> None:
|
|
75
|
+
with open(file_path, "r", encoding="ISO-8859-1") as f:
|
|
76
|
+
content = f.read()
|
|
77
|
+
|
|
78
|
+
if (
|
|
79
|
+
content.startswith(header)
|
|
80
|
+
or content.startswith(header_2023)
|
|
81
|
+
or should_skip(file_path, content)
|
|
82
|
+
):
|
|
83
|
+
return
|
|
84
|
+
|
|
85
|
+
if not fix:
|
|
86
|
+
failed_headers.append(file_path)
|
|
87
|
+
return
|
|
88
|
+
|
|
89
|
+
# Add or replace the header
|
|
90
|
+
lines = content.splitlines()
|
|
91
|
+
first_non_comment_line_index = next(
|
|
92
|
+
(i for i, line in enumerate(lines) if not line.strip().startswith("#")), None
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
new_content_lines = [header.rstrip("\r\n")] + (
|
|
96
|
+
lines[first_non_comment_line_index:] if first_non_comment_line_index is not None else []
|
|
97
|
+
)
|
|
98
|
+
new_content = "\n".join(new_content_lines) + "\n"
|
|
99
|
+
|
|
100
|
+
with open(file_path, "w", encoding="ISO-8859-1") as f:
|
|
101
|
+
f.write(new_content)
|
|
102
|
+
|
|
103
|
+
fixed_headers.append(file_path)
|
|
104
|
+
return
|
|
105
|
+
|
|
106
|
+
def process_files_in_directory(directory: str, fix: bool = False) -> int:
|
|
107
|
+
count = 0
|
|
108
|
+
if not os.path.isdir(directory):
|
|
109
|
+
return count
|
|
110
|
+
for root, _, files in os.walk(directory):
|
|
111
|
+
for file in files:
|
|
112
|
+
if file.endswith(".py"):
|
|
113
|
+
file_path = os.path.join(root, file)
|
|
114
|
+
replace_or_add_header(file_path, fix)
|
|
115
|
+
count += 1
|
|
116
|
+
return count
|
|
117
|
+
|
|
118
|
+
checked = 0
|
|
119
|
+
for item in src_paths:
|
|
120
|
+
if os.path.isdir(item):
|
|
121
|
+
checked += process_files_in_directory(item, fix)
|
|
122
|
+
elif os.path.isfile(item) and item.endswith(".py"):
|
|
123
|
+
replace_or_add_header(item, fix)
|
|
124
|
+
checked += 1
|
|
125
|
+
else:
|
|
126
|
+
failed_headers.append(item)
|
|
127
|
+
print(f"Directory not found: {item}")
|
|
128
|
+
|
|
129
|
+
if not fix:
|
|
130
|
+
if failed_headers:
|
|
131
|
+
for file in failed_headers:
|
|
132
|
+
print(f"failed {os.path.relpath(file)}")
|
|
133
|
+
num_failed = len(failed_headers)
|
|
134
|
+
s1, s2 = ("", "s") if num_failed == 1 else ("s", "")
|
|
135
|
+
sys.stderr.write(f"\n{num_failed} file header{s1} need{s2} updating.\n")
|
|
136
|
+
else:
|
|
137
|
+
print("All file header checks passed!")
|
|
138
|
+
|
|
139
|
+
else:
|
|
140
|
+
for file in fixed_headers:
|
|
141
|
+
print(f"fixed {os.path.relpath(file)}")
|
|
142
|
+
num_fixed = len(fixed_headers)
|
|
143
|
+
num_ok = checked - num_fixed
|
|
144
|
+
s_fixed = "" if num_fixed == 1 else "s"
|
|
145
|
+
s_ok = "" if num_ok == 1 else "s"
|
|
146
|
+
print("\nAll done! ✨ 🚀 ✨")
|
|
147
|
+
print(f"{num_fixed} header{s_fixed} fixed, {num_ok} header{s_ok} left unchanged.")
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def display_help() -> None:
|
|
151
|
+
help_message = """
|
|
152
|
+
Usage: python verify_headers.py SRC [OPTIONS] ...
|
|
153
|
+
|
|
154
|
+
This script checks for copyright headers at the specified path.
|
|
155
|
+
If no flags are passed, it will indicate which files would be
|
|
156
|
+
modified without actually making any changes.
|
|
157
|
+
|
|
158
|
+
Options:
|
|
159
|
+
--help Display this help message and exit.
|
|
160
|
+
--fix Adds/modifies file headers as necessary.
|
|
161
|
+
"""
|
|
162
|
+
print(help_message)
|
|
163
|
+
sys.exit(0)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
if __name__ == "__main__":
|
|
167
|
+
if "--help" in sys.argv:
|
|
168
|
+
display_help()
|
|
169
|
+
|
|
170
|
+
# Check if at least two arguments are provided and the first argument is not a flag
|
|
171
|
+
if len(sys.argv) < 2 or sys.argv[1].startswith("--"):
|
|
172
|
+
print("Usage: python verify_headers.py SRC [OPTIONS] ...")
|
|
173
|
+
sys.exit(1)
|
|
174
|
+
|
|
175
|
+
skip_files = ["qbraid_core/_version.py"]
|
|
176
|
+
script_directory = os.path.dirname(os.path.abspath(__file__))
|
|
177
|
+
project_directory = os.path.abspath(os.path.join(script_directory, ".."))
|
|
178
|
+
skip_files = [os.path.join(project_directory, file_path) for file_path in skip_files]
|
|
179
|
+
|
|
180
|
+
fix = "--fix" in sys.argv
|
|
181
|
+
files_and_dirs = [arg for arg in sys.argv[1:] if arg != "--fix"]
|
|
182
|
+
verify_headers(files_and_dirs, fix=fix, skip_files=skip_files)
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2024, qBraid Development Team
|
|
2
|
-
# All rights reserved.
|
|
3
|
-
|
|
4
|
-
# pylint: skip-file
|
|
5
|
-
|
|
6
|
-
"""
|
|
7
|
-
Script to verify qBraid copyright file headers
|
|
8
|
-
|
|
9
|
-
"""
|
|
10
|
-
import os
|
|
11
|
-
import sys
|
|
12
|
-
|
|
13
|
-
# ANSI escape codes
|
|
14
|
-
BLUE = "\033[94m"
|
|
15
|
-
BOLD = "\033[1m"
|
|
16
|
-
RESET = "\033[0m"
|
|
17
|
-
|
|
18
|
-
header = """# Copyright (c) 2024, qBraid Development Team
|
|
19
|
-
# All rights reserved.
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
header_gpl = """# Copyright (C) 2024 qBraid
|
|
23
|
-
#
|
|
24
|
-
# This file is part of the qBraid-SDK
|
|
25
|
-
#
|
|
26
|
-
# The qBraid-SDK is free software released under the GNU General Public License v3
|
|
27
|
-
# or later. You can redistribute and/or modify it under the terms of the GPL v3.
|
|
28
|
-
# See the LICENSE file in the project root or <https://www.gnu.org/licenses/gpl-3.0.html>.
|
|
29
|
-
#
|
|
30
|
-
# THERE IS NO WARRANTY for the qBraid-SDK, as per Section 15 of the GPL v3.
|
|
31
|
-
"""
|
|
32
|
-
|
|
33
|
-
header_2023 = header.replace("2024", "2023")
|
|
34
|
-
header_gpl_2023 = header_gpl.replace("2024", "2023")
|
|
35
|
-
|
|
36
|
-
skip_files = ["qbraid_core/_version.py"]
|
|
37
|
-
|
|
38
|
-
failed_headers = []
|
|
39
|
-
fixed_headers = []
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def should_skip(file_path: str, content: str) -> bool:
|
|
43
|
-
if file_path in skip_files:
|
|
44
|
-
return True
|
|
45
|
-
|
|
46
|
-
if os.path.basename(file_path) == "__init__.py":
|
|
47
|
-
return not content.strip()
|
|
48
|
-
|
|
49
|
-
skip_header_tag = "# qbraid: skip-header"
|
|
50
|
-
line_number = 0
|
|
51
|
-
|
|
52
|
-
for line in content.splitlines():
|
|
53
|
-
line_number += 1
|
|
54
|
-
if 5 <= line_number <= 30 and skip_header_tag in line:
|
|
55
|
-
return True
|
|
56
|
-
if line_number > 30:
|
|
57
|
-
break
|
|
58
|
-
|
|
59
|
-
return False
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def replace_or_add_header(file_path: str, fix: bool = False) -> None:
|
|
63
|
-
with open(file_path, "r", encoding="ISO-8859-1") as f:
|
|
64
|
-
content = f.read()
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
content.startswith(header)
|
|
68
|
-
or content.startswith(header_2023)
|
|
69
|
-
or content.startswith(header_gpl)
|
|
70
|
-
or content.startswith(header_gpl_2023)
|
|
71
|
-
or should_skip(file_path, content)
|
|
72
|
-
):
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
if not fix:
|
|
76
|
-
failed_headers.append(file_path)
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
lines = content.splitlines()
|
|
80
|
-
|
|
81
|
-
comment_lines = []
|
|
82
|
-
first_skipped_line = None
|
|
83
|
-
for index, line in enumerate(lines):
|
|
84
|
-
if line.startswith("#"):
|
|
85
|
-
comment_lines.append(line)
|
|
86
|
-
else:
|
|
87
|
-
first_skipped_line = index
|
|
88
|
-
break
|
|
89
|
-
|
|
90
|
-
new_content_lines = [header.rstrip("\r\n")] + lines[first_skipped_line:]
|
|
91
|
-
new_content = "\n".join(new_content_lines) + "\n"
|
|
92
|
-
|
|
93
|
-
with open(file_path, "w", encoding="ISO-8859-1") as f:
|
|
94
|
-
f.write(new_content)
|
|
95
|
-
|
|
96
|
-
fixed_headers.append(file_path)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
def process_files_in_directory(directory: str, fix: bool = False) -> int:
|
|
100
|
-
count = 0
|
|
101
|
-
for root, _, files in os.walk(directory):
|
|
102
|
-
for file in files:
|
|
103
|
-
if file.endswith(".py"):
|
|
104
|
-
file_path = os.path.join(root, file)
|
|
105
|
-
replace_or_add_header(file_path, fix)
|
|
106
|
-
count += 1
|
|
107
|
-
return count
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
def display_help() -> None:
|
|
111
|
-
help_message = """
|
|
112
|
-
Usage: python verify_headers.py SRC [OPTIONS] ...
|
|
113
|
-
|
|
114
|
-
This script checks for copyright headers at the specified path.
|
|
115
|
-
If no flags are passed, it will indicate which files would be
|
|
116
|
-
modified without actually making any changes.
|
|
117
|
-
|
|
118
|
-
Options:
|
|
119
|
-
--help Display this help message and exit.
|
|
120
|
-
--fix Adds/modifies file headers as necessary.
|
|
121
|
-
"""
|
|
122
|
-
print(help_message)
|
|
123
|
-
sys.exit(0)
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if __name__ == "__main__":
|
|
127
|
-
if "--help" in sys.argv:
|
|
128
|
-
display_help()
|
|
129
|
-
|
|
130
|
-
# Check if at least two arguments are provided and the first argument is not a flag
|
|
131
|
-
if len(sys.argv) < 2 or sys.argv[1].startswith("--"):
|
|
132
|
-
print("Usage: python verify_headers.py SRC [OPTIONS] ...")
|
|
133
|
-
sys.exit(1)
|
|
134
|
-
|
|
135
|
-
script_directory = os.path.dirname(os.path.abspath(__file__))
|
|
136
|
-
project_directory = os.path.abspath(os.path.join(script_directory, ".."))
|
|
137
|
-
skip_files = [os.path.join(project_directory, file_path) for file_path in skip_files]
|
|
138
|
-
|
|
139
|
-
fix = "--fix" in sys.argv
|
|
140
|
-
files_and_dirs = [arg for arg in sys.argv[1:] if arg != "--fix"]
|
|
141
|
-
|
|
142
|
-
checked = 0
|
|
143
|
-
for item in files_and_dirs:
|
|
144
|
-
full_path = os.path.join(project_directory, item)
|
|
145
|
-
if os.path.isdir(full_path):
|
|
146
|
-
checked += process_files_in_directory(full_path, fix)
|
|
147
|
-
elif os.path.isfile(full_path) and full_path.endswith(".py"):
|
|
148
|
-
replace_or_add_header(full_path, fix)
|
|
149
|
-
checked += 1
|
|
150
|
-
else:
|
|
151
|
-
failed_headers.append(full_path)
|
|
152
|
-
print(f"Directory not found: {full_path}")
|
|
153
|
-
|
|
154
|
-
if not fix:
|
|
155
|
-
if failed_headers:
|
|
156
|
-
for file in failed_headers:
|
|
157
|
-
print(f"failed {os.path.relpath(file)}")
|
|
158
|
-
num_failed = len(failed_headers)
|
|
159
|
-
s1, s2 = ("", "s") if num_failed == 1 else ("s", "")
|
|
160
|
-
sys.stderr.write(f"\n{num_failed} file header{s1} need{s2} updating.\n")
|
|
161
|
-
sys.exit(1)
|
|
162
|
-
else:
|
|
163
|
-
print("All file header checks passed!")
|
|
164
|
-
|
|
165
|
-
else:
|
|
166
|
-
for file in fixed_headers:
|
|
167
|
-
print(f"fixed {os.path.relpath(file)}")
|
|
168
|
-
num_fixed = len(fixed_headers)
|
|
169
|
-
num_ok = checked - num_fixed
|
|
170
|
-
s_fixed = "" if num_fixed == 1 else "s"
|
|
171
|
-
s_ok = "" if num_ok == 1 else "s"
|
|
172
|
-
print("\nAll done! ✨ 🚀 ✨")
|
|
173
|
-
print(f"{num_fixed} header{s_fixed} fixed, {num_ok} header{s_ok} left unchanged.")
|
|
File without changes
|
{qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/.github/ISSUE_TEMPLATE/feature_request.yml
RENAMED
|
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
|
{qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/environments/__init__.py
RENAMED
|
File without changes
|
{qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/environments/client.py
RENAMED
|
File without changes
|
{qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/environments/exceptions.py
RENAMED
|
File without changes
|
{qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/environments/validate.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{qbraid-core-0.1.0.dev3 → qbraid-core-0.1.0.dev4}/qbraid_core/services/quantum/exceptions.py
RENAMED
|
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
|