lightning-sdk 0.1.29__py3-none-any.whl → 0.1.30__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.
- lightning_sdk/__init__.py +1 -1
- lightning_sdk/cli/download.py +19 -2
- lightning_sdk/cli/models.py +38 -0
- lightning_sdk/cli/upload.py +21 -2
- {lightning_sdk-0.1.29.dist-info → lightning_sdk-0.1.30.dist-info}/METADATA +1 -1
- {lightning_sdk-0.1.29.dist-info → lightning_sdk-0.1.30.dist-info}/RECORD +10 -9
- {lightning_sdk-0.1.29.dist-info → lightning_sdk-0.1.30.dist-info}/LICENSE +0 -0
- {lightning_sdk-0.1.29.dist-info → lightning_sdk-0.1.30.dist-info}/WHEEL +0 -0
- {lightning_sdk-0.1.29.dist-info → lightning_sdk-0.1.30.dist-info}/entry_points.txt +0 -0
- {lightning_sdk-0.1.29.dist-info → lightning_sdk-0.1.30.dist-info}/top_level.txt +0 -0
lightning_sdk/__init__.py
CHANGED
lightning_sdk/cli/download.py
CHANGED
|
@@ -4,6 +4,7 @@ from pathlib import Path
|
|
|
4
4
|
from typing import Optional
|
|
5
5
|
|
|
6
6
|
from lightning_sdk.cli.exceptions import StudioCliError
|
|
7
|
+
from lightning_sdk.cli.models import _get_teamspace, _parse_model_name
|
|
7
8
|
from lightning_sdk.cli.studios_menu import _StudiosMenu
|
|
8
9
|
from lightning_sdk.studio import Studio
|
|
9
10
|
from lightning_sdk.utils.resolve import _get_authed_user, skip_studio_init
|
|
@@ -12,6 +13,22 @@ from lightning_sdk.utils.resolve import _get_authed_user, skip_studio_init
|
|
|
12
13
|
class _Downloads(_StudiosMenu):
|
|
13
14
|
"""Download files and folders from Lightning AI."""
|
|
14
15
|
|
|
16
|
+
def model(self, name: str, path: Optional[str] = None) -> None:
|
|
17
|
+
"""Download a Model.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
name: The name of the Model you want to download.
|
|
21
|
+
This should have the format <ORGANIZATION-NAME>/<TEAMSPACE-NAME>/<MODEL-NAME>.
|
|
22
|
+
path: The path to the directory where the Model should be downloaded.
|
|
23
|
+
"""
|
|
24
|
+
org_name, teamspace_name, model_name = _parse_model_name(name)
|
|
25
|
+
teamspace = _get_teamspace(name=teamspace_name, organization=org_name)
|
|
26
|
+
teamspace.download_model(
|
|
27
|
+
name=model_name,
|
|
28
|
+
download_dir=path or ".",
|
|
29
|
+
progress_bar=True,
|
|
30
|
+
)
|
|
31
|
+
|
|
15
32
|
def _resolve_studio(self, studio: Optional[str]) -> Studio:
|
|
16
33
|
user = _get_authed_user()
|
|
17
34
|
# if no studio specify suggest/filter only user's studios
|
|
@@ -53,7 +70,7 @@ class _Downloads(_StudiosMenu):
|
|
|
53
70
|
return Studio(**selected_studio)
|
|
54
71
|
|
|
55
72
|
def folder(self, path: str = "", studio: Optional[str] = None, local_path: str = ".") -> None:
|
|
56
|
-
"""Download a folder from a
|
|
73
|
+
"""Download a folder from a Studio.
|
|
57
74
|
|
|
58
75
|
Args:
|
|
59
76
|
path: The relative path within the Studio you want to download.
|
|
@@ -86,7 +103,7 @@ class _Downloads(_StudiosMenu):
|
|
|
86
103
|
) from e
|
|
87
104
|
|
|
88
105
|
def file(self, path: str = "", studio: Optional[str] = None, local_path: str = ".") -> None:
|
|
89
|
-
"""Download a file from a
|
|
106
|
+
"""Download a file from a Studio.
|
|
90
107
|
|
|
91
108
|
Args:
|
|
92
109
|
path: The relative path within the Studio you want to download.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from typing import Tuple
|
|
2
|
+
|
|
3
|
+
from lightning_sdk.api import OrgApi, UserApi
|
|
4
|
+
from lightning_sdk.cli.exceptions import StudioCliError
|
|
5
|
+
from lightning_sdk.teamspace import Teamspace
|
|
6
|
+
from lightning_sdk.utils.resolve import _get_authed_user
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _parse_model_name(name: str) -> Tuple[str, str, str]:
|
|
10
|
+
"""Parse the name argument into its components."""
|
|
11
|
+
try:
|
|
12
|
+
org_name, teamspace_name, model_name = name.split("/")
|
|
13
|
+
except ValueError as err:
|
|
14
|
+
raise StudioCliError(
|
|
15
|
+
f"Model name must be in the format 'organization/teamspace/model' but you provided '{name}'."
|
|
16
|
+
) from err
|
|
17
|
+
return org_name, teamspace_name, model_name
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _get_teamspace(name: str, organization: str) -> Teamspace:
|
|
21
|
+
"""Get a Teamspace object from the SDK."""
|
|
22
|
+
org_api = OrgApi()
|
|
23
|
+
user = _get_authed_user()
|
|
24
|
+
teamspaces = {}
|
|
25
|
+
for ts in UserApi()._get_all_teamspace_memberships(""):
|
|
26
|
+
if ts.owner_type == "organization":
|
|
27
|
+
org = org_api._get_org_by_id(ts.owner_id)
|
|
28
|
+
teamspaces[f"{org.name}/{ts.name}"] = {"name": ts.name, "org": org.name}
|
|
29
|
+
elif ts.owner_type == "user": # todo: check also the name
|
|
30
|
+
teamspaces[f"{user.name}/{ts.name}"] = {"name": ts.name, "user": user}
|
|
31
|
+
else:
|
|
32
|
+
raise StudioCliError(f"Unknown organization type {ts.owner_type}")
|
|
33
|
+
|
|
34
|
+
requested_teamspace = f"{organization}/{name}".lower()
|
|
35
|
+
if requested_teamspace not in teamspaces:
|
|
36
|
+
options = "\n\t".join(teamspaces.keys())
|
|
37
|
+
raise StudioCliError(f"Teamspace `{requested_teamspace}` not found. Available teamspaces: \n\t{options}")
|
|
38
|
+
return Teamspace(**teamspaces[requested_teamspace])
|
lightning_sdk/cli/upload.py
CHANGED
|
@@ -9,6 +9,7 @@ from tqdm import tqdm
|
|
|
9
9
|
|
|
10
10
|
from lightning_sdk.api.utils import _get_cloud_url
|
|
11
11
|
from lightning_sdk.cli.exceptions import StudioCliError
|
|
12
|
+
from lightning_sdk.cli.models import _get_teamspace, _parse_model_name
|
|
12
13
|
from lightning_sdk.cli.studios_menu import _StudiosMenu
|
|
13
14
|
from lightning_sdk.studio import Studio
|
|
14
15
|
from lightning_sdk.utils.resolve import _get_authed_user, skip_studio_init
|
|
@@ -19,6 +20,24 @@ class _Uploads(_StudiosMenu):
|
|
|
19
20
|
|
|
20
21
|
_studio_upload_status_path = "~/.lightning/studios/uploads"
|
|
21
22
|
|
|
23
|
+
def model(self, name: str, path: Optional[str] = None, cloud_account: Optional[str] = None) -> None:
|
|
24
|
+
"""Upload a Model.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
name: The name of the Model you want to upload.
|
|
28
|
+
This should have the format <ORGANIZATION-NAME>/<TEAMSPACE-NAME>/<MODEL-NAME>.
|
|
29
|
+
path: The path to the file or directory you want to upload. Defaults to the current directory.
|
|
30
|
+
cloud_account: The name of the cloud account to store the Model in.
|
|
31
|
+
"""
|
|
32
|
+
org_name, teamspace_name, model_name = _parse_model_name(name)
|
|
33
|
+
teamspace = _get_teamspace(name=teamspace_name, organization=org_name)
|
|
34
|
+
teamspace.upload_model(
|
|
35
|
+
path=path or ".",
|
|
36
|
+
name=model_name,
|
|
37
|
+
progress_bar=True,
|
|
38
|
+
cluster_id=cloud_account,
|
|
39
|
+
)
|
|
40
|
+
|
|
22
41
|
def _resolve_studio(self, studio: Optional[str]) -> Studio:
|
|
23
42
|
user = _get_authed_user()
|
|
24
43
|
possible_studios = self._get_possible_studios(user)
|
|
@@ -43,7 +62,7 @@ class _Uploads(_StudiosMenu):
|
|
|
43
62
|
return Studio(**selected_studio)
|
|
44
63
|
|
|
45
64
|
def folder(self, path: str, studio: Optional[str] = None, remote_path: Optional[str] = None) -> None:
|
|
46
|
-
"""Upload a file or folder to a
|
|
65
|
+
"""Upload a file or folder to a Studio.
|
|
47
66
|
|
|
48
67
|
Args:
|
|
49
68
|
path: The path to the file or directory you want to upload
|
|
@@ -97,7 +116,7 @@ class _Uploads(_StudiosMenu):
|
|
|
97
116
|
print(f"See your files at {studio_url}")
|
|
98
117
|
|
|
99
118
|
def file(self, path: str, studio: Optional[str] = None, remote_path: Optional[str] = None) -> None:
|
|
100
|
-
"""Upload a file to a
|
|
119
|
+
"""Upload a file to a Studio.
|
|
101
120
|
|
|
102
121
|
Args:
|
|
103
122
|
path: The path to the file you want to upload
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
docs/source/conf.py,sha256=r8yX20eC-4mHhMTd0SbQb5TlSWHhO6wnJ0VJ_FBFpag,13249
|
|
2
|
-
lightning_sdk/__init__.py,sha256=
|
|
2
|
+
lightning_sdk/__init__.py,sha256=3XBiirAYfvf8AM-l2cNOgRfPkmtJGyFdE9C7IFIjQFc,873
|
|
3
3
|
lightning_sdk/agents.py,sha256=ly6Ma1j0ZgGPFyvPvMN28JWiB9dATIstFa5XM8pMi6I,1577
|
|
4
4
|
lightning_sdk/constants.py,sha256=ztl1PTUBULnqTf3DyKUSJaV_O20hNtUYT6XvAYIrmIk,749
|
|
5
5
|
lightning_sdk/helpers.py,sha256=RnQwUquc_YPotjh6YXOoJvZs8krX_QFhd7kGv4U_spQ,1844
|
|
@@ -21,12 +21,13 @@ lightning_sdk/api/teamspace_api.py,sha256=XXK9ApV7yya5tYUNr4uSVDQT0Z6KU-B2PDN1gO
|
|
|
21
21
|
lightning_sdk/api/user_api.py,sha256=FcvJ7nVPrZIh94JGxtPscKMb-de-vV_FUOGEwbuyKcg,2312
|
|
22
22
|
lightning_sdk/api/utils.py,sha256=Pnze_iy14cScQdOs8oELLXP-9WncpyigVEaohiT7uLM,20380
|
|
23
23
|
lightning_sdk/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
|
-
lightning_sdk/cli/download.py,sha256=
|
|
24
|
+
lightning_sdk/cli/download.py,sha256=b6dpUMLhro6p0y6CleCHxggQnZlZMxCq0bjuf8B6_eA,6191
|
|
25
25
|
lightning_sdk/cli/entrypoint.py,sha256=DD9rbmNqH6uE0IKMzfOenVymyrvfTMYi_zDPHr4Pk5E,1258
|
|
26
26
|
lightning_sdk/cli/exceptions.py,sha256=QUF3OMAMZwBikvlusimSHSBjb6ywvHpfAumJBEaodSw,169
|
|
27
27
|
lightning_sdk/cli/legacy.py,sha256=ocTVNwlsLRS5aMjbMkwFPjT3uEYvS8C40CJ0PeRRv8g,4707
|
|
28
|
+
lightning_sdk/cli/models.py,sha256=_OT5sqk8lC40fKyutfx9XKvVhoj7QSrU7PhPJhBCSCQ,1647
|
|
28
29
|
lightning_sdk/cli/studios_menu.py,sha256=0kQGqGel8gAbpdJtjOM1a6NEat_TnIqRNprNn8QiK58,3236
|
|
29
|
-
lightning_sdk/cli/upload.py,sha256=
|
|
30
|
+
lightning_sdk/cli/upload.py,sha256=05LVL5CnXuTefuU8dkyI5GLdSPoTkeLBCJIhznoKvVM,9246
|
|
30
31
|
lightning_sdk/deployment/__init__.py,sha256=BLu7_cVLp97TYxe6qe-J1zKUSZXAVcvCjgcA7plV2k4,497
|
|
31
32
|
lightning_sdk/deployment/deployment.py,sha256=47-aga7g8emJWrEkqr4FzfhMaNnsWhTSoinOl7FAMI0,15035
|
|
32
33
|
lightning_sdk/job/__init__.py,sha256=1MxjQ6rHkyUHCypSW9RuXuVMVH11WiqhIXcU2LCFMwE,64
|
|
@@ -775,9 +776,9 @@ lightning_sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
|
|
|
775
776
|
lightning_sdk/utils/dynamic.py,sha256=glUTO1JC9APtQ6Gr9SO02a3zr56-sPAXM5C3NrTpgyQ,1959
|
|
776
777
|
lightning_sdk/utils/enum.py,sha256=h2JRzqoBcSlUdanFHmkj_j5DleBHAu1esQYUsdNI-hU,4106
|
|
777
778
|
lightning_sdk/utils/resolve.py,sha256=gU3MSko9Y7rE4jcnVwstNBaW83OFnSgvM-N44Ibrc_A,5148
|
|
778
|
-
lightning_sdk-0.1.
|
|
779
|
-
lightning_sdk-0.1.
|
|
780
|
-
lightning_sdk-0.1.
|
|
781
|
-
lightning_sdk-0.1.
|
|
782
|
-
lightning_sdk-0.1.
|
|
783
|
-
lightning_sdk-0.1.
|
|
779
|
+
lightning_sdk-0.1.30.dist-info/LICENSE,sha256=uFIuZwj5z-4TeF2UuacPZ1o17HkvKObT8fY50qN84sg,1064
|
|
780
|
+
lightning_sdk-0.1.30.dist-info/METADATA,sha256=UaWQnogmihUzuy1qN_1MY9klBbNU4tHgA3x_wT666r8,3941
|
|
781
|
+
lightning_sdk-0.1.30.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
782
|
+
lightning_sdk-0.1.30.dist-info/entry_points.txt,sha256=msB9PJWIJ784dX-OP8by51d4IbKYH3Fj1vCuA9oXjHY,68
|
|
783
|
+
lightning_sdk-0.1.30.dist-info/top_level.txt,sha256=ps8doKILFXmN7F1mHncShmnQoTxKBRPIcchC8TpoBw4,19
|
|
784
|
+
lightning_sdk-0.1.30.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|