qbraid-cli 0.6.0.dev0__tar.gz → 0.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of qbraid-cli might be problematic. Click here for more details.
- {qbraid-cli-0.6.0.dev0 → qbraid-cli-0.7.0}/PKG-INFO +4 -3
- {qbraid-cli-0.6.0.dev0 → qbraid-cli-0.7.0}/README.md +1 -1
- {qbraid-cli-0.6.0.dev0 → qbraid-cli-0.7.0}/qbraid_cli/_version.py +1 -1
- {qbraid-cli-0.6.0.dev0 → qbraid-cli-0.7.0}/qbraid_cli/bin/qbraid.sh +124 -43
- qbraid-cli-0.7.0/qbraid_cli/configure.py +87 -0
- qbraid-cli-0.7.0/qbraid_cli/wrapper.py +91 -0
- {qbraid-cli-0.6.0.dev0 → qbraid-cli-0.7.0}/qbraid_cli.egg-info/PKG-INFO +4 -3
- {qbraid-cli-0.6.0.dev0 → qbraid-cli-0.7.0}/qbraid_cli.egg-info/SOURCES.txt +1 -1
- {qbraid-cli-0.6.0.dev0 → qbraid-cli-0.7.0}/qbraid_cli.egg-info/requires.txt +2 -0
- {qbraid-cli-0.6.0.dev0 → qbraid-cli-0.7.0}/setup.py +2 -3
- qbraid-cli-0.6.0.dev0/qbraid_cli/bin/banner.sh +0 -17
- qbraid-cli-0.6.0.dev0/qbraid_cli/wrapper.py +0 -48
- {qbraid-cli-0.6.0.dev0 → qbraid-cli-0.7.0}/qbraid_cli/__init__.py +0 -0
- {qbraid-cli-0.6.0.dev0 → qbraid-cli-0.7.0}/qbraid_cli.egg-info/dependency_links.txt +0 -0
- {qbraid-cli-0.6.0.dev0 → qbraid-cli-0.7.0}/qbraid_cli.egg-info/entry_points.txt +0 -0
- {qbraid-cli-0.6.0.dev0 → qbraid-cli-0.7.0}/qbraid_cli.egg-info/top_level.txt +0 -0
- {qbraid-cli-0.6.0.dev0 → qbraid-cli-0.7.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: qbraid-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: Command Line Interface for interacting with all parts of the qBraid platform.
|
|
5
5
|
Home-page: https://www.qbraid.com/
|
|
6
6
|
Author: qBraid Development Team
|
|
@@ -16,14 +16,15 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
16
16
|
Classifier: Programming Language :: Python
|
|
17
17
|
Classifier: Programming Language :: Python :: 3
|
|
18
18
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.9
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
22
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
23
22
|
Classifier: Programming Language :: Python :: 3.12
|
|
24
23
|
Requires-Python: >= 3.8
|
|
25
24
|
Description-Content-Type: text/markdown
|
|
25
|
+
Requires-Dist: qbraid>=0.5.0
|
|
26
26
|
Requires-Dist: awscli
|
|
27
|
+
Requires-Dist: ipykernel
|
|
27
28
|
Provides-Extra: dev
|
|
28
29
|
Requires-Dist: black; extra == "dev"
|
|
29
30
|
Requires-Dist: isort; extra == "dev"
|
|
@@ -46,7 +47,7 @@ The **qBraid CLI** is a specialized command-line interface tool designed *exclus
|
|
|
46
47
|
|
|
47
48
|
## Getting Started
|
|
48
49
|
|
|
49
|
-
To use the qBraid CLI, login (or create an account), launch
|
|
50
|
+
To use the qBraid CLI, login to qBraid (or create an account), launch Lab, and then open Terminal. You can also access the CLI directly from within [Notebooks](https://docs.qbraid.com/projects/lab/en/latest/lab/notebooks.html) using the ``!`` operator. See [quantum jobs example](https://github.com/qBraid/qbraid-lab-demo/blob/045c7a8fbdcae66a7e64533dd9fe0e981dc02cf4/qbraid_lab/quantum_jobs/aws_quantum_jobs.ipynb).
|
|
50
51
|
|
|
51
52
|
- [Launch qBraid Lab →](https://lab.qbraid.com/)
|
|
52
53
|
- [Make an account →](https://account.qbraid.com/)
|
|
@@ -11,7 +11,7 @@ The **qBraid CLI** is a specialized command-line interface tool designed *exclus
|
|
|
11
11
|
|
|
12
12
|
## Getting Started
|
|
13
13
|
|
|
14
|
-
To use the qBraid CLI, login (or create an account), launch
|
|
14
|
+
To use the qBraid CLI, login to qBraid (or create an account), launch Lab, and then open Terminal. You can also access the CLI directly from within [Notebooks](https://docs.qbraid.com/projects/lab/en/latest/lab/notebooks.html) using the ``!`` operator. See [quantum jobs example](https://github.com/qBraid/qbraid-lab-demo/blob/045c7a8fbdcae66a7e64533dd9fe0e981dc02cf4/qbraid_lab/quantum_jobs/aws_quantum_jobs.ipynb).
|
|
15
15
|
|
|
16
16
|
- [Launch qBraid Lab →](https://lab.qbraid.com/)
|
|
17
17
|
- [Make an account →](https://account.qbraid.com/)
|
|
@@ -10,9 +10,6 @@
|
|
|
10
10
|
#-------------------------------------------------------------------------
|
|
11
11
|
# Global variables
|
|
12
12
|
|
|
13
|
-
# CLI version (DEPRECATED, now kept by python _version.py)
|
|
14
|
-
VERSION="0.6.0.dev0"
|
|
15
|
-
|
|
16
13
|
# Styling
|
|
17
14
|
NC="\033[0m" # No Color
|
|
18
15
|
PURPLE="\033[0;35m"
|
|
@@ -890,19 +887,6 @@ help_jobs_add() {
|
|
|
890
887
|
echo ""
|
|
891
888
|
}
|
|
892
889
|
|
|
893
|
-
# qbraid jobs get-credits -h
|
|
894
|
-
help_jobs_credits() {
|
|
895
|
-
echo ""
|
|
896
|
-
echo "Command"
|
|
897
|
-
echo " qbraid jobs get-credits : Get number of qBraid credits remaining."
|
|
898
|
-
echo " Recently added credits may not appear, but"
|
|
899
|
-
echo " will be synced after submitting quantum job."
|
|
900
|
-
echo ""
|
|
901
|
-
echo "Optional Arguments"
|
|
902
|
-
echo " -h, --help : Show this help message and exit."
|
|
903
|
-
echo ""
|
|
904
|
-
}
|
|
905
|
-
|
|
906
890
|
# qbraids jobs enable -h
|
|
907
891
|
help_jobs_enable() {
|
|
908
892
|
echo ""
|
|
@@ -962,15 +946,6 @@ jobs() {
|
|
|
962
946
|
((argDepth++))
|
|
963
947
|
if [ "$(help_command "${argDepth}")" = "yes" ]; then
|
|
964
948
|
help_jobs_list
|
|
965
|
-
else
|
|
966
|
-
awsJobs="$HOME/.qbraid/quantum-jobs/aws"
|
|
967
|
-
if [ ! -f "${awsJobs}" ] || [ "$(cat "${awsJobs}" | wc -l)" = 0 ]; then
|
|
968
|
-
echo -e "${RED}No quantum jobs found.${NC}"
|
|
969
|
-
echo ""
|
|
970
|
-
echo -e "Use \`qbraid jobs enable -h\` for information on enabling qBraid Quantum Jobs."
|
|
971
|
-
else
|
|
972
|
-
cat "${awsJobs}"
|
|
973
|
-
fi
|
|
974
949
|
fi
|
|
975
950
|
|
|
976
951
|
# qbraid jobs add
|
|
@@ -1148,6 +1123,66 @@ jobs() {
|
|
|
1148
1123
|
fi
|
|
1149
1124
|
}
|
|
1150
1125
|
|
|
1126
|
+
############################### DEVICES GROUP ###############################
|
|
1127
|
+
#-------------------------------------------------------------------------
|
|
1128
|
+
# Help functions
|
|
1129
|
+
|
|
1130
|
+
# qbraid devices -h
|
|
1131
|
+
help_devices() {
|
|
1132
|
+
echo ""
|
|
1133
|
+
echo "Group"
|
|
1134
|
+
echo " qbraid devices : Manage qBraid Quantum Devices."
|
|
1135
|
+
echo ""
|
|
1136
|
+
echo "Commands"
|
|
1137
|
+
echo " list : Get list of qBraid Quantum Devices."
|
|
1138
|
+
echo ""
|
|
1139
|
+
echo "Optional Arguments"
|
|
1140
|
+
echo " -h, --help : Show this help message and exit."
|
|
1141
|
+
echo ""
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
# qbraid devices list -h
|
|
1145
|
+
help_devices_list() {
|
|
1146
|
+
echo ""
|
|
1147
|
+
echo "Command"
|
|
1148
|
+
echo " qbraid devices list : Get list of qBraid Quantum Jobs."
|
|
1149
|
+
echo ""
|
|
1150
|
+
echo "Optional Arguments"
|
|
1151
|
+
echo " -h, --help : Show this help message and exit."
|
|
1152
|
+
echo ""
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
#-------------------------------------------------------------------------
|
|
1156
|
+
# qbraid devices commands
|
|
1157
|
+
|
|
1158
|
+
devices() {
|
|
1159
|
+
|
|
1160
|
+
argDepth=2
|
|
1161
|
+
|
|
1162
|
+
# qbraid jobs -h
|
|
1163
|
+
if [ "$(help_command "${argDepth}")" = "yes" ]; then
|
|
1164
|
+
help_devices
|
|
1165
|
+
|
|
1166
|
+
# qbraid jobs
|
|
1167
|
+
elif [ -z "${1}" ]; then
|
|
1168
|
+
echo -e "${RED}ERROR: Invalid command ${NC}"
|
|
1169
|
+
echo ""
|
|
1170
|
+
echo -e "Use \`qbraid devices -h\` to see available commands"
|
|
1171
|
+
exit 1
|
|
1172
|
+
|
|
1173
|
+
# qbraid devices list
|
|
1174
|
+
elif [ "${1}" = "list" ]; then
|
|
1175
|
+
((argDepth++))
|
|
1176
|
+
if [ "$(help_command "${argDepth}")" = "yes" ]; then
|
|
1177
|
+
help_devices_list
|
|
1178
|
+
fi
|
|
1179
|
+
else
|
|
1180
|
+
echo -e "${RED}ERROR: Invalid argument ${NC}${1}"
|
|
1181
|
+
echo ""
|
|
1182
|
+
echo -e "Use \`qbraid devices -h\` to see available commands"
|
|
1183
|
+
exit 1
|
|
1184
|
+
fi
|
|
1185
|
+
}
|
|
1151
1186
|
|
|
1152
1187
|
############################### CLI ENTRYPOINT ###########################
|
|
1153
1188
|
#-------------------------------------------------------------------------
|
|
@@ -1159,10 +1194,15 @@ help() {
|
|
|
1159
1194
|
echo "Group"
|
|
1160
1195
|
echo " qbraid"
|
|
1161
1196
|
echo ""
|
|
1197
|
+
echo "Commands"
|
|
1198
|
+
echo " configure : Update or add qbraidrc config values."
|
|
1199
|
+
echo " credits : Get number of qBraid credits remaining."
|
|
1200
|
+
echo ""
|
|
1162
1201
|
echo "Subgroups"
|
|
1163
1202
|
echo " envs : Manage qBraid environments."
|
|
1164
1203
|
echo " kernels : Manage qBraid kernels."
|
|
1165
1204
|
echo " jobs : Manage qBraid Quantum Jobs."
|
|
1205
|
+
echo " devices : Manage qBraid Quantum Devices."
|
|
1166
1206
|
echo ""
|
|
1167
1207
|
echo "Arguments"
|
|
1168
1208
|
echo " -V, --version : Show version and exit"
|
|
@@ -1170,7 +1210,34 @@ help() {
|
|
|
1170
1210
|
echo "Global Arguments"
|
|
1171
1211
|
echo " -h, --help : Show this help message and exit."
|
|
1172
1212
|
echo ""
|
|
1173
|
-
echo "Reference Docs: https://docs.qbraid.com/en/latest/cli/qbraid.html"
|
|
1213
|
+
echo "Reference Docs: https://docs.qbraid.com/projects/cli/en/latest/cli/qbraid.html"
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
# qbraid configure -h
|
|
1217
|
+
help_configure() {
|
|
1218
|
+
echo ""
|
|
1219
|
+
echo "Command"
|
|
1220
|
+
echo " qbraid configure : Update or add qbraidrc config values."
|
|
1221
|
+
echo ""
|
|
1222
|
+
echo "Optional Arguments"
|
|
1223
|
+
echo " -h, --help : Show this help message and exit."
|
|
1224
|
+
echo ""
|
|
1225
|
+
echo "Examples"
|
|
1226
|
+
echo " $ qbraid configure"
|
|
1227
|
+
echo " email [None]: contact@qbraid.com"
|
|
1228
|
+
echo " api-key [None]: 1234567890"
|
|
1229
|
+
echo ""
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
# qbraid credits -h
|
|
1233
|
+
help_credits() {
|
|
1234
|
+
echo ""
|
|
1235
|
+
echo "Command"
|
|
1236
|
+
echo " qbraid credits : Get number of qBraid credits remaining."
|
|
1237
|
+
echo ""
|
|
1238
|
+
echo "Optional Arguments"
|
|
1239
|
+
echo " -h, --help : Show this help message and exit."
|
|
1240
|
+
echo ""
|
|
1174
1241
|
}
|
|
1175
1242
|
|
|
1176
1243
|
#-------------------------------------------------------------------------
|
|
@@ -1186,27 +1253,37 @@ qbraid() {
|
|
|
1186
1253
|
|
|
1187
1254
|
# qbraid
|
|
1188
1255
|
elif [ -z "${1}" ]; then
|
|
1189
|
-
echo -e "
|
|
1190
|
-
echo -e "* ${PURPLE}Welcome to the qBraid CLI!${NC} *"
|
|
1191
|
-
echo -e "
|
|
1256
|
+
echo -e "---------------------------------"
|
|
1257
|
+
echo -e " * ${PURPLE}Welcome to the qBraid CLI!${NC} * "
|
|
1258
|
+
echo -e "---------------------------------"
|
|
1259
|
+
echo -e ""
|
|
1260
|
+
echo -e " ____ _ _ "
|
|
1261
|
+
echo -e " __ _| __ ) _ __ __ _(_) __| | "
|
|
1262
|
+
echo -e " / _ | _ \| __/ _ | |/ _ | "
|
|
1263
|
+
echo -e " | (_| | |_) | | | (_| | | (_| | "
|
|
1264
|
+
echo -e " \__ |____/|_| \__ _|_|\__ _| "
|
|
1265
|
+
echo -e " |_| "
|
|
1192
1266
|
echo -e ""
|
|
1193
|
-
echo -e " - Use \`qbraid -h\` to see available commands."
|
|
1194
1267
|
echo -e ""
|
|
1195
|
-
echo -e "
|
|
1268
|
+
echo -e "- Use \`qbraid -h\` to see available commands."
|
|
1269
|
+
echo -e ""
|
|
1270
|
+
echo -e "- Use \`qbraid --version\` to display the current version."
|
|
1196
1271
|
echo -e ""
|
|
1197
1272
|
echo -e "Reference Docs: https://docs.qbraid.com/projects/cli/en/latest/cli/qbraid.html"
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1273
|
+
|
|
1274
|
+
# qbraid configure
|
|
1275
|
+
elif [ "${1}" = "configure" ]; then
|
|
1276
|
+
((argDepth++))
|
|
1277
|
+
if [ "$(help_command "${argDepth}")" = "yes" ]; then
|
|
1278
|
+
help_configure
|
|
1279
|
+
fi
|
|
1280
|
+
|
|
1281
|
+
# qbraid credits
|
|
1282
|
+
elif [ "${1}" = "credits" ]; then
|
|
1283
|
+
((argDepth++))
|
|
1284
|
+
if [ "$(help_command "${argDepth}")" = "yes" ]; then
|
|
1285
|
+
help_credits
|
|
1286
|
+
fi
|
|
1210
1287
|
|
|
1211
1288
|
# qbraid envs
|
|
1212
1289
|
elif [ "${1}" = "envs" ]; then
|
|
@@ -1220,6 +1297,10 @@ qbraid() {
|
|
|
1220
1297
|
elif [ "${1}" = "jobs" ]; then
|
|
1221
1298
|
jobs "${@:2}"
|
|
1222
1299
|
|
|
1300
|
+
# qbraid devices
|
|
1301
|
+
elif [ "${1}" = "devices" ]; then
|
|
1302
|
+
devices "${@:2}"
|
|
1303
|
+
|
|
1223
1304
|
else
|
|
1224
1305
|
echo -e "${RED}ERROR: Invalid argument ${NC}${1}"
|
|
1225
1306
|
echo ""
|
|
@@ -0,0 +1,87 @@
|
|
|
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}")
|
|
@@ -0,0 +1,91 @@
|
|
|
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()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: qbraid-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: Command Line Interface for interacting with all parts of the qBraid platform.
|
|
5
5
|
Home-page: https://www.qbraid.com/
|
|
6
6
|
Author: qBraid Development Team
|
|
@@ -16,14 +16,15 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
16
16
|
Classifier: Programming Language :: Python
|
|
17
17
|
Classifier: Programming Language :: Python :: 3
|
|
18
18
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.9
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
22
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
23
22
|
Classifier: Programming Language :: Python :: 3.12
|
|
24
23
|
Requires-Python: >= 3.8
|
|
25
24
|
Description-Content-Type: text/markdown
|
|
25
|
+
Requires-Dist: qbraid>=0.5.0
|
|
26
26
|
Requires-Dist: awscli
|
|
27
|
+
Requires-Dist: ipykernel
|
|
27
28
|
Provides-Extra: dev
|
|
28
29
|
Requires-Dist: black; extra == "dev"
|
|
29
30
|
Requires-Dist: isort; extra == "dev"
|
|
@@ -46,7 +47,7 @@ The **qBraid CLI** is a specialized command-line interface tool designed *exclus
|
|
|
46
47
|
|
|
47
48
|
## Getting Started
|
|
48
49
|
|
|
49
|
-
To use the qBraid CLI, login (or create an account), launch
|
|
50
|
+
To use the qBraid CLI, login to qBraid (or create an account), launch Lab, and then open Terminal. You can also access the CLI directly from within [Notebooks](https://docs.qbraid.com/projects/lab/en/latest/lab/notebooks.html) using the ``!`` operator. See [quantum jobs example](https://github.com/qBraid/qbraid-lab-demo/blob/045c7a8fbdcae66a7e64533dd9fe0e981dc02cf4/qbraid_lab/quantum_jobs/aws_quantum_jobs.ipynb).
|
|
50
51
|
|
|
51
52
|
- [Launch qBraid Lab →](https://lab.qbraid.com/)
|
|
52
53
|
- [Make an account →](https://account.qbraid.com/)
|
|
@@ -2,6 +2,7 @@ README.md
|
|
|
2
2
|
setup.py
|
|
3
3
|
qbraid_cli/__init__.py
|
|
4
4
|
qbraid_cli/_version.py
|
|
5
|
+
qbraid_cli/configure.py
|
|
5
6
|
qbraid_cli/wrapper.py
|
|
6
7
|
qbraid_cli.egg-info/PKG-INFO
|
|
7
8
|
qbraid_cli.egg-info/SOURCES.txt
|
|
@@ -9,5 +10,4 @@ qbraid_cli.egg-info/dependency_links.txt
|
|
|
9
10
|
qbraid_cli.egg-info/entry_points.txt
|
|
10
11
|
qbraid_cli.egg-info/requires.txt
|
|
11
12
|
qbraid_cli.egg-info/top_level.txt
|
|
12
|
-
qbraid_cli/bin/banner.sh
|
|
13
13
|
qbraid_cli/bin/qbraid.sh
|
|
@@ -48,12 +48,12 @@ setup(
|
|
|
48
48
|
packages=find_packages(),
|
|
49
49
|
include_package_data=True,
|
|
50
50
|
python_requires=">= 3.8",
|
|
51
|
-
install_requires=["awscli"],
|
|
51
|
+
install_requires=["qbraid>=0.5.0", "awscli", "ipykernel"],
|
|
52
52
|
extras_require={
|
|
53
53
|
"dev": ["black", "isort", "pylint"],
|
|
54
54
|
"docs": ["sphinx~=5.3.0", "sphinx-rtd-theme~=1.3.0", "docutils~=0.18.1"],
|
|
55
55
|
},
|
|
56
|
-
scripts=["qbraid_cli/bin/qbraid.sh"
|
|
56
|
+
scripts=["qbraid_cli/bin/qbraid.sh"],
|
|
57
57
|
entry_points={
|
|
58
58
|
"console_scripts": [
|
|
59
59
|
"qbraid=qbraid_cli.wrapper:main",
|
|
@@ -68,7 +68,6 @@ setup(
|
|
|
68
68
|
"Programming Language :: Python",
|
|
69
69
|
"Programming Language :: Python :: 3",
|
|
70
70
|
"Programming Language :: Python :: 3 :: Only",
|
|
71
|
-
"Programming Language :: Python :: 3.8",
|
|
72
71
|
"Programming Language :: Python :: 3.9",
|
|
73
72
|
"Programming Language :: Python :: 3.10",
|
|
74
73
|
"Programming Language :: Python :: 3.11",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
NC="\033[0m" # No Color
|
|
2
|
-
PURPLE="\033[0;35m"
|
|
3
|
-
|
|
4
|
-
echo -e "---------------------------------------"
|
|
5
|
-
echo -e "* ${PURPLE}Welcome to the qBraid Lab Terminal!${NC} *"
|
|
6
|
-
echo -e "---------------------------------------"
|
|
7
|
-
echo -e ""
|
|
8
|
-
echo -e " ____ _ _ "
|
|
9
|
-
echo -e " __ _| __ ) _ __ __ _(_) __| | "
|
|
10
|
-
echo -e " / _ | _ \| __/ _ | |/ _ | "
|
|
11
|
-
echo -e " | (_| | |_) | | | (_| | | (_| | "
|
|
12
|
-
echo -e " \__ |____/|_| \__ _|_|\__ _| "
|
|
13
|
-
echo -e " |_| "
|
|
14
|
-
echo -e ""
|
|
15
|
-
echo -e ""
|
|
16
|
-
echo -e "Use \`qbraid -h\` to see available CLI commands."
|
|
17
|
-
echo -e ""
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Module to run the qbraid command line interface.
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
import os
|
|
7
|
-
import subprocess
|
|
8
|
-
import sys
|
|
9
|
-
|
|
10
|
-
from ._version import __version__
|
|
11
|
-
|
|
12
|
-
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def main():
|
|
16
|
-
"""The subprocess.run function is used to run the script and pass arguments."""
|
|
17
|
-
|
|
18
|
-
if sys.argv[1:] == ["--version"] or sys.argv[1:] == ["-V"]:
|
|
19
|
-
print(f"qbraid-cli/{__version__}")
|
|
20
|
-
else:
|
|
21
|
-
result = subprocess.run(
|
|
22
|
-
[os.path.join(PROJECT_ROOT, "bin", "qbraid.sh")] + sys.argv[1:],
|
|
23
|
-
text=True,
|
|
24
|
-
capture_output=True,
|
|
25
|
-
check=False,
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
if result.stdout:
|
|
29
|
-
if len(sys.argv) == 4 and sys.argv[2] == "activate":
|
|
30
|
-
line_lst = result.stdout.split("\n")
|
|
31
|
-
line_lst = line_lst[:-1] # remove trailing blank line
|
|
32
|
-
bin_path = line_lst.pop() # last line contains bin_path
|
|
33
|
-
std_out = "\n".join(line_lst) # all other lines are regular stdout
|
|
34
|
-
print(std_out)
|
|
35
|
-
# activate python environment using bin_path
|
|
36
|
-
os.system(
|
|
37
|
-
f"cat ~/.bashrc {bin_path}/activate > {bin_path}/activate2 && "
|
|
38
|
-
rf"sed -i 's/echo -e/\# echo -e/' {bin_path}/activate2 && "
|
|
39
|
-
f"/bin/bash --rcfile {bin_path}/activate2"
|
|
40
|
-
)
|
|
41
|
-
else:
|
|
42
|
-
print(result.stdout)
|
|
43
|
-
if result.stderr:
|
|
44
|
-
print(result.stderr)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if __name__ == "__main__":
|
|
48
|
-
main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|