Skip to content

Commit 25a1194

Browse files
committed
Fix ART Megatron installer uninstall step
1 parent 45266dc commit 25a1194

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/art_megatron_install.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ def _specifier_matches(requirement: Requirement) -> bool:
137137
return requirement.specifier.contains(Version(installed_version), prereleases=True)
138138

139139

140+
def _package_installed(name: str) -> bool:
141+
try:
142+
metadata.version(name)
143+
except metadata.PackageNotFoundError:
144+
return False
145+
return True
146+
147+
140148
def dependencies_in_sync() -> bool:
141149
for requirement in _megatron_requirements().values():
142150
if requirement.url is not None:
@@ -204,7 +212,8 @@ def install_megatron_dependencies(*, dry_run: bool = False) -> None:
204212
dry_run=dry_run,
205213
)
206214

207-
_run([_uv_executable(), "pip", "uninstall", "-y", "pynvml"], dry_run=dry_run)
215+
if dry_run or _package_installed("pynvml"):
216+
_run([_uv_executable(), "pip", "uninstall", "pynvml"], dry_run=dry_run)
208217

209218
remaining_requirements = [
210219
_format_requirement(requirement) for requirement in requirements.values()

0 commit comments

Comments
 (0)