Skip to content

Commit bebb5d1

Browse files
Move kr8s objects into separate submodule for better reuse (#732)
1 parent b35cd81 commit bebb5d1

File tree

2 files changed

+41
-40
lines changed

2 files changed

+41
-40
lines changed

dask_kubernetes/operator/controller/controller.py

+1-40
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import kubernetes_asyncio as kubernetes
1212
from importlib_metadata import entry_points
1313
from kubernetes_asyncio.client import ApiException
14-
from kr8s.asyncio.objects import APIObject
1514

15+
from dask_kubernetes.operator.objects import DaskCluster
1616
from dask_kubernetes.common.auth import ClusterAuth
1717
from dask_kubernetes.common.networking import get_scheduler_address
1818
from distributed.core import rpc, clean_exception
@@ -39,45 +39,6 @@ class SchedulerCommError(Exception):
3939
"""Raised when unable to communicate with a scheduler."""
4040

4141

42-
class DaskCluster(APIObject):
43-
version = "kubernetes.dask.org/v1"
44-
endpoint = "daskclusters"
45-
kind = "DaskCluster"
46-
plural = "daskclusters"
47-
singular = "daskcluster"
48-
namespaced = True
49-
scalable = True
50-
scalable_spec = "worker.replicas"
51-
52-
53-
class DaskWorkerGroup(APIObject):
54-
version = "kubernetes.dask.org/v1"
55-
endpoint = "daskworkergroups"
56-
kind = "DaskWorkerGroup"
57-
plural = "daskworkergroups"
58-
singular = "daskworkergroup"
59-
namespaced = True
60-
scalable = True
61-
62-
63-
class DaskAutoscaler(APIObject):
64-
version = "kubernetes.dask.org/v1"
65-
endpoint = "daskautoscalers"
66-
kind = "DaskAutoscaler"
67-
plural = "daskautoscalers"
68-
singular = "daskautoscaler"
69-
namespaced = True
70-
71-
72-
class DaskJob(APIObject):
73-
version = "kubernetes.dask.org/v1"
74-
endpoint = "daskjobs"
75-
kind = "DaskJob"
76-
plural = "daskjobs"
77-
singular = "daskjob"
78-
namespaced = True
79-
80-
8142
def _get_annotations(meta):
8243
return {
8344
annotation_key: annotation_value

dask_kubernetes/operator/objects.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from kr8s.asyncio.objects import APIObject
2+
3+
4+
class DaskCluster(APIObject):
5+
version = "kubernetes.dask.org/v1"
6+
endpoint = "daskclusters"
7+
kind = "DaskCluster"
8+
plural = "daskclusters"
9+
singular = "daskcluster"
10+
namespaced = True
11+
scalable = True
12+
scalable_spec = "worker.replicas"
13+
14+
15+
class DaskWorkerGroup(APIObject):
16+
version = "kubernetes.dask.org/v1"
17+
endpoint = "daskworkergroups"
18+
kind = "DaskWorkerGroup"
19+
plural = "daskworkergroups"
20+
singular = "daskworkergroup"
21+
namespaced = True
22+
scalable = True
23+
24+
25+
class DaskAutoscaler(APIObject):
26+
version = "kubernetes.dask.org/v1"
27+
endpoint = "daskautoscalers"
28+
kind = "DaskAutoscaler"
29+
plural = "daskautoscalers"
30+
singular = "daskautoscaler"
31+
namespaced = True
32+
33+
34+
class DaskJob(APIObject):
35+
version = "kubernetes.dask.org/v1"
36+
endpoint = "daskjobs"
37+
kind = "DaskJob"
38+
plural = "daskjobs"
39+
singular = "daskjob"
40+
namespaced = True

0 commit comments

Comments
 (0)