qbraid-cli 0.7.0__py3-none-any.whl → 0.8.0__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 +14 -5
- qbraid_cli/admin/__init__.py +9 -0
- qbraid_cli/admin/app.py +50 -0
- qbraid_cli/admin/headers.py +193 -0
- qbraid_cli/admin/validation.py +33 -0
- qbraid_cli/configure/__init__.py +9 -0
- qbraid_cli/configure/actions.py +111 -0
- qbraid_cli/configure/app.py +77 -0
- qbraid_cli/credits/__init__.py +9 -0
- qbraid_cli/credits/app.py +32 -0
- qbraid_cli/devices/__init__.py +9 -0
- qbraid_cli/devices/app.py +80 -0
- qbraid_cli/devices/validation.py +26 -0
- qbraid_cli/envs/__init__.py +9 -0
- qbraid_cli/envs/activate.py +65 -0
- qbraid_cli/envs/app.py +270 -0
- qbraid_cli/envs/create.py +128 -0
- qbraid_cli/envs/data_handling.py +140 -0
- qbraid_cli/exceptions.py +24 -0
- qbraid_cli/handlers.py +168 -0
- qbraid_cli/jobs/__init__.py +9 -0
- qbraid_cli/jobs/app.py +149 -0
- qbraid_cli/jobs/toggle_braket.py +185 -0
- qbraid_cli/jobs/validation.py +93 -0
- qbraid_cli/kernels/__init__.py +9 -0
- qbraid_cli/kernels/app.py +111 -0
- qbraid_cli/main.py +80 -0
- qbraid_cli-0.8.0.dist-info/METADATA +143 -0
- qbraid_cli-0.8.0.dist-info/RECORD +33 -0
- {qbraid_cli-0.7.0.dist-info → qbraid_cli-0.8.0.dist-info}/WHEEL +1 -1
- qbraid_cli-0.8.0.dist-info/entry_points.txt +2 -0
- qbraid_cli/bin/qbraid.sh +0 -1317
- qbraid_cli/configure.py +0 -87
- qbraid_cli/wrapper.py +0 -91
- qbraid_cli-0.7.0.data/scripts/qbraid.sh +0 -1317
- qbraid_cli-0.7.0.dist-info/METADATA +0 -118
- qbraid_cli-0.7.0.dist-info/RECORD +0 -11
- qbraid_cli-0.7.0.dist-info/entry_points.txt +0 -2
- {qbraid_cli-0.7.0.dist-info → qbraid_cli-0.8.0.dist-info}/top_level.txt +0 -0
qbraid_cli/configure.py
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Update qbraidrc configuration file
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
import configparser
|
|
6
|
-
import re
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def load_config():
|
|
11
|
-
"""Load the configuration from the file."""
|
|
12
|
-
config_path = Path.home() / ".qbraid" / "qbraidrc"
|
|
13
|
-
config = configparser.ConfigParser()
|
|
14
|
-
config.read(config_path)
|
|
15
|
-
return config
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def save_config(config):
|
|
19
|
-
"""Save the configuration to the file."""
|
|
20
|
-
config_path = Path.home() / ".qbraid" / "qbraidrc"
|
|
21
|
-
with config_path.open("w") as configfile:
|
|
22
|
-
config.write(configfile)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def validate_input(key, value):
|
|
26
|
-
"""Validate the user input based on the key."""
|
|
27
|
-
if key == "url":
|
|
28
|
-
if not re.match(r"^https?://\S+$", value):
|
|
29
|
-
raise ValueError("Invalid URL format.")
|
|
30
|
-
elif key == "email":
|
|
31
|
-
if not re.match(r"^\S+@\S+\.\S+$", value):
|
|
32
|
-
raise ValueError("Invalid email format.")
|
|
33
|
-
return value
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def prompt_for_config(config, section, key, default_values=None):
|
|
37
|
-
"""Prompt the user for a configuration setting, showing the current value as default."""
|
|
38
|
-
default_values = default_values or {}
|
|
39
|
-
current_value = config.get(section, key, fallback=default_values.get(key, ""))
|
|
40
|
-
display_value = "None" if not current_value else current_value
|
|
41
|
-
|
|
42
|
-
while True:
|
|
43
|
-
try:
|
|
44
|
-
new_value = input(f"Enter {key} [{display_value}]: ").strip()
|
|
45
|
-
new_value = new_value or current_value
|
|
46
|
-
return validate_input(key, new_value)
|
|
47
|
-
except ValueError as e:
|
|
48
|
-
print(f"Error: {e}")
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def configure():
|
|
52
|
-
"""Prompt the user to configure each setting."""
|
|
53
|
-
try:
|
|
54
|
-
config = load_config()
|
|
55
|
-
except Exception as e: # pylint: disable=broad-exception-caught
|
|
56
|
-
print(f"Error loading configuration: {e}")
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
section = "default"
|
|
60
|
-
|
|
61
|
-
if section not in config:
|
|
62
|
-
config[section] = {}
|
|
63
|
-
|
|
64
|
-
default_values = {"url": "https://api.qbraid.com/api"}
|
|
65
|
-
|
|
66
|
-
try:
|
|
67
|
-
config[section]["url"] = prompt_for_config(
|
|
68
|
-
config, section, "url", default_values
|
|
69
|
-
)
|
|
70
|
-
config[section]["email"] = prompt_for_config(
|
|
71
|
-
config, section, "email", default_values
|
|
72
|
-
)
|
|
73
|
-
config[section]["api-key"] = prompt_for_config(
|
|
74
|
-
config, section, "api-key", default_values
|
|
75
|
-
)
|
|
76
|
-
config[section]["refresh-token"] = prompt_for_config(
|
|
77
|
-
config, section, "refresh-token", default_values
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
for key in list(config[section]):
|
|
81
|
-
if not config[section][key]:
|
|
82
|
-
del config[section][key]
|
|
83
|
-
|
|
84
|
-
save_config(config)
|
|
85
|
-
print("Configuration updated successfully.")
|
|
86
|
-
except Exception as e: # pylint: disable=broad-exception-caught
|
|
87
|
-
print(f"Error updating configuration: {e}")
|
qbraid_cli/wrapper.py
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Module to run the qbraid command line interface.
|
|
3
|
-
|
|
4
|
-
Lazy loading is used to avoid loading the qbraid package until it is needed.
|
|
5
|
-
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
import os
|
|
9
|
-
import subprocess
|
|
10
|
-
import sys
|
|
11
|
-
|
|
12
|
-
from ._version import __version__
|
|
13
|
-
from .configure import configure
|
|
14
|
-
|
|
15
|
-
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def flag_help_command():
|
|
19
|
-
"""Check if the help command should be triggered."""
|
|
20
|
-
if len(sys.argv) > 0:
|
|
21
|
-
last_arg = sys.argv[-1]
|
|
22
|
-
if last_arg in ["-h", "--help", "help"]:
|
|
23
|
-
return True
|
|
24
|
-
return False
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def is_help_command(arg_index):
|
|
28
|
-
"""Check if the help command should be triggered for the given argument index"""
|
|
29
|
-
if flag_help_command() and arg_index == len(sys.argv) - 1:
|
|
30
|
-
return True
|
|
31
|
-
return False
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def get_credits():
|
|
35
|
-
"""Get the number of credits available to the user."""
|
|
36
|
-
# pylint: disable-next=import-outside-toplevel
|
|
37
|
-
from qbraid.api import QbraidSession
|
|
38
|
-
|
|
39
|
-
session = QbraidSession()
|
|
40
|
-
res = session.get("/billing/credits/get-user-credits").json()
|
|
41
|
-
qbraid_credits = res["qbraidCredits"]
|
|
42
|
-
print(qbraid_credits)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def main():
|
|
46
|
-
"""The subprocess.run function is used to run the script and pass arguments."""
|
|
47
|
-
if len(sys.argv) == 2 and sys.argv[1] == "configure":
|
|
48
|
-
configure()
|
|
49
|
-
elif len(sys.argv) == 2 and sys.argv[1] == "credits":
|
|
50
|
-
get_credits()
|
|
51
|
-
elif sys.argv[1:] == ["--version"] or sys.argv[1:] == ["-V"]:
|
|
52
|
-
print(f"qbraid-cli/{__version__}")
|
|
53
|
-
elif len(sys.argv) == 3 and sys.argv[1:] == ["jobs", "list"]:
|
|
54
|
-
# pylint: disable-next=import-outside-toplevel
|
|
55
|
-
from qbraid import get_jobs
|
|
56
|
-
|
|
57
|
-
get_jobs()
|
|
58
|
-
elif len(sys.argv) == 3 and sys.argv[1:] == ["devices", "list"]:
|
|
59
|
-
# pylint: disable-next=import-outside-toplevel
|
|
60
|
-
from qbraid import get_devices
|
|
61
|
-
|
|
62
|
-
get_devices()
|
|
63
|
-
else:
|
|
64
|
-
result = subprocess.run(
|
|
65
|
-
[os.path.join(PROJECT_ROOT, "bin", "qbraid.sh")] + sys.argv[1:],
|
|
66
|
-
text=True,
|
|
67
|
-
capture_output=True,
|
|
68
|
-
check=False,
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
if result.stdout:
|
|
72
|
-
if len(sys.argv) == 4 and sys.argv[2] == "activate":
|
|
73
|
-
line_lst = result.stdout.split("\n")
|
|
74
|
-
line_lst = line_lst[:-1] # remove trailing blank line
|
|
75
|
-
bin_path = line_lst.pop() # last line contains bin_path
|
|
76
|
-
std_out = "\n".join(line_lst) # all other lines are regular stdout
|
|
77
|
-
print(std_out)
|
|
78
|
-
# activate python environment using bin_path
|
|
79
|
-
os.system(
|
|
80
|
-
f"cat ~/.bashrc {bin_path}/activate > {bin_path}/activate2 && "
|
|
81
|
-
rf"sed -i 's/echo -e/\# echo -e/' {bin_path}/activate2 && "
|
|
82
|
-
f"/bin/bash --rcfile {bin_path}/activate2"
|
|
83
|
-
)
|
|
84
|
-
else:
|
|
85
|
-
print(result.stdout)
|
|
86
|
-
if result.stderr:
|
|
87
|
-
print(result.stderr)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if __name__ == "__main__":
|
|
91
|
-
main()
|