Skip to content

Commit

Permalink
K8s runner - WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
TaekyungHeo committed Sep 30, 2024
1 parent 8915eb3 commit 4b064e6
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/cloudai/runner/kubernetes/kubernetes_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.

import logging
from pathlib import Path
from typing import cast

from cloudai import BaseJob, BaseRunner, TestRun
Expand All @@ -36,19 +37,23 @@ def _submit_test(self, tr: TestRun) -> KubernetesJob:
Returns:
KubernetesJob: A KubernetesJob object containing job details.
"""
logging.info(f"Running test: {tr.test.section_name}")
job_output_path = self.get_job_output_path(tr.test)
job_name = tr.test.section_name.replace(".", "-").lower()
job_spec = tr.test.gen_json(job_output_path, job_name, tr.time_limit, tr.num_nodes, tr.nodes)
job_kind = job_spec.get("kind", "").lower()
logging.info(f"Generated JSON string for test {tr.test.section_name}: {job_spec}")
job_namespace = ""
if tr.test.test_template.json_gen_strategy is not None:
logging.info(f"Running test: {tr.test.section_name}")
job_output_path = self.get_job_output_path(tr.test)
job_name = tr.test.section_name.replace(".", "-").lower()
job_spec = tr.test.gen_json(job_output_path, job_name, tr.time_limit, tr.num_nodes, tr.nodes)
job_kind = job_spec.get("kind", "").lower()
logging.info(f"Generated JSON string for test {tr.test.section_name}: {job_spec}")
job_namespace = ""

if self.mode == "run":
k8s_system: KubernetesSystem = cast(KubernetesSystem, self.system)
job_name, job_namespace = k8s_system.create_job(job_spec)
if self.mode == "run":
k8s_system: KubernetesSystem = cast(KubernetesSystem, self.system)
job_name, job_namespace = k8s_system.create_job(job_spec)

return KubernetesJob(self.mode, self.system, tr, job_namespace, job_name, job_kind, job_output_path)
return KubernetesJob(self.mode, self.system, tr, job_namespace, job_name, job_kind, job_output_path)
else:
print("Command Gen")
return KubernetesJob(self.mode, self.system, tr, "", "", "", Path(""))

async def job_completion_callback(self, job: BaseJob) -> None:
"""
Expand Down

0 comments on commit 4b064e6

Please sign in to comment.