lightning-sdk 0.1.57__py3-none-any.whl → 0.2.0__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 (118) hide show
  1. lightning_sdk/__init__.py +5 -3
  2. lightning_sdk/api/deployment_api.py +23 -11
  3. lightning_sdk/api/job_api.py +42 -7
  4. lightning_sdk/api/lit_container_api.py +88 -22
  5. lightning_sdk/api/mmt_api.py +46 -8
  6. lightning_sdk/api/pipeline_api.py +50 -0
  7. lightning_sdk/api/teamspace_api.py +2 -2
  8. lightning_sdk/api/utils.py +15 -5
  9. lightning_sdk/cli/ai_hub.py +30 -65
  10. lightning_sdk/cli/coloring.py +60 -0
  11. lightning_sdk/cli/configure.py +25 -40
  12. lightning_sdk/cli/connect.py +7 -20
  13. lightning_sdk/cli/create.py +83 -0
  14. lightning_sdk/cli/delete.py +72 -75
  15. lightning_sdk/cli/docker.py +77 -0
  16. lightning_sdk/cli/download.py +71 -111
  17. lightning_sdk/cli/entrypoint.py +44 -65
  18. lightning_sdk/cli/generate.py +28 -43
  19. lightning_sdk/cli/inspect.py +22 -50
  20. lightning_sdk/cli/list.py +281 -222
  21. lightning_sdk/cli/mmts_menu.py +1 -1
  22. lightning_sdk/cli/open.py +62 -0
  23. lightning_sdk/cli/run.py +430 -263
  24. lightning_sdk/cli/serve.py +162 -189
  25. lightning_sdk/cli/start.py +55 -36
  26. lightning_sdk/cli/stop.py +97 -55
  27. lightning_sdk/cli/switch.py +53 -36
  28. lightning_sdk/cli/upload.py +318 -245
  29. lightning_sdk/deployment/__init__.py +2 -0
  30. lightning_sdk/deployment/deployment.py +33 -8
  31. lightning_sdk/lightning_cloud/openapi/__init__.py +21 -0
  32. lightning_sdk/lightning_cloud/openapi/api/__init__.py +1 -0
  33. lightning_sdk/lightning_cloud/openapi/api/assistants_service_api.py +10 -6
  34. lightning_sdk/lightning_cloud/openapi/api/jobs_service_api.py +355 -4
  35. lightning_sdk/lightning_cloud/openapi/api/lit_logger_service_api.py +4 -4
  36. lightning_sdk/lightning_cloud/openapi/api/lit_registry_service_api.py +14 -2
  37. lightning_sdk/lightning_cloud/openapi/api/pipelines_service_api.py +670 -0
  38. lightning_sdk/lightning_cloud/openapi/api/storage_service_api.py +303 -4
  39. lightning_sdk/lightning_cloud/openapi/models/__init__.py +20 -0
  40. lightning_sdk/lightning_cloud/openapi/models/agents_id_body.py +17 -69
  41. lightning_sdk/lightning_cloud/openapi/models/cluster_id_capacityreservations_body.py +27 -1
  42. lightning_sdk/lightning_cloud/openapi/models/create.py +27 -1
  43. lightning_sdk/lightning_cloud/openapi/models/create_deployment_request_defines_a_spec_for_the_job_that_allows_for_autoscaling_jobs.py +53 -1
  44. lightning_sdk/lightning_cloud/openapi/models/deployments_id_body.py +105 -1
  45. lightning_sdk/lightning_cloud/openapi/models/id_visibility_body1.py +1 -27
  46. lightning_sdk/lightning_cloud/openapi/models/id_visibility_body2.py +149 -0
  47. lightning_sdk/lightning_cloud/openapi/models/org_id_memberships_body.py +27 -1
  48. lightning_sdk/lightning_cloud/openapi/models/orgs_id_body.py +157 -1
  49. lightning_sdk/lightning_cloud/openapi/models/pipelines_id_body.py +435 -0
  50. lightning_sdk/lightning_cloud/openapi/models/project_id_pipelines_body.py +201 -0
  51. lightning_sdk/lightning_cloud/openapi/models/projects_id_body.py +157 -1
  52. lightning_sdk/lightning_cloud/openapi/models/slurm_jobs_body.py +79 -1
  53. lightning_sdk/lightning_cloud/openapi/models/uploads_upload_id_body.py +1 -27
  54. lightning_sdk/lightning_cloud/openapi/models/uploads_upload_id_body1.py +175 -0
  55. lightning_sdk/lightning_cloud/openapi/models/v1_agent_job.py +79 -1
  56. lightning_sdk/lightning_cloud/openapi/models/v1_assistant.py +17 -69
  57. lightning_sdk/lightning_cloud/openapi/models/v1_capacity_block_offering.py +27 -1
  58. lightning_sdk/lightning_cloud/openapi/models/v1_cloud_space_artifact_event_type.py +1 -1
  59. lightning_sdk/lightning_cloud/openapi/models/v1_cluster_accelerator.py +131 -1
  60. lightning_sdk/lightning_cloud/openapi/models/v1_cluster_capacity_reservation.py +79 -1
  61. lightning_sdk/lightning_cloud/openapi/models/v1_cluster_security_options.py +27 -1
  62. lightning_sdk/lightning_cloud/openapi/models/v1_complete_upload_temporary_artifact_request.py +175 -0
  63. lightning_sdk/lightning_cloud/openapi/models/v1_create_deployment_request.py +461 -0
  64. lightning_sdk/lightning_cloud/openapi/models/v1_create_deployment_template_request.py +27 -1
  65. lightning_sdk/lightning_cloud/openapi/models/v1_create_job_request.py +201 -0
  66. lightning_sdk/lightning_cloud/openapi/models/v1_create_managed_endpoint_response.py +149 -0
  67. lightning_sdk/lightning_cloud/openapi/models/v1_create_multi_machine_job_request.py +253 -0
  68. lightning_sdk/lightning_cloud/openapi/models/v1_data_connection.py +27 -1
  69. lightning_sdk/lightning_cloud/openapi/models/v1_delete_pipeline_response.py +149 -0
  70. lightning_sdk/lightning_cloud/openapi/models/v1_deployment.py +105 -1
  71. lightning_sdk/lightning_cloud/openapi/models/v1_deployment_details.py +175 -0
  72. lightning_sdk/lightning_cloud/openapi/models/v1_deployment_template.py +53 -1
  73. lightning_sdk/lightning_cloud/openapi/models/v1_filestore_data_connection.py +201 -0
  74. lightning_sdk/lightning_cloud/openapi/models/v1_filesystem_job.py +27 -1
  75. lightning_sdk/lightning_cloud/openapi/models/v1_filesystem_mmt.py +27 -1
  76. lightning_sdk/lightning_cloud/openapi/models/v1_find_capacity_block_offering_response.py +29 -3
  77. lightning_sdk/lightning_cloud/openapi/models/v1_job.py +133 -3
  78. lightning_sdk/lightning_cloud/openapi/models/v1_job_spec.py +53 -1
  79. lightning_sdk/lightning_cloud/openapi/models/v1_job_timing.py +27 -1
  80. lightning_sdk/lightning_cloud/openapi/models/v1_list_pipelines_response.py +123 -0
  81. lightning_sdk/lightning_cloud/openapi/models/v1_lit_registry_artifact.py +27 -1
  82. lightning_sdk/lightning_cloud/openapi/models/v1_lit_repository.py +29 -1
  83. lightning_sdk/lightning_cloud/openapi/models/v1_managed_model.py +27 -1
  84. lightning_sdk/lightning_cloud/openapi/models/v1_multi_machine_job.py +27 -1
  85. lightning_sdk/lightning_cloud/openapi/models/v1_multi_machine_job_state.py +2 -0
  86. lightning_sdk/lightning_cloud/openapi/models/v1_organization.py +157 -1
  87. lightning_sdk/lightning_cloud/openapi/models/v1_pipeline.py +487 -0
  88. lightning_sdk/lightning_cloud/openapi/models/v1_pipeline_step.py +253 -0
  89. lightning_sdk/lightning_cloud/openapi/models/v1_pipeline_step_status.py +331 -0
  90. lightning_sdk/lightning_cloud/openapi/models/v1_pipeline_step_type.py +104 -0
  91. lightning_sdk/lightning_cloud/openapi/models/v1_project_settings.py +157 -1
  92. lightning_sdk/lightning_cloud/openapi/models/v1_restart_timing.py +27 -1
  93. lightning_sdk/lightning_cloud/openapi/models/v1_rule_resource.py +1 -0
  94. lightning_sdk/lightning_cloud/openapi/models/v1_shared_filesystem.py +201 -0
  95. lightning_sdk/lightning_cloud/openapi/models/v1_slurm_job.py +27 -1
  96. lightning_sdk/lightning_cloud/openapi/models/v1_update_job_visibility_response.py +97 -0
  97. lightning_sdk/lightning_cloud/openapi/models/v1_upload_temporary_artifact_request.py +123 -0
  98. lightning_sdk/lightning_cloud/openapi/models/v1_user_features.py +95 -355
  99. lightning_sdk/lightning_cloud/openapi/models/validate.py +27 -1
  100. lightning_sdk/lightning_cloud/rest_client.py +4 -2
  101. lightning_sdk/machine.py +25 -1
  102. lightning_sdk/models.py +18 -12
  103. lightning_sdk/pipeline/__init__.py +4 -0
  104. lightning_sdk/pipeline/pipeline.py +109 -0
  105. lightning_sdk/pipeline/types.py +268 -0
  106. lightning_sdk/pipeline/utils.py +69 -0
  107. lightning_sdk/plugin.py +9 -10
  108. lightning_sdk/services/utilities.py +2 -2
  109. lightning_sdk/studio.py +5 -1
  110. lightning_sdk/teamspace.py +1 -1
  111. lightning_sdk/utils/resolve.py +12 -1
  112. {lightning_sdk-0.1.57.dist-info → lightning_sdk-0.2.0.dist-info}/METADATA +6 -8
  113. {lightning_sdk-0.1.57.dist-info → lightning_sdk-0.2.0.dist-info}/RECORD +117 -88
  114. lightning_sdk/cli/legacy.py +0 -135
  115. {lightning_sdk-0.1.57.dist-info → lightning_sdk-0.2.0.dist-info}/LICENSE +0 -0
  116. {lightning_sdk-0.1.57.dist-info → lightning_sdk-0.2.0.dist-info}/WHEEL +0 -0
  117. {lightning_sdk-0.1.57.dist-info → lightning_sdk-0.2.0.dist-info}/entry_points.txt +0 -0
  118. {lightning_sdk-0.1.57.dist-info → lightning_sdk-0.2.0.dist-info}/top_level.txt +0 -0
@@ -15,74 +15,24 @@ from lightning_sdk.studio import Studio
15
15
  from lightning_sdk.utils.resolve import _get_authed_user, skip_studio_init
16
16
 
17
17
 
18
- class _Downloads(_StudiosMenu, _TeamspacesMenu):
19
- """Download files and folders from Lightning AI."""
20
-
21
- def model(self, name: str, download_dir: str = ".") -> None:
22
- """Download a Model.
23
-
24
- Args:
25
- name: The name of the Model you want to download.
26
- This should have the format <ORGANIZATION-NAME>/<TEAMSPACE-NAME>/<MODEL-NAME>.
27
- download_dir: The directory where the Model should be downloaded.
28
- """
29
- model(name=name, download_dir=download_dir)
30
-
31
- def folder(self, path: str = "", studio: Optional[str] = None, local_path: str = ".") -> None:
32
- """Download a folder from a Studio.
33
-
34
- Args:
35
- path: The relative path within the Studio you want to download.
36
- If you leave it empty it will download whole studio and locally creates a new folder
37
- with the same name as the selected studio.
38
- studio: The name of the studio to upload to. Will show a menu with user's owned studios for selection
39
- if not specified. If provided, should be in the form of <TEAMSPACE-NAME>/<STUDIO-NAME> where the names
40
- are case-sensitive. The teamspace and studio names can be regular expressions to match, then a menu
41
- with filtered studios will be shown for final selection.
42
- local_path: The path to the directory you want to download the folder to.
43
- """
44
- folder(path=path, studio=studio, local_path=local_path)
45
-
46
- def file(self, path: str, studio: Optional[str] = None, local_path: str = ".") -> None:
47
- """Download a file from a Studio.
48
-
49
- Args:
50
- path: The relative path within the Studio you want to download.
51
- studio: The name of the studio to upload to. Will show a menu with user's owned studios for selection
52
- if not specified. If provided, should be in the form of <TEAMSPACE-NAME>/<STUDIO-NAME> where the names
53
- are case-sensitive. The teamspace and studio names can be regular expressions to match, then a menu
54
- with filtered studios will be shown for final selection.
55
- local_path: The path to the directory you want to download the file to.
56
- """
57
- file(path=path, studio=studio, local_path=local_path)
58
-
59
- def container(self, container: str, teamspace: Optional[str] = None, tag: str = "latest") -> None:
60
- """Download a docker container from a teamspace.
61
-
62
- Args:
63
- container: The name of the container to download.
64
- teamspace: The name of the teamspace to download the container from.
65
- tag: The tag of the container to download.
66
- """
67
- download_container(container=container, teamspace=teamspace, tag=tag)
68
-
69
-
70
18
  @click.group(name="download")
71
19
  def download() -> None:
72
20
  """Download resources from Lightning AI."""
73
21
 
74
22
 
75
- # @download.command(name="model")
76
- # @click.option(
77
- # "--name",
78
- # help=(
79
- # "The name of the Model you want to download. "
80
- # "This should have the format <ORGANIZATION-NAME>/<TEAMSPACE-NAME>/<MODEL-NAME>."
81
- # ),
82
- # )
83
- # @click.option("--download-dir", default=".", help="The directory where the Model should be downloaded.")
23
+ @download.command(name="model")
24
+ @click.argument("name")
25
+ @click.option(
26
+ "--download-dir", "--download_dir", default=".", help="The directory where the Model should be downloaded."
27
+ )
84
28
  def model(name: str, download_dir: str = ".") -> None:
85
- """Download a Model."""
29
+ """Download a model from a teamspace.
30
+
31
+ Example:
32
+ lightning download model NAME
33
+
34
+ NAME: The name of the model to download in the format of <ORGANIZATION-NAME>/<TEAMSPACE-NAME>/<MODEL-NAME>.
35
+ """
86
36
  download_model(
87
37
  name=name,
88
38
  download_dir=download_dir,
@@ -90,28 +40,30 @@ def model(name: str, download_dir: str = ".") -> None:
90
40
  )
91
41
 
92
42
 
93
- # @download.command(name="folder")
94
- # @click.option(
95
- # "--path",
96
- # default="",
97
- # help=(
98
- # "The relative path within the Studio you want to download. "
99
- # "If you leave it empty it will download whole studio and locally creates a "
100
- # "new folder with the same name as the selected studio."
101
- # ),
102
- # )
103
- # @click.option(
104
- # "--studio",
105
- # default=None,
106
- # help=(
107
- # "The name of the studio to upload to. "
108
- # "Will show a menu with user's owned studios for selection if not specified. "
109
- # "If provided, should be in the form of <TEAMSPACE-NAME>/<STUDIO-NAME> where the names are case-sensitive. "
110
- # "The teamspace and studio names can be regular expressions to match, "
111
- # "a menu filtered studios will be shown for final selection."
112
- # ),
113
- # )
114
- # @click.option("--local-path", default=".", help="The path to the directory you want to download the folder to.")
43
+ @download.command(name="folder")
44
+ @click.option(
45
+ "--path",
46
+ default="",
47
+ help=(
48
+ "The relative path within the Studio you want to download. "
49
+ "If you leave it empty it will download whole studio and locally creates a "
50
+ "new folder with the same name as the selected studio."
51
+ ),
52
+ )
53
+ @click.option(
54
+ "--studio",
55
+ default=None,
56
+ help=(
57
+ "The name of the studio to upload to. "
58
+ "Will show a menu with user's owned studios for selection if not specified. "
59
+ "If provided, should be in the form of <TEAMSPACE-NAME>/<STUDIO-NAME> where the names are case-sensitive. "
60
+ "The teamspace and studio names can be regular expressions to match, "
61
+ "a menu filtered studios will be shown for final selection."
62
+ ),
63
+ )
64
+ @click.option(
65
+ "--local-path", "--local_path", default=".", help="The path to the directory you want to download the folder to."
66
+ )
115
67
  def folder(path: str = "", studio: Optional[str] = None, local_path: str = ".") -> None:
116
68
  """Download a folder from a Studio."""
117
69
  local_path = Path(local_path)
@@ -136,28 +88,30 @@ def folder(path: str = "", studio: Optional[str] = None, local_path: str = ".")
136
88
  ) from e
137
89
 
138
90
 
139
- # @download.command(name="file")
140
- # @click.option(
141
- # "--path",
142
- # default="",
143
- # help=(
144
- # "The relative path within the Studio you want to download. "
145
- # "If you leave it empty it will download whole studio and locally creates a new folder "
146
- # "with the same name as the selected studio."
147
- # ),
148
- # )
149
- # @click.option(
150
- # "--studio",
151
- # default=None,
152
- # help=(
153
- # "The name of the studio to upload to. "
154
- # "Will show a menu with user's owned studios for selection if not specified. "
155
- # "If provided, should be in the form of <TEAMSPACE-NAME>/<STUDIO-NAME> where the names are case-sensitive. "
156
- # "The teamspace and studio names can be regular expressions to match, "
157
- # "a menu filtered studios will be shown for final selection."
158
- # ),
159
- # )
160
- # @click.option("--local-path", default=".", help="The path to the directory you want to download the folder to.")
91
+ @download.command(name="file")
92
+ @click.option(
93
+ "--path",
94
+ default="",
95
+ help=(
96
+ "The relative path within the Studio you want to download. "
97
+ "If you leave it empty it will download whole studio and locally creates a new folder "
98
+ "with the same name as the selected studio."
99
+ ),
100
+ )
101
+ @click.option(
102
+ "--studio",
103
+ default=None,
104
+ help=(
105
+ "The name of the studio to upload to. "
106
+ "Will show a menu with user's owned studios for selection if not specified. "
107
+ "If provided, should be in the form of <TEAMSPACE-NAME>/<STUDIO-NAME> where the names are case-sensitive. "
108
+ "The teamspace and studio names can be regular expressions to match, "
109
+ "a menu filtered studios will be shown for final selection."
110
+ ),
111
+ )
112
+ @click.option(
113
+ "--local-path", "--local_path", default=".", help="The path to the directory you want to download the folder to."
114
+ )
161
115
  def file(path: str = "", studio: Optional[str] = None, local_path: str = ".") -> None:
162
116
  """Download a file from a Studio."""
163
117
  local_path = Path(local_path)
@@ -181,12 +135,18 @@ def file(path: str = "", studio: Optional[str] = None, local_path: str = ".") ->
181
135
  ) from e
182
136
 
183
137
 
184
- # @download.command(name="container")
185
- # @click.argument("container")
186
- # @click.argument("teamspace", default=None, help="The name of the teamspace to download the container from")
187
- # @click.argument("tag", default="latest", show_default=True, help="The tag of the container to download.")
138
+ @download.command(name="container")
139
+ @click.argument("container")
140
+ @click.option("--teamspace", default=None, help="The name of the teamspace to download the container from")
141
+ @click.option("--tag", default="latest", show_default=True, help="The tag of the container to download.")
188
142
  def download_container(container: str, teamspace: Optional[str] = None, tag: str = "latest") -> None:
189
- """Download the docker container CONTAINER from a teamspace."""
143
+ """Download a docker container from a teamspace.
144
+
145
+ Example:
146
+ lightning download container CONTAINER
147
+
148
+ CONTAINER: The name of the container to download.
149
+ """
190
150
  console = Console()
191
151
  menu = _TeamspacesMenu()
192
152
  resolved_teamspace = menu._resolve_teamspace(teamspace)
@@ -3,62 +3,31 @@ from types import TracebackType
3
3
  from typing import Type
4
4
 
5
5
  import click
6
- from fire import Fire
7
- from lightning_utilities.core.imports import RequirementCache
8
6
  from rich.console import Console
9
7
  from rich.panel import Panel
10
8
 
9
+ from lightning_sdk import __version__
11
10
  from lightning_sdk.api.studio_api import _cloud_url
12
- from lightning_sdk.cli.ai_hub import _AIHub, aihub
13
- from lightning_sdk.cli.configure import _Configure, configure
14
- from lightning_sdk.cli.connect import _Connect, connect
15
- from lightning_sdk.cli.delete import _Delete, delete
16
- from lightning_sdk.cli.download import _Downloads, download
17
- from lightning_sdk.cli.generate import _Generate, generate
18
- from lightning_sdk.cli.inspect import _Inspect, inspect
19
- from lightning_sdk.cli.legacy import _LegacyLightningCLI
20
- from lightning_sdk.cli.list import _List
21
- from lightning_sdk.cli.run import _Run
22
- from lightning_sdk.cli.serve import _Docker, _LitServe
23
- from lightning_sdk.cli.start import _Start
24
- from lightning_sdk.cli.stop import _Stop
25
- from lightning_sdk.cli.switch import _Switch
26
- from lightning_sdk.cli.upload import _Uploads
11
+ from lightning_sdk.cli.ai_hub import aihub
12
+ from lightning_sdk.cli.coloring import CustomHelpFormatter
13
+ from lightning_sdk.cli.configure import configure
14
+ from lightning_sdk.cli.connect import connect
15
+ from lightning_sdk.cli.create import create
16
+ from lightning_sdk.cli.delete import delete
17
+ from lightning_sdk.cli.docker import dockerize
18
+ from lightning_sdk.cli.download import download
19
+ from lightning_sdk.cli.generate import generate
20
+ from lightning_sdk.cli.inspect import inspect
21
+ from lightning_sdk.cli.list import list_cli
22
+ from lightning_sdk.cli.open import open
23
+ from lightning_sdk.cli.run import run
24
+ from lightning_sdk.cli.serve import serve
25
+ from lightning_sdk.cli.start import start
26
+ from lightning_sdk.cli.stop import stop
27
+ from lightning_sdk.cli.switch import switch
28
+ from lightning_sdk.cli.upload import upload
27
29
  from lightning_sdk.lightning_cloud.login import Auth
28
30
 
29
- _LIGHTNING_AVAILABLE = RequirementCache("lightning")
30
-
31
-
32
- class StudioCLI:
33
- """Command line interface (CLI) to interact with/manage Lightning AI Studios."""
34
-
35
- def __init__(self) -> None:
36
- self.download = _Downloads()
37
- self.upload = _Uploads()
38
- self.aihub = _AIHub()
39
- self.run = _Run(legacy_run=_LegacyLightningCLI() if _LIGHTNING_AVAILABLE else None)
40
- self.serve = _LitServe()
41
- self.dockerize = _Docker()
42
- self.list = _List()
43
- self.delete = _Delete()
44
- self.inspect = _Inspect()
45
- self.stop = _Stop()
46
- self.start = _Start()
47
- self.switch = _Switch()
48
- self.generate = _Generate()
49
- self.connect = _Connect()
50
- self.configure = _Configure()
51
-
52
- sys.excepthook = _notify_exception
53
-
54
- def login(self) -> None:
55
- """Login to Lightning AI Studios."""
56
- return login()
57
-
58
- def logout(self) -> None:
59
- """Logout from Lightning AI Studios."""
60
- return logout()
61
-
62
31
 
63
32
  def _notify_exception(exception_type: Type[BaseException], value: BaseException, tb: TracebackType) -> None: # No
64
33
  """CLI won't show tracebacks, just print the exception message."""
@@ -66,17 +35,17 @@ def _notify_exception(exception_type: Type[BaseException], value: BaseException,
66
35
  console.print(Panel(value))
67
36
 
68
37
 
38
+ @click.group(name="lightning", help="Command line interface (CLI) to interact with/manage Lightning AI Studios.")
39
+ @click.version_option(__version__, message="Lightning CLI version %(version)s")
69
40
  def main_cli() -> None:
70
- """CLI entrypoint."""
71
- Fire(StudioCLI(), name="lightning")
41
+ sys.excepthook = _notify_exception
72
42
 
73
43
 
74
- @click.group(name="lightning", help="Command line interface (CLI) to interact with/manage Lightning AI Studios.")
75
- def main_cli_click() -> None:
76
- pass
44
+ # colorful help messages
45
+ main_cli.context_class.formatter_class = CustomHelpFormatter
77
46
 
78
47
 
79
- # @main_cli_click.command
48
+ @main_cli.command
80
49
  def login() -> None:
81
50
  """Login to Lightning AI Studios."""
82
51
  auth = Auth()
@@ -88,21 +57,31 @@ def login() -> None:
88
57
  raise RuntimeError(f"Unable to connect to {_cloud_url()}. Please check your internet connection.") from None
89
58
 
90
59
 
91
- # @main_cli_click.command
60
+ @main_cli.command
92
61
  def logout() -> None:
93
62
  """Logout from Lightning AI Studios."""
94
63
  auth = Auth()
95
64
  auth.clear()
96
65
 
97
66
 
98
- # TODO: handle exception hook registration
99
- main_cli_click.add_command(aihub)
100
- main_cli_click.add_command(configure)
101
- main_cli_click.add_command(connect)
102
- main_cli_click.add_command(delete)
103
- main_cli_click.add_command(download)
104
- main_cli_click.add_command(generate)
105
- main_cli_click.add_command(inspect)
67
+ # additional commands
68
+ main_cli.add_command(aihub)
69
+ main_cli.add_command(configure)
70
+ main_cli.add_command(connect)
71
+ main_cli.add_command(create)
72
+ main_cli.add_command(delete)
73
+ main_cli.add_command(dockerize)
74
+ main_cli.add_command(download)
75
+ main_cli.add_command(generate)
76
+ main_cli.add_command(inspect)
77
+ main_cli.add_command(list_cli)
78
+ main_cli.add_command(run)
79
+ main_cli.add_command(serve)
80
+ main_cli.add_command(start)
81
+ main_cli.add_command(stop)
82
+ main_cli.add_command(switch)
83
+ main_cli.add_command(upload)
84
+ main_cli.add_command(open)
106
85
 
107
86
 
108
87
  if __name__ == "__main__":
@@ -6,19 +6,37 @@ from rich.console import Console
6
6
  from lightning_sdk.cli.studios_menu import _StudiosMenu
7
7
 
8
8
 
9
- class _Generate:
9
+ @click.group(name="generate")
10
+ def generate() -> None:
10
11
  """Generate configs (such as ssh for studio) and print them to commandline."""
11
12
 
12
- def ssh(self, name: Optional[str] = None, teamspace: Optional[str] = None) -> None:
13
- """Get SSH config entry for a studio.
14
13
 
15
- Args:
16
- name: The name of the studio to obtain SSH config.
17
- If not specified, tries to infer from the environment (e.g. when run from within a Studio.)
18
- teamspace: The teamspace the studio is part of. Should be of format <OWNER>/<TEAMSPACE_NAME>.
19
- If not specified, tries to infer from the environment (e.g. when run from within a Studio.)
20
- """
21
- ssh(name=name, teamspace=teamspace)
14
+ @generate.command(name="ssh")
15
+ @click.option(
16
+ "--name",
17
+ default=None,
18
+ help=(
19
+ "The name of the studio to obtain SSH config. "
20
+ "If not specified, tries to infer from the environment (e.g. when run from within a Studio.)"
21
+ ),
22
+ )
23
+ @click.option(
24
+ "--teamspace",
25
+ default=None,
26
+ help=(
27
+ "The teamspace the studio is part of. "
28
+ "Should be of format <OWNER>/<TEAMSPACE_NAME>. "
29
+ "If not specified, tries to infer from the environment (e.g. when run from within a Studio.)"
30
+ ),
31
+ )
32
+ def ssh(name: Optional[str] = None, teamspace: Optional[str] = None) -> None:
33
+ """Get SSH config entry for a studio."""
34
+ menu = _StudiosMenu()
35
+ studio = menu._get_studio(name=name, teamspace=teamspace)
36
+
37
+ conf = _generate_ssh_config(key_path="~/.ssh/lightning_rsa", user=f"s_{studio._studio.id}", host=studio.name)
38
+ # Print the SSH config
39
+ Console().print(f"# ssh s_{studio._studio.id}@ssh.lightning.ai\n\n" + conf)
22
40
 
23
41
 
24
42
  def _generate_ssh_config(key_path: str, host: str, user: str) -> str:
@@ -32,36 +50,3 @@ def _generate_ssh_config(key_path: str, host: str, user: str) -> str:
32
50
  StrictHostKeyChecking no
33
51
  UserKnownHostsFile=/dev/null
34
52
  """
35
-
36
-
37
- @click.group(name="generate")
38
- def generate() -> None:
39
- """Generate configs (such as ssh for studio) and print them to commandline."""
40
-
41
-
42
- # @generate.command(name="ssh")
43
- # @click.option(
44
- # "--name",
45
- # default=None,
46
- # help=(
47
- # "The name of the studio to obtain SSH config. "
48
- # "If not specified, tries to infer from the environment (e.g. when run from within a Studio.)"
49
- # ),
50
- # )
51
- # @click.option(
52
- # "--teamspace",
53
- # default=None,
54
- # help=(
55
- # "The teamspace the studio is part of. "
56
- # "Should be of format <OWNER>/<TEAMSPACE_NAME>. "
57
- # "If not specified, tries to infer from the environment (e.g. when run from within a Studio.)"
58
- # ),
59
- # )
60
- def ssh(name: Optional[str] = None, teamspace: Optional[str] = None) -> None:
61
- """Get SSH config entry for a studio."""
62
- menu = _StudiosMenu()
63
- studio = menu._get_studio(name=name, teamspace=teamspace)
64
-
65
- conf = _generate_ssh_config(key_path="~/.ssh/lightning_rsa", user=f"s_{studio._studio.id}", host=studio.name)
66
- # Print the SSH config
67
- Console().print(f"# ssh s_{studio._studio.id}@ssh.lightning.ai\n\n" + conf)
@@ -6,67 +6,39 @@ from rich.console import Console
6
6
  from lightning_sdk.cli.job_and_mmt_action import _JobAndMMTAction
7
7
 
8
8
 
9
- class _Inspect:
10
- """Inspect resources of the Lightning AI platform to get additional details as JSON."""
11
-
12
- def job(self, name: Optional[str] = None, teamspace: Optional[str] = None) -> None:
13
- """Inspect a job for further details as JSON.
14
-
15
- Args:
16
- name: the name of the job. If not specified can be selected interactively.
17
- teamspace: the name of the teamspace the job lives in.
18
- Should be specified as {teamspace_owner}/{teamspace_name} (e.g my-org/my-teamspace).
19
- If not specified can be selected interactively.
20
-
21
- """
22
- job(name=name, teamspace=teamspace)
23
-
24
- def mmt(self, name: Optional[str] = None, teamspace: Optional[str] = None) -> None:
25
- """Inspect a multi-machine job for further details as JSON.
26
-
27
- Args:
28
- name: the name of the job. If not specified can be selected interactively.
29
- teamspace: the name of the teamspace the job lives in.
30
- Should be specified as {teamspace_owner}/{teamspace_name} (e.g my-org/my-teamspace).
31
- If not specified can be selected interactively.
32
-
33
- """
34
- mmt(name=name, teamspace=teamspace)
35
-
36
-
37
9
  @click.group(name="inspect")
38
10
  def inspect() -> None:
39
11
  """Inspect resources of the Lightning AI platform to get additional details as JSON."""
40
12
 
41
13
 
42
- # @inspect.command(name="job")
43
- # @click.option("--name", default=None, help="the name of the job. If not specified can be selected interactively.")
44
- # @click.option(
45
- # "--teamspace",
46
- # default=None,
47
- # help=(
48
- # "the name of the teamspace the job lives in."
49
- # "Should be specified as {teamspace_owner}/{teamspace_name} (e.g my-org/my-teamspace). "
50
- # "If not specified can be selected interactively."
51
- # ),
52
- # )
14
+ @inspect.command(name="job")
15
+ @click.option("--name", default=None, help="the name of the job. If not specified can be selected interactively.")
16
+ @click.option(
17
+ "--teamspace",
18
+ default=None,
19
+ help=(
20
+ "the name of the teamspace the job lives in."
21
+ "Should be specified as {teamspace_owner}/{teamspace_name} (e.g my-org/my-teamspace). "
22
+ "If not specified can be selected interactively."
23
+ ),
24
+ )
53
25
  def job(name: Optional[str] = None, teamspace: Optional[str] = None) -> None:
54
26
  """Inspect a job for further details as JSON."""
55
27
  menu = _JobAndMMTAction()
56
28
  Console().print(menu.job(name=name, teamspace=teamspace).json())
57
29
 
58
30
 
59
- # @inspect.command(name="mmt")
60
- # @click.option("--name", default=None, help="the name of the job. If not specified can be selected interactively.")
61
- # @click.option(
62
- # "--teamspace",
63
- # default=None,
64
- # help=(
65
- # "the name of the teamspace the job lives in."
66
- # "Should be specified as {teamspace_owner}/{teamspace_name} (e.g my-org/my-teamspace). "
67
- # "If not specified can be selected interactively."
68
- # ),
69
- # )
31
+ @inspect.command(name="mmt")
32
+ @click.option("--name", default=None, help="the name of the job. If not specified can be selected interactively.")
33
+ @click.option(
34
+ "--teamspace",
35
+ default=None,
36
+ help=(
37
+ "the name of the teamspace the job lives in."
38
+ "Should be specified as {teamspace_owner}/{teamspace_name} (e.g my-org/my-teamspace). "
39
+ "If not specified can be selected interactively."
40
+ ),
41
+ )
70
42
  def mmt(name: Optional[str] = None, teamspace: Optional[str] = None) -> None:
71
43
  """Inspect a multi-machine job for further details as JSON."""
72
44
  menu = _JobAndMMTAction()