← back to Exo
check if user has read/write access to HF_HOME and warn them if not
fa8825fae243eb3681257373f9cd781a2590c533 · 2024-11-18 20:22:04 +0400 · Alex Cheema
Files touched
M exo/download/hf/hf_helpers.pyM exo/main.py
Diff
commit fa8825fae243eb3681257373f9cd781a2590c533
Author: Alex Cheema <alexcheema123@gmail.com>
Date: Mon Nov 18 20:22:04 2024 +0400
check if user has read/write access to HF_HOME and warn them if not
---
exo/download/hf/hf_helpers.py | 10 ++++++++++
exo/main.py | 13 +++++++++++++
2 files changed, 23 insertions(+)
diff --git a/exo/download/hf/hf_helpers.py b/exo/download/hf/hf_helpers.py
index e0087da0..4729e5f6 100644
--- a/exo/download/hf/hf_helpers.py
+++ b/exo/download/hf/hf_helpers.py
@@ -412,3 +412,13 @@ def get_allow_patterns(weight_map: Dict[str, str], shard: Shard) -> List[str]:
shard_specific_patterns = set("*.safetensors")
if DEBUG >= 2: print(f"get_allow_patterns {weight_map=} {shard=} {shard_specific_patterns=}")
return list(default_patterns | shard_specific_patterns)
+
+async def has_hf_home_read_access() -> bool:
+ hf_home = get_hf_home()
+ try: return await aios.access(hf_home, os.R_OK)
+ except OSError: return False
+
+async def has_hf_home_write_access() -> bool:
+ hf_home = get_hf_home()
+ try: return await aios.access(hf_home, os.W_OK)
+ except OSError: return False
diff --git a/exo/main.py b/exo/main.py
index 470fb8ea..b6701c6d 100644
--- a/exo/main.py
+++ b/exo/main.py
@@ -24,6 +24,7 @@ from exo.inference.tokenizers import resolve_tokenizer
from exo.orchestration.node import Node
from exo.models import build_base_shard, get_repo
from exo.viz.topology_viz import TopologyViz
+from exo.download.hf.hf_helpers import has_hf_home_read_access, has_hf_home_write_access, get_hf_home
# parse args
parser = argparse.ArgumentParser(description="Initialize GRPC Discovery")
@@ -207,6 +208,18 @@ async def run_model_cli(node: Node, inference_engine: InferenceEngine, model_nam
async def main():
loop = asyncio.get_running_loop()
+ # Check HuggingFace directory permissions
+ hf_home, has_read, has_write = get_hf_home(), await has_hf_home_read_access(), await has_hf_home_write_access()
+ if DEBUG >= 1: print(f"Model storage directory: {hf_home}")
+ print(f"{has_read=}, {has_write=}")
+ if not has_read or not has_write:
+ print(f"""
+ WARNING: Limited permissions for model storage directory: {hf_home}.
+ This may prevent model downloads from working correctly.
+ {"❌ No read access" if not has_read else ""}
+ {"❌ No write access" if not has_write else ""}
+ """)
+
# Use a more direct approach to handle signals
def handle_exit():
asyncio.ensure_future(shutdown(signal.SIGTERM, loop))
← fd84201b remove redundant dummy import
·
back to Exo
·
clean branch fea1c0fc →