lightning-sdk 2025.12.17__py3-none-any.whl → 2026.1.27__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 (130) hide show
  1. lightning_sdk/__version__.py +1 -1
  2. lightning_sdk/api/k8s_api.py +75 -29
  3. lightning_sdk/api/studio_api.py +192 -37
  4. lightning_sdk/api/teamspace_api.py +180 -54
  5. lightning_sdk/api/utils.py +8 -0
  6. lightning_sdk/cli/cp/__init__.py +67 -0
  7. lightning_sdk/cli/cp/teamspace_uploads.py +93 -0
  8. lightning_sdk/cli/entrypoint.py +2 -0
  9. lightning_sdk/cli/groups.py +22 -0
  10. lightning_sdk/cli/legacy/clusters_menu.py +2 -2
  11. lightning_sdk/cli/legacy/deploy/_auth.py +7 -6
  12. lightning_sdk/cli/legacy/download.py +29 -98
  13. lightning_sdk/cli/legacy/run.py +13 -2
  14. lightning_sdk/cli/legacy/upload.py +24 -31
  15. lightning_sdk/cli/studio/__init__.py +4 -0
  16. lightning_sdk/cli/studio/cp.py +24 -65
  17. lightning_sdk/cli/studio/ls.py +57 -0
  18. lightning_sdk/cli/studio/rm.py +71 -0
  19. lightning_sdk/cli/utils/filesystem.py +103 -0
  20. lightning_sdk/cli/utils/logging.py +2 -1
  21. lightning_sdk/cli/utils/teamspace_selection.py +5 -0
  22. lightning_sdk/exceptions.py +31 -0
  23. lightning_sdk/job/base.py +1 -1
  24. lightning_sdk/k8s_cluster.py +9 -10
  25. lightning_sdk/lightning_cloud/__version__.py +1 -1
  26. lightning_sdk/lightning_cloud/openapi/__init__.py +43 -23
  27. lightning_sdk/lightning_cloud/openapi/api/__init__.py +2 -1
  28. lightning_sdk/lightning_cloud/openapi/api/cloud_space_service_api.py +118 -1
  29. lightning_sdk/lightning_cloud/openapi/api/cluster_service_api.py +378 -536
  30. lightning_sdk/lightning_cloud/openapi/api/container_registry_service_api.py +456 -0
  31. lightning_sdk/lightning_cloud/openapi/api/data_connection_service_api.py +5 -1
  32. lightning_sdk/lightning_cloud/openapi/api/file_system_service_api.py +11 -11
  33. lightning_sdk/lightning_cloud/openapi/api/jobs_service_api.py +113 -0
  34. lightning_sdk/lightning_cloud/openapi/api/k8_s_cluster_service_api.py +246 -19
  35. lightning_sdk/lightning_cloud/openapi/api/lightningwork_service_api.py +116 -11
  36. lightning_sdk/lightning_cloud/openapi/api/lit_logger_service_api.py +588 -2
  37. lightning_sdk/lightning_cloud/openapi/api/models_store_api.py +9 -1
  38. lightning_sdk/lightning_cloud/openapi/api/organizations_service_api.py +113 -0
  39. lightning_sdk/lightning_cloud/openapi/api/storage_service_api.py +5 -1
  40. lightning_sdk/lightning_cloud/openapi/api/{kubernetes_virtual_machine_service_api.py → virtual_machine_service_api.py} +82 -82
  41. lightning_sdk/lightning_cloud/openapi/models/__init__.py +41 -22
  42. lightning_sdk/lightning_cloud/openapi/models/cluster_service_create_cluster_capacity_reservation_body.py +53 -1
  43. lightning_sdk/lightning_cloud/openapi/models/cluster_service_create_machine_body.py +53 -1
  44. lightning_sdk/lightning_cloud/openapi/models/cluster_service_create_org_cluster_capacity_reservation_body.py +409 -0
  45. lightning_sdk/lightning_cloud/openapi/models/{v1_add_container_registry_response.py → cluster_service_report_machine_system_metrics_body.py} +23 -23
  46. lightning_sdk/lightning_cloud/openapi/models/container_registry_config_ecr.py +149 -0
  47. lightning_sdk/lightning_cloud/openapi/models/{v1_container_registry_status.py → container_registry_provider.py} +14 -10
  48. lightning_sdk/lightning_cloud/openapi/models/container_registry_service_create_container_registry_body.py +201 -0
  49. lightning_sdk/lightning_cloud/openapi/models/{v1_ecr_registry_config_input.py → container_registry_service_refresh_container_registry_credentials_body.py} +21 -21
  50. lightning_sdk/lightning_cloud/openapi/models/externalv1_cloud_space_instance_status.py +27 -1
  51. lightning_sdk/lightning_cloud/openapi/models/{v1_ecr_registry_config.py → jobs_service_duplicate_deployment_body.py} +51 -51
  52. lightning_sdk/lightning_cloud/openapi/models/lit_logger_service_create_lit_logger_media_body.py +305 -0
  53. lightning_sdk/lightning_cloud/openapi/models/lit_logger_service_update_lit_logger_media_body.py +149 -0
  54. lightning_sdk/lightning_cloud/openapi/models/lit_logger_service_update_metrics_stream_body.py +53 -1
  55. lightning_sdk/lightning_cloud/openapi/models/organizations_service_update_org_role_body.py +175 -0
  56. lightning_sdk/lightning_cloud/openapi/models/v1_capacity_reservation_used_by.py +227 -0
  57. lightning_sdk/lightning_cloud/openapi/models/v1_cloud_provider.py +2 -1
  58. lightning_sdk/lightning_cloud/openapi/models/v1_cloud_space_environment_type.py +1 -0
  59. lightning_sdk/lightning_cloud/openapi/models/v1_cluster_accelerator.py +27 -1
  60. lightning_sdk/lightning_cloud/openapi/models/v1_cluster_capacity_reservation.py +53 -1
  61. lightning_sdk/lightning_cloud/openapi/models/v1_cluster_spec.py +79 -27
  62. lightning_sdk/lightning_cloud/openapi/models/v1_cluster_type.py +0 -1
  63. lightning_sdk/lightning_cloud/openapi/models/v1_container_registry.py +63 -89
  64. lightning_sdk/lightning_cloud/openapi/models/{cluster_service_add_container_registry_body.py → v1_container_registry_config.py} +16 -16
  65. lightning_sdk/lightning_cloud/openapi/models/v1_container_registry_scopes.py +149 -0
  66. lightning_sdk/lightning_cloud/openapi/models/{v1_delete_kubernetes_virtual_machine_response.py → v1_create_container_registry_response.py} +6 -6
  67. lightning_sdk/lightning_cloud/openapi/models/v1_create_lit_logger_media_response.py +149 -0
  68. lightning_sdk/lightning_cloud/openapi/models/v1_create_org_cluster_capacity_reservation_response.py +201 -0
  69. lightning_sdk/lightning_cloud/openapi/models/v1_create_sdk_command_history_request.py +29 -3
  70. lightning_sdk/lightning_cloud/openapi/models/v1_cudo_direct_v1.py +175 -0
  71. lightning_sdk/lightning_cloud/openapi/models/{cluster_service_refresh_container_registry_credentials_body.py → v1_delete_lit_logger_media_response.py} +6 -6
  72. lightning_sdk/lightning_cloud/openapi/models/{kubernetes_virtual_machine_service_update_kubernetes_virtual_machine_body.py → v1_delete_org_cluster_capacity_reservation_response.py} +6 -6
  73. lightning_sdk/lightning_cloud/openapi/models/v1_delete_virtual_machine_response.py +97 -0
  74. lightning_sdk/lightning_cloud/openapi/models/v1_describe_org_cluster_capacity_reservation_response.py +201 -0
  75. lightning_sdk/lightning_cloud/openapi/models/v1_external_cluster_spec.py +27 -27
  76. lightning_sdk/lightning_cloud/openapi/models/v1_external_search_user.py +27 -1
  77. lightning_sdk/lightning_cloud/openapi/models/v1_generic_job_spec.py +79 -1
  78. lightning_sdk/lightning_cloud/openapi/models/{v1_validate_container_registry_response.py → v1_get_kubernetes_pod_logs_response.py} +37 -37
  79. lightning_sdk/lightning_cloud/openapi/models/{v1_get_machine_response.py → v1_get_kubernetes_pod_response.py} +23 -23
  80. lightning_sdk/lightning_cloud/openapi/models/v1_job.py +27 -1
  81. lightning_sdk/lightning_cloud/openapi/models/v1_job_spec.py +27 -1
  82. lightning_sdk/lightning_cloud/openapi/models/v1_joinable_organization.py +27 -1
  83. lightning_sdk/lightning_cloud/openapi/models/{v1_container_registry_integration.py → v1_k8s_incident_setting.py} +49 -23
  84. lightning_sdk/lightning_cloud/openapi/models/v1_k8s_incident_type.py +108 -0
  85. lightning_sdk/lightning_cloud/openapi/models/v1_kubernetes_direct_settings_v1.py +53 -1
  86. lightning_sdk/lightning_cloud/openapi/models/v1_kubernetes_direct_v1.py +53 -27
  87. lightning_sdk/lightning_cloud/openapi/models/v1_kubernetes_pod.py +27 -1
  88. lightning_sdk/lightning_cloud/openapi/models/v1_kubernetes_pod_logs_page.py +227 -0
  89. lightning_sdk/lightning_cloud/openapi/models/v1_kubevirt_config.py +53 -1
  90. lightning_sdk/lightning_cloud/openapi/models/v1_list_container_registries_response.py +6 -6
  91. lightning_sdk/lightning_cloud/openapi/models/v1_list_kubernetes_pods_response.py +43 -17
  92. lightning_sdk/lightning_cloud/openapi/models/v1_list_kubernetes_pods_sort_order.py +104 -0
  93. lightning_sdk/lightning_cloud/openapi/models/v1_list_lit_logger_media_response.py +149 -0
  94. lightning_sdk/lightning_cloud/openapi/models/v1_list_models_response.py +55 -3
  95. lightning_sdk/lightning_cloud/openapi/models/{v1_list_kubernetes_virtual_machines_response.py → v1_list_virtual_machines_response.py} +16 -16
  96. lightning_sdk/lightning_cloud/openapi/models/v1_lit_logger_media.py +513 -0
  97. lightning_sdk/lightning_cloud/openapi/models/v1_machine.py +27 -53
  98. lightning_sdk/lightning_cloud/openapi/models/v1_machine_direct_v1.py +107 -3
  99. lightning_sdk/lightning_cloud/openapi/models/v1_media_type.py +104 -0
  100. lightning_sdk/lightning_cloud/openapi/models/{v1_ai_pod_v1.py → v1_mithril_direct_v1.py} +51 -51
  101. lightning_sdk/lightning_cloud/openapi/models/v1_nebius_direct_v1.py +29 -3
  102. lightning_sdk/lightning_cloud/openapi/models/v1_organization.py +27 -1
  103. lightning_sdk/lightning_cloud/openapi/models/v1_refresh_container_registry_credentials_response.py +1 -27
  104. lightning_sdk/lightning_cloud/openapi/models/{cluster_service_validate_container_registry_body.py → v1_report_cloud_space_instance_idle_state_response.py} +6 -6
  105. lightning_sdk/lightning_cloud/openapi/models/v1_report_machine_system_metrics_response.py +97 -0
  106. lightning_sdk/lightning_cloud/openapi/models/{v1_ecr_registry_details.py → v1_tenant_credentials.py} +53 -53
  107. lightning_sdk/lightning_cloud/openapi/models/v1_user_features.py +183 -157
  108. lightning_sdk/lightning_cloud/openapi/models/{v1_kubernetes_virtual_machine.py → v1_virtual_machine.py} +94 -68
  109. lightning_sdk/lightning_cloud/openapi/models/{v1_kubevirt_vm_configuration.py → v1_vm_configuration.py} +20 -20
  110. lightning_sdk/lightning_cloud/openapi/models/{v1_kubevirt_provider_configuration.py → v1_vm_provider_configuration.py} +32 -32
  111. lightning_sdk/lightning_cloud/openapi/models/virtual_machine_service_create_virtual_machine_body.py +565 -0
  112. lightning_sdk/lightning_cloud/openapi/models/virtual_machine_service_update_virtual_machine_body.py +97 -0
  113. lightning_sdk/lightning_cloud/openapi/rest.py +2 -2
  114. lightning_sdk/lightning_cloud/rest_client.py +0 -2
  115. lightning_sdk/machine.py +3 -3
  116. lightning_sdk/studio.py +14 -4
  117. lightning_sdk/teamspace.py +28 -7
  118. lightning_sdk/utils/logging.py +2 -1
  119. {lightning_sdk-2025.12.17.dist-info → lightning_sdk-2026.1.27.dist-info}/METADATA +1 -5
  120. {lightning_sdk-2025.12.17.dist-info → lightning_sdk-2026.1.27.dist-info}/RECORD +125 -102
  121. {lightning_sdk-2025.12.17.dist-info → lightning_sdk-2026.1.27.dist-info}/WHEEL +1 -1
  122. lightning_sdk/lightning_cloud/cli/__main__.py +0 -29
  123. lightning_sdk/lightning_cloud/openapi/models/kubernetes_virtual_machine_service_create_kubernetes_virtual_machine_body.py +0 -513
  124. lightning_sdk/lightning_cloud/openapi/models/v1_container_registry_info.py +0 -281
  125. lightning_sdk/lightning_cloud/openapi/models/v1_kubevirt_vm_resources.py +0 -201
  126. lightning_sdk/lightning_cloud/source_code/logs_socket_api.py +0 -103
  127. /lightning_sdk/lightning_cloud/openapi/models/{v1_list_filesystem_mmts_response.py → v1_list_filesystem_mm_ts_response.py} +0 -0
  128. {lightning_sdk-2025.12.17.dist-info → lightning_sdk-2026.1.27.dist-info}/LICENSE +0 -0
  129. {lightning_sdk-2025.12.17.dist-info → lightning_sdk-2026.1.27.dist-info}/entry_points.txt +0 -0
  130. {lightning_sdk-2025.12.17.dist-info → lightning_sdk-2026.1.27.dist-info}/top_level.txt +0 -0
@@ -1,281 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- external/v1/auth_service.proto
5
-
6
- No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
7
-
8
- OpenAPI spec version: version not set
9
-
10
- Generated by: https://github.com/swagger-api/swagger-codegen.git
11
-
12
- NOTE
13
- ----
14
- standard swagger-codegen-cli for this python client has been modified
15
- by custom templates. The purpose of these templates is to include
16
- typing information in the API and Model code. Please refer to the
17
- main grid repository for more info
18
- """
19
-
20
- import pprint
21
- import re # noqa: F401
22
-
23
- from typing import TYPE_CHECKING
24
-
25
- import six
26
-
27
- if TYPE_CHECKING:
28
- from datetime import datetime
29
- from lightning_sdk.lightning_cloud.openapi.models import *
30
-
31
- class V1ContainerRegistryInfo(object):
32
- """NOTE: This class is auto generated by the swagger code generator program.
33
-
34
- Do not edit the class manually.
35
- """
36
- """
37
- Attributes:
38
- swagger_types (dict): The key is attribute name
39
- and the value is attribute type.
40
- attribute_map (dict): The key is attribute name
41
- and the value is json key in definition.
42
- """
43
- swagger_types = {
44
- 'ecr': 'V1ECRRegistryDetails',
45
- 'id': 'str',
46
- 'last_refresh': 'datetime',
47
- 'status': 'V1ContainerRegistryStatus',
48
- 'status_message': 'str',
49
- 'type': 'str',
50
- 'validated_at': 'datetime'
51
- }
52
-
53
- attribute_map = {
54
- 'ecr': 'ecr',
55
- 'id': 'id',
56
- 'last_refresh': 'lastRefresh',
57
- 'status': 'status',
58
- 'status_message': 'statusMessage',
59
- 'type': 'type',
60
- 'validated_at': 'validatedAt'
61
- }
62
-
63
- def __init__(self, ecr: 'V1ECRRegistryDetails' =None, id: 'str' =None, last_refresh: 'datetime' =None, status: 'V1ContainerRegistryStatus' =None, status_message: 'str' =None, type: 'str' =None, validated_at: 'datetime' =None): # noqa: E501
64
- """V1ContainerRegistryInfo - a model defined in Swagger""" # noqa: E501
65
- self._ecr = None
66
- self._id = None
67
- self._last_refresh = None
68
- self._status = None
69
- self._status_message = None
70
- self._type = None
71
- self._validated_at = None
72
- self.discriminator = None
73
- if ecr is not None:
74
- self.ecr = ecr
75
- if id is not None:
76
- self.id = id
77
- if last_refresh is not None:
78
- self.last_refresh = last_refresh
79
- if status is not None:
80
- self.status = status
81
- if status_message is not None:
82
- self.status_message = status_message
83
- if type is not None:
84
- self.type = type
85
- if validated_at is not None:
86
- self.validated_at = validated_at
87
-
88
- @property
89
- def ecr(self) -> 'V1ECRRegistryDetails':
90
- """Gets the ecr of this V1ContainerRegistryInfo. # noqa: E501
91
-
92
-
93
- :return: The ecr of this V1ContainerRegistryInfo. # noqa: E501
94
- :rtype: V1ECRRegistryDetails
95
- """
96
- return self._ecr
97
-
98
- @ecr.setter
99
- def ecr(self, ecr: 'V1ECRRegistryDetails'):
100
- """Sets the ecr of this V1ContainerRegistryInfo.
101
-
102
-
103
- :param ecr: The ecr of this V1ContainerRegistryInfo. # noqa: E501
104
- :type: V1ECRRegistryDetails
105
- """
106
-
107
- self._ecr = ecr
108
-
109
- @property
110
- def id(self) -> 'str':
111
- """Gets the id of this V1ContainerRegistryInfo. # noqa: E501
112
-
113
-
114
- :return: The id of this V1ContainerRegistryInfo. # noqa: E501
115
- :rtype: str
116
- """
117
- return self._id
118
-
119
- @id.setter
120
- def id(self, id: 'str'):
121
- """Sets the id of this V1ContainerRegistryInfo.
122
-
123
-
124
- :param id: The id of this V1ContainerRegistryInfo. # noqa: E501
125
- :type: str
126
- """
127
-
128
- self._id = id
129
-
130
- @property
131
- def last_refresh(self) -> 'datetime':
132
- """Gets the last_refresh of this V1ContainerRegistryInfo. # noqa: E501
133
-
134
-
135
- :return: The last_refresh of this V1ContainerRegistryInfo. # noqa: E501
136
- :rtype: datetime
137
- """
138
- return self._last_refresh
139
-
140
- @last_refresh.setter
141
- def last_refresh(self, last_refresh: 'datetime'):
142
- """Sets the last_refresh of this V1ContainerRegistryInfo.
143
-
144
-
145
- :param last_refresh: The last_refresh of this V1ContainerRegistryInfo. # noqa: E501
146
- :type: datetime
147
- """
148
-
149
- self._last_refresh = last_refresh
150
-
151
- @property
152
- def status(self) -> 'V1ContainerRegistryStatus':
153
- """Gets the status of this V1ContainerRegistryInfo. # noqa: E501
154
-
155
-
156
- :return: The status of this V1ContainerRegistryInfo. # noqa: E501
157
- :rtype: V1ContainerRegistryStatus
158
- """
159
- return self._status
160
-
161
- @status.setter
162
- def status(self, status: 'V1ContainerRegistryStatus'):
163
- """Sets the status of this V1ContainerRegistryInfo.
164
-
165
-
166
- :param status: The status of this V1ContainerRegistryInfo. # noqa: E501
167
- :type: V1ContainerRegistryStatus
168
- """
169
-
170
- self._status = status
171
-
172
- @property
173
- def status_message(self) -> 'str':
174
- """Gets the status_message of this V1ContainerRegistryInfo. # noqa: E501
175
-
176
-
177
- :return: The status_message of this V1ContainerRegistryInfo. # noqa: E501
178
- :rtype: str
179
- """
180
- return self._status_message
181
-
182
- @status_message.setter
183
- def status_message(self, status_message: 'str'):
184
- """Sets the status_message of this V1ContainerRegistryInfo.
185
-
186
-
187
- :param status_message: The status_message of this V1ContainerRegistryInfo. # noqa: E501
188
- :type: str
189
- """
190
-
191
- self._status_message = status_message
192
-
193
- @property
194
- def type(self) -> 'str':
195
- """Gets the type of this V1ContainerRegistryInfo. # noqa: E501
196
-
197
- \"ecr\", \"lightning\", etc. # noqa: E501
198
-
199
- :return: The type of this V1ContainerRegistryInfo. # noqa: E501
200
- :rtype: str
201
- """
202
- return self._type
203
-
204
- @type.setter
205
- def type(self, type: 'str'):
206
- """Sets the type of this V1ContainerRegistryInfo.
207
-
208
- \"ecr\", \"lightning\", etc. # noqa: E501
209
-
210
- :param type: The type of this V1ContainerRegistryInfo. # noqa: E501
211
- :type: str
212
- """
213
-
214
- self._type = type
215
-
216
- @property
217
- def validated_at(self) -> 'datetime':
218
- """Gets the validated_at of this V1ContainerRegistryInfo. # noqa: E501
219
-
220
-
221
- :return: The validated_at of this V1ContainerRegistryInfo. # noqa: E501
222
- :rtype: datetime
223
- """
224
- return self._validated_at
225
-
226
- @validated_at.setter
227
- def validated_at(self, validated_at: 'datetime'):
228
- """Sets the validated_at of this V1ContainerRegistryInfo.
229
-
230
-
231
- :param validated_at: The validated_at of this V1ContainerRegistryInfo. # noqa: E501
232
- :type: datetime
233
- """
234
-
235
- self._validated_at = validated_at
236
-
237
- def to_dict(self) -> dict:
238
- """Returns the model properties as a dict"""
239
- result = {}
240
-
241
- for attr, _ in six.iteritems(self.swagger_types):
242
- value = getattr(self, attr)
243
- if isinstance(value, list):
244
- result[attr] = list(map(
245
- lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
246
- value
247
- ))
248
- elif hasattr(value, "to_dict"):
249
- result[attr] = value.to_dict()
250
- elif isinstance(value, dict):
251
- result[attr] = dict(map(
252
- lambda item: (item[0], item[1].to_dict())
253
- if hasattr(item[1], "to_dict") else item,
254
- value.items()
255
- ))
256
- else:
257
- result[attr] = value
258
- if issubclass(V1ContainerRegistryInfo, dict):
259
- for key, value in self.items():
260
- result[key] = value
261
-
262
- return result
263
-
264
- def to_str(self) -> str:
265
- """Returns the string representation of the model"""
266
- return pprint.pformat(self.to_dict())
267
-
268
- def __repr__(self) -> str:
269
- """For `print` and `pprint`"""
270
- return self.to_str()
271
-
272
- def __eq__(self, other: 'V1ContainerRegistryInfo') -> bool:
273
- """Returns true if both objects are equal"""
274
- if not isinstance(other, V1ContainerRegistryInfo):
275
- return False
276
-
277
- return self.__dict__ == other.__dict__
278
-
279
- def __ne__(self, other: 'V1ContainerRegistryInfo') -> bool:
280
- """Returns true if both objects are not equal"""
281
- return not self == other
@@ -1,201 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- external/v1/auth_service.proto
5
-
6
- No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
7
-
8
- OpenAPI spec version: version not set
9
-
10
- Generated by: https://github.com/swagger-api/swagger-codegen.git
11
-
12
- NOTE
13
- ----
14
- standard swagger-codegen-cli for this python client has been modified
15
- by custom templates. The purpose of these templates is to include
16
- typing information in the API and Model code. Please refer to the
17
- main grid repository for more info
18
- """
19
-
20
- import pprint
21
- import re # noqa: F401
22
-
23
- from typing import TYPE_CHECKING
24
-
25
- import six
26
-
27
- if TYPE_CHECKING:
28
- from datetime import datetime
29
- from lightning_sdk.lightning_cloud.openapi.models import *
30
-
31
- class V1KubevirtVmResources(object):
32
- """NOTE: This class is auto generated by the swagger code generator program.
33
-
34
- Do not edit the class manually.
35
- """
36
- """
37
- Attributes:
38
- swagger_types (dict): The key is attribute name
39
- and the value is attribute type.
40
- attribute_map (dict): The key is attribute name
41
- and the value is json key in definition.
42
- """
43
- swagger_types = {
44
- 'cpu': 'int',
45
- 'gpus': 'int',
46
- 'ram': 'str',
47
- 'storage': 'int'
48
- }
49
-
50
- attribute_map = {
51
- 'cpu': 'cpu',
52
- 'gpus': 'gpus',
53
- 'ram': 'ram',
54
- 'storage': 'storage'
55
- }
56
-
57
- def __init__(self, cpu: 'int' =None, gpus: 'int' =None, ram: 'str' =None, storage: 'int' =None): # noqa: E501
58
- """V1KubevirtVmResources - a model defined in Swagger""" # noqa: E501
59
- self._cpu = None
60
- self._gpus = None
61
- self._ram = None
62
- self._storage = None
63
- self.discriminator = None
64
- if cpu is not None:
65
- self.cpu = cpu
66
- if gpus is not None:
67
- self.gpus = gpus
68
- if ram is not None:
69
- self.ram = ram
70
- if storage is not None:
71
- self.storage = storage
72
-
73
- @property
74
- def cpu(self) -> 'int':
75
- """Gets the cpu of this V1KubevirtVmResources. # noqa: E501
76
-
77
-
78
- :return: The cpu of this V1KubevirtVmResources. # noqa: E501
79
- :rtype: int
80
- """
81
- return self._cpu
82
-
83
- @cpu.setter
84
- def cpu(self, cpu: 'int'):
85
- """Sets the cpu of this V1KubevirtVmResources.
86
-
87
-
88
- :param cpu: The cpu of this V1KubevirtVmResources. # noqa: E501
89
- :type: int
90
- """
91
-
92
- self._cpu = cpu
93
-
94
- @property
95
- def gpus(self) -> 'int':
96
- """Gets the gpus of this V1KubevirtVmResources. # noqa: E501
97
-
98
-
99
- :return: The gpus of this V1KubevirtVmResources. # noqa: E501
100
- :rtype: int
101
- """
102
- return self._gpus
103
-
104
- @gpus.setter
105
- def gpus(self, gpus: 'int'):
106
- """Sets the gpus of this V1KubevirtVmResources.
107
-
108
-
109
- :param gpus: The gpus of this V1KubevirtVmResources. # noqa: E501
110
- :type: int
111
- """
112
-
113
- self._gpus = gpus
114
-
115
- @property
116
- def ram(self) -> 'str':
117
- """Gets the ram of this V1KubevirtVmResources. # noqa: E501
118
-
119
-
120
- :return: The ram of this V1KubevirtVmResources. # noqa: E501
121
- :rtype: str
122
- """
123
- return self._ram
124
-
125
- @ram.setter
126
- def ram(self, ram: 'str'):
127
- """Sets the ram of this V1KubevirtVmResources.
128
-
129
-
130
- :param ram: The ram of this V1KubevirtVmResources. # noqa: E501
131
- :type: str
132
- """
133
-
134
- self._ram = ram
135
-
136
- @property
137
- def storage(self) -> 'int':
138
- """Gets the storage of this V1KubevirtVmResources. # noqa: E501
139
-
140
-
141
- :return: The storage of this V1KubevirtVmResources. # noqa: E501
142
- :rtype: int
143
- """
144
- return self._storage
145
-
146
- @storage.setter
147
- def storage(self, storage: 'int'):
148
- """Sets the storage of this V1KubevirtVmResources.
149
-
150
-
151
- :param storage: The storage of this V1KubevirtVmResources. # noqa: E501
152
- :type: int
153
- """
154
-
155
- self._storage = storage
156
-
157
- def to_dict(self) -> dict:
158
- """Returns the model properties as a dict"""
159
- result = {}
160
-
161
- for attr, _ in six.iteritems(self.swagger_types):
162
- value = getattr(self, attr)
163
- if isinstance(value, list):
164
- result[attr] = list(map(
165
- lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
166
- value
167
- ))
168
- elif hasattr(value, "to_dict"):
169
- result[attr] = value.to_dict()
170
- elif isinstance(value, dict):
171
- result[attr] = dict(map(
172
- lambda item: (item[0], item[1].to_dict())
173
- if hasattr(item[1], "to_dict") else item,
174
- value.items()
175
- ))
176
- else:
177
- result[attr] = value
178
- if issubclass(V1KubevirtVmResources, dict):
179
- for key, value in self.items():
180
- result[key] = value
181
-
182
- return result
183
-
184
- def to_str(self) -> str:
185
- """Returns the string representation of the model"""
186
- return pprint.pformat(self.to_dict())
187
-
188
- def __repr__(self) -> str:
189
- """For `print` and `pprint`"""
190
- return self.to_str()
191
-
192
- def __eq__(self, other: 'V1KubevirtVmResources') -> bool:
193
- """Returns true if both objects are equal"""
194
- if not isinstance(other, V1KubevirtVmResources):
195
- return False
196
-
197
- return self.__dict__ == other.__dict__
198
-
199
- def __ne__(self, other: 'V1KubevirtVmResources') -> bool:
200
- """Returns true if both objects are not equal"""
201
- return not self == other
@@ -1,103 +0,0 @@
1
- from urllib.parse import urlparse
2
-
3
- from lightning_sdk.lightning_cloud.login import Auth
4
- from lightning_sdk.lightning_cloud.openapi import ApiClient, AuthServiceApi, V1LoginRequest
5
- import websocket
6
-
7
-
8
- class LightningLogsSocketAPI:
9
-
10
- def __init__(self, api_client=None):
11
- if api_client is None:
12
- api_client = ApiClient()
13
- self.api_client = api_client
14
- self._auth = None
15
- self._auth_service = None
16
-
17
- def _init_auth(self):
18
- self._auth = Auth()
19
- self._auth.authenticate()
20
- self._auth_service = AuthServiceApi(self.api_client)
21
-
22
- def _get_api_token(self):
23
- if not self._auth_service:
24
- self._init_auth()
25
- token_resp = self._auth_service.auth_service_login(body=V1LoginRequest(
26
- username=self._auth.user_id,
27
- api_key=self._auth.api_key,
28
- ))
29
- return token_resp.token
30
-
31
- @staticmethod
32
- def _socket_url(host: str, project_id: str, app_id: str, token: str,
33
- component: str):
34
- return (f"wss://{host}/v1/projects/{project_id}/apps/{app_id}/logs?"
35
- f"token={token}&component={component}&follow=true")
36
-
37
- def create_lightning_logs_socket(
38
- self,
39
- project_id: str,
40
- app_id: str,
41
- component: str,
42
- on_message_callback,
43
- on_error_callback=None,
44
- ) -> websocket.WebSocketApp:
45
- """
46
- Creates and returns WebSocketApp to listen to lightning app logs.
47
-
48
- Usage example synchronous:
49
- def print_log_msg(ws_app, msg):
50
- print(msg)
51
-
52
- flow_logs_socket = client.create_lightning_logs_socket('project_id', 'app_id', 'flow', print_log_msg)
53
- flow_socket.run_forever()
54
-
55
- Usage example asynchronous, multiple components:
56
- def print_log_msg(ws_app, msg):
57
- print(msg)
58
-
59
- flow_logs_socket = client.create_lightning_logs_socket('project_id', 'app_id', 'flow', print_log_msg)
60
- work_logs_socket = client.create_lightning_logs_socket('project_id', 'app_id', 'work_1', print_log_msg)
61
-
62
- flow_logs_thread = Thread(target=flow_logs_socket.run_forever)
63
- work_logs_thread = Thread(target=work_logs_socket.run_forever)
64
-
65
- flow_logs_thread.start()
66
- work_logs_thread.start()
67
- .......
68
-
69
- flow_logs_socket.close()
70
- work_logs_thread.close()
71
-
72
- Parameters
73
- ----------
74
- project_id: str
75
- app_id: str
76
- component: str
77
- on_message_callback: function
78
- Callback object which is called when received data.
79
- on_message_callback has 2 arguments.
80
- The 1st argument is the WebSocketApp object.
81
- The 2nd argument is utf-8 data received from the server.
82
- on_error_callback: function
83
- Callback object which is called when we get error.
84
- on_error has 2 arguments.
85
- The 1st argument is this class object.
86
- The 2nd argument is exception object.
87
-
88
- Returns
89
- -------
90
- WebSocketApp of the wanted socket
91
- """
92
- clean_ws_host = urlparse(self.api_client.configuration.host).netloc
93
- socket_url = self._socket_url(
94
- host=clean_ws_host,
95
- project_id=project_id,
96
- app_id=app_id,
97
- token=self._get_api_token(),
98
- component=component,
99
- )
100
-
101
- return websocket.WebSocketApp(socket_url,
102
- on_message=on_message_callback,
103
- on_error=on_error_callback)