lightning-sdk 2025.8.6rc0__py3-none-any.whl → 2025.8.6rc2__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 (61) hide show
  1. lightning_sdk/__init__.py +1 -1
  2. lightning_sdk/api/llm_api.py +48 -0
  3. lightning_sdk/lightning_cloud/login.py +1 -0
  4. lightning_sdk/lightning_cloud/openapi/__init__.py +15 -23
  5. lightning_sdk/lightning_cloud/openapi/api/__init__.py +1 -0
  6. lightning_sdk/lightning_cloud/openapi/api/assistants_service_api.py +5 -1
  7. lightning_sdk/lightning_cloud/openapi/api/cloud_space_service_api.py +228 -1
  8. lightning_sdk/lightning_cloud/openapi/api/endpoint_service_api.py +126 -2129
  9. lightning_sdk/lightning_cloud/openapi/api/k8_s_cluster_service_api.py +625 -0
  10. lightning_sdk/lightning_cloud/openapi/api/storage_service_api.py +5 -1
  11. lightning_sdk/lightning_cloud/openapi/models/__init__.py +14 -23
  12. lightning_sdk/lightning_cloud/openapi/models/cluster_id_metrics_body.py +175 -0
  13. lightning_sdk/lightning_cloud/openapi/models/orgs_id_body.py +53 -1
  14. lightning_sdk/lightning_cloud/openapi/models/projects_id_body.py +53 -1
  15. lightning_sdk/lightning_cloud/openapi/models/v1_cloud_space.py +27 -1
  16. lightning_sdk/lightning_cloud/openapi/models/v1_cloud_space_transfer_metadata.py +201 -0
  17. lightning_sdk/lightning_cloud/openapi/models/v1_cloudflare_v1.py +29 -3
  18. 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
  19. lightning_sdk/lightning_cloud/openapi/models/v1_container_metrics.py +461 -0
  20. lightning_sdk/lightning_cloud/openapi/models/v1_filesystem_metrics.py +227 -0
  21. lightning_sdk/lightning_cloud/openapi/models/{v1_list_file_endpoints_response.py → v1_list_container_metrics_response.py} +23 -23
  22. lightning_sdk/lightning_cloud/openapi/models/{service_artifact_artifact_kind.py → v1_list_node_file_system_metrics_response.py} +6 -13
  23. lightning_sdk/lightning_cloud/openapi/models/{v1_upload_service_execution_artifact_parts_response.py → v1_list_node_metrics_response.py} +23 -23
  24. lightning_sdk/lightning_cloud/openapi/models/v1_list_pod_metrics_response.py +123 -0
  25. lightning_sdk/lightning_cloud/openapi/models/v1_managed_model.py +79 -1
  26. lightning_sdk/lightning_cloud/openapi/models/v1_node_metrics.py +357 -0
  27. lightning_sdk/lightning_cloud/openapi/models/v1_organization.py +53 -1
  28. lightning_sdk/lightning_cloud/openapi/models/v1_pod_metrics.py +435 -0
  29. lightning_sdk/lightning_cloud/openapi/models/v1_project_settings.py +53 -1
  30. lightning_sdk/lightning_cloud/openapi/models/{v1_delete_service_execution_response.py → v1_report_k8s_cluster_metrics_response.py} +6 -6
  31. lightning_sdk/lightning_cloud/openapi/models/{command_argument_command_argument_type.py → v1_request_cloud_space_access_response.py} +6 -12
  32. lightning_sdk/lightning_cloud/openapi/models/v1_update_cloud_space_instance_config_request.py +331 -0
  33. lightning_sdk/lightning_cloud/openapi/models/v1_user_features.py +157 -53
  34. lightning_sdk/lightning_cloud/utils/data_connection.py +56 -1
  35. lightning_sdk/llm/llm.py +5 -15
  36. lightning_sdk/llm/public_assistants.py +17 -0
  37. lightning_sdk/services/file_endpoint.py +3 -4
  38. {lightning_sdk-2025.8.6rc0.dist-info → lightning_sdk-2025.8.6rc2.dist-info}/METADATA +1 -1
  39. {lightning_sdk-2025.8.6rc0.dist-info → lightning_sdk-2025.8.6rc2.dist-info}/RECORD +43 -51
  40. lightning_sdk/lightning_cloud/openapi/models/fileendpoints_id_body.py +0 -409
  41. lightning_sdk/lightning_cloud/openapi/models/id_complete_body.py +0 -175
  42. lightning_sdk/lightning_cloud/openapi/models/id_storage_body.py +0 -175
  43. lightning_sdk/lightning_cloud/openapi/models/id_uploads_body1.py +0 -175
  44. lightning_sdk/lightning_cloud/openapi/models/project_id_fileendpoints_body.py +0 -357
  45. lightning_sdk/lightning_cloud/openapi/models/project_id_serviceexecution_body.py +0 -175
  46. lightning_sdk/lightning_cloud/openapi/models/serviceexecution_id_body.py +0 -331
  47. lightning_sdk/lightning_cloud/openapi/models/v1_command_argument.py +0 -305
  48. lightning_sdk/lightning_cloud/openapi/models/v1_delete_file_endpoint_response.py +0 -149
  49. lightning_sdk/lightning_cloud/openapi/models/v1_download_service_execution_artifact_response.py +0 -175
  50. lightning_sdk/lightning_cloud/openapi/models/v1_file_endpoint.py +0 -461
  51. lightning_sdk/lightning_cloud/openapi/models/v1_get_service_execution_status_response.py +0 -175
  52. lightning_sdk/lightning_cloud/openapi/models/v1_list_service_execution_lightningapp_instances_response.py +0 -175
  53. lightning_sdk/lightning_cloud/openapi/models/v1_list_service_executions_response.py +0 -123
  54. lightning_sdk/lightning_cloud/openapi/models/v1_service_artifact.py +0 -201
  55. lightning_sdk/lightning_cloud/openapi/models/v1_service_execution.py +0 -383
  56. lightning_sdk/lightning_cloud/openapi/models/v1_upload_service_execution_artifact_response.py +0 -149
  57. lightning_sdk/llm/public_assistants.json +0 -34
  58. {lightning_sdk-2025.8.6rc0.dist-info → lightning_sdk-2025.8.6rc2.dist-info}/LICENSE +0 -0
  59. {lightning_sdk-2025.8.6rc0.dist-info → lightning_sdk-2025.8.6rc2.dist-info}/WHEEL +0 -0
  60. {lightning_sdk-2025.8.6rc0.dist-info → lightning_sdk-2025.8.6rc2.dist-info}/entry_points.txt +0 -0
  61. {lightning_sdk-2025.8.6rc0.dist-info → lightning_sdk-2025.8.6rc2.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
- from lightning_sdk.api.llm_api import LLMApi
5
+ from lightning_sdk.api.llm_api import LLMApi, authenticate
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]]] = {}
@@ -67,9 +56,9 @@ class LLM:
67
56
  "(e.g., 'my-org/my-teamspace')."
68
57
  ) from e
69
58
 
59
+ self._model_provider, self._model_name = self._parse_model_name(name)
70
60
  self._get_auth_info(teamspace_name)
71
61
 
72
- self._model_provider, self._model_name = self._parse_model_name(name)
73
62
  self._enable_async = enable_async
74
63
 
75
64
  # Reuse LLMApi per teamspace (as billing is based on teamspace)
@@ -109,6 +98,7 @@ class LLM:
109
98
  if teamspace_name is None:
110
99
  # local users with no given teamspace
111
100
  try:
101
+ authenticate(model=f"{self.provider}/{self.name}")
112
102
  teamspace_api = TeamspaceApi()
113
103
  user_api = UserApi()
114
104
  authed_user = user_api._client.auth_service_get_user()
@@ -138,7 +128,7 @@ class LLM:
138
128
  }
139
129
  LLM._auth_info_cached = True
140
130
  if LLM._public_assistants is None:
141
- LLM._public_assistants = _load_public_assistants()
131
+ LLM._public_assistants = PUBLIC_MODELS
142
132
  # Always assign to the current instance
143
133
  self._teamspace_name = LLM._cached_auth_info["teamspace_name"]
144
134
  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
+ }
@@ -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.6rc0
3
+ Version: 2025.8.6rc2
4
4
  Summary: SDK to develop using Lightning AI Studios
5
5
  Author-email: Lightning-AI <justus@lightning.ai>
6
6
  License: MIT License