Skip to content

Commit fa1428b

Browse files
authored
Merge pull request #781 from NVIDIA/am/bug-4843478
Fix installation logic for File on k8s
2 parents 3f0d873 + 0d5725d commit fa1428b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/cloudai/systems/kubernetes/kubernetes_installer.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
2-
# Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
# SPDX-License-Identifier: Apache-2.0
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -118,6 +118,13 @@ def is_installed_one(self, item: Installable) -> InstallStatusResult:
118118
return InstallStatusResult(False, f"Git repository {item.url} not cloned")
119119
elif isinstance(item, PythonExecutable):
120120
return self._is_python_executable_installed(item)
121+
elif isinstance(item, File):
122+
if (self.system.install_path / item.src.name).exists() and (
123+
self.system.install_path / item.src.name
124+
).read_text() == item.src.read_text():
125+
item.installed_path = self.system.install_path / item.src.name
126+
return InstallStatusResult(True)
127+
return InstallStatusResult(False, f"File {self.system.install_path / item.src.name} does not exist")
121128
elif isinstance(item, HFModel):
122129
return self.hf_model_manager.is_model_downloaded(item)
123130
return InstallStatusResult(False, f"Unsupported item type: {type(item)}")
@@ -132,6 +139,9 @@ def mark_as_installed_one(self, item: Installable) -> InstallStatusResult:
132139
item.git_repo.installed_path = self.system.install_path / item.git_repo.repo_name
133140
item.venv_path = self.system.install_path / item.venv_name
134141
return InstallStatusResult(True)
142+
elif isinstance(item, File):
143+
item.installed_path = self.system.install_path / item.src.name
144+
return InstallStatusResult(True)
135145
elif isinstance(item, HFModel):
136146
item.installed_path = self.system.hf_home_path # fake path is OK here as the whole HF home will be mounted
137147
return InstallStatusResult(True)

tests/test_base_installer.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
2-
# Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
# SPDX-License-Identifier: Apache-2.0
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -331,9 +331,7 @@ def test_check_supported(installer: KubernetesInstaller | SlurmInstaller):
331331
installer.hf_model_manager = Mock()
332332

333333
git = GitRepo(url="./git_url", commit="commit_hash")
334-
items = [DockerImage("fake_url/img"), PythonExecutable(git), HFModel("model_name")]
335-
if isinstance(installer, SlurmInstaller):
336-
items.append(File(Path(__file__)))
334+
items = [DockerImage("fake_url/img"), PythonExecutable(git), HFModel("model_name"), File(Path(__file__))]
337335
for item in items:
338336
res = installer.install_one(item)
339337
assert res.success, f"Failed to install {item} for {installer.__class__.__name__=} {res.message=}"

0 commit comments

Comments
 (0)