-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Peng Wang <pengwang@nvidia.com>
- Loading branch information
1 parent
75084ae
commit 691c6e9
Showing
5 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/cloudai/schema/test_template/sleep/kubernetes_install_strategy.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES | ||
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from cloudai import InstallStatusResult, InstallStrategy | ||
|
||
|
||
class SleepKubernetesInstallStrategy(InstallStrategy): | ||
"""Installation strategy for the Sleep test on Kubernetes systems.""" | ||
|
||
def is_installed(self) -> InstallStatusResult: | ||
return InstallStatusResult(success=True) | ||
|
||
def install(self) -> InstallStatusResult: | ||
return InstallStatusResult(success=True) | ||
|
||
def uninstall(self) -> InstallStatusResult: | ||
return InstallStatusResult(success=True) |
65 changes: 65 additions & 0 deletions
65
src/cloudai/schema/test_template/sleep/kubernetes_json_gen_strategy.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES | ||
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from pathlib import Path | ||
from typing import Any, Dict, List, cast | ||
|
||
from cloudai import JsonGenStrategy | ||
from cloudai.systems import KubernetesSystem | ||
|
||
|
||
class SleepKubernetesJsonGenStrategy(JsonGenStrategy): | ||
"""JSON generation strategy for Sleep on Kubernetes systems.""" | ||
|
||
def gen_json( | ||
self, | ||
env_vars: Dict[str, str], | ||
cmd_args: Dict[str, str], | ||
extra_env_vars: Dict[str, str], | ||
extra_cmd_args: str, | ||
output_path: Path, | ||
job_name: str, | ||
num_nodes: int, | ||
nodes: List[str], | ||
) -> Dict[Any, Any]: | ||
self.final_cmd_args = self._override_cmd_args(self.default_cmd_args, cmd_args) | ||
sec = self.final_cmd_args["seconds"] | ||
|
||
kubernetes_system = cast(KubernetesSystem, self.system) | ||
|
||
job_spec = { | ||
"apiVersion": "batch/v1", | ||
"kind": "Job", | ||
"metadata": {"name": job_name, "namespace": kubernetes_system.default_namespace}, | ||
"spec": { | ||
"ttlSecondsAfterFinished": 0, | ||
"template": { | ||
"spec": { | ||
"containers": [ | ||
{ | ||
"args": ["sleep " + sec], | ||
"command": ["/bin/bash", "-c"], | ||
"image": kubernetes_system.default_image, | ||
"name": "task", | ||
} | ||
], | ||
"restartPolicy": "Never", | ||
} | ||
}, | ||
}, | ||
} | ||
|
||
return job_spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters