lightning-sdk 0.1.38__py3-none-any.whl → 0.1.39__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/api/deployment_api.py +0 -2
- lightning_sdk/api/job_api.py +4 -0
- lightning_sdk/api/teamspace_api.py +4 -2
- lightning_sdk/api/utils.py +6 -3
- lightning_sdk/cli/download.py +3 -5
- lightning_sdk/cli/run.py +16 -0
- lightning_sdk/cli/upload.py +3 -10
- lightning_sdk/job/base.py +22 -0
- lightning_sdk/job/job.py +10 -1
- lightning_sdk/job/v1.py +5 -0
- lightning_sdk/job/v2.py +12 -0
- lightning_sdk/lightning_cloud/openapi/api/data_connection_service_api.py +6 -1
- lightning_sdk/lightning_cloud/openapi/api/models_store_api.py +118 -1
- lightning_sdk/lightning_cloud/openapi/models/id_start_body.py +29 -3
- lightning_sdk/lightning_cloud/openapi/models/project_id_cloudspaces_body.py +27 -1
- lightning_sdk/lightning_cloud/openapi/models/v1_data_path.py +29 -3
- lightning_sdk/lightning_cloud/openapi/models/v1_job_spec.py +53 -53
- lightning_sdk/lightning_cloud/openapi/models/v1_multi_machine_job.py +27 -1
- lightning_sdk/lightning_cloud/openapi/models/v1_multi_machine_job_state.py +0 -2
- lightning_sdk/models.py +132 -0
- lightning_sdk/teamspace.py +3 -2
- {lightning_sdk-0.1.38.dist-info → lightning_sdk-0.1.39.dist-info}/METADATA +1 -1
- {lightning_sdk-0.1.38.dist-info → lightning_sdk-0.1.39.dist-info}/RECORD +28 -28
- lightning_sdk/cli/models.py +0 -68
- {lightning_sdk-0.1.38.dist-info → lightning_sdk-0.1.39.dist-info}/LICENSE +0 -0
- {lightning_sdk-0.1.38.dist-info → lightning_sdk-0.1.39.dist-info}/WHEEL +0 -0
- {lightning_sdk-0.1.38.dist-info → lightning_sdk-0.1.39.dist-info}/entry_points.txt +0 -0
- {lightning_sdk-0.1.38.dist-info → lightning_sdk-0.1.39.dist-info}/top_level.txt +0 -0
lightning_sdk/cli/models.py
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from typing import Any, Dict, List, Tuple
|
|
3
|
-
|
|
4
|
-
from lightning_sdk.api import OrgApi, UserApi
|
|
5
|
-
from lightning_sdk.cli.exceptions import StudioCliError
|
|
6
|
-
from lightning_sdk.lightning_cloud.openapi.models import V1Membership, V1OwnerType
|
|
7
|
-
from lightning_sdk.teamspace import Teamspace
|
|
8
|
-
from lightning_sdk.user import User
|
|
9
|
-
from lightning_sdk.utils.resolve import _get_authed_user
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def _parse_model_name(name: str) -> Tuple[str, str, str]:
|
|
13
|
-
"""Parse the name argument into its components."""
|
|
14
|
-
try:
|
|
15
|
-
org_name, teamspace_name, model_name = name.split("/")
|
|
16
|
-
except ValueError as err:
|
|
17
|
-
raise StudioCliError(
|
|
18
|
-
f"Model name must be in the format 'organization/teamspace/model' but you provided '{name}'."
|
|
19
|
-
) from err
|
|
20
|
-
return org_name, teamspace_name, model_name
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def _get_teamspace_and_path(
|
|
24
|
-
ts: V1Membership, org_api: OrgApi, user_api: UserApi, authed_user: User
|
|
25
|
-
) -> Tuple[str, Dict[str, Any]]:
|
|
26
|
-
if ts.owner_type == V1OwnerType.ORGANIZATION:
|
|
27
|
-
org = org_api._get_org_by_id(ts.owner_id)
|
|
28
|
-
return f"{org.name}/{ts.name}", {"name": ts.name, "org": org.name}
|
|
29
|
-
|
|
30
|
-
if ts.owner_type == V1OwnerType.USER and ts.owner_id != authed_user.id:
|
|
31
|
-
user = user_api._get_user_by_id(ts.owner_id) # todo: check also the name
|
|
32
|
-
return f"{user.username}/{ts.name}", {"name": ts.name, "user": User(name=user.username)}
|
|
33
|
-
|
|
34
|
-
if ts.owner_type == V1OwnerType.USER:
|
|
35
|
-
return f"{authed_user.name}/{ts.name}", {"name": ts.name, "user": authed_user}
|
|
36
|
-
|
|
37
|
-
raise StudioCliError(f"Unknown organization type {ts.owner_type}")
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def _list_teamspaces() -> List[str]:
|
|
41
|
-
org_api = OrgApi()
|
|
42
|
-
user_api = UserApi()
|
|
43
|
-
authed_user = _get_authed_user()
|
|
44
|
-
|
|
45
|
-
return [
|
|
46
|
-
_get_teamspace_and_path(ts, org_api, user_api, authed_user)[0]
|
|
47
|
-
for ts in user_api._get_all_teamspace_memberships("")
|
|
48
|
-
]
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def _get_teamspace(name: str, organization: str) -> Teamspace:
|
|
52
|
-
"""Get a Teamspace object from the SDK."""
|
|
53
|
-
org_api = OrgApi()
|
|
54
|
-
user_api = UserApi()
|
|
55
|
-
authed_user = _get_authed_user()
|
|
56
|
-
|
|
57
|
-
requested_teamspace = f"{organization}/{name}".lower()
|
|
58
|
-
|
|
59
|
-
for ts in user_api._get_all_teamspace_memberships(""):
|
|
60
|
-
if ts.name != name:
|
|
61
|
-
continue
|
|
62
|
-
|
|
63
|
-
teamspace_path, teamspace = _get_teamspace_and_path(ts, org_api, user_api, authed_user)
|
|
64
|
-
if requested_teamspace == teamspace_path:
|
|
65
|
-
return Teamspace(**teamspace)
|
|
66
|
-
|
|
67
|
-
options = f"{os.linesep}\t".join(_list_teamspaces())
|
|
68
|
-
raise StudioCliError(f"Teamspace `{requested_teamspace}` not found. Available teamspaces: {os.linesep}\t{options}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|