qbraid-cli 0.9.2__py3-none-any.whl → 0.9.4__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 +2 -2
- qbraid_cli/envs/app.py +46 -6
- qbraid_cli/files/__init__.py +11 -0
- qbraid_cli/files/app.py +118 -0
- qbraid_cli/main.py +2 -0
- {qbraid_cli-0.9.2.dist-info → qbraid_cli-0.9.4.dist-info}/METADATA +2 -2
- {qbraid_cli-0.9.2.dist-info → qbraid_cli-0.9.4.dist-info}/RECORD +11 -9
- {qbraid_cli-0.9.2.dist-info → qbraid_cli-0.9.4.dist-info}/LICENSE +0 -0
- {qbraid_cli-0.9.2.dist-info → qbraid_cli-0.9.4.dist-info}/WHEEL +0 -0
- {qbraid_cli-0.9.2.dist-info → qbraid_cli-0.9.4.dist-info}/entry_points.txt +0 -0
- {qbraid_cli-0.9.2.dist-info → qbraid_cli-0.9.4.dist-info}/top_level.txt +0 -0
qbraid_cli/_version.py
CHANGED
qbraid_cli/envs/app.py
CHANGED
|
@@ -13,12 +13,13 @@ from pathlib import Path
|
|
|
13
13
|
from typing import TYPE_CHECKING, Optional
|
|
14
14
|
|
|
15
15
|
import typer
|
|
16
|
+
from qbraid_core.services.environments.schema import EnvironmentConfig
|
|
16
17
|
from rich.console import Console
|
|
17
18
|
|
|
18
19
|
from qbraid_cli.envs.create import create_qbraid_env_assets, create_venv
|
|
19
20
|
from qbraid_cli.envs.data_handling import get_envs_data as installed_envs_data
|
|
20
21
|
from qbraid_cli.envs.data_handling import validate_env_name
|
|
21
|
-
from qbraid_cli.handlers import QbraidException, run_progress_task
|
|
22
|
+
from qbraid_cli.handlers import QbraidException, handle_error, run_progress_task
|
|
22
23
|
|
|
23
24
|
if TYPE_CHECKING:
|
|
24
25
|
from qbraid_core.services.environments.client import EnvironmentManagerClient as EMC
|
|
@@ -28,18 +29,51 @@ envs_app = typer.Typer(help="Manage qBraid environments.", no_args_is_help=True)
|
|
|
28
29
|
|
|
29
30
|
@envs_app.command(name="create")
|
|
30
31
|
def envs_create( # pylint: disable=too-many-statements
|
|
31
|
-
name: str = typer.Option(
|
|
32
|
-
..., "--name", "-n", help="Name of the environment to create", callback=validate_env_name
|
|
33
|
-
),
|
|
32
|
+
name: str = typer.Option(None, "--name", "-n", help="Name of the environment to create"),
|
|
34
33
|
description: Optional[str] = typer.Option(
|
|
35
34
|
None, "--description", "-d", help="Short description of the environment"
|
|
36
35
|
),
|
|
36
|
+
file_path: str = typer.Option(
|
|
37
|
+
None, "--file", "-f", help="Path to a .yml file containing the environment details"
|
|
38
|
+
),
|
|
37
39
|
auto_confirm: bool = typer.Option(
|
|
38
40
|
False, "--yes", "-y", help="Automatically answer 'yes' to all prompts"
|
|
39
41
|
),
|
|
40
42
|
) -> None:
|
|
41
43
|
"""Create a new qBraid environment."""
|
|
42
44
|
env_description = description or ""
|
|
45
|
+
if name:
|
|
46
|
+
if not validate_env_name(name):
|
|
47
|
+
handle_error(
|
|
48
|
+
error_type="ValueError",
|
|
49
|
+
include_traceback=False,
|
|
50
|
+
message=f"Invalid environment name '{name}'. ",
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
env_details_in_cli = name is not None and env_description != ""
|
|
54
|
+
custom_env_data = None
|
|
55
|
+
if env_details_in_cli and file_path:
|
|
56
|
+
handle_error(
|
|
57
|
+
error_type="ArgumentConflictError",
|
|
58
|
+
include_traceback=False,
|
|
59
|
+
message="Cannot use --file with --name or --description while creating an environment",
|
|
60
|
+
)
|
|
61
|
+
elif not env_details_in_cli and not file_path:
|
|
62
|
+
handle_error(
|
|
63
|
+
error_type="MalformedCommandError",
|
|
64
|
+
include_traceback=False,
|
|
65
|
+
message="Must provide either --name and --description or --file "
|
|
66
|
+
"while creating an environment",
|
|
67
|
+
)
|
|
68
|
+
else:
|
|
69
|
+
try:
|
|
70
|
+
if file_path:
|
|
71
|
+
custom_env_data: EnvironmentConfig = EnvironmentConfig.from_yaml(file_path)
|
|
72
|
+
except ValueError as err:
|
|
73
|
+
handle_error(error_type="YamlValidationError", message=str(err))
|
|
74
|
+
|
|
75
|
+
if not name:
|
|
76
|
+
name = custom_env_data.name
|
|
43
77
|
|
|
44
78
|
def create_environment(*args, **kwargs) -> "tuple[dict, EMC]":
|
|
45
79
|
"""Create a qBraid environment."""
|
|
@@ -65,10 +99,15 @@ def envs_create( # pylint: disable=too-many-statements
|
|
|
65
99
|
|
|
66
100
|
return env_path, python_version
|
|
67
101
|
|
|
102
|
+
if not custom_env_data:
|
|
103
|
+
custom_env_data = EnvironmentConfig(
|
|
104
|
+
name=name,
|
|
105
|
+
description=env_description,
|
|
106
|
+
)
|
|
107
|
+
|
|
68
108
|
environment, emc = run_progress_task(
|
|
69
109
|
create_environment,
|
|
70
|
-
|
|
71
|
-
env_description,
|
|
110
|
+
custom_env_data,
|
|
72
111
|
description="Validating request...",
|
|
73
112
|
error_message="Failed to create qBraid environment",
|
|
74
113
|
)
|
|
@@ -78,6 +117,7 @@ def envs_create( # pylint: disable=too-many-statements
|
|
|
78
117
|
description="Solving environment...",
|
|
79
118
|
error_message="Failed to create qBraid environment",
|
|
80
119
|
)
|
|
120
|
+
|
|
81
121
|
slug = environment.get("slug")
|
|
82
122
|
display_name = environment.get("displayName")
|
|
83
123
|
prompt = environment.get("prompt")
|
qbraid_cli/files/app.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Copyright (c) 2024, qBraid Development Team
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Module defining commands in the 'qbraid files' namespace.
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
import rich
|
|
13
|
+
import typer
|
|
14
|
+
|
|
15
|
+
from qbraid_cli.handlers import run_progress_task
|
|
16
|
+
|
|
17
|
+
files_app = typer.Typer(help="Manage qBraid cloud storage files.", no_args_is_help=True)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@files_app.command(name="upload")
|
|
21
|
+
def files_upload(
|
|
22
|
+
filepath: Path = typer.Argument(
|
|
23
|
+
...,
|
|
24
|
+
exists=True,
|
|
25
|
+
dir_okay=False,
|
|
26
|
+
resolve_path=True,
|
|
27
|
+
help="Local path to the file to upload.",
|
|
28
|
+
),
|
|
29
|
+
namespace: str = typer.Option(
|
|
30
|
+
"user",
|
|
31
|
+
"--namespace",
|
|
32
|
+
"-n",
|
|
33
|
+
help="Target qBraid namespace for the upload.",
|
|
34
|
+
),
|
|
35
|
+
object_path: str = typer.Option(
|
|
36
|
+
None,
|
|
37
|
+
"--object-path",
|
|
38
|
+
"-p",
|
|
39
|
+
help=("Target object path. " "Defaults to original filename in namespace root."),
|
|
40
|
+
),
|
|
41
|
+
overwrite: bool = typer.Option(
|
|
42
|
+
False,
|
|
43
|
+
"--overwrite",
|
|
44
|
+
"-o",
|
|
45
|
+
help="Overwrite existing file if it already exists in the target location.",
|
|
46
|
+
),
|
|
47
|
+
):
|
|
48
|
+
"""Upload a local file to qBraid storage."""
|
|
49
|
+
|
|
50
|
+
def upload_file() -> dict[str, Any]:
|
|
51
|
+
from qbraid_core.services.files import FileManagerClient
|
|
52
|
+
|
|
53
|
+
client = FileManagerClient()
|
|
54
|
+
data = client.upload_file(
|
|
55
|
+
filepath, namespace=namespace, object_path=object_path, overwrite=overwrite
|
|
56
|
+
)
|
|
57
|
+
return data
|
|
58
|
+
|
|
59
|
+
data: dict = run_progress_task(
|
|
60
|
+
upload_file, description="Uploading file...", include_error_traceback=False
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
rich.print("File uploaded successfully!")
|
|
64
|
+
namespace = data.get("namespace")
|
|
65
|
+
object_path = data.get("objectPath")
|
|
66
|
+
|
|
67
|
+
if namespace and object_path:
|
|
68
|
+
rich.print(f"\nNamespace: '{namespace}'")
|
|
69
|
+
rich.print(f"Object path: '{object_path}'")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@files_app.command(name="download")
|
|
73
|
+
def files_download(
|
|
74
|
+
object_path: str = typer.Argument(
|
|
75
|
+
...,
|
|
76
|
+
help="The folder + filename describing the file to download.",
|
|
77
|
+
),
|
|
78
|
+
namespace: str = typer.Option(
|
|
79
|
+
"user",
|
|
80
|
+
"--namespace",
|
|
81
|
+
"-n",
|
|
82
|
+
help="Source qBraid namespace for the download.",
|
|
83
|
+
),
|
|
84
|
+
save_path: Path = typer.Option(
|
|
85
|
+
Path.cwd(),
|
|
86
|
+
"--save-path",
|
|
87
|
+
"-s",
|
|
88
|
+
resolve_path=True,
|
|
89
|
+
help="Local directory to save the downloaded file.",
|
|
90
|
+
),
|
|
91
|
+
overwrite: bool = typer.Option(
|
|
92
|
+
False,
|
|
93
|
+
"--overwrite",
|
|
94
|
+
"-o",
|
|
95
|
+
help="Overwrite existing file if it already exists in the target location.",
|
|
96
|
+
),
|
|
97
|
+
):
|
|
98
|
+
"""Download a file from qBraid storage."""
|
|
99
|
+
|
|
100
|
+
def download_file() -> Path:
|
|
101
|
+
from qbraid_core.services.files import FileManagerClient
|
|
102
|
+
|
|
103
|
+
client = FileManagerClient()
|
|
104
|
+
file_path = client.download_file(
|
|
105
|
+
object_path, namespace=namespace, save_path=save_path, overwrite=overwrite
|
|
106
|
+
)
|
|
107
|
+
return file_path
|
|
108
|
+
|
|
109
|
+
file_path: Path = run_progress_task(
|
|
110
|
+
download_file, description="Downloading file...", include_error_traceback=False
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
rich.print("File downloaded successfully!")
|
|
114
|
+
rich.print(f"Saved to: '{str(file_path)}'")
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
if __name__ == "__main__":
|
|
118
|
+
files_app()
|
qbraid_cli/main.py
CHANGED
|
@@ -15,6 +15,7 @@ from qbraid_cli.admin import admin_app
|
|
|
15
15
|
from qbraid_cli.chat import ChatFormat, list_models_callback, prompt_callback
|
|
16
16
|
from qbraid_cli.configure import configure_app
|
|
17
17
|
from qbraid_cli.devices import devices_app
|
|
18
|
+
from qbraid_cli.files import files_app
|
|
18
19
|
from qbraid_cli.jobs import jobs_app
|
|
19
20
|
|
|
20
21
|
try:
|
|
@@ -32,6 +33,7 @@ app.add_typer(admin_app, name="admin")
|
|
|
32
33
|
app.add_typer(configure_app, name="configure")
|
|
33
34
|
app.add_typer(account_app, name="account")
|
|
34
35
|
app.add_typer(devices_app, name="devices")
|
|
36
|
+
app.add_typer(files_app, name="files")
|
|
35
37
|
app.add_typer(jobs_app, name="jobs")
|
|
36
38
|
|
|
37
39
|
if ENVS_COMMANDS is True:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: qbraid-cli
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.4
|
|
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
|
|
@@ -30,7 +30,7 @@ License-File: LICENSE
|
|
|
30
30
|
Requires-Dist: typer>=0.12.1
|
|
31
31
|
Requires-Dist: rich>=10.11.0
|
|
32
32
|
Requires-Dist: click
|
|
33
|
-
Requires-Dist: qbraid-core>=0.1.
|
|
33
|
+
Requires-Dist: qbraid-core>=0.1.33
|
|
34
34
|
Provides-Extra: jobs
|
|
35
35
|
Requires-Dist: amazon-braket-sdk>=1.48.1; extra == "jobs"
|
|
36
36
|
Provides-Extra: envs
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
qbraid_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
qbraid_cli/_version.py,sha256=
|
|
2
|
+
qbraid_cli/_version.py,sha256=N2r6Pxbr0xZx1XwnfGZ1tTgnRDaJpNzOV5NmOdJYA4A,411
|
|
3
3
|
qbraid_cli/exceptions.py,sha256=KjlhYJhSHMVazaNiBjD_Ur06w4sekP8zRsFzBdyIpno,672
|
|
4
4
|
qbraid_cli/handlers.py,sha256=B9H1Qw6yx8izrqp9OGR2TgSJa_mxA8KLXUkX8LB7Feg,7650
|
|
5
|
-
qbraid_cli/main.py,sha256=
|
|
5
|
+
qbraid_cli/main.py,sha256=aSOQyoRRvKBJBcx8VtU4zKZ2WHvGKHhw8I-WiRwPxcE,3926
|
|
6
6
|
qbraid_cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
qbraid_cli/account/__init__.py,sha256=smlpUcVkM3QEbJG0norGM7i71XBJlUGQYByswTfPnmg,181
|
|
8
8
|
qbraid_cli/account/app.py,sha256=1UogauwgX0Hnr7H6cBV2Qv-lT6aRpRLAimCyLi0afGI,1843
|
|
@@ -20,9 +20,11 @@ qbraid_cli/devices/app.py,sha256=q8AQ8o05JXODsaFR_16_S3UtLWPzwC2qi0bVw2h7RJ8,254
|
|
|
20
20
|
qbraid_cli/devices/validation.py,sha256=YhShyUufgrKnx2XjXOXF-PqFJYklJT9CgeqIwKcNam4,809
|
|
21
21
|
qbraid_cli/envs/__init__.py,sha256=1-cMvrATsddYxcetPJWxq6bEOqJWMktGdhoZ4qm8euA,172
|
|
22
22
|
qbraid_cli/envs/activate.py,sha256=VpvVYSfQDlcmlNWJOgkLIQ2p8YXPPLG8Jbl5t8GHUDw,2140
|
|
23
|
-
qbraid_cli/envs/app.py,sha256=
|
|
23
|
+
qbraid_cli/envs/app.py,sha256=c3O5fB6PThCXS2hyYMHrj8YvvEJaI-_8NZd_GN_4iZ0,9972
|
|
24
24
|
qbraid_cli/envs/create.py,sha256=xudzkLCNegY34zkXN_Vfl_0zVzg_tW83LcVx9quoWfU,988
|
|
25
25
|
qbraid_cli/envs/data_handling.py,sha256=Ibnp2yJoUDpivb_sNqi0suYgJZNat_LmM6Ya0Ovez5s,1288
|
|
26
|
+
qbraid_cli/files/__init__.py,sha256=3_yhgFoNcviEtS6B75uJBrfFFUjsrMcccCNEntJ54xU,175
|
|
27
|
+
qbraid_cli/files/app.py,sha256=PoJAyfd1Y2OJm9wKNjbnzbouVOmOnrYeLWforOSFwgA,3182
|
|
26
28
|
qbraid_cli/jobs/__init__.py,sha256=qVLRHYIzP4XHpx_QWP_vCzd3LsCscCORaEx-Vcbx29U,172
|
|
27
29
|
qbraid_cli/jobs/app.py,sha256=LnrxALu7OWSUg1FD6FvlGsILdoH46Y-ra12eiSfiMlE,4938
|
|
28
30
|
qbraid_cli/jobs/toggle_braket.py,sha256=3AEu-Z5q4avduB-fJMyMTVTuyZXuA8m-hnvi325wIv4,7444
|
|
@@ -32,9 +34,9 @@ qbraid_cli/kernels/app.py,sha256=n-iyWJHy7_ML6qk4pp-v_rQkGA7WfnZMG8gyiCFGO1c,294
|
|
|
32
34
|
qbraid_cli/pip/__init__.py,sha256=tJtU0rxn-ODogNh5Y4pp_BgDQXMN-3JY1QGj0OZHwjQ,169
|
|
33
35
|
qbraid_cli/pip/app.py,sha256=jkk-djductrDOJIRYfHK_7WDJ12f0zOT3MMkiZp97oM,1365
|
|
34
36
|
qbraid_cli/pip/hooks.py,sha256=jkIeev3cOd-cmaoJSdSqbmhTYCs6z1we84FMqa3ZoZw,2124
|
|
35
|
-
qbraid_cli-0.9.
|
|
36
|
-
qbraid_cli-0.9.
|
|
37
|
-
qbraid_cli-0.9.
|
|
38
|
-
qbraid_cli-0.9.
|
|
39
|
-
qbraid_cli-0.9.
|
|
40
|
-
qbraid_cli-0.9.
|
|
37
|
+
qbraid_cli-0.9.4.dist-info/LICENSE,sha256=P1gi-ofB8lmkRt_mxDoJpcgQq9Ckq9WhRAS1oYk-G1s,2506
|
|
38
|
+
qbraid_cli-0.9.4.dist-info/METADATA,sha256=fi9PnYYH7xpt09ko6-ejSpC_pdw4b6NsIj6LNcT8tEE,6806
|
|
39
|
+
qbraid_cli-0.9.4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
40
|
+
qbraid_cli-0.9.4.dist-info/entry_points.txt,sha256=c5ZJ7NjbxhDqMpou9q5F03_b_KG34HzFDijIDmEIwgQ,47
|
|
41
|
+
qbraid_cli-0.9.4.dist-info/top_level.txt,sha256=LTYJgeYSCHo9Il8vZu0yIPuGdGyNaIw6iRy6BeoZo8o,11
|
|
42
|
+
qbraid_cli-0.9.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|