qbraid-cli 0.8.1__py3-none-any.whl → 0.8.1a0__py3-none-any.whl

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/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.8.1'
15
+ __version__ = version = '0.8.1a0'
16
16
  __version_tuple__ = version_tuple = (0, 8, 1)
@@ -7,5 +7,3 @@ Module defining the qbraid admin namespace
7
7
  """
8
8
 
9
9
  from .app import admin_app
10
-
11
- __all__ = ["admin_app"]
qbraid_cli/admin/app.py CHANGED
@@ -3,20 +3,21 @@
3
3
 
4
4
  """
5
5
  Module defining commands in the 'qbraid admin' namespace.
6
+
6
7
  """
7
8
 
8
9
  from typing import List
9
10
 
10
11
  import typer
11
12
 
12
- from qbraid_cli.admin.buildlogs import buildlogs_app
13
13
  from qbraid_cli.admin.headers import check_and_fix_headers
14
14
  from qbraid_cli.admin.validation import validate_header_type, validate_paths_exist
15
15
 
16
+ # disable pretty_exceptions_show_locals to avoid printing sensative information in the traceback
16
17
  admin_app = typer.Typer(
17
- help="CI/CD commands for qBraid maintainers.", pretty_exceptions_show_locals=False
18
+ help="CI/CD commands for qBraid maintainers.",
19
+ pretty_exceptions_show_locals=False,
18
20
  )
19
- admin_app.add_typer(buildlogs_app, name="buildlogs")
20
21
 
21
22
 
22
23
  @admin_app.command(name="headers")
@@ -7,5 +7,3 @@ Module defining the qbraid configure namespace
7
7
  """
8
8
 
9
9
  from .app import configure_app
10
-
11
- __all__ = ["configure_app"]
@@ -7,5 +7,3 @@ Module defining the qbraid credits namespace
7
7
  """
8
8
 
9
9
  from .app import credits_app
10
-
11
- __all__ = ["credits_app"]
@@ -7,5 +7,3 @@ Module defining the qbraid devices namespace
7
7
  """
8
8
 
9
9
  from .app import devices_app
10
-
11
- __all__ = ["devices_app"]
@@ -7,5 +7,3 @@ Module defining the qbraid envs namespace
7
7
  """
8
8
 
9
9
  from .app import envs_app
10
-
11
- __all__ = ["envs_app"]
qbraid_cli/envs/app.py CHANGED
@@ -10,19 +10,14 @@ import shutil
10
10
  import subprocess
11
11
  import sys
12
12
  from pathlib import Path
13
- from typing import TYPE_CHECKING, Optional, Tuple
13
+ from typing import Any, Dict, Optional, Tuple
14
14
 
15
15
  import typer
16
16
  from rich.console import Console
17
17
 
18
- from qbraid_cli.envs.create import create_qbraid_env_assets, create_venv
19
- from qbraid_cli.envs.data_handling import get_envs_data as installed_envs_data
20
- from qbraid_cli.envs.data_handling import validate_env_name
18
+ from qbraid_cli.envs.data_handling import installed_envs_data, request_delete_env, validate_env_name
21
19
  from qbraid_cli.handlers import QbraidException, run_progress_task
22
20
 
23
- if TYPE_CHECKING:
24
- from qbraid_core.services.environments.client import EnvironmentManagerClient as EMC
25
-
26
21
  envs_app = typer.Typer(help="Manage qBraid environments.")
27
22
 
28
23
 
@@ -39,14 +34,25 @@ def envs_create( # pylint: disable=too-many-statements
39
34
  ),
40
35
  ) -> None:
41
36
  """Create a new qBraid environment."""
42
- env_description = description or ""
37
+ from .create import create_qbraid_env_assets, create_venv
38
+
39
+ def request_new_env(req_body: Dict[str, str]) -> Dict[str, Any]:
40
+ """Send request to create new environment and return the slug."""
41
+ from qbraid_core import QbraidSession, RequestsApiError
42
+
43
+ session = QbraidSession()
44
+
45
+ try:
46
+ env_data = session.post("/environments/create", json=req_body).json()
47
+ except RequestsApiError as err:
48
+ raise QbraidException("Create environment request failed") from err
43
49
 
44
- def create_environment(*args, **kwargs) -> "Tuple[dict, EMC]":
45
- """Create a qBraid environment."""
46
- from qbraid_core.services.environments.client import EnvironmentManagerClient
50
+ if env_data is None or len(env_data) == 0 or env_data.get("slug") is None:
51
+ raise QbraidException(
52
+ "Create environment request responsed with invalid environment data"
53
+ )
47
54
 
48
- client = EnvironmentManagerClient()
49
- return client.create_environment(*args, **kwargs), client
55
+ return env_data
50
56
 
51
57
  def gather_local_data() -> Tuple[Path, str]:
52
58
  """Gather environment data and return the slug."""
@@ -65,10 +71,20 @@ def envs_create( # pylint: disable=too-many-statements
65
71
 
66
72
  return env_path, python_version
67
73
 
68
- environment, emc = run_progress_task(
69
- create_environment,
70
- name,
71
- env_description,
74
+ req_body = {
75
+ "name": name,
76
+ "description": description or "",
77
+ "tags": "", # comma separated list of tags
78
+ "code": "", # newline separated list of packages
79
+ "visibility": "private",
80
+ "kernelName": "",
81
+ "prompt": "",
82
+ "origin": "CLI",
83
+ }
84
+
85
+ environment = run_progress_task(
86
+ request_new_env,
87
+ req_body,
72
88
  description="Validating request...",
73
89
  error_message="Failed to create qBraid environment",
74
90
  )
@@ -78,6 +94,7 @@ def envs_create( # pylint: disable=too-many-statements
78
94
  description="Solving environment...",
79
95
  error_message="Failed to create qBraid environment",
80
96
  )
97
+
81
98
  slug = environment.get("slug")
82
99
  display_name = environment.get("displayName")
83
100
  prompt = environment.get("prompt")
@@ -103,7 +120,7 @@ def envs_create( # pylint: disable=too-many-statements
103
120
  user_confirmation = auto_confirm or typer.confirm("Proceed", default=True)
104
121
  typer.echo("")
105
122
  if not user_confirmation:
106
- emc.delete_environment(slug)
123
+ request_delete_env(slug)
107
124
  typer.echo("qBraidSystemExit: Exiting.")
108
125
  raise typer.Exit()
109
126
 
@@ -148,13 +165,6 @@ def envs_remove(
148
165
  ) -> None:
149
166
  """Delete a qBraid environment."""
150
167
 
151
- def delete_environment(slug: str) -> None:
152
- """Delete a qBraid environment."""
153
- from qbraid_core.services.environments.client import EnvironmentManagerClient
154
-
155
- emc = EnvironmentManagerClient()
156
- emc.delete_environment(slug)
157
-
158
168
  def gather_local_data(env_name: str) -> Tuple[Path, str]:
159
169
  """Get environment path and slug from name (alias)."""
160
170
  installed, aliases = installed_envs_data()
@@ -180,7 +190,7 @@ def envs_remove(
180
190
  if auto_confirm or typer.confirm(confirmation_message, abort=True):
181
191
  typer.echo("")
182
192
  run_progress_task(
183
- delete_environment,
193
+ request_delete_env,
184
194
  slug,
185
195
  description="Deleting remote environment data...",
186
196
  error_message="Failed to delete qBraid environment",
qbraid_cli/envs/create.py CHANGED
@@ -5,29 +5,93 @@
5
5
  Module supporting 'qbraid envs create' command.
6
6
 
7
7
  """
8
+
8
9
  import json
9
10
  import os
10
11
  import shutil
12
+ import subprocess
11
13
  import sys
14
+ from typing import Optional
15
+
16
+
17
+ def replace_str(target: str, replacement: str, file_path: str) -> None:
18
+ """Replace all instances of string in file"""
19
+ with open(file_path, "r", encoding="utf-8") as file:
20
+ content = file.read()
21
+
22
+ content = content.replace(target, replacement)
23
+
24
+ with open(file_path, "w", encoding="utf-8") as file:
25
+ file.write(content)
26
+
27
+
28
+ def update_state_json(
29
+ slug_path: str,
30
+ install_complete: int,
31
+ install_success: int,
32
+ message: Optional[str] = None,
33
+ env_name: Optional[str] = None,
34
+ ) -> None:
35
+ """Update environment's install status values in a JSON file.
36
+ Truth table values: 0 = False, 1 = True, -1 = Unknown
37
+ """
38
+ # Set default message if none provided
39
+ message = "" if message is None else message.replace("\n", " ")
40
+
41
+ # File path for state.json
42
+ state_json_path = os.path.join(slug_path, "state.json")
12
43
 
44
+ # Read existing data or use default structure
45
+ if os.path.exists(state_json_path):
46
+ with open(state_json_path, "r", encoding="utf-8") as f:
47
+ data = json.load(f)
48
+ else:
49
+ data = {"install": {}}
50
+
51
+ # Update the data
52
+ data["install"]["complete"] = install_complete
53
+ data["install"]["success"] = install_success
54
+ data["install"]["message"] = message
55
+
56
+ if env_name is not None:
57
+ data["name"] = env_name
58
+
59
+ # Write updated data back to state.json
60
+ with open(state_json_path, "w", encoding="utf-8") as f:
61
+ json.dump(data, f, indent=4)
13
62
 
14
- def create_venv(*args, **kwargs) -> None:
15
- """Create a python virtual environment for the qBraid environment."""
16
- from qbraid_core.services.environments import create_local_venv
17
63
 
18
- return create_local_venv(*args, **kwargs)
64
+ def create_venv(slug_path: str, prompt: str) -> None:
65
+ """Create virtual environment and swap PS1 display name."""
66
+ venv_path = os.path.join(slug_path, "pyenv")
67
+ subprocess.run([sys.executable, "-m", "venv", venv_path], check=True)
19
68
 
69
+ # Determine the correct directory for activation scripts based on the operating system
70
+ if sys.platform == "win32":
71
+ scripts_path = os.path.join(venv_path, "Scripts")
72
+ activate_files = ["activate.bat", "Activate.ps1"]
73
+ else:
74
+ scripts_path = os.path.join(venv_path, "bin")
75
+ activate_files = ["activate", "activate.csh", "activate.fish"]
20
76
 
21
- def update_state_json(*ags, **kwargs) -> None:
22
- """Update the state.json file for the qBraid environment."""
23
- from qbraid_core.services.environments.state import update_install_status
77
+ for file in activate_files:
78
+ file_path = os.path.join(scripts_path, file)
79
+ if os.path.isfile(file_path):
80
+ replace_str("(pyenv)", f"({prompt})", file_path)
24
81
 
25
- return update_install_status(*ags, **kwargs)
82
+ replace_str(
83
+ "include-system-site-packages = false",
84
+ "include-system-site-packages = true",
85
+ os.path.join(venv_path, "pyvenv.cfg"),
86
+ )
87
+
88
+ update_state_json(slug_path, 1, 1)
26
89
 
27
90
 
28
91
  def create_qbraid_env_assets(slug: str, alias: str, kernel_name: str, slug_path: str) -> None:
29
92
  """Create a qBraid environment including python venv, PS1 configs,
30
93
  kernel resource files, and qBraid state.json."""
94
+ # pylint: disable-next=import-outside-toplevel
31
95
  from jupyter_client.kernelspec import KernelSpecManager
32
96
 
33
97
  local_resource_dir = os.path.join(slug_path, "kernels", f"python3_{slug}")
@@ -59,3 +123,6 @@ def create_qbraid_env_assets(slug: str, alias: str, kernel_name: str, slug_path:
59
123
  loc_path = os.path.join(local_resource_dir, file)
60
124
  if os.path.isfile(sys_path):
61
125
  shutil.copy(sys_path, loc_path)
126
+
127
+ # create python venv
128
+ create_venv(slug_path, alias)
@@ -6,23 +6,85 @@ Module for handling data related to qBraid environments.
6
6
 
7
7
  """
8
8
 
9
+ import json
10
+ import keyword
11
+ import re
12
+ from pathlib import Path
13
+ from typing import Dict, List, Tuple
14
+
9
15
  import typer
10
16
 
11
17
  from qbraid_cli.handlers import QbraidException
12
18
 
13
19
 
14
- def get_envs_data(*args, **kwargs) -> dict:
15
- """Get data for installed environments."""
16
- from qbraid_core.services.environments.paths import installed_envs_data
17
-
18
- return installed_envs_data(*args, **kwargs)
19
-
20
-
21
- def is_valid_env_name(value: str) -> bool:
22
- """Check if a given string is a valid Python environment name."""
23
- from qbraid_core.services.environments.validate import is_valid_env_name as is_valid
24
-
25
- return is_valid(value)
20
+ def is_valid_env_name(env_name: str) -> bool: # pylint: disable=too-many-return-statements
21
+ """
22
+ Validates a Python virtual environment name against best practices.
23
+
24
+ This function checks if the given environment name is valid based on certain
25
+ criteria, including length, use of special characters, reserved names, and
26
+ operating system-specific restrictions.
27
+
28
+ Args:
29
+ env_name (str): The name of the Python virtual environment to validate.
30
+
31
+ Returns:
32
+ bool: True if the name is valid, False otherwise.
33
+
34
+ Raises:
35
+ ValueError: If the environment name is not a string or is empty.
36
+ """
37
+ # Basic checks for empty names or purely whitespace names
38
+ if not env_name or env_name.isspace():
39
+ return False
40
+
41
+ # Check for invalid characters, including shell metacharacters and spaces
42
+ if re.search(r'[<>:"/\\|?*\s&;()$[\]#~!{}]', env_name):
43
+ return False
44
+
45
+ if env_name.startswith("tmp"):
46
+ return False
47
+
48
+ # Reserved names for Windows (example list, can be expanded)
49
+ reserved_names = [
50
+ "CON",
51
+ "PRN",
52
+ "AUX",
53
+ "NUL",
54
+ "COM1",
55
+ "COM2",
56
+ "COM3",
57
+ "COM4",
58
+ "COM5",
59
+ "COM6",
60
+ "COM7",
61
+ "COM8",
62
+ "COM9",
63
+ "LPT1",
64
+ "LPT2",
65
+ "LPT3",
66
+ "LPT4",
67
+ "LPT5",
68
+ "LPT6",
69
+ "LPT7",
70
+ "LPT8",
71
+ "LPT9",
72
+ ]
73
+ if env_name.upper() in reserved_names:
74
+ return False
75
+
76
+ if len(env_name) > 20:
77
+ return False
78
+
79
+ # Check against Python reserved words
80
+ if keyword.iskeyword(env_name):
81
+ return False
82
+
83
+ # Check if it starts with a number, which is not a good practice
84
+ if env_name[0].isdigit():
85
+ return False
86
+
87
+ return True
26
88
 
27
89
 
28
90
  def validate_env_name(value: str) -> str:
@@ -34,6 +96,38 @@ def validate_env_name(value: str) -> str:
34
96
  return value
35
97
 
36
98
 
99
+ def installed_envs_data() -> Tuple[Dict[str, Path], Dict[str, str]]:
100
+ """Gather paths and aliases for all installed qBraid environments."""
101
+ from qbraid_core.services.environments.paths import get_default_envs_paths, is_valid_slug
102
+
103
+ installed = {}
104
+ aliases = {}
105
+
106
+ qbraid_env_paths: List[Path] = get_default_envs_paths()
107
+
108
+ for env_path in qbraid_env_paths:
109
+ for entry in env_path.iterdir():
110
+ if entry.is_dir() and is_valid_slug(entry.name):
111
+ installed[entry.name] = entry
112
+
113
+ if entry.name == "qbraid_000000":
114
+ aliases["default"] = entry.name
115
+ continue
116
+
117
+ state_json_path = entry / "state.json"
118
+ if state_json_path.exists():
119
+ try:
120
+ with open(state_json_path, "r", encoding="utf-8") as f:
121
+ data = json.load(f)
122
+ aliases[data.get("name", entry.name[:-7])] = entry.name
123
+ # pylint: disable-next=broad-exception-caught
124
+ except (json.JSONDecodeError, Exception):
125
+ aliases[entry.name[:-7]] = entry.name
126
+ else:
127
+ aliases[entry.name[:-7]] = entry.name
128
+ return installed, aliases
129
+
130
+
37
131
  def request_delete_env(slug: str) -> str:
38
132
  """Send request to delete environment given slug."""
39
133
  from qbraid_core import QbraidSession, RequestsApiError
@@ -7,5 +7,3 @@ Module defining the qbraid jobs namespace
7
7
  """
8
8
 
9
9
  from .app import jobs_app
10
-
11
- __all__ = ["jobs_app"]
@@ -7,5 +7,3 @@ Module defining the qbraid kernels namespace
7
7
  """
8
8
 
9
9
  from .app import kernels_app
10
-
11
- __all__ = ["kernels_app"]
qbraid_cli/kernels/app.py CHANGED
@@ -12,6 +12,7 @@ import typer
12
12
  from jupyter_client.kernelspec import KernelSpecManager
13
13
  from rich.console import Console
14
14
 
15
+ from qbraid_cli.envs.data_handling import installed_envs_data
15
16
  from qbraid_cli.handlers import handle_error
16
17
 
17
18
  kernels_app = typer.Typer(help="Manage qBraid kernels.")
@@ -19,9 +20,6 @@ kernels_app = typer.Typer(help="Manage qBraid kernels.")
19
20
 
20
21
  def _get_kernels_path(environment: str) -> Path:
21
22
  """Get the path to the kernels directory for the given environment."""
22
- # pylint: disable-next=import-outside-toplevel
23
- from qbraid_core.services.environments.paths import installed_envs_data
24
-
25
23
  slug_to_path, name_to_slug = installed_envs_data()
26
24
 
27
25
  if environment in name_to_slug:
qbraid_cli/main.py CHANGED
@@ -15,7 +15,6 @@ from qbraid_cli.devices.app import devices_app
15
15
  from qbraid_cli.envs.app import envs_app
16
16
  from qbraid_cli.jobs.app import jobs_app
17
17
  from qbraid_cli.kernels.app import kernels_app
18
- from qbraid_cli.pip.app import pip_app
19
18
 
20
19
  app = typer.Typer(context_settings={"help_option_names": ["-h", "--help"]})
21
20
 
@@ -26,7 +25,6 @@ app.add_typer(devices_app, name="devices")
26
25
  app.add_typer(envs_app, name="envs")
27
26
  app.add_typer(jobs_app, name="jobs")
28
27
  app.add_typer(kernels_app, name="kernels")
29
- app.add_typer(pip_app, name="pip")
30
28
 
31
29
 
32
30
  def version_callback(value: bool):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qbraid-cli
3
- Version: 0.8.1
3
+ Version: 0.8.1a0
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
@@ -26,17 +26,24 @@ Classifier: Programming Language :: Python :: 3.11
26
26
  Classifier: Programming Language :: Python :: 3.12
27
27
  Requires-Python: >=3.9
28
28
  Description-Content-Type: text/markdown
29
- License-File: LICENSE
30
29
  Requires-Dist: typer >=0.12.1
31
30
  Requires-Dist: rich >=10.11.0
32
31
  Requires-Dist: jupyter-client <9.0.0,>=7.0.0
33
32
  Requires-Dist: ipykernel
34
- Requires-Dist: qbraid-core >=0.1.10
33
+ Requires-Dist: qbraid-core >=0.1.4
35
34
  Provides-Extra: dev
36
- Requires-Dist: ruff ; extra == 'dev'
37
- Requires-Dist: isort ; extra == 'dev'
38
35
  Requires-Dist: black ; extra == 'dev'
36
+ Requires-Dist: isort ; extra == 'dev'
37
+ Requires-Dist: pylint ; extra == 'dev'
39
38
  Requires-Dist: pytest ; extra == 'dev'
39
+ Provides-Extra: docs
40
+ Requires-Dist: sphinx <7.4.0,>=7.2.6 ; extra == 'docs'
41
+ Requires-Dist: sphinx-rtd-theme <2.1,>=1.3 ; extra == 'docs'
42
+ Requires-Dist: docutils <0.22 ; extra == 'docs'
43
+ Requires-Dist: toml ; extra == 'docs'
44
+ Requires-Dist: build ; extra == 'docs'
45
+ Requires-Dist: m2r ; extra == 'docs'
46
+ Requires-Dist: typer ; extra == 'docs'
40
47
  Provides-Extra: jobs
41
48
  Requires-Dist: amazon-braket-sdk >=1.48.1 ; extra == 'jobs'
42
49
 
@@ -47,6 +54,7 @@ Requires-Dist: amazon-braket-sdk >=1.48.1 ; extra == 'jobs'
47
54
  [![Python verions](https://img.shields.io/pypi/pyversions/qbraid-cli.svg?color=blue)](https://pypi.org/project/qbraid-cli/)
48
55
  [![Downloads](https://static.pepy.tech/badge/qbraid-cli)](https://pepy.tech/project/qbraid-cli)
49
56
  [![GitHub](https://img.shields.io/badge/issue_tracking-github-blue?logo=github)](https://github.com/qBraid/qBraid-Lab/issues)
57
+ [![Discord](https://img.shields.io/discord/771898982564626445.svg?color=pink)](https://discord.gg/KugF6Cnncm)
50
58
 
51
59
  Command Line Interface for interacting with all parts of the qBraid platform.
52
60
 
@@ -63,7 +71,7 @@ For help, see qBraid Lab User Guide: [Getting Started](https://docs.qbraid.com/p
63
71
 
64
72
  You can also install the qBraid-CLI from PyPI with:
65
73
 
66
- ```bash
74
+ ```shell
67
75
  pip install qbraid-cli
68
76
  ```
69
77
 
@@ -77,13 +85,13 @@ After installation, you must configure your account credentials to use the CLI l
77
85
  your [account page](https://account.qbraid.com/):
78
86
  3. Save your API key from step 2 in local configuration file `~/.qbraid/qbraidrc` using:
79
87
 
80
- ```bash
88
+ ```shell
81
89
  $ qbraid configure
82
90
  ```
83
91
 
84
92
  ## Basic Commands
85
93
 
86
- ```bash
94
+ ```shell
87
95
  $ qbraid
88
96
  ----------------------------------
89
97
  * Welcome to the qBraid CLI! *
@@ -106,19 +114,19 @@ Reference Docs: https://docs.qbraid.com/projects/cli/en/stable/guide/overview.ht
106
114
 
107
115
  A qBraid CLI command has the following structure:
108
116
 
109
- ```bash
117
+ ```shell
110
118
  $ qbraid <command> <subcommand> [options and parameters]
111
119
  ```
112
120
 
113
121
  For example, to list installed environments, the command would be:
114
122
 
115
- ```bash
123
+ ```shell
116
124
  $ qbraid envs list
117
125
  ```
118
126
 
119
127
  To view help documentation, use one of the following:
120
128
 
121
- ```bash
129
+ ```shell
122
130
  $ qbraid --help
123
131
  $ qbraid <command> --help
124
132
  $ qbraid <command> <subcommand> --help
@@ -126,7 +134,7 @@ $ qbraid <command> <subcommand> --help
126
134
 
127
135
  For example:
128
136
 
129
- ```bash
137
+ ```shell
130
138
  $ qbraid --help
131
139
 
132
140
  Usage: qbraid [OPTIONS] COMMAND [ARGS]...
@@ -150,7 +158,7 @@ Commands
150
158
 
151
159
  To get the version of the qBraid CLI:
152
160
 
153
- ```bash
161
+ ```shell
154
162
  $ qbraid --version
155
163
  ```
156
164
 
@@ -158,7 +166,7 @@ $ qbraid --version
158
166
 
159
167
  You can also access the CLI directly from within [Notebooks](https://docs.qbraid.com/projects/lab/en/latest/lab/notebooks.html) using IPython [magic commands](https://ipython.readthedocs.io/en/stable/interactive/magics.html). First, configure the qBraid magic commands extension using:
160
168
 
161
- ```bash
169
+ ```shell
162
170
  $ qbraid configure magic
163
171
  ```
164
172
 
@@ -0,0 +1,33 @@
1
+ qbraid_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ qbraid_cli/_version.py,sha256=uh6qRUKYp5CUuk-ID8cyEoLnsVpY7iGTUwo68466d6k,413
3
+ qbraid_cli/exceptions.py,sha256=KjlhYJhSHMVazaNiBjD_Ur06w4sekP8zRsFzBdyIpno,672
4
+ qbraid_cli/handlers.py,sha256=glxTEwxax3zKgYl9qsZ2evZXgrWQrseJS_OGyHTMFeA,7040
5
+ qbraid_cli/main.py,sha256=R26PkxijuuCzcW_PVREHb11oNlNN2rWDcRY7BmiDV0Q,2564
6
+ qbraid_cli/admin/__init__.py,sha256=Suo_L1_yBodCvLM_fpw8gRIhD4mVVOXKObtxeoMaBVo,150
7
+ qbraid_cli/admin/app.py,sha256=__6lo-iFsbfz-ayD1-AS8X1z_gYhCad1NK17hnrL7HY,1451
8
+ qbraid_cli/admin/headers.py,sha256=E6mE3odZL57VfHHZxYtRUkqMKmrmT4zuUoINzI7eJF8,6435
9
+ qbraid_cli/admin/validation.py,sha256=LkAVXlHtM0MhCa34MIWrfX59wGXMVlZmdVB4-AQ8fBk,1003
10
+ qbraid_cli/configure/__init__.py,sha256=6GU7vR6JYRGcMsmdrpFbwLO5VSUmnLgwSbtmGWMQND4,158
11
+ qbraid_cli/configure/actions.py,sha256=3rrWHaCAsogyx0Ll-lcjbSzldD4kPuz1z6VQiWebSWw,3203
12
+ qbraid_cli/configure/app.py,sha256=1uRe2lkUA4TtYb5b4mbD4LH-cKCbsZGT3Wfk7fpNzX0,2414
13
+ qbraid_cli/credits/__init__.py,sha256=t-3XAJFAXiu_jI4sgjaIOuNne_AoSYaSEsi-SSRkvPw,154
14
+ qbraid_cli/credits/app.py,sha256=AY3qtveO50KeQ2XREiEVqUcTrESgRuoqt9pt2Z8t4Y0,866
15
+ qbraid_cli/devices/__init__.py,sha256=_PU3eMQRV4DkPw-oCmfCPh8EbVmgG76ieEKuNsY9Xqc,154
16
+ qbraid_cli/devices/app.py,sha256=zxSxrEQn7irkJoME4S_CBnRqWeB8cqPaBsIMfpdYFk0,2530
17
+ qbraid_cli/devices/validation.py,sha256=YhShyUufgrKnx2XjXOXF-PqFJYklJT9CgeqIwKcNam4,809
18
+ qbraid_cli/envs/__init__.py,sha256=YgIoMWxfGqzmwfypO5JHYuCOu6BfFwb9NHgQel1IJM8,148
19
+ qbraid_cli/envs/activate.py,sha256=VpvVYSfQDlcmlNWJOgkLIQ2p8YXPPLG8Jbl5t8GHUDw,2140
20
+ qbraid_cli/envs/app.py,sha256=t6bRwJGy-M3PAu870ZsttsM8tpSB0OFasgCJiV9nTSA,8620
21
+ qbraid_cli/envs/create.py,sha256=uCRex_TcFYw26jUOU06Ta5I8Mq5pRqLVaOE6MxrrExs,4337
22
+ qbraid_cli/envs/data_handling.py,sha256=mTVzsj6KleeeYDKGhgD-IesF9KQQMSszKFSEo8Wrv9w,4001
23
+ qbraid_cli/jobs/__init__.py,sha256=bj9XmZ4JL8OtMMZbHIu-DPhpOMXGLSB-W1b0wO7wKro,148
24
+ qbraid_cli/jobs/app.py,sha256=kmg9mYla3Nd7EdjQlFu7IOvm7sejLNfPPA6Qeet-IfE,4898
25
+ qbraid_cli/jobs/toggle_braket.py,sha256=d5C_Di80jWMFlh-77eH8YY9pjMKWXK5abenUDtPlE_I,6662
26
+ qbraid_cli/jobs/validation.py,sha256=xNbjUggMhUs4wzkuRm4PuFPi_wrElYicUgYXLznHz3U,2983
27
+ qbraid_cli/kernels/__init__.py,sha256=VhpBota_v7OoiGxrPCqJU4XBVcolf81mbCYGSxXzVhc,154
28
+ qbraid_cli/kernels/app.py,sha256=ZJWVdKzCDfzGnA1pqp01vDbE7fh8p84jC-y6DDgWlxc,3373
29
+ qbraid_cli-0.8.1a0.dist-info/METADATA,sha256=KVpOOlMih6hukKoS6rXu6ybRv0oN9NWsU2zb5ilxJHE,7170
30
+ qbraid_cli-0.8.1a0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
31
+ qbraid_cli-0.8.1a0.dist-info/entry_points.txt,sha256=c5ZJ7NjbxhDqMpou9q5F03_b_KG34HzFDijIDmEIwgQ,47
32
+ qbraid_cli-0.8.1a0.dist-info/top_level.txt,sha256=LTYJgeYSCHo9Il8vZu0yIPuGdGyNaIw6iRy6BeoZo8o,11
33
+ qbraid_cli-0.8.1a0.dist-info/RECORD,,
@@ -1,114 +0,0 @@
1
- # Copyright (c) 2024, qBraid Development Team
2
- # All rights reserved.
3
-
4
- """
5
- Module defining commands in the 'qbraid admin buildlogs' namespace.
6
-
7
- This module uses the Typer library to create CLI commands for managing Docker builds and logs
8
- in an administrative context.
9
- """
10
-
11
- import json
12
-
13
- import typer
14
- from qbraid_core.exceptions import RequestsApiError
15
- from qbraid_core.services.admin.client import AdminClient
16
- from rich.console import Console
17
-
18
- from qbraid_cli.handlers import handle_error
19
-
20
- buildlogs_app = typer.Typer(
21
- help="Manage qBraid containerized services logs.", pretty_exceptions_show_locals=False
22
- )
23
- console = Console()
24
-
25
-
26
- @buildlogs_app.command(name="get")
27
- def get_docker_build_logs(
28
- build_id: str = typer.Option(None, "--build_id", "-b", help="Name of the build ID")
29
- ) -> None:
30
- """
31
- Fetches and displays Docker build logs for a specified build ID.
32
-
33
- Args:
34
- build_id (str, optional): The unique identifier for the Docker build.
35
-
36
- This function queries the administrative backend to retrieve and display build logs.
37
- If a build ID is provided, it will retrieve and display logs specific to that build ID.
38
- If build ID not provided, fetches all logs.
39
- """
40
- client = AdminClient()
41
-
42
- build_log = client.get_docker_build_logs(build_id)
43
- if build_id and "buildLogs" in build_log and build_log["buildLogs"]:
44
- log_entry = build_log["buildLogs"][0]
45
- console.print(log_entry)
46
- else:
47
- console.print(build_log)
48
-
49
-
50
- @buildlogs_app.command(name="post")
51
- def post_docker_build_log(
52
- data: str = typer.Option(..., "--data", "-d", help="Data to post to Docker logs")
53
- ) -> None:
54
- """
55
- Posts a new Docker build log entry.
56
-
57
- Args:
58
- data (str): JSON string containing the data to be logged.
59
-
60
- This command converts a JSON string into a dictionary and sends it to the backend service
61
- to create a new Docker build log.
62
- """
63
- client = AdminClient()
64
-
65
- try:
66
- data_dict = json.loads(data)
67
- console.print(client.post_docker_build_logs(data_dict))
68
- except RequestsApiError:
69
- handle_error(message="Couldn't post a build_log.")
70
-
71
-
72
- @buildlogs_app.command(name="put")
73
- def put_docker_build_log(
74
- build_id: str = typer.Option(..., "--build_id", "-b", help="Name of the build ID"),
75
- data: str = typer.Option(..., "--data", "-d", help="Data to post to Docker logs"),
76
- ) -> None:
77
- """
78
- Updates an existing Docker build log entry by a given build ID.
79
-
80
- Args:
81
- build_id (str): The unique identifier of the Docker build to update.
82
- data (str): JSON string containing the updated data for the log.
83
-
84
- This command updates a Docker build log entry, identified by the provided build ID,
85
- with the new data provided in JSON format.
86
- """
87
- client = AdminClient()
88
-
89
- try:
90
- data_dict = json.loads(data)
91
- console.print(client.put_docker_build_logs(build_id, data_dict))
92
- except RequestsApiError:
93
- handle_error(message="Couldn't post a build_log.")
94
-
95
-
96
- @buildlogs_app.command(name="delete")
97
- def delete_docker_build_log(
98
- build_id: str = typer.Option(..., "--build_id", "-b", help="ID of the build log to delete")
99
- ) -> None:
100
- """
101
- Deletes a Docker build log entry by a specified build ID.
102
-
103
- Args:
104
- build_id (str): The unique identifier of the Docker build log to delete.
105
-
106
- This command sends a request to delete a Docker build log identified by the provided build ID.
107
- """
108
- client = AdminClient()
109
-
110
- console.print(client.delete_docker_build_logs(build_id))
111
-
112
-
113
- if __name__ == "__main__":
114
- buildlogs_app()
@@ -1,11 +0,0 @@
1
- # Copyright (c) 2024, qBraid Development Team
2
- # All rights reserved.
3
-
4
- """
5
- Module defining the qbraid pip namespace
6
-
7
- """
8
-
9
- from .app import pip_app
10
-
11
- __all__ = ["pip_app"]
qbraid_cli/pip/app.py DELETED
@@ -1,49 +0,0 @@
1
- # Copyright (c) 2024, qBraid Development Team
2
- # All rights reserved.
3
-
4
- """
5
- Module defining commands in the 'qbraid pip' namespace.
6
-
7
- """
8
- import subprocess
9
- import sys
10
-
11
- import typer
12
- from qbraid_core.system import QbraidSystemError, get_active_python_path
13
-
14
- from qbraid_cli.handlers import handle_error
15
- from qbraid_cli.pip.hooks import get_env_cfg_path, safe_set_include_sys_packages
16
-
17
- # disable pretty_exceptions_show_locals to avoid printing sensative information in the traceback
18
- pip_app = typer.Typer(help="Run pip command in active qBraid environment.")
19
-
20
-
21
- @pip_app.command(
22
- "install", context_settings={"allow_extra_args": True, "ignore_unknown_options": True}
23
- )
24
- def pip_install(ctx: typer.Context):
25
- """
26
- Perform pip install action with open-ended arguments and options.
27
-
28
- """
29
- try:
30
- python_exe = get_active_python_path()
31
- cfg_path = get_env_cfg_path(python_exe)
32
- except QbraidSystemError:
33
- python_exe = sys.executable
34
- cfg_path = None
35
-
36
- safe_set_include_sys_packages(False, cfg_path)
37
-
38
- command = [str(python_exe), "-m", "pip", "install"] + ctx.args
39
-
40
- try:
41
- subprocess.check_call(command)
42
- except (subprocess.CalledProcessError, FileNotFoundError):
43
- handle_error(message="Failed carry-out pip command.")
44
- finally:
45
- safe_set_include_sys_packages(True, cfg_path)
46
-
47
-
48
- if __name__ == "__main__":
49
- pip_app()
qbraid_cli/pip/hooks.py DELETED
@@ -1,73 +0,0 @@
1
- # Copyright (c) 2024, qBraid Development Team
2
- # All rights reserved.
3
-
4
- """
5
- Module defining pre- and post-command hooks for the 'qbraid pip' namespace.
6
-
7
- """
8
- import sys
9
- from pathlib import Path
10
- from typing import Optional, Union
11
-
12
- from qbraid_core.services.environments import get_default_envs_paths
13
- from qbraid_core.system.executables import python_paths_equivalent
14
- from qbraid_core.system.packages import (
15
- extract_include_sys_site_pkgs_value,
16
- set_include_sys_site_pkgs_value,
17
- )
18
-
19
-
20
- def safe_set_include_sys_packages(value: bool, file_path: Optional[Union[str, Path]]) -> None:
21
- """Set include-system-site-packages value safely"""
22
- if not file_path:
23
- return None
24
-
25
- try:
26
- set_include_sys_site_pkgs_value(value, file_path)
27
- except Exception: # pylint: disable=broad-exception-caught
28
- pass
29
-
30
- return None
31
-
32
-
33
- def find_matching_prefix(python_executable: Path, path_list: list[Path]) -> Optional[Path]:
34
- """
35
- Finds and returns the first path in the list that is a prefix of the Python executable path.
36
-
37
- Args:
38
- python_executable (Path): The path to the Python executable.
39
- path_list (List[Path]): A list of paths to check against the Python executable path.
40
-
41
- Returns:
42
- Optional[Path]: The first matching path that is a prefix of the Python executable path,
43
- or None if no match is found.
44
- """
45
- python_executable_str = str(python_executable.resolve())
46
- for path in path_list:
47
- if python_executable_str.startswith(str(path.resolve())):
48
- return path
49
- return None
50
-
51
-
52
- def get_env_cfg_path(python_exe: Path) -> Optional[Path]:
53
- """Get the path to the pyvenv.cfg file."""
54
- is_sys_python = python_paths_equivalent(python_exe, sys.executable)
55
-
56
- if is_sys_python:
57
- return None
58
-
59
- all_envs_paths = get_default_envs_paths()
60
-
61
- env_path = find_matching_prefix(python_exe, all_envs_paths)
62
-
63
- if not env_path:
64
- return None
65
-
66
- cfg_path = env_path / "pyvenv.cfg"
67
-
68
- should_flip = extract_include_sys_site_pkgs_value(cfg_path)
69
-
70
- if should_flip:
71
- return cfg_path
72
-
73
- return None
qbraid_cli/py.typed DELETED
File without changes
@@ -1,41 +0,0 @@
1
- qBraid Closed-Source Software License
2
-
3
- Copyright (c) 2024, qBraid Development Team
4
-
5
- All rights reserved.
6
-
7
- This license agreement ("License") is between the qBraid Development Team ("Author") and you, the Licensee. By using or distributing the qBraid ("Software"), you agree to the following terms:
8
-
9
- 1. Grant of License.
10
-
11
- Subject to the terms of this License, the Author grants you a non-exclusive, non-transferable license to use the Software for personal, academic, and educational purposes. Use of the Software for commercial purposes is strictly prohibited unless express permission is granted by the Author.
12
-
13
- 2. Distribution.
14
-
15
- You may distribute the Software to others, provided that any such distribution is made under the same terms of this License. Modifications to the Software may not be distributed.
16
-
17
- 3. Modification.
18
-
19
- You are permitted to modify the Software for personal use. You may contribute improvements or bug fixes back to the Author or the community, but you may not distribute the modifications.
20
-
21
- 4. Commercial Use.
22
-
23
- The Software may not be used for commercial purposes without explicit, prior written permission from the Author. Permissions for commercial use will be considered on a case-by-case basis.
24
-
25
- 5. Attribution
26
-
27
- If the Software is used in a non-private setting, including but not limited to academic work, commercial settings, or published literature, attribution must be given to the "qBraid Jupyter Environment Manager authored by the qBraid Development Team."
28
-
29
- 6. Disclaimer of Warranty.
30
-
31
- 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.
32
-
33
- 7. Limitation of Liability.
34
-
35
- 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.
36
-
37
- 8. Termination.
38
-
39
- This License is effective until terminated. Your rights under this License will terminate automatically without notice from the Author if you fail to comply with any term(s) of this License.
40
-
41
- By using the Software, you agree to be bound by the terms of this License. Redistribution of the Software or use of the Software other than as specifically authorized under this License is prohibited and may result in severe civil and criminal penalties.
@@ -1,39 +0,0 @@
1
- qbraid_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- qbraid_cli/_version.py,sha256=Z8fNqmfsoA07nbVEewR90wZCgaN6eyDwPwgtgc2KIak,411
3
- qbraid_cli/exceptions.py,sha256=KjlhYJhSHMVazaNiBjD_Ur06w4sekP8zRsFzBdyIpno,672
4
- qbraid_cli/handlers.py,sha256=glxTEwxax3zKgYl9qsZ2evZXgrWQrseJS_OGyHTMFeA,7040
5
- qbraid_cli/main.py,sha256=eRgBEYj9WPxHqTbSQvlV39yaDje-6yvZdrTnw5UQbQY,2638
6
- qbraid_cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- qbraid_cli/admin/__init__.py,sha256=qcWD5mQEUCtr49mrUpZmk7eGDe0L_Gtc8RwZmzIXSwo,175
8
- qbraid_cli/admin/app.py,sha256=ZyTBkEvlAR-xK3fbC32yntsE3rywzL4WHjJzRTFTlzs,1454
9
- qbraid_cli/admin/buildlogs.py,sha256=1i7CRpkIHIcKgGvHesPr9duCkyV7M-MESaHI5Z3ZdD0,3578
10
- qbraid_cli/admin/headers.py,sha256=E6mE3odZL57VfHHZxYtRUkqMKmrmT4zuUoINzI7eJF8,6435
11
- qbraid_cli/admin/validation.py,sha256=LkAVXlHtM0MhCa34MIWrfX59wGXMVlZmdVB4-AQ8fBk,1003
12
- qbraid_cli/configure/__init__.py,sha256=YaJ74Ztz2vl3eYp8_jVBucWkXscxz7EZEIzr70OfuOM,187
13
- qbraid_cli/configure/actions.py,sha256=3rrWHaCAsogyx0Ll-lcjbSzldD4kPuz1z6VQiWebSWw,3203
14
- qbraid_cli/configure/app.py,sha256=1uRe2lkUA4TtYb5b4mbD4LH-cKCbsZGT3Wfk7fpNzX0,2414
15
- qbraid_cli/credits/__init__.py,sha256=MJhgWgpFT1_886sB-_POlRs1y3SRy23HIrKVBkp0X-Y,181
16
- qbraid_cli/credits/app.py,sha256=AY3qtveO50KeQ2XREiEVqUcTrESgRuoqt9pt2Z8t4Y0,866
17
- qbraid_cli/devices/__init__.py,sha256=hiScO-px6jCL5cJj5Hbty55EUfNejTO4bmqUZuS3aqc,181
18
- qbraid_cli/devices/app.py,sha256=zxSxrEQn7irkJoME4S_CBnRqWeB8cqPaBsIMfpdYFk0,2530
19
- qbraid_cli/devices/validation.py,sha256=YhShyUufgrKnx2XjXOXF-PqFJYklJT9CgeqIwKcNam4,809
20
- qbraid_cli/envs/__init__.py,sha256=1-cMvrATsddYxcetPJWxq6bEOqJWMktGdhoZ4qm8euA,172
21
- qbraid_cli/envs/activate.py,sha256=VpvVYSfQDlcmlNWJOgkLIQ2p8YXPPLG8Jbl5t8GHUDw,2140
22
- qbraid_cli/envs/app.py,sha256=PD7U-zdQeoWPXPRpmKC3nwDVOfa69dk5GCIsE3mpla8,8411
23
- qbraid_cli/envs/create.py,sha256=HxNciItDoGC5jqiruHm0oUfNSqtuDfzE-ro4ztGUh5Q,2185
24
- qbraid_cli/envs/data_handling.py,sha256=Ibnp2yJoUDpivb_sNqi0suYgJZNat_LmM6Ya0Ovez5s,1288
25
- qbraid_cli/jobs/__init__.py,sha256=qVLRHYIzP4XHpx_QWP_vCzd3LsCscCORaEx-Vcbx29U,172
26
- qbraid_cli/jobs/app.py,sha256=kmg9mYla3Nd7EdjQlFu7IOvm7sejLNfPPA6Qeet-IfE,4898
27
- qbraid_cli/jobs/toggle_braket.py,sha256=d5C_Di80jWMFlh-77eH8YY9pjMKWXK5abenUDtPlE_I,6662
28
- qbraid_cli/jobs/validation.py,sha256=xNbjUggMhUs4wzkuRm4PuFPi_wrElYicUgYXLznHz3U,2983
29
- qbraid_cli/kernels/__init__.py,sha256=jORS9vV17s5laQyq8gSVB18EPBImgEIbMZ1wKC094DA,181
30
- qbraid_cli/kernels/app.py,sha256=eELxcuYV_d0wNR5t3IYznEcjqGmRM1j7GeHqVgcvDqs,3439
31
- qbraid_cli/pip/__init__.py,sha256=tJtU0rxn-ODogNh5Y4pp_BgDQXMN-3JY1QGj0OZHwjQ,169
32
- qbraid_cli/pip/app.py,sha256=yd55KzE1dApxPV5fyBa8PfdxaeDovUZyrPm_UZy_Ie0,1386
33
- qbraid_cli/pip/hooks.py,sha256=KuDHmntPXVK8tSb4MLk9VANhL-eINswhLd8_g_25WMY,2123
34
- qbraid_cli-0.8.1.dist-info/LICENSE,sha256=P1gi-ofB8lmkRt_mxDoJpcgQq9Ckq9WhRAS1oYk-G1s,2506
35
- qbraid_cli-0.8.1.dist-info/METADATA,sha256=Hab46g_Tequpsr6ehVMyS8QoAS051pJTr6lvz57RKXc,6732
36
- qbraid_cli-0.8.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
37
- qbraid_cli-0.8.1.dist-info/entry_points.txt,sha256=c5ZJ7NjbxhDqMpou9q5F03_b_KG34HzFDijIDmEIwgQ,47
38
- qbraid_cli-0.8.1.dist-info/top_level.txt,sha256=LTYJgeYSCHo9Il8vZu0yIPuGdGyNaIw6iRy6BeoZo8o,11
39
- qbraid_cli-0.8.1.dist-info/RECORD,,