Skip to content

Commit f493678

Browse files
[Part-1] Refactor k8s related code into a separate module
This commit is first of the chain in refactoring the cluster/ package.
1 parent 932b925 commit f493678

File tree

18 files changed

+331
-294
lines changed

18 files changed

+331
-294
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ node_modules
1212
.DS_Store
1313
ui-tests/playwright-report
1414
ui-tests/test-results
15+
/src/codeflare_sdk.egg-info/

poetry.lock

Lines changed: 252 additions & 243 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/codeflare_sdk.egg-info/SOURCES.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ src/codeflare_sdk.egg-info/SOURCES.txt
77
src/codeflare_sdk.egg-info/dependency_links.txt
88
src/codeflare_sdk.egg-info/top_level.txt
99
src/codeflare_sdk/cluster/__init__.py
10-
src/codeflare_sdk/cluster/auth.py
1110
src/codeflare_sdk/cluster/awload.py
1211
src/codeflare_sdk/cluster/cluster.py
1312
src/codeflare_sdk/cluster/config.py
1413
src/codeflare_sdk/cluster/model.py
1514
src/codeflare_sdk/cluster/widgets.py
15+
src/codeflare_sdk/common/__init__.py
16+
src/codeflare_sdk/common/kubernetes_cluster/__init__.py
17+
src/codeflare_sdk/common/kubernetes_cluster/auth.py
18+
src/codeflare_sdk/common/kubernetes_cluster/kube_api_helpers.py
1619
src/codeflare_sdk/job/__init__.py
1720
src/codeflare_sdk/job/ray_jobs.py
1821
src/codeflare_sdk/utils/__init__.py
1922
src/codeflare_sdk/utils/demos.py
2023
src/codeflare_sdk/utils/generate_cert.py
2124
src/codeflare_sdk/utils/generate_yaml.py
22-
src/codeflare_sdk/utils/kube_api_helpers.py
2325
src/codeflare_sdk/utils/pretty_print.py

src/codeflare_sdk/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
from .cluster import (
2-
Authentication,
3-
KubeConfiguration,
4-
TokenAuthentication,
5-
KubeConfigFileAuthentication,
62
AWManager,
73
Cluster,
84
ClusterConfiguration,
@@ -17,6 +13,13 @@
1713
view_clusters,
1814
)
1915

16+
from .common import (
17+
Authentication,
18+
KubeConfiguration,
19+
TokenAuthentication,
20+
KubeConfigFileAuthentication,
21+
)
22+
2023
from .job import RayJobClient
2124

2225
from .utils import generate_cert

src/codeflare_sdk/cluster/__init__.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
from .auth import (
2-
Authentication,
3-
KubeConfiguration,
4-
TokenAuthentication,
5-
KubeConfigFileAuthentication,
6-
)
7-
81
from .model import (
92
RayClusterStatus,
103
AppWrapperStatus,

src/codeflare_sdk/cluster/awload.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@
2222
import os
2323
import yaml
2424

25-
from kubernetes import client, config
26-
from ..utils.kube_api_helpers import _kube_api_error_handling
27-
from .auth import config_check, get_api_client
25+
from kubernetes import client
26+
from ..common import _kube_api_error_handling
27+
from ..common.kubernetes_cluster.auth import (
28+
config_check,
29+
get_api_client,
30+
)
2831

2932

3033
class AWManager:

src/codeflare_sdk/cluster/cluster.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@
1818
cluster setup queue, a list of all existing clusters, and the user's working namespace.
1919
"""
2020

21-
import re
22-
import subprocess
2321
from time import sleep
2422
from typing import List, Optional, Tuple, Dict
2523

26-
from kubernetes import config
2724
from ray.job_submission import JobSubmissionClient
2825

29-
from .auth import config_check, get_api_client
26+
from ..common.kubernetes_cluster.auth import (
27+
config_check,
28+
get_api_client,
29+
)
3030
from ..utils import pretty_print
3131
from ..utils.generate_yaml import (
3232
generate_appwrapper,
3333
head_worker_gpu_count_from_cluster,
3434
)
35-
from ..utils.kube_api_helpers import _kube_api_error_handling
35+
from ..common import _kube_api_error_handling
3636
from ..utils.generate_yaml import is_openshift_cluster
3737

3838
from .config import ClusterConfiguration
@@ -47,8 +47,7 @@
4747
cluster_up_down_buttons,
4848
is_notebook,
4949
)
50-
from kubernetes import client, config
51-
from kubernetes.utils import parse_quantity
50+
from kubernetes import client
5251
import yaml
5352
import os
5453
import requests

src/codeflare_sdk/cluster/widgets.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@
2828
import pandas as pd
2929
from .config import ClusterConfiguration
3030
from .model import RayClusterStatus
31-
from ..utils.kube_api_helpers import _kube_api_error_handling
32-
from .auth import config_check, get_api_client
31+
from ..common import _kube_api_error_handling
32+
from ..common.kubernetes_cluster.auth import (
33+
config_check,
34+
get_api_client,
35+
)
3336

3437

3538
def cluster_up_down_buttons(cluster: "codeflare_sdk.cluster.Cluster") -> widgets.Button:

src/codeflare_sdk/common/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Importing everything from the kubernetes_cluster module
2+
from .kubernetes_cluster import (
3+
Authentication,
4+
KubeConfiguration,
5+
TokenAuthentication,
6+
KubeConfigFileAuthentication,
7+
_kube_api_error_handling,
8+
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from .auth import (
2+
Authentication,
3+
KubeConfiguration,
4+
TokenAuthentication,
5+
KubeConfigFileAuthentication,
6+
config_check,
7+
get_api_client,
8+
)
9+
10+
from .kube_api_helpers import _kube_api_error_handling

0 commit comments

Comments
 (0)