hanzo 0.2.5__py3-none-any.whl → 0.2.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of hanzo might be problematic. Click here for more details.
- hanzo/__init__.py +1 -1
- hanzo/cli.py +48 -65
- hanzo/utils/net_check.py +109 -0
- {hanzo-0.2.5.dist-info → hanzo-0.2.7.dist-info}/METADATA +2 -1
- {hanzo-0.2.5.dist-info → hanzo-0.2.7.dist-info}/RECORD +7 -6
- {hanzo-0.2.5.dist-info → hanzo-0.2.7.dist-info}/WHEEL +0 -0
- {hanzo-0.2.5.dist-info → hanzo-0.2.7.dist-info}/entry_points.txt +0 -0
hanzo/__init__.py
CHANGED
hanzo/cli.py
CHANGED
|
@@ -12,7 +12,7 @@ from .interactive.repl import HanzoREPL
|
|
|
12
12
|
from .utils.output import console
|
|
13
13
|
|
|
14
14
|
# Version
|
|
15
|
-
__version__ = "0.2.
|
|
15
|
+
__version__ = "0.2.7"
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
@click.group(invoke_without_command=True)
|
|
@@ -104,78 +104,63 @@ async def start_compute_node(ctx, name: str = None, port: int = 52415,
|
|
|
104
104
|
network: str = "mainnet", models: tuple = None,
|
|
105
105
|
max_jobs: int = 10):
|
|
106
106
|
"""Start this instance as a compute node using hanzo/net."""
|
|
107
|
+
from .utils.net_check import check_net_installation, get_missing_dependencies
|
|
108
|
+
|
|
107
109
|
console = ctx.obj.get("console", Console())
|
|
108
110
|
|
|
109
111
|
console.print("[bold cyan]Starting Hanzo Net Compute Node[/bold cyan]")
|
|
110
112
|
console.print(f"Network: {network}")
|
|
111
113
|
console.print(f"Port: {port}")
|
|
112
114
|
|
|
115
|
+
# Check hanzo/net availability
|
|
116
|
+
is_available, net_path, python_exe = check_net_installation()
|
|
117
|
+
|
|
118
|
+
if not is_available:
|
|
119
|
+
console.print("[red]Error:[/red] hanzo-net is not installed")
|
|
120
|
+
console.print("\nTo install hanzo-net from PyPI:")
|
|
121
|
+
console.print(" pip install hanzo-net")
|
|
122
|
+
console.print("\nOr for development, clone from GitHub:")
|
|
123
|
+
console.print(" git clone https://github.com/hanzoai/net.git ~/work/hanzo/net")
|
|
124
|
+
console.print(" cd ~/work/hanzo/net && pip install -e .")
|
|
125
|
+
return
|
|
126
|
+
|
|
113
127
|
try:
|
|
114
128
|
import subprocess
|
|
115
129
|
import sys
|
|
116
130
|
import os
|
|
117
131
|
|
|
118
|
-
#
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
# Run net
|
|
145
|
-
await net_run()
|
|
146
|
-
|
|
147
|
-
except ImportError:
|
|
148
|
-
# net not installed, try to run from source
|
|
149
|
-
console.print("[yellow]hanzo/net not installed, checking for source...[/yellow]")
|
|
150
|
-
|
|
151
|
-
if os.path.exists(net_path):
|
|
152
|
-
console.print(f"[green]✓[/green] Found hanzo/net at {net_path}")
|
|
153
|
-
|
|
154
|
-
# Add net to Python path
|
|
155
|
-
sys.path.insert(0, os.path.join(net_path, "src"))
|
|
156
|
-
|
|
157
|
-
# Import and run net
|
|
158
|
-
from net.main import run as net_run
|
|
159
|
-
|
|
160
|
-
console.print(f"\n[green]✓[/green] Starting net node")
|
|
161
|
-
console.print(f" Port: {port}")
|
|
162
|
-
console.print(f" Models: {', '.join(models) if models else 'auto-detect'}")
|
|
163
|
-
console.print("\n[bold green]Hanzo Net is running![/bold green]")
|
|
164
|
-
console.print("WebUI: http://localhost:52415")
|
|
165
|
-
console.print("API: http://localhost:52415/v1/chat/completions")
|
|
166
|
-
console.print("\nPress Ctrl+C to stop\n")
|
|
167
|
-
|
|
168
|
-
# Run net
|
|
169
|
-
await net_run()
|
|
170
|
-
else:
|
|
171
|
-
console.print("[red]Error:[/red] hanzo/net not found")
|
|
172
|
-
console.print("\nInstall hanzo/net:")
|
|
173
|
-
console.print(" git clone https://github.com/hanzoai/net.git")
|
|
174
|
-
console.print(" cd net && pip install -e .")
|
|
175
|
-
return
|
|
132
|
+
# Use the checked net_path and python_exe
|
|
133
|
+
if not net_path:
|
|
134
|
+
# net is installed as a package
|
|
135
|
+
console.print("[green]✓[/green] Using installed hanzo/net")
|
|
136
|
+
|
|
137
|
+
# Import and run net
|
|
138
|
+
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.executable)), "lib", "python3.*/site-packages"))
|
|
139
|
+
from net.main import run as net_run
|
|
140
|
+
|
|
141
|
+
# Set up environment for net
|
|
142
|
+
if models:
|
|
143
|
+
os.environ["NET_MODELS"] = ",".join(models)
|
|
144
|
+
if name:
|
|
145
|
+
os.environ["NET_NODE_NAME"] = name
|
|
146
|
+
|
|
147
|
+
console.print(f"\n[green]✓[/green] Node initialized")
|
|
148
|
+
console.print(f" Port: {port}")
|
|
149
|
+
console.print(f" Models: {', '.join(models) if models else 'auto-detect'}")
|
|
150
|
+
console.print("\n[bold green]Hanzo Net is running![/bold green]")
|
|
151
|
+
console.print("WebUI: http://localhost:52415")
|
|
152
|
+
console.print("API: http://localhost:52415/v1/chat/completions")
|
|
153
|
+
console.print("\nPress Ctrl+C to stop\n")
|
|
154
|
+
|
|
155
|
+
# Run net
|
|
156
|
+
await net_run()
|
|
176
157
|
else:
|
|
177
|
-
# Run from source directory
|
|
158
|
+
# Run from source directory using the detected python_exe
|
|
178
159
|
console.print(f"[green]✓[/green] Using hanzo/net from {net_path}")
|
|
160
|
+
if python_exe != sys.executable:
|
|
161
|
+
console.print(f"[green]✓[/green] Using hanzo/net venv")
|
|
162
|
+
else:
|
|
163
|
+
console.print("[yellow]⚠[/yellow] Using system Python")
|
|
179
164
|
|
|
180
165
|
# Change to net directory and run
|
|
181
166
|
original_cwd = os.getcwd()
|
|
@@ -188,6 +173,7 @@ async def start_compute_node(ctx, name: str = None, port: int = 52415,
|
|
|
188
173
|
env["NET_MODELS"] = ",".join(models)
|
|
189
174
|
if name:
|
|
190
175
|
env["NET_NODE_NAME"] = name
|
|
176
|
+
env["PYTHONPATH"] = os.path.join(net_path, "src") + ":" + env.get("PYTHONPATH", "")
|
|
191
177
|
|
|
192
178
|
console.print(f"\n[green]✓[/green] Starting net node")
|
|
193
179
|
console.print(f" Port: {port}")
|
|
@@ -197,12 +183,9 @@ async def start_compute_node(ctx, name: str = None, port: int = 52415,
|
|
|
197
183
|
console.print("API: http://localhost:52415/v1/chat/completions")
|
|
198
184
|
console.print("\nPress Ctrl+C to stop\n")
|
|
199
185
|
|
|
200
|
-
#
|
|
201
|
-
env["PYTHONPATH"] = os.path.join(net_path, "src") + ":" + env.get("PYTHONPATH", "")
|
|
202
|
-
|
|
203
|
-
# Run net command
|
|
186
|
+
# Run net command with detected python
|
|
204
187
|
process = subprocess.run(
|
|
205
|
-
[
|
|
188
|
+
[python_exe, "-c", "from net.main import run; run()"],
|
|
206
189
|
env=env,
|
|
207
190
|
check=False
|
|
208
191
|
)
|
hanzo/utils/net_check.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""Utilities for checking hanzo/net availability and dependencies."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
from typing import Optional, Tuple
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def check_net_installation() -> Tuple[bool, Optional[str], Optional[str]]:
|
|
11
|
+
"""Check if hanzo/net is available and properly configured.
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
Tuple of (is_available, net_path, python_exe)
|
|
15
|
+
"""
|
|
16
|
+
# First try to import as PyPI package (hanzo-net)
|
|
17
|
+
try:
|
|
18
|
+
import net
|
|
19
|
+
return True, None, sys.executable
|
|
20
|
+
except ImportError:
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
# For development: check for hanzo/net in standard location
|
|
24
|
+
net_path = Path.home() / "work" / "hanzo" / "net"
|
|
25
|
+
if not net_path.exists():
|
|
26
|
+
net_path = Path("/Users/z/work/hanzo/net")
|
|
27
|
+
|
|
28
|
+
if not net_path.exists():
|
|
29
|
+
return False, None, None
|
|
30
|
+
|
|
31
|
+
# Check for venv
|
|
32
|
+
venv_python = net_path / ".venv" / "bin" / "python"
|
|
33
|
+
if venv_python.exists():
|
|
34
|
+
# Check if venv has required packages
|
|
35
|
+
result = subprocess.run(
|
|
36
|
+
[str(venv_python), "-c", "import net, scapy, mlx, transformers"],
|
|
37
|
+
capture_output=True,
|
|
38
|
+
text=True
|
|
39
|
+
)
|
|
40
|
+
if result.returncode == 0:
|
|
41
|
+
return True, str(net_path), str(venv_python)
|
|
42
|
+
else:
|
|
43
|
+
# Venv exists but missing dependencies
|
|
44
|
+
return False, str(net_path), str(venv_python)
|
|
45
|
+
|
|
46
|
+
# No venv, check system Python
|
|
47
|
+
result = subprocess.run(
|
|
48
|
+
[sys.executable, "-c", "import scapy"],
|
|
49
|
+
capture_output=True,
|
|
50
|
+
text=True
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
if result.returncode == 0:
|
|
54
|
+
return True, str(net_path), sys.executable
|
|
55
|
+
else:
|
|
56
|
+
return False, str(net_path), None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def install_net_dependencies(net_path: str, python_exe: str = None) -> bool:
|
|
60
|
+
"""Install hanzo/net dependencies.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
net_path: Path to hanzo/net directory
|
|
64
|
+
python_exe: Python executable to use (optional)
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
True if installation successful
|
|
68
|
+
"""
|
|
69
|
+
if python_exe is None:
|
|
70
|
+
python_exe = sys.executable
|
|
71
|
+
|
|
72
|
+
# Install dependencies
|
|
73
|
+
result = subprocess.run(
|
|
74
|
+
[python_exe, "-m", "pip", "install", "-e", net_path],
|
|
75
|
+
capture_output=True,
|
|
76
|
+
text=True
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
return result.returncode == 0
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def get_missing_dependencies(python_exe: str = None) -> list:
|
|
83
|
+
"""Check which dependencies are missing for hanzo/net.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
python_exe: Python executable to check (default: sys.executable)
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
List of missing package names
|
|
90
|
+
"""
|
|
91
|
+
if python_exe is None:
|
|
92
|
+
python_exe = sys.executable
|
|
93
|
+
|
|
94
|
+
required_packages = [
|
|
95
|
+
"scapy", "mlx", "mlx_lm", "transformers", "tinygrad",
|
|
96
|
+
"aiohttp", "grpcio", "pydantic", "rich", "tqdm"
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
missing = []
|
|
100
|
+
for package in required_packages:
|
|
101
|
+
result = subprocess.run(
|
|
102
|
+
[python_exe, "-c", f"import {package}"],
|
|
103
|
+
capture_output=True,
|
|
104
|
+
text=True
|
|
105
|
+
)
|
|
106
|
+
if result.returncode != 0:
|
|
107
|
+
missing.append(package)
|
|
108
|
+
|
|
109
|
+
return missing
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hanzo
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: Hanzo AI - Complete AI Infrastructure Platform with CLI, Router, MCP, and Agent Runtime
|
|
5
5
|
Project-URL: Homepage, https://hanzo.ai
|
|
6
6
|
Project-URL: Repository, https://github.com/hanzoai/python-sdk
|
|
@@ -23,6 +23,7 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
|
23
23
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
24
|
Requires-Python: >=3.8
|
|
25
25
|
Requires-Dist: click>=8.1.0
|
|
26
|
+
Requires-Dist: hanzo-net>=0.1.0
|
|
26
27
|
Requires-Dist: httpx>=0.23.0
|
|
27
28
|
Requires-Dist: prompt-toolkit>=3.0.0
|
|
28
29
|
Requires-Dist: pydantic>=2.0.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
hanzo/__init__.py,sha256=
|
|
1
|
+
hanzo/__init__.py,sha256=QXW5M-0xXAPkNapOByrAATqn9tjNUhl5BekPICT4zLY,168
|
|
2
2
|
hanzo/__main__.py,sha256=qRjwG8-7MHPOy3czoyDP9VK1GhEaJJsVeZcz2AG9NV0,104
|
|
3
|
-
hanzo/cli.py,sha256=
|
|
3
|
+
hanzo/cli.py,sha256=OKi2C6pxqlCYSpXd7XwtFU3wskipIfZPODAeO4Br_-Q,8900
|
|
4
4
|
hanzo/mcp_server.py,sha256=FBqcXhaJgV8_9O83H3fUy_pv4cV1707XCYm7FXaJeWY,422
|
|
5
5
|
hanzo/repl.py,sha256=sC7EXbIBn7Oxnmzqey6neAg5-116gfpmrF0YFDYrhAQ,1014
|
|
6
6
|
hanzo/commands/__init__.py,sha256=vXfIgioA6eakIYEN5ff5k_5BqOYQCJggD_MW40gb56w,138
|
|
@@ -20,8 +20,9 @@ hanzo/interactive/repl.py,sha256=-SwCSxwIHLiZBJOEShvqa4tgg2c7YYMf00zYRHazyIY,578
|
|
|
20
20
|
hanzo/router/__init__.py,sha256=7Ulou75xQF8KKVzxOd4xXrmn3_Ti52M0NsAf6jXgGhk,913
|
|
21
21
|
hanzo/utils/__init__.py,sha256=zmCH4YxefrpWmR-netV99UeECqrXjkKbi3ZjbcD79dw,68
|
|
22
22
|
hanzo/utils/config.py,sha256=RU27eiSxGWAT9fI5-CjRdEJZEeT_xjMxjlMVeKC1gMg,4830
|
|
23
|
+
hanzo/utils/net_check.py,sha256=WDElDu19MYN3qs7y_DbIpcnVsxiMCgg2CTI-48A15vE,3066
|
|
23
24
|
hanzo/utils/output.py,sha256=lROF8RDOkck7ySt1kiTlVlHZqx1E0B-PqcJc78ZHYOs,2694
|
|
24
|
-
hanzo-0.2.
|
|
25
|
-
hanzo-0.2.
|
|
26
|
-
hanzo-0.2.
|
|
27
|
-
hanzo-0.2.
|
|
25
|
+
hanzo-0.2.7.dist-info/METADATA,sha256=ePZsIg6wTtju_Y9PVZWEvQNOpmd6aACB20rU9pFivHM,4347
|
|
26
|
+
hanzo-0.2.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
27
|
+
hanzo-0.2.7.dist-info/entry_points.txt,sha256=pQLPMdqOXU_2BfTcMDhkqTCDNk_H6ApvYuSaWcuQOOw,171
|
|
28
|
+
hanzo-0.2.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|