qbraid-cli 0.8.0.dev3__py3-none-any.whl → 0.8.0.dev4__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.0.dev3'
16
- __version_tuple__ = version_tuple = (0, 8, 0, 'dev3')
15
+ __version__ = version = '0.8.0.dev4'
16
+ __version_tuple__ = version_tuple = (0, 8, 0, 'dev4')
qbraid_cli/handlers.py CHANGED
@@ -44,7 +44,11 @@ def handle_error(
44
44
  full_message = f"\n{error_prefix} {message}\n"
45
45
  if include_traceback:
46
46
  tb_string = traceback.format_exc()
47
- full_message += f"\n{tb_string}"
47
+ # TODO: find out reason for weird traceback emitted from
48
+ # qbraid jobs enable/disable when library not installed.
49
+ # For now, if matches, just don't print it.
50
+ if tb_string.strip() != "NoneType: None":
51
+ full_message += f"\n{tb_string}"
48
52
  typer.echo(full_message, err=True)
49
53
  raise typer.Exit(code=1)
50
54
 
qbraid_cli/jobs/app.py CHANGED
@@ -5,8 +5,6 @@
5
5
  Module defining commands in the 'qbraid jobs' namespace.
6
6
 
7
7
  """
8
-
9
- import sys
10
8
  from typing import Any, Callable, Dict, Tuple
11
9
 
12
10
  import typer
@@ -68,7 +66,8 @@ def jobs_state(
68
66
  )
69
67
  ) -> None:
70
68
  """Display the state of qBraid Quantum Jobs for the current environment."""
71
- state_values: Dict[str, Tuple[bool, bool]] = run_progress_get_state(library)
69
+ result: Tuple[str, Dict[str, Tuple[bool, bool]]] = run_progress_get_state(library)
70
+ python_exe, state_values = result
72
71
  state_values = dict(sorted(state_values.items()))
73
72
 
74
73
  console = Console()
@@ -76,7 +75,7 @@ def jobs_state(
76
75
  max_lib_length = max((len(lib) for lib in state_values.keys()), default=len(header_1))
77
76
  padding = max_lib_length + 9
78
77
 
79
- console.print(f"Executable: {sys.executable}")
78
+ console.print(f"Executable: {python_exe}")
80
79
  console.print(f"\n{header_1:<{padding}}{header_2}", style="bold")
81
80
 
82
81
  for lib, (installed, enabled) in state_values.items():
@@ -9,17 +9,10 @@ Module supporting 'qbraid jobs enable/disable braket' and commands.
9
9
  import logging
10
10
  import os
11
11
  import subprocess
12
- import sys
13
12
  from pathlib import Path
14
13
  from typing import Optional, Tuple
15
14
 
16
15
  import typer
17
- from qbraid_core.system import (
18
- QbraidSystemError,
19
- get_active_site_packages_path,
20
- get_latest_package_version,
21
- get_local_package_version,
22
- )
23
16
 
24
17
  from qbraid_cli.exceptions import QbraidException
25
18
  from qbraid_cli.handlers import handle_error, handle_filesystem_operation, run_progress_task
@@ -28,33 +21,38 @@ logging.basicConfig(level=logging.INFO)
28
21
  logger = logging.getLogger(__name__)
29
22
 
30
23
 
31
- def get_package_data(package: str) -> Tuple[str, str, str]:
24
+ def get_package_data(package: str) -> Tuple[str, str, str, str]:
32
25
  """Retrieve package version and location data.
33
26
 
34
27
  Args:
35
28
  package (str): The name of the package to retrieve data for.
36
29
 
37
30
  Returns:
38
- Tuple[str, str, str]: The installed and latest versions of the package, and the
39
- local site-packages path where it is / would be installed.
31
+ Tuple[str, str, str, str]: The installed and latest versions of the package, and the
32
+ local site-packages path where it is / would be installed.
40
33
 
41
34
  Raises:
42
35
  QbraidException: If package version or location data cannot be retrieved.
43
36
 
44
37
  """
38
+ # pylint: disable=import-outside-toplevel
39
+ from qbraid_core.system import (
40
+ QbraidSystemError,
41
+ get_active_python_path,
42
+ get_active_site_packages_path,
43
+ get_latest_package_version,
44
+ get_local_package_version,
45
+ )
45
46
 
46
47
  try:
47
- installed_version = get_local_package_version(package)
48
+ python_pathlib = get_active_python_path()
49
+ site_packages_path = get_active_site_packages_path(python_path=python_pathlib)
50
+ installed_version = get_local_package_version(package, python_path=python_pathlib)
48
51
  latest_version = get_latest_package_version(package)
49
52
  except QbraidSystemError as err:
50
- raise QbraidException("Failed to retrieve package version information") from err
51
-
52
- try:
53
- site_packages_path = get_active_site_packages_path()
54
- except QbraidSystemError as err:
55
- raise QbraidException("Failed to retrieve site-package location") from err
53
+ raise QbraidException("Failed to retrieve required system and/or package metadata") from err
56
54
 
57
- return installed_version, latest_version, site_packages_path
55
+ return installed_version, latest_version, str(site_packages_path), str(python_pathlib)
58
56
 
59
57
 
60
58
  def confirm_updates(
@@ -117,8 +115,6 @@ def confirm_updates(
117
115
  typer.echo("\nqBraidSystemExit: Exiting.")
118
116
  raise typer.Exit()
119
117
 
120
- typer.echo("")
121
-
122
118
 
123
119
  def aws_configure_dummy() -> None:
124
120
  """
@@ -156,23 +152,23 @@ def aws_configure_dummy() -> None:
156
152
 
157
153
  def enable_braket(auto_confirm: bool = False):
158
154
  """Enable qBraid quantum jobs for Amazon Braket."""
159
- installed, latest, path = run_progress_task(
155
+ installed, latest, path, python_exe = run_progress_task(
160
156
  get_package_data, "boto3", description="Solving environment..."
161
157
  )
162
158
 
163
159
  if not auto_confirm:
164
160
  confirm_updates("enable", path, installed_version=installed, latest_version=latest)
161
+ typer.echo("")
165
162
 
166
163
  aws_configure_dummy() # TODO: possibly add another confirmation for writing aws config files
164
+
167
165
  try:
168
- subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "boto3"])
166
+ subprocess.check_call([python_exe, "-m", "pip", "install", "--upgrade", "boto3"])
167
+ subprocess.check_call([python_exe, "-m", "pip", "uninstall", "botocore", "-y", "--quiet"])
169
168
  subprocess.check_call(
170
- [sys.executable, "-m", "pip", "uninstall", "botocore", "-y", "--quiet"]
169
+ [python_exe, "-m", "pip", "install", "git+https://github.com/qBraid/botocore.git"]
171
170
  )
172
- subprocess.check_call(
173
- [sys.executable, "-m", "pip", "install", "git+https://github.com/qBraid/botocore.git"]
174
- )
175
- except subprocess.CalledProcessError:
171
+ except (subprocess.CalledProcessError, FileNotFoundError):
176
172
  handle_error(message="Failed to enable qBraid quantum jobs.")
177
173
 
178
174
  typer.secho("\nSuccessfully enabled qBraid quantum jobs.", fg=typer.colors.GREEN, bold=True)
@@ -182,18 +178,19 @@ def enable_braket(auto_confirm: bool = False):
182
178
  def disable_braket(auto_confirm: bool = False):
183
179
  """Disable qBraid quantum jobs for Amazon Braket."""
184
180
  package = "botocore"
185
- installed, latest, path = run_progress_task(
181
+ installed, latest, path, python_exe = run_progress_task(
186
182
  get_package_data, package, description="Solving environment..."
187
183
  )
188
184
  package = f"{package}~={installed}" if installed < latest else package
189
185
 
190
186
  if not auto_confirm:
191
187
  confirm_updates("disable", path)
188
+ typer.echo("")
192
189
 
193
190
  try:
194
191
  subprocess.check_call(
195
192
  [
196
- sys.executable,
193
+ python_exe,
197
194
  "-m",
198
195
  "pip",
199
196
  "install",
@@ -202,7 +199,7 @@ def disable_braket(auto_confirm: bool = False):
202
199
  ],
203
200
  stderr=subprocess.DEVNULL,
204
201
  )
205
- except subprocess.CalledProcessError:
202
+ except (subprocess.CalledProcessError, FileNotFoundError):
206
203
  handle_error(message="Failed to disable qBraid quantum jobs.")
207
204
 
208
205
  typer.secho("\nSuccessfully disabled qBraid quantum jobs.", fg=typer.colors.GREEN, bold=True)
@@ -5,39 +5,59 @@
5
5
  Module for validating command arguments for qBraid Quantum Jobs.
6
6
 
7
7
  """
8
-
9
- from typing import Callable, Dict, Optional, Tuple
8
+ import sys
9
+ from typing import Any, Callable, Dict, Optional, Tuple
10
10
 
11
11
  import typer
12
- from qbraid_core.services.quantum.proxy import SUPPORTED_QJOB_LIBS, quantum_lib_proxy_state
13
12
  from rich.console import Console
14
13
 
15
14
  from qbraid_cli.handlers import handle_error, run_progress_task, validate_item
16
15
 
16
+ LEGACY_ARGS: Dict[str, str] = {
17
+ "amazon_braket": "braket",
18
+ "aws_braket": "braket",
19
+ }
20
+
17
21
 
18
22
  def validate_library(value: str) -> str:
19
23
  """Validate quantum jobs library."""
20
- return validate_item(value, SUPPORTED_QJOB_LIBS, "Library")
24
+ # pylint:disable-next=import-outside-toplevel
25
+ from qbraid_core.services.quantum.proxy import SUPPORTED_QJOB_LIBS
26
+
27
+ qjobs_libs = list(SUPPORTED_QJOB_LIBS.keys())
21
28
 
29
+ if value in LEGACY_ARGS:
30
+ old_value = value
31
+ value = LEGACY_ARGS[value]
22
32
 
23
- def get_state(library: Optional[str] = None) -> Dict[str, Tuple[bool, bool]]:
33
+ console = Console()
34
+ console.print(
35
+ f"[red]DeprecationWarning:[/red] Argument '{old_value}' "
36
+ f"is deprecated. Use '{value}' instead.\n"
37
+ )
38
+
39
+ return validate_item(value, qjobs_libs, "Library")
40
+
41
+
42
+ def get_state(library: Optional[str] = None) -> Tuple[str, Dict[str, Tuple[bool, bool]]]:
24
43
  """Get the state of qBraid Quantum Jobs for the specified library."""
44
+ from qbraid_core.services.quantum import QuantumClient
25
45
 
26
- state_values = {}
46
+ jobs_state = QuantumClient.qbraid_jobs_state(device_lib=library)
27
47
 
28
- if library:
29
- libraries_to_check = [library]
30
- else:
31
- libraries_to_check = SUPPORTED_QJOB_LIBS
48
+ python_exe: str = jobs_state.get("exe", sys.executable)
49
+ libs_state: Dict[str, Any] = jobs_state.get("libs", {})
32
50
 
33
- for lib in libraries_to_check:
34
- state = quantum_lib_proxy_state(lib)
35
- state_values[lib] = state["supported"], state["enabled"]
51
+ state_values = {
52
+ lib: (state["supported"], state["enabled"]) for lib, state in libs_state.items()
53
+ }
36
54
 
37
- return state_values
55
+ return python_exe, state_values
38
56
 
39
57
 
40
- def run_progress_get_state(library: Optional[str] = None) -> Dict[str, Tuple[bool, bool]]:
58
+ def run_progress_get_state(
59
+ library: Optional[str] = None,
60
+ ) -> Tuple[str, Dict[str, Tuple[bool, bool]]]:
41
61
  """Run get state function with rich progress UI."""
42
62
  return run_progress_task(
43
63
  get_state,
@@ -53,21 +73,20 @@ def handle_jobs_state(
53
73
  action_callback: Callable[[], None],
54
74
  ) -> None:
55
75
  """Handle the common logic for enabling or disabling qBraid Quantum Jobs."""
56
- state_values: Dict[str, Tuple[bool, bool]] = run_progress_get_state(library)
76
+ _, state_values = run_progress_get_state(library)
57
77
  installed, enabled = state_values[library]
58
78
 
59
79
  if not installed:
60
- handle_error(message=f"{library} not installed.")
80
+ handle_error(
81
+ message=f"{library} not installed."
82
+ ) # TODO: Provide command to install library?
61
83
  if (enabled and action == "enable") or (not enabled and action == "disable"):
62
84
  action_color = "green" if enabled else "red"
63
85
  console = Console()
64
86
  console.print(
65
87
  f"\nqBraid quantum jobs already [bold {action_color}]{action}d[/bold {action_color}] "
66
- f"for [magenta]{library}[/magenta]."
67
- )
68
- console.print(
69
- "To check the state of all quantum jobs libraries in this environment, "
70
- "use: \n\n\t$ qbraid jobs state\n"
88
+ f"for [magenta]{library}[/magenta].\n\nCheck the state of all quantum jobs "
89
+ "libraries in this environment with: \n\n\t$ qbraid jobs state\n"
71
90
  )
72
91
  raise typer.Exit()
73
92
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qbraid-cli
3
- Version: 0.8.0.dev3
3
+ Version: 0.8.0.dev4
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
@@ -29,7 +29,7 @@ Description-Content-Type: text/markdown
29
29
  Requires-Dist: typer >=0.12.1
30
30
  Requires-Dist: rich >=10.11.0
31
31
  Requires-Dist: jupyter-client <9.0.0,>=7.0.0
32
- Requires-Dist: qbraid-core >=0.1.1
32
+ Requires-Dist: qbraid-core >=0.1.2
33
33
  Provides-Extra: dev
34
34
  Requires-Dist: black ; extra == 'dev'
35
35
  Requires-Dist: isort ; extra == 'dev'
@@ -41,6 +41,8 @@ Requires-Dist: sphinx-rtd-theme <2.1,>=1.3 ; extra == 'docs'
41
41
  Requires-Dist: docutils <0.21 ; extra == 'docs'
42
42
  Requires-Dist: toml ; extra == 'docs'
43
43
  Requires-Dist: build ; extra == 'docs'
44
+ Requires-Dist: m2r ; extra == 'docs'
45
+ Requires-Dist: typer ; extra == 'docs'
44
46
  Provides-Extra: jobs
45
47
  Requires-Dist: amazon-braket-sdk >=1.48.1 ; extra == 'jobs'
46
48
 
@@ -1,7 +1,7 @@
1
1
  qbraid_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- qbraid_cli/_version.py,sha256=gmvID9vFrR93SKxjTAMGcHF8k0zAbpA7V0aBbjfr5jw,424
2
+ qbraid_cli/_version.py,sha256=slOqxGpZ52igr23ftZbPTgtbqVPwjKuyUyILwEde3R4,424
3
3
  qbraid_cli/exceptions.py,sha256=KjlhYJhSHMVazaNiBjD_Ur06w4sekP8zRsFzBdyIpno,672
4
- qbraid_cli/handlers.py,sha256=rGxHrwrPHvwP3CKVlJSCZ_KkgGvFlLXd3SsxcC4LqS0,6306
4
+ qbraid_cli/handlers.py,sha256=i3vdRtdy4bZKg3j6fwfVMz1ddhMgzlc2hhmj-vewxpI,6542
5
5
  qbraid_cli/main.py,sha256=ko3c8fkzwcNlNb0AFLFgwlSoOOC4DJgeHlRuHbz-dyw,2504
6
6
  qbraid_cli/configure/__init__.py,sha256=6GU7vR6JYRGcMsmdrpFbwLO5VSUmnLgwSbtmGWMQND4,158
7
7
  qbraid_cli/configure/actions.py,sha256=3rrWHaCAsogyx0Ll-lcjbSzldD4kPuz1z6VQiWebSWw,3203
@@ -17,13 +17,13 @@ qbraid_cli/envs/app.py,sha256=t6bRwJGy-M3PAu870ZsttsM8tpSB0OFasgCJiV9nTSA,8620
17
17
  qbraid_cli/envs/create.py,sha256=uCRex_TcFYw26jUOU06Ta5I8Mq5pRqLVaOE6MxrrExs,4337
18
18
  qbraid_cli/envs/data_handling.py,sha256=mTVzsj6KleeeYDKGhgD-IesF9KQQMSszKFSEo8Wrv9w,4001
19
19
  qbraid_cli/jobs/__init__.py,sha256=bj9XmZ4JL8OtMMZbHIu-DPhpOMXGLSB-W1b0wO7wKro,148
20
- qbraid_cli/jobs/app.py,sha256=LsyYFh2949-6eCVfdzcY-Nvt4rSN5lNBDZ57j0OBzWE,4870
21
- qbraid_cli/jobs/toggle_braket.py,sha256=2vCkKcDsQmVYpElHwOI-fQCVbIH-0HBnnDZSfp_bSlk,7553
22
- qbraid_cli/jobs/validation.py,sha256=6QKkFINk8Jqw1wuwPivbD5HuFTzT1cUT_G2WVqaKcnc,2405
20
+ qbraid_cli/jobs/app.py,sha256=kmg9mYla3Nd7EdjQlFu7IOvm7sejLNfPPA6Qeet-IfE,4898
21
+ qbraid_cli/jobs/toggle_braket.py,sha256=jlmVEGB30ZQmLePiKj48mCXltluUUb47BZlgZT85yuY,7718
22
+ qbraid_cli/jobs/validation.py,sha256=xNbjUggMhUs4wzkuRm4PuFPi_wrElYicUgYXLznHz3U,2983
23
23
  qbraid_cli/kernels/__init__.py,sha256=VhpBota_v7OoiGxrPCqJU4XBVcolf81mbCYGSxXzVhc,154
24
24
  qbraid_cli/kernels/app.py,sha256=ZJWVdKzCDfzGnA1pqp01vDbE7fh8p84jC-y6DDgWlxc,3373
25
- qbraid_cli-0.8.0.dev3.dist-info/METADATA,sha256=Ud547dThxdfsRnAXTcTy_J2s3xQcLVglP9houT2FNSw,5818
26
- qbraid_cli-0.8.0.dev3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
27
- qbraid_cli-0.8.0.dev3.dist-info/entry_points.txt,sha256=c5ZJ7NjbxhDqMpou9q5F03_b_KG34HzFDijIDmEIwgQ,47
28
- qbraid_cli-0.8.0.dev3.dist-info/top_level.txt,sha256=LTYJgeYSCHo9Il8vZu0yIPuGdGyNaIw6iRy6BeoZo8o,11
29
- qbraid_cli-0.8.0.dev3.dist-info/RECORD,,
25
+ qbraid_cli-0.8.0.dev4.dist-info/METADATA,sha256=zL1Ut9rcHVtO1mZeduN5dqpe9H5H_Wu8R3rn7t7NBww,5894
26
+ qbraid_cli-0.8.0.dev4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
27
+ qbraid_cli-0.8.0.dev4.dist-info/entry_points.txt,sha256=c5ZJ7NjbxhDqMpou9q5F03_b_KG34HzFDijIDmEIwgQ,47
28
+ qbraid_cli-0.8.0.dev4.dist-info/top_level.txt,sha256=LTYJgeYSCHo9Il8vZu0yIPuGdGyNaIw6iRy6BeoZo8o,11
29
+ qbraid_cli-0.8.0.dev4.dist-info/RECORD,,