Skip to content

Commit 4ce8829

Browse files
committed
Generate test-run.toml in Dynamo k8s runs
1 parent a2b4f99 commit 4ce8829

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/cloudai/_core/json_gen_strategy.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
from abc import ABC, abstractmethod
1919
from typing import Any, Dict
2020

21+
import toml
22+
2123
from .system import System
2224
from .test_scenario import TestRun
2325

@@ -29,6 +31,8 @@ class JsonGenStrategy(ABC):
2931
It specifies how to generate JSON job specifications based on system and test parameters.
3032
"""
3133

34+
TEST_RUN_DUMP_FILE_NAME: str = "test-run.toml"
35+
3236
def __init__(self, system: System, test_run: TestRun) -> None:
3337
self.system = system
3438
self.test_run = test_run
@@ -54,6 +58,14 @@ def sanitize_k8s_job_name(self, job_name: str) -> str:
5458
sanitized_name = re.sub(r"[^a-z0-9]+$", "", sanitized_name)
5559
return sanitized_name[:253]
5660

61+
def store_test_run(self) -> None:
62+
from cloudai.models.scenario import TestRunDetails
63+
64+
test_cmd, srun_cmd = ("", "n/a")
65+
with (self.test_run.output_path / self.TEST_RUN_DUMP_FILE_NAME).open("w") as f:
66+
trd = TestRunDetails.from_test_run(self.test_run, test_cmd=test_cmd, full_cmd=srun_cmd)
67+
toml.dump(trd.model_dump(), f)
68+
5769
@abstractmethod
5870
def gen_json(self) -> Dict[Any, Any]:
5971
"""

src/cloudai/systems/kubernetes/kubernetes_runner.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def _submit_test(self, tr: TestRun) -> KubernetesJob:
4242

4343
return job
4444

45+
def on_job_submit(self, tr: TestRun) -> None:
46+
json_gen = self.get_json_gen_strategy(self.system, tr)
47+
json_gen.store_test_run()
48+
4549
def on_job_completion(self, job: BaseJob) -> None:
4650
k8s_system: KubernetesSystem = cast(KubernetesSystem, self.system)
4751
k_job = cast(KubernetesJob, job)

0 commit comments

Comments
 (0)