thds.mops 3.9.20251006172707__py3-none-any.whl → 3.9.20251008013233__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.
Potentially problematic release.
This version of thds.mops might be problematic. Click here for more details.
- thds/mops/k8s/apply_yaml.py +26 -3
- {thds_mops-3.9.20251006172707.dist-info → thds_mops-3.9.20251008013233.dist-info}/METADATA +1 -1
- {thds_mops-3.9.20251006172707.dist-info → thds_mops-3.9.20251008013233.dist-info}/RECORD +6 -6
- {thds_mops-3.9.20251006172707.dist-info → thds_mops-3.9.20251008013233.dist-info}/WHEEL +0 -0
- {thds_mops-3.9.20251006172707.dist-info → thds_mops-3.9.20251008013233.dist-info}/entry_points.txt +0 -0
- {thds_mops-3.9.20251006172707.dist-info → thds_mops-3.9.20251008013233.dist-info}/top_level.txt +0 -0
thds/mops/k8s/apply_yaml.py
CHANGED
|
@@ -1,22 +1,45 @@
|
|
|
1
|
+
import subprocess
|
|
1
2
|
import tempfile
|
|
2
3
|
|
|
4
|
+
import kubernetes
|
|
3
5
|
from kubernetes import client, utils
|
|
6
|
+
from packaging import version
|
|
4
7
|
|
|
5
8
|
|
|
6
9
|
def format_yaml(yaml_template_str: str, **template_values: str) -> str:
|
|
7
10
|
return yaml_template_str.format(**template_values)
|
|
8
11
|
|
|
9
12
|
|
|
13
|
+
def kubectl_apply_file(yaml_path: str) -> None:
|
|
14
|
+
subprocess.run(["kubectl", "apply", "-f", yaml_path], check=True)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def kubectl_apply(yaml_string: str) -> None:
|
|
18
|
+
with tempfile.NamedTemporaryFile("w", prefix="kubectl-yaml") as f:
|
|
19
|
+
f.write(yaml_string)
|
|
20
|
+
f.flush()
|
|
21
|
+
kubectl_apply_file(f.name)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def apply_yaml(yaml_path: str) -> None:
|
|
25
|
+
if version.parse(kubernetes.__version__) < version.parse("32.0.0"):
|
|
26
|
+
kubectl_apply_file(yaml_path) # best effort
|
|
27
|
+
return
|
|
28
|
+
|
|
29
|
+
# NOTE: Prior to 32.0.0, this function doesn't actually server-side apply.
|
|
30
|
+
# https://github.com/kubernetes-client/python/pull/2252
|
|
31
|
+
# Hence the check above to use kubectl for older versions.
|
|
32
|
+
utils.create_from_yaml(client.ApiClient(), yaml_path)
|
|
33
|
+
|
|
34
|
+
|
|
10
35
|
def create_yaml_template(yaml_str: str, **template_values: str) -> None:
|
|
11
36
|
"""Format a YAML template with the given keyword arguments, then apply it to the Kubernetes cluster.
|
|
12
37
|
|
|
13
38
|
You must already have set up your SDK config.
|
|
14
39
|
|
|
15
|
-
NOTE: This function doesn't actually apply, and can't until the next release of the K8S SDK:
|
|
16
|
-
https://github.com/kubernetes-client/python/pull/2252
|
|
17
40
|
"""
|
|
18
41
|
formatted_yaml = format_yaml(yaml_str, **template_values)
|
|
19
42
|
with tempfile.NamedTemporaryFile("w", prefix="kubectl-yaml") as f:
|
|
20
43
|
f.write(formatted_yaml)
|
|
21
44
|
f.flush()
|
|
22
|
-
|
|
45
|
+
apply_yaml(f.name)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: thds.mops
|
|
3
|
-
Version: 3.9.
|
|
3
|
+
Version: 3.9.20251008013233
|
|
4
4
|
Summary: ML Ops tools for Trilliant Health
|
|
5
5
|
Author-email: Trilliant Health <info@trillianthealth.com>
|
|
6
6
|
Project-URL: Repository, https://github.com/TrilliantHealth/ds-monorepo
|
|
@@ -18,7 +18,7 @@ thds/mops/impure/runner.py,sha256=UI1NZWMZ_5TQHfFKLnoiSm2zDR3zCunTKFmJoybkyCo,28
|
|
|
18
18
|
thds/mops/k8s/__init__.py,sha256=zl4GVcCFRvPscyo6gvv5Lx0OKB7d3QjtVFjYurnxMuE,764
|
|
19
19
|
thds/mops/k8s/_launch.py,sha256=hgPty47CdwryPHKMmEnoxSsSvcSpXhHYSVYnLC2QJb0,10956
|
|
20
20
|
thds/mops/k8s/_shared.py,sha256=MR-s6ijWUHZGjxK_fsOpHuRDB6kuofjo5xiIb7ul2VM,86
|
|
21
|
-
thds/mops/k8s/apply_yaml.py,sha256=
|
|
21
|
+
thds/mops/k8s/apply_yaml.py,sha256=zMiQ_k1KcdlIg6diqp6FJD_74I_01YD3cZWA9lqu1fo,1462
|
|
22
22
|
thds/mops/k8s/auth.py,sha256=0zs4TQgkD6VPrhDD43xt7JGwP6uWf3ctySGLcPKN7iw,1691
|
|
23
23
|
thds/mops/k8s/batching.py,sha256=Djt17ffxWyTq4Q7XcAKQdCe9JIIfPahHwm0wqgFqevI,8368
|
|
24
24
|
thds/mops/k8s/config.py,sha256=_znocX5BW8kfG_Cbq6f3apx5FqSihD7Tmic-SBkVjMQ,2992
|
|
@@ -109,8 +109,8 @@ thds/mops/pure/tools/summarize/cli.py,sha256=7kDtn24ok8oBO3jFjlMmOK3jnZYpMoE_5Y8
|
|
|
109
109
|
thds/mops/pure/tools/summarize/run_summary.py,sha256=w45qiQr7elrHDiK9Hgs85gtU3gwLuXa447ih1Y23BBY,5776
|
|
110
110
|
thds/mops/testing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
111
111
|
thds/mops/testing/deferred_imports.py,sha256=f0ezCgQAtzTqW1yAOb0OWgsB9ZrlztLB894LtpWDaVw,3780
|
|
112
|
-
thds_mops-3.9.
|
|
113
|
-
thds_mops-3.9.
|
|
114
|
-
thds_mops-3.9.
|
|
115
|
-
thds_mops-3.9.
|
|
116
|
-
thds_mops-3.9.
|
|
112
|
+
thds_mops-3.9.20251008013233.dist-info/METADATA,sha256=6LW6wUN2leKSh6dydFr-h8rPMPWaE2WzfMo247XIbLw,2225
|
|
113
|
+
thds_mops-3.9.20251008013233.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
114
|
+
thds_mops-3.9.20251008013233.dist-info/entry_points.txt,sha256=qKvCAaB80syXfxVR3xx6x9J0YJdaQWkIbVSw-NwFgMw,322
|
|
115
|
+
thds_mops-3.9.20251008013233.dist-info/top_level.txt,sha256=LTZaE5SkWJwv9bwOlMbIhiS-JWQEEIcjVYnJrt-CriY,5
|
|
116
|
+
thds_mops-3.9.20251008013233.dist-info/RECORD,,
|
|
File without changes
|
{thds_mops-3.9.20251006172707.dist-info → thds_mops-3.9.20251008013233.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{thds_mops-3.9.20251006172707.dist-info → thds_mops-3.9.20251008013233.dist-info}/top_level.txt
RENAMED
|
File without changes
|