Skip to content

Commit 4cf5bee

Browse files
Merge pull request #3465 from AI-Hypercomputer:install_github_fix
PiperOrigin-RevId: 886870803
2 parents b723c4e + de7d1f5 commit 4cf5bee

3 files changed

Lines changed: 20 additions & 48 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Repository = "https://github.com/AI-Hypercomputer/maxtext.git"
4040
allow-direct-references = true
4141

4242
[tool.hatch.build.targets.wheel]
43-
packages = ["src/MaxText", "src/maxtext", "src/dependencies/github_deps", "src/dependencies"]
43+
packages = ["src/MaxText", "src/maxtext", "src/dependencies"]
4444

4545
# TODO: Add this hook back when it handles device-type parsing
4646
# [tool.hatch.build.targets.wheel.hooks.custom]

src/dependencies/github_deps/install_post_train_deps.py

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import os
2424
import subprocess
2525
import sys
26-
from pathlib import Path
2726

2827

2928
def main():
@@ -33,18 +32,14 @@ def main():
3332
This script looks for 'post_train_deps.txt' relative to its own location.
3433
It executes 'uv pip install -r <path_to_extra_deps.txt> --resolution=lowest'.
3534
"""
36-
script_dir = Path(__file__).resolve().parent
37-
3835
os.environ["VLLM_TARGET_DEVICE"] = "tpu"
3936

40-
# Adjust this path if your post_train_deps.txt is in a different location,
41-
# e.g., script_dir / "data" / "post_train_deps.txt"
42-
extra_deps_file = script_dir / "post_train_deps.txt"
37+
current_dir = os.path.dirname(os.path.abspath(__file__))
38+
repo_root = os.path.abspath(os.path.join(current_dir, "..", ".."))
39+
extra_deps_path = os.path.join(current_dir, "post_train_deps.txt")
40+
if not os.path.exists(extra_deps_path):
41+
raise FileNotFoundError(f"Dependencies file not found at {extra_deps_path}")
4342

44-
if not extra_deps_file.exists():
45-
print(f"Error: '{extra_deps_file}' not found.")
46-
print("Please ensure 'post_train_deps.txt' is in the correct location relative to the script.")
47-
sys.exit(1)
4843
# Check if 'uv' is available in the environment
4944
try:
5045
subprocess.run([sys.executable, "-m", "pip", "install", "uv"], check=True, capture_output=True)
@@ -61,7 +56,7 @@ def main():
6156
"pip",
6257
"install",
6358
"-r",
64-
str(extra_deps_file),
59+
str(extra_deps_path),
6560
"--no-deps",
6661
]
6762

@@ -71,31 +66,20 @@ def main():
7166
"uv",
7267
"pip",
7368
"install",
74-
"src/maxtext/integration/vllm", # MaxText on vllm installations
69+
f"{repo_root}/maxtext/integration/vllm", # MaxText on vllm installations
7570
"--no-deps",
7671
]
7772

78-
print(f"Installing extra dependencies from '{extra_deps_file}' using uv...")
79-
print(f"Running command: {' '.join(command)}")
80-
8173
try:
8274
# Run the command to install Github dependencies
83-
process = subprocess.run(command, check=True, capture_output=True, text=True)
75+
print(f"Installing extra dependencies: {' '.join(command)}")
76+
_ = subprocess.run(command, check=True, capture_output=True, text=True)
8477
print("Extra dependencies installed successfully!")
85-
print("--- Output from uv ---")
86-
print(process.stdout)
87-
if process.stderr:
88-
print("--- Errors/Warnings from uv (if any) ---")
89-
print(process.stderr)
9078

9179
# Run the command to install the MaxText vLLM directory
92-
vllm_install_process = subprocess.run(local_vllm_install_command, check=True, capture_output=True, text=True)
80+
print(f"Installing MaxText vLLM dependency: {' '.join(local_vllm_install_command)}")
81+
_ = subprocess.run(local_vllm_install_command, check=True, capture_output=True, text=True)
9382
print("MaxText vLLM dependency installed successfully!")
94-
print("--- Output from uv ---")
95-
print(vllm_install_process.stdout)
96-
if vllm_install_process.stderr:
97-
print("--- Errors/Warnings from uv (if any) ---")
98-
print(vllm_install_process.stderr)
9983
except subprocess.CalledProcessError as e:
10084
print("Failed to install extra dependencies.")
10185
print(f"Command '{' '.join(e.cmd)}' returned non-zero exit status {e.returncode}.")

src/dependencies/github_deps/install_pre_train_deps.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
listed in the requirements file.
2121
"""
2222

23+
import os
2324
import subprocess
2425
import sys
25-
from pathlib import Path
2626

2727

2828
def main():
@@ -32,16 +32,11 @@ def main():
3232
This script looks for 'pre_train_deps.txt' relative to its own location.
3333
It executes 'uv pip install -r <path_to_extra_deps.txt> --resolution=lowest'.
3434
"""
35-
script_dir = Path(__file__).resolve().parent
35+
current_dir = os.path.dirname(os.path.abspath(__file__))
36+
extra_deps_path = os.path.join(current_dir, "pre_train_deps.txt")
37+
if not os.path.exists(extra_deps_path):
38+
raise FileNotFoundError(f"Dependencies file not found at {extra_deps_path}")
3639

37-
# Adjust this path if your pre_train_deps.txt is in a different location,
38-
# e.g., script_dir / "data" / "pre_train_deps.txt"
39-
extra_deps_file = script_dir / "pre_train_deps.txt"
40-
41-
if not extra_deps_file.exists():
42-
print(f"Error: '{extra_deps_file}' not found.")
43-
print("Please ensure 'pre_train_deps.txt' is in the correct location relative to the script.")
44-
sys.exit(1)
4540
# Check if 'uv' is available in the environment
4641
try:
4742
subprocess.run([sys.executable, "-m", "pip", "install", "uv"], check=True, capture_output=True)
@@ -58,22 +53,15 @@ def main():
5853
"pip",
5954
"install",
6055
"-r",
61-
str(extra_deps_file),
56+
str(extra_deps_path),
6257
"--no-deps",
6358
]
6459

65-
print(f"Installing extra dependencies from '{extra_deps_file}' using uv...")
66-
print(f"Running command: {' '.join(command)}")
67-
6860
try:
6961
# Run the command
70-
process = subprocess.run(command, check=True, capture_output=True, text=True)
62+
print(f"Installing extra dependencies: {' '.join(command)}")
63+
_ = subprocess.run(command, check=True, capture_output=True, text=True)
7164
print("Extra dependencies installed successfully!")
72-
print("--- Output from uv ---")
73-
print(process.stdout)
74-
if process.stderr:
75-
print("--- Errors/Warnings from uv (if any) ---")
76-
print(process.stderr)
7765
except subprocess.CalledProcessError as e:
7866
print("Failed to install extra dependencies.")
7967
print(f"Command '{' '.join(e.cmd)}' returned non-zero exit status {e.returncode}.")

0 commit comments

Comments
 (0)