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.
Files changed (29) hide show
  1. lightning_sdk/__init__.py +1 -1
  2. lightning_sdk/api/deployment_api.py +0 -2
  3. lightning_sdk/api/job_api.py +4 -0
  4. lightning_sdk/api/teamspace_api.py +4 -2
  5. lightning_sdk/api/utils.py +6 -3
  6. lightning_sdk/cli/download.py +3 -5
  7. lightning_sdk/cli/run.py +16 -0
  8. lightning_sdk/cli/upload.py +3 -10
  9. lightning_sdk/job/base.py +22 -0
  10. lightning_sdk/job/job.py +10 -1
  11. lightning_sdk/job/v1.py +5 -0
  12. lightning_sdk/job/v2.py +12 -0
  13. lightning_sdk/lightning_cloud/openapi/api/data_connection_service_api.py +6 -1
  14. lightning_sdk/lightning_cloud/openapi/api/models_store_api.py +118 -1
  15. lightning_sdk/lightning_cloud/openapi/models/id_start_body.py +29 -3
  16. lightning_sdk/lightning_cloud/openapi/models/project_id_cloudspaces_body.py +27 -1
  17. lightning_sdk/lightning_cloud/openapi/models/v1_data_path.py +29 -3
  18. lightning_sdk/lightning_cloud/openapi/models/v1_job_spec.py +53 -53
  19. lightning_sdk/lightning_cloud/openapi/models/v1_multi_machine_job.py +27 -1
  20. lightning_sdk/lightning_cloud/openapi/models/v1_multi_machine_job_state.py +0 -2
  21. lightning_sdk/models.py +132 -0
  22. lightning_sdk/teamspace.py +3 -2
  23. {lightning_sdk-0.1.38.dist-info → lightning_sdk-0.1.39.dist-info}/METADATA +1 -1
  24. {lightning_sdk-0.1.38.dist-info → lightning_sdk-0.1.39.dist-info}/RECORD +28 -28
  25. lightning_sdk/cli/models.py +0 -68
  26. {lightning_sdk-0.1.38.dist-info → lightning_sdk-0.1.39.dist-info}/LICENSE +0 -0
  27. {lightning_sdk-0.1.38.dist-info → lightning_sdk-0.1.39.dist-info}/WHEEL +0 -0
  28. {lightning_sdk-0.1.38.dist-info → lightning_sdk-0.1.39.dist-info}/entry_points.txt +0 -0
  29. {lightning_sdk-0.1.38.dist-info → lightning_sdk-0.1.39.dist-info}/top_level.txt +0 -0
@@ -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}")