nebu 0.1.3__py3-none-any.whl → 0.1.4__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.
@@ -10,6 +10,7 @@ from nebu.containers.models import (
10
10
  V1ContainerRequest,
11
11
  V1ContainerResources,
12
12
  V1Containers,
13
+ V1ContainerSearch,
13
14
  V1EnvVar,
14
15
  V1Meter,
15
16
  V1PortRequest,
@@ -23,9 +24,9 @@ class Container:
23
24
  def __init__(
24
25
  self,
25
26
  name: str,
27
+ image: str,
26
28
  namespace: str = "default",
27
29
  platform: Optional[str] = None,
28
- image: str = "",
29
30
  env: Optional[List[V1EnvVar]] = None,
30
31
  command: Optional[str] = None,
31
32
  volumes: Optional[List[V1VolumePath]] = None,
@@ -48,6 +49,7 @@ class Container:
48
49
  raise ValueError("No current server config found")
49
50
  self.api_key = current_server.api_key
50
51
  self.nebu_host = current_server.server
52
+ self.config = config
51
53
 
52
54
  # print(f"nebu_host: {self.nebu_host}")
53
55
  # print(f"api_key: {self.api_key}")
@@ -240,3 +242,123 @@ class Container:
240
242
  )
241
243
  response.raise_for_status()
242
244
  print(f"Deleted container {self.name} in namespace {self.namespace}")
245
+
246
+ @classmethod
247
+ def get(
248
+ cls,
249
+ name: Optional[str] = None,
250
+ namespace: Optional[str] = None,
251
+ config: Optional[GlobalConfig] = None,
252
+ ) -> List[V1Container]:
253
+ """
254
+ Get a list of containers that match the optional name and/or namespace filters.
255
+ """
256
+ config = config or GlobalConfig.read()
257
+ current_server = config.get_current_server_config()
258
+ if not current_server:
259
+ raise ValueError("No current server config found")
260
+ api_key = current_server.api_key
261
+ nebu_host = current_server.server
262
+
263
+ containers_url = f"{nebu_host}/v1/containers"
264
+
265
+ response = requests.get(
266
+ containers_url, headers={"Authorization": f"Bearer {api_key}"}
267
+ )
268
+ response.raise_for_status()
269
+
270
+ containers_response = V1Containers.model_validate(response.json())
271
+ filtered_containers = containers_response.containers
272
+
273
+ if name:
274
+ filtered_containers = [
275
+ container
276
+ for container in filtered_containers
277
+ if container.metadata.name == name
278
+ ]
279
+ if namespace:
280
+ filtered_containers = [
281
+ container
282
+ for container in filtered_containers
283
+ if container.metadata.namespace == namespace
284
+ ]
285
+
286
+ return filtered_containers
287
+
288
+ @classmethod
289
+ def load(
290
+ cls,
291
+ name: str,
292
+ namespace: str = "default",
293
+ config: Optional[GlobalConfig] = None,
294
+ ):
295
+ """
296
+ Get a container from the remote server.
297
+ """
298
+ containers = cls.get(namespace=namespace, name=name, config=config)
299
+ if not containers:
300
+ raise ValueError("Container not found")
301
+ container_v1 = containers[0]
302
+
303
+ out = cls.__new__(cls)
304
+ out.container = container_v1
305
+ out.config = config or GlobalConfig.read()
306
+ current_server = out.config.get_current_server_config()
307
+ if not current_server:
308
+ raise ValueError("No current server config found")
309
+ out.api_key = current_server.api_key
310
+ out.nebu_host = current_server.server
311
+ out.containers_url = f"{out.nebu_host}/v1/containers"
312
+
313
+ out = cls.from_v1(container_v1)
314
+ return out
315
+
316
+ @classmethod
317
+ def from_v1(cls, v1: V1Container) -> "Container":
318
+ out = cls.__new__(cls)
319
+ out.name = v1.metadata.name
320
+ out.namespace = v1.metadata.namespace
321
+ out.status = v1.status
322
+ out.kind = v1.kind
323
+ out.platform = v1.platform
324
+ out.metadata = v1.metadata
325
+ out.image = v1.image
326
+ out.env = v1.env
327
+ out.command = v1.command
328
+ out.volumes = v1.volumes
329
+ out.accelerators = v1.accelerators
330
+ out.resources = v1.resources
331
+ out.meters = v1.meters
332
+ out.restart = v1.restart
333
+ out.queue = v1.queue
334
+ out.timeout = v1.timeout
335
+ out.ssh_keys = v1.ssh_keys
336
+ return out
337
+
338
+ @classmethod
339
+ def search(
340
+ cls,
341
+ params: V1ContainerSearch,
342
+ config: Optional[GlobalConfig] = None,
343
+ ) -> List[V1Container]:
344
+ """
345
+ Search for containers on the remote server.
346
+ """
347
+ config = config or GlobalConfig.read()
348
+ current_server = config.get_current_server_config()
349
+ if not current_server:
350
+ raise ValueError("No current server config found")
351
+ api_key = current_server.api_key
352
+ nebu_host = current_server.server
353
+
354
+ search_url = f"{nebu_host}/v1/containers/search"
355
+
356
+ response = requests.post(
357
+ search_url,
358
+ headers={"Authorization": f"Bearer {api_key}"},
359
+ json=params.model_dump(),
360
+ )
361
+ response.raise_for_status()
362
+
363
+ containers_response = V1Containers.model_validate(response.json())
364
+ return containers_response.containers
nebu/containers/models.py CHANGED
@@ -212,3 +212,27 @@ class V1Containers(BaseModel):
212
212
  containers: List[V1Container]
213
213
 
214
214
  model_config = ConfigDict(use_enum_values=True)
215
+
216
+
217
+ class V1ContainerSearch(BaseModel):
218
+ namespace: Optional[str] = None
219
+ image: Optional[str] = None
220
+ env: Optional[List[V1EnvVar]] = None
221
+ command: Optional[str] = None
222
+ args: Optional[str] = None
223
+ volumes: Optional[List[V1VolumePath]] = None
224
+ accelerators: Optional[List[str]] = None
225
+ labels: Optional[Dict[str, str]] = None
226
+ cpu_request: Optional[str] = None
227
+ memory_request: Optional[str] = None
228
+ platform: Optional[str] = None
229
+ health_check: Optional[V1ContainerHealthCheck] = None
230
+ meters: Optional[List[V1Meter]] = None
231
+ restart: Optional[str] = None
232
+ queue: Optional[str] = None
233
+ timeout: Optional[str] = None
234
+ resources: Optional[V1ContainerResources] = None
235
+ proxy_port: Optional[int] = None
236
+ authz: Optional[V1AuthzConfig] = None
237
+
238
+ model_config = ConfigDict(use_enum_values=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nebu
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: A globally distributed container runtime
5
5
  Requires-Python: >=3.10.14
6
6
  Description-Content-Type: text/markdown
@@ -1,16 +1,16 @@
1
1
  nebu/__init__.py,sha256=EbdC8ZKnRTt6jkX0WN0p1pnaDEzb2InqZ1r8QZWzph0,195
2
2
  nebu/config.py,sha256=XBY7uKgcJX9d1HGxqqpx87o_9DuF3maUlUnKkcpUrKU,4565
3
3
  nebu/meta.py,sha256=AnvrtP0mc7a-YP4zVhErHPsU0FSmwMejYgKWnV8wqqE,566
4
- nebu/containers/container.py,sha256=WCXBadAHhvkFQdpDjHu7nh6NjLlMxRsJbMbLXH8zaCs,9283
4
+ nebu/containers/container.py,sha256=sCi96l5CJ-wt0xf0ELjXN1MOTljzCzJ-qN-xgYs7Pw0,13217
5
5
  nebu/containers/decorator.py,sha256=sZQ4ZwqQk_jLDJ-n9P6N0MlxvWL9Ac7eCPIHVxYq58c,5576
6
- nebu/containers/models.py,sha256=o4jHBiXpcnxdxvUSR4q38ctHdL0w6M0uRj4DD-5B0o8,5932
6
+ nebu/containers/models.py,sha256=_d6BS6puoVWvyHhWX-74WFHJSOE8WJaFt2zGMTm9EEA,6782
7
7
  nebu/containers/server.py,sha256=yFa2Y9PzBn59E1HftKiv0iapPonli2rbGAiU6r-wwe0,2513
8
8
  nebu/processors/models.py,sha256=6XSw4iM77XYJf6utm8QReN9fyMS0dK40a5sVwsC7RRA,1970
9
9
  nebu/processors/processor.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  nebu/redis/models.py,sha256=coPovAcVXnOU1Xh_fpJL4PO3QctgK9nBe5QYoqEcnxg,1230
11
11
  nebu/services/service.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- nebu-0.1.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
13
- nebu-0.1.3.dist-info/METADATA,sha256=QAQ6mgaNa41T-MxXPykyYFibeki6AUZw1kNPoWQHPHo,1587
14
- nebu-0.1.3.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
15
- nebu-0.1.3.dist-info/top_level.txt,sha256=uLIbEKJeGSHWOAJN5S0i5XBGwybALlF9bYoB1UhdEgQ,5
16
- nebu-0.1.3.dist-info/RECORD,,
12
+ nebu-0.1.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
13
+ nebu-0.1.4.dist-info/METADATA,sha256=bfMCjbLisYyBt-JXZT1Bu9MS2aLePTjz1cWjcxpPKqc,1587
14
+ nebu-0.1.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
15
+ nebu-0.1.4.dist-info/top_level.txt,sha256=uLIbEKJeGSHWOAJN5S0i5XBGwybALlF9bYoB1UhdEgQ,5
16
+ nebu-0.1.4.dist-info/RECORD,,
File without changes