lightning-sdk 2025.8.1__py3-none-any.whl → 2025.8.6rc1__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 (65) hide show
  1. lightning_sdk/__init__.py +1 -1
  2. lightning_sdk/api/deployment_api.py +6 -4
  3. lightning_sdk/api/job_api.py +2 -0
  4. lightning_sdk/api/mmt_api.py +2 -0
  5. lightning_sdk/deployment/deployment.py +5 -0
  6. lightning_sdk/lightning_cloud/login.py +1 -7
  7. lightning_sdk/lightning_cloud/openapi/__init__.py +15 -23
  8. lightning_sdk/lightning_cloud/openapi/api/__init__.py +1 -0
  9. lightning_sdk/lightning_cloud/openapi/api/assistants_service_api.py +5 -1
  10. lightning_sdk/lightning_cloud/openapi/api/cloud_space_service_api.py +228 -1
  11. lightning_sdk/lightning_cloud/openapi/api/endpoint_service_api.py +126 -2129
  12. lightning_sdk/lightning_cloud/openapi/api/k8_s_cluster_service_api.py +625 -0
  13. lightning_sdk/lightning_cloud/openapi/api/storage_service_api.py +5 -1
  14. lightning_sdk/lightning_cloud/openapi/models/__init__.py +14 -23
  15. lightning_sdk/lightning_cloud/openapi/models/cluster_id_metrics_body.py +175 -0
  16. lightning_sdk/lightning_cloud/openapi/models/orgs_id_body.py +53 -1
  17. lightning_sdk/lightning_cloud/openapi/models/projects_id_body.py +53 -1
  18. lightning_sdk/lightning_cloud/openapi/models/v1_cloud_space.py +27 -1
  19. lightning_sdk/lightning_cloud/openapi/models/v1_cloud_space_transfer_metadata.py +201 -0
  20. lightning_sdk/lightning_cloud/openapi/models/v1_cloudflare_v1.py +29 -3
  21. lightning_sdk/lightning_cloud/openapi/models/{v1_complete_upload_service_execution_artifact_response.py → v1_complete_running_cloud_space_instance_transfer_response.py} +6 -6
  22. lightning_sdk/lightning_cloud/openapi/models/v1_container_metrics.py +461 -0
  23. lightning_sdk/lightning_cloud/openapi/models/v1_filesystem_metrics.py +227 -0
  24. lightning_sdk/lightning_cloud/openapi/models/{v1_list_file_endpoints_response.py → v1_list_container_metrics_response.py} +23 -23
  25. lightning_sdk/lightning_cloud/openapi/models/{service_artifact_artifact_kind.py → v1_list_node_file_system_metrics_response.py} +6 -13
  26. lightning_sdk/lightning_cloud/openapi/models/{v1_upload_service_execution_artifact_parts_response.py → v1_list_node_metrics_response.py} +23 -23
  27. lightning_sdk/lightning_cloud/openapi/models/v1_list_pod_metrics_response.py +123 -0
  28. lightning_sdk/lightning_cloud/openapi/models/v1_managed_model.py +79 -1
  29. lightning_sdk/lightning_cloud/openapi/models/v1_node_metrics.py +357 -0
  30. lightning_sdk/lightning_cloud/openapi/models/v1_organization.py +53 -1
  31. lightning_sdk/lightning_cloud/openapi/models/v1_pod_metrics.py +435 -0
  32. lightning_sdk/lightning_cloud/openapi/models/v1_project_settings.py +53 -1
  33. lightning_sdk/lightning_cloud/openapi/models/{v1_delete_service_execution_response.py → v1_report_k8s_cluster_metrics_response.py} +6 -6
  34. lightning_sdk/lightning_cloud/openapi/models/{command_argument_command_argument_type.py → v1_request_cloud_space_access_response.py} +6 -12
  35. lightning_sdk/lightning_cloud/openapi/models/v1_update_cloud_space_instance_config_request.py +331 -0
  36. lightning_sdk/lightning_cloud/openapi/models/v1_user_features.py +157 -53
  37. lightning_sdk/lightning_cloud/utils/data_connection.py +56 -1
  38. lightning_sdk/llm/llm.py +2 -13
  39. lightning_sdk/llm/public_assistants.py +17 -0
  40. lightning_sdk/pipeline/steps.py +30 -1
  41. lightning_sdk/services/file_endpoint.py +3 -4
  42. {lightning_sdk-2025.8.1.dist-info → lightning_sdk-2025.8.6rc1.dist-info}/METADATA +1 -1
  43. {lightning_sdk-2025.8.1.dist-info → lightning_sdk-2025.8.6rc1.dist-info}/RECORD +47 -55
  44. lightning_sdk/lightning_cloud/openapi/models/fileendpoints_id_body.py +0 -409
  45. lightning_sdk/lightning_cloud/openapi/models/id_complete_body.py +0 -175
  46. lightning_sdk/lightning_cloud/openapi/models/id_storage_body.py +0 -175
  47. lightning_sdk/lightning_cloud/openapi/models/id_uploads_body1.py +0 -175
  48. lightning_sdk/lightning_cloud/openapi/models/project_id_fileendpoints_body.py +0 -357
  49. lightning_sdk/lightning_cloud/openapi/models/project_id_serviceexecution_body.py +0 -175
  50. lightning_sdk/lightning_cloud/openapi/models/serviceexecution_id_body.py +0 -331
  51. lightning_sdk/lightning_cloud/openapi/models/v1_command_argument.py +0 -305
  52. lightning_sdk/lightning_cloud/openapi/models/v1_delete_file_endpoint_response.py +0 -149
  53. lightning_sdk/lightning_cloud/openapi/models/v1_download_service_execution_artifact_response.py +0 -175
  54. lightning_sdk/lightning_cloud/openapi/models/v1_file_endpoint.py +0 -461
  55. lightning_sdk/lightning_cloud/openapi/models/v1_get_service_execution_status_response.py +0 -175
  56. lightning_sdk/lightning_cloud/openapi/models/v1_list_service_execution_lightningapp_instances_response.py +0 -175
  57. lightning_sdk/lightning_cloud/openapi/models/v1_list_service_executions_response.py +0 -123
  58. lightning_sdk/lightning_cloud/openapi/models/v1_service_artifact.py +0 -201
  59. lightning_sdk/lightning_cloud/openapi/models/v1_service_execution.py +0 -383
  60. lightning_sdk/lightning_cloud/openapi/models/v1_upload_service_execution_artifact_response.py +0 -149
  61. lightning_sdk/llm/public_assistants.json +0 -34
  62. {lightning_sdk-2025.8.1.dist-info → lightning_sdk-2025.8.6rc1.dist-info}/LICENSE +0 -0
  63. {lightning_sdk-2025.8.1.dist-info → lightning_sdk-2025.8.6rc1.dist-info}/WHEEL +0 -0
  64. {lightning_sdk-2025.8.1.dist-info → lightning_sdk-2025.8.6rc1.dist-info}/entry_points.txt +0 -0
  65. {lightning_sdk-2025.8.1.dist-info → lightning_sdk-2025.8.6rc1.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,7 @@
1
1
  import os
2
2
  from time import sleep, time
3
3
  from lightning_sdk.lightning_cloud import rest_client
4
- from lightning_sdk.lightning_cloud.openapi import Create, V1AwsDataConnection, V1S3FolderDataConnection, V1EfsConfig, V1GcpDataConnection
4
+ from lightning_sdk.lightning_cloud.openapi import Create, V1AwsDataConnection, V1S3FolderDataConnection, V1EfsConfig, V1GcpDataConnection, V1FilestoreDataConnection, V1DataConnectionTier
5
5
  from lightning_sdk.lightning_cloud.openapi.rest import ApiException
6
6
  import urllib3
7
7
 
@@ -272,6 +272,61 @@ def add_gcs_connection(connection_name: str, bucket_name: str, create_timeout: i
272
272
 
273
273
  return
274
274
 
275
+ def create_filestore_folder(folder_name: str, region: str, capacity_gb: int = 1024, tier: V1DataConnectionTier = V1DataConnectionTier.HDD, create_timeout: int = 600) -> None:
276
+ """
277
+ Utility function to create a Filestore folder.
278
+
279
+ Args:
280
+ folder_name: The name of the folder to create.
281
+ region: the region to create the folder in, e.g. "us-central1".
282
+ capacity_gb: capacity of the Filestore folder.
283
+ tier: Filestore folder tier, SSD or HDD.
284
+ create_timeout (int): The timeout for the folder creation.
285
+ """
286
+ client = rest_client.LightningClient(retry=False)
287
+
288
+ project_id = os.getenv("LIGHTNING_CLOUD_PROJECT_ID")
289
+ cluster_id = os.getenv("LIGHTNING_CLUSTER_ID")
290
+
291
+ # Get existing data connections
292
+ data_connections = client.data_connection_service_list_data_connections(project_id).data_connections
293
+
294
+ for connection in data_connections:
295
+ existing_folder_name = getattr(connection, 'name', None)
296
+ isFilestore = getattr(connection, 'filestore', None) is not None
297
+
298
+ if existing_folder_name == folder_name and isFilestore:
299
+ return
300
+
301
+ # If we get here, no matching folder was found, proceed with creation
302
+ body = Create(
303
+ name=folder_name,
304
+ create_resources=True,
305
+ cluster_id=cluster_id,
306
+ access_cluster_ids=[cluster_id],
307
+ filestore=V1FilestoreDataConnection(region=region, capacity_gb=capacity_gb, tier=tier, source=folder_name),
308
+ )
309
+ try:
310
+ connection = client.data_connection_service_create_data_connection(body, project_id)
311
+ except ApiException as e:
312
+ # Note: This function can be called in a distributed way.
313
+ # There is a race condition where one machine might create the entry before another machine
314
+ # and this request would fail with duplicated key
315
+ # In this case, it is fine not to raise
316
+ if'duplicate key value violates unique constraint' in str(e.body):
317
+ return
318
+ raise e from None
319
+
320
+ except urllib3.exceptions.HTTPError as e:
321
+ raise e from None
322
+
323
+ # Wait for the filesystem picks up the newly added Filestore folder
324
+ start = time()
325
+
326
+ while not os.path.isdir(f"/teamspace/filestore_folders/{folder_name}") and (time() - start) < create_timeout:
327
+ sleep(1)
328
+
329
+
275
330
  def delete_data_connection(name: str):
276
331
  """Utility to delete a data connection
277
332
 
lightning_sdk/llm/llm.py CHANGED
@@ -1,10 +1,10 @@
1
- import json
2
1
  import os
3
2
  from typing import Any, AsyncGenerator, ClassVar, Dict, Generator, List, Optional, Tuple, Union
4
3
 
5
4
  from lightning_sdk.api import TeamspaceApi, UserApi
6
5
  from lightning_sdk.api.llm_api import LLMApi
7
6
  from lightning_sdk.lightning_cloud.openapi.models.v1_conversation_response_chunk import V1ConversationResponseChunk
7
+ from lightning_sdk.llm.public_assistants import PUBLIC_MODELS
8
8
 
9
9
  PUBLIC_MODEL_PROVIDERS: Dict[str, str] = {
10
10
  "openai": "OpenAI",
@@ -14,17 +14,6 @@ PUBLIC_MODEL_PROVIDERS: Dict[str, str] = {
14
14
  }
15
15
 
16
16
 
17
- def _load_public_assistants() -> Dict[str, Dict[str, Any]]:
18
- """Load public assistants from a JSON file."""
19
- try:
20
- json_path = os.path.join(os.path.dirname(__file__), "public_assistants.json")
21
- with open(json_path) as f:
22
- return json.load(f)
23
- except Exception as e:
24
- print(f"[warning] Failed to load public_assistants.json: {e}")
25
- return {}
26
-
27
-
28
17
  class LLM:
29
18
  _auth_info_cached: ClassVar[bool] = False
30
19
  _cached_auth_info: ClassVar[Dict[str, Optional[str]]] = {}
@@ -138,7 +127,7 @@ class LLM:
138
127
  }
139
128
  LLM._auth_info_cached = True
140
129
  if LLM._public_assistants is None:
141
- LLM._public_assistants = _load_public_assistants()
130
+ LLM._public_assistants = PUBLIC_MODELS
142
131
  # Always assign to the current instance
143
132
  self._teamspace_name = LLM._cached_auth_info["teamspace_name"]
144
133
  self._teamspace_id = LLM._cached_auth_info["teamspace_id"]
@@ -0,0 +1,17 @@
1
+ PUBLIC_MODELS = {
2
+ "openai/gpt-4o": {"id": "ast_01jdjds71fs8gt47jexzed4czs", "context_length": 128000},
3
+ "openai/gpt-4": {"id": "ast_01jd38ze6tjbrcd4942nhz41zn", "context_length": 8192},
4
+ "openai/o3-mini": {"id": "ast_01jz3t13fhnjhh11t1k8b5gyp1", "context_length": 128000},
5
+ "anthropic/claude-3-5-sonnet-20240620": {"id": "ast_01jd3923a6p98rqwh3dpj686pq", "context_length": 200000},
6
+ "google/gemini-2.5-pro": {"id": "ast_01jz3tdb1fhey798k95pv61v57", "context_length": 1048576},
7
+ "google/gemini-2.5-flash": {"id": "ast_01jz3thxskg4fcdk4xhkjkym5a", "context_length": 8000},
8
+ "google/gemini-2.5-flash-lite-preview-06-17": {"id": "ast_01jz3thxskg4fcdk4xhkjkym5b", "context_length": 8000},
9
+ "lightning-ai/gpt-oss-20b": {
10
+ "id": "ast_01k1y2ywfh9zzexjzrva6y96ms",
11
+ "context_length": 128000,
12
+ },
13
+ "lightning-ai/gpt-oss-120b": {
14
+ "id": "ast_01k1z7ajxbz7wq62xj5bc0mrcs",
15
+ "context_length": 128000,
16
+ },
17
+ }
@@ -59,6 +59,7 @@ class DeploymentStep:
59
59
  include_credentials: Optional[bool] = None,
60
60
  max_runtime: Optional[int] = None,
61
61
  wait_for: Optional[Union[str, List[str]]] = DEFAULT,
62
+ cloud_provider: Optional[Union["CloudProvider", str]] = None,
62
63
  ) -> None:
63
64
  self.name = name
64
65
  self.studio = _get_studio(studio)
@@ -99,11 +100,28 @@ class DeploymentStep:
99
100
  self.include_credentials = include_credentials or True
100
101
  self.max_runtime = max_runtime
101
102
  self.wait_for = wait_for
103
+ self.cloud_provider = cloud_provider
102
104
 
103
105
  def to_proto(
104
106
  self, teamspace: "Teamspace", cloud_account: str, shared_filesystem: Union[bool, V1SharedFilesystem]
105
107
  ) -> V1PipelineStep:
106
- _validate_cloud_account(cloud_account, self.cloud_account, shared_filesystem)
108
+ machine_image_version = None
109
+
110
+ studio = _get_studio(self.studio)
111
+ if isinstance(studio, Studio):
112
+ machine_image_version = studio._studio.machine_image_version
113
+
114
+ if self.cloud_account is None:
115
+ self.cloud_account = studio.cloud_account
116
+ elif studio.cloud_account != self.cloud_account:
117
+ raise ValueError("The provided cloud account doesn't match the studio")
118
+
119
+ resolved_cloud_account = CloudAccountApi().resolve_cloud_account(
120
+ teamspace.id, self.cloud_account, self.cloud_provider, teamspace.default_cloud_account
121
+ )
122
+
123
+ _validate_cloud_account(cloud_account, resolved_cloud_account, shared_filesystem)
124
+
107
125
  return V1PipelineStep(
108
126
  name=self.name,
109
127
  type=V1PipelineStepType.DEPLOYMENT,
@@ -127,6 +145,7 @@ class DeploymentStep:
127
145
  cloudspace_id=self.studio._studio.id if self.studio else None,
128
146
  include_credentials=self.include_credentials,
129
147
  max_runtime=self.max_runtime,
148
+ machine_image_version=machine_image_version,
130
149
  ),
131
150
  strategy=to_strategy(self.release_strategy),
132
151
  ),
@@ -186,8 +205,12 @@ class JobStep:
186
205
  def to_proto(
187
206
  self, teamspace: "Teamspace", cloud_account: str, shared_filesystem: Union[bool, V1SharedFilesystem]
188
207
  ) -> V1PipelineStep:
208
+ machine_image_version = None
209
+
189
210
  studio = _get_studio(self.studio)
190
211
  if isinstance(studio, Studio):
212
+ machine_image_version = studio._studio.machine_image_version
213
+
191
214
  if self.cloud_account is None:
192
215
  self.cloud_account = studio.cloud_account
193
216
  elif studio.cloud_account != self.cloud_account:
@@ -215,6 +238,7 @@ class JobStep:
215
238
  artifacts_local=None,
216
239
  artifacts_remote=None,
217
240
  max_runtime=self.max_runtime,
241
+ machine_image_version=machine_image_version,
218
242
  )
219
243
 
220
244
  return V1PipelineStep(
@@ -277,8 +301,12 @@ class MMTStep:
277
301
  def to_proto(
278
302
  self, teamspace: "Teamspace", cloud_account: str, shared_filesystem: Union[bool, V1SharedFilesystem]
279
303
  ) -> V1PipelineStep:
304
+ machine_image_version = None
305
+
280
306
  studio = _get_studio(self.studio)
281
307
  if isinstance(studio, Studio):
308
+ machine_image_version = studio._studio.machine_image_version
309
+
282
310
  if self.cloud_account is None:
283
311
  self.cloud_account = studio.cloud_account
284
312
  elif studio.cloud_account != self.cloud_account:
@@ -303,6 +331,7 @@ class MMTStep:
303
331
  artifacts_local=None, # deprecated in favor of path_mappings
304
332
  artifacts_remote=None, # deprecated in favor of path_mappings
305
333
  max_runtime=self.max_runtime,
334
+ machine_image_version=machine_image_version,
306
335
  )
307
336
 
308
337
  return V1PipelineStep(
@@ -8,7 +8,6 @@ import urllib3
8
8
 
9
9
  from lightning_sdk.api.utils import _FileUploader
10
10
  from lightning_sdk.lightning_cloud.login import Auth
11
- from lightning_sdk.lightning_cloud.openapi import CommandArgumentCommandArgumentType
12
11
  from lightning_sdk.lightning_cloud.rest_client import LightningClient
13
12
  from lightning_sdk.services.utilities import _get_cluster, _get_project, _get_service_url
14
13
  from lightning_sdk.utils.resolve import _resolve_deprecated_cluster
@@ -162,7 +161,7 @@ class Client:
162
161
  class Argument:
163
162
  """A holder for the service argument."""
164
163
 
165
- def __init__(self, name: str, type: CommandArgumentCommandArgumentType, **kwargs: Any) -> None: # noqa: A002
164
+ def __init__(self, name: str, type: str, **kwargs: Any) -> None: # noqa: A002
166
165
  self._name = name
167
166
  self._type = type
168
167
  self._value = None
@@ -171,12 +170,12 @@ class Argument:
171
170
  @property
172
171
  def is_text(self) -> bool:
173
172
  """Whether this argument is of type Text."""
174
- return self._type == CommandArgumentCommandArgumentType.TEXT
173
+ return self._type == "Text"
175
174
 
176
175
  @property
177
176
  def is_file(self) -> bool:
178
177
  """Whether this argument is of type File."""
179
- return self._type == CommandArgumentCommandArgumentType.FILE
178
+ return self._type == "File"
180
179
 
181
180
  @property
182
181
  def value(self) -> Any:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lightning_sdk
3
- Version: 2025.8.1
3
+ Version: 2025.8.6rc1
4
4
  Summary: SDK to develop using Lightning AI Studios
5
5
  Author-email: Lightning-AI <justus@lightning.ai>
6
6
  License: MIT License