hanzo 0.2.5__tar.gz → 0.2.6__tar.gz
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-0.2.5 → hanzo-0.2.6}/PKG-INFO +1 -1
- {hanzo-0.2.5 → hanzo-0.2.6}/pyproject.toml +1 -1
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/__init__.py +1 -1
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/cli.py +54 -65
- hanzo-0.2.6/src/hanzo/utils/net_check.py +107 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/.gitignore +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/README.md +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/__main__.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/commands/__init__.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/commands/agent.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/commands/auth.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/commands/chat.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/commands/cluster.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/commands/config.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/commands/mcp.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/commands/miner.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/commands/network.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/commands/repl.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/commands/tools.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/interactive/__init__.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/interactive/dashboard.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/interactive/repl.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/mcp_server.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/repl.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/router/__init__.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/utils/__init__.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/utils/config.py +0 -0
- {hanzo-0.2.5 → hanzo-0.2.6}/src/hanzo/utils/output.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hanzo
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.6
|
|
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
|
|
@@ -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.6"
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
@click.group(invoke_without_command=True)
|
|
@@ -104,78 +104,69 @@ 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 properly configured")
|
|
120
|
+
if net_path:
|
|
121
|
+
console.print(f"Found hanzo/net at {net_path} but dependencies are missing")
|
|
122
|
+
missing = get_missing_dependencies(python_exe)
|
|
123
|
+
if missing:
|
|
124
|
+
console.print(f"Missing packages: {', '.join(missing)}")
|
|
125
|
+
console.print("\nTo fix, run:")
|
|
126
|
+
console.print(f" cd {net_path} && pip install -e .")
|
|
127
|
+
else:
|
|
128
|
+
console.print("\nTo install hanzo/net:")
|
|
129
|
+
console.print(" git clone https://github.com/hanzoai/net.git ~/work/hanzo/net")
|
|
130
|
+
console.print(" cd ~/work/hanzo/net && pip install -e .")
|
|
131
|
+
return
|
|
132
|
+
|
|
113
133
|
try:
|
|
114
134
|
import subprocess
|
|
115
135
|
import sys
|
|
116
136
|
import os
|
|
117
137
|
|
|
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
|
|
138
|
+
# Use the checked net_path and python_exe
|
|
139
|
+
if not net_path:
|
|
140
|
+
# net is installed as a package
|
|
141
|
+
console.print("[green]✓[/green] Using installed hanzo/net")
|
|
142
|
+
|
|
143
|
+
# Import and run net
|
|
144
|
+
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.executable)), "lib", "python3.*/site-packages"))
|
|
145
|
+
from net.main import run as net_run
|
|
146
|
+
|
|
147
|
+
# Set up environment for net
|
|
148
|
+
if models:
|
|
149
|
+
os.environ["NET_MODELS"] = ",".join(models)
|
|
150
|
+
if name:
|
|
151
|
+
os.environ["NET_NODE_NAME"] = name
|
|
152
|
+
|
|
153
|
+
console.print(f"\n[green]✓[/green] Node initialized")
|
|
154
|
+
console.print(f" Port: {port}")
|
|
155
|
+
console.print(f" Models: {', '.join(models) if models else 'auto-detect'}")
|
|
156
|
+
console.print("\n[bold green]Hanzo Net is running![/bold green]")
|
|
157
|
+
console.print("WebUI: http://localhost:52415")
|
|
158
|
+
console.print("API: http://localhost:52415/v1/chat/completions")
|
|
159
|
+
console.print("\nPress Ctrl+C to stop\n")
|
|
160
|
+
|
|
161
|
+
# Run net
|
|
162
|
+
await net_run()
|
|
176
163
|
else:
|
|
177
|
-
# Run from source directory
|
|
164
|
+
# Run from source directory using the detected python_exe
|
|
178
165
|
console.print(f"[green]✓[/green] Using hanzo/net from {net_path}")
|
|
166
|
+
if python_exe != sys.executable:
|
|
167
|
+
console.print(f"[green]✓[/green] Using hanzo/net venv")
|
|
168
|
+
else:
|
|
169
|
+
console.print("[yellow]⚠[/yellow] Using system Python")
|
|
179
170
|
|
|
180
171
|
# Change to net directory and run
|
|
181
172
|
original_cwd = os.getcwd()
|
|
@@ -188,6 +179,7 @@ async def start_compute_node(ctx, name: str = None, port: int = 52415,
|
|
|
188
179
|
env["NET_MODELS"] = ",".join(models)
|
|
189
180
|
if name:
|
|
190
181
|
env["NET_NODE_NAME"] = name
|
|
182
|
+
env["PYTHONPATH"] = os.path.join(net_path, "src") + ":" + env.get("PYTHONPATH", "")
|
|
191
183
|
|
|
192
184
|
console.print(f"\n[green]✓[/green] Starting net node")
|
|
193
185
|
console.print(f" Port: {port}")
|
|
@@ -197,12 +189,9 @@ async def start_compute_node(ctx, name: str = None, port: int = 52415,
|
|
|
197
189
|
console.print("API: http://localhost:52415/v1/chat/completions")
|
|
198
190
|
console.print("\nPress Ctrl+C to stop\n")
|
|
199
191
|
|
|
200
|
-
#
|
|
201
|
-
env["PYTHONPATH"] = os.path.join(net_path, "src") + ":" + env.get("PYTHONPATH", "")
|
|
202
|
-
|
|
203
|
-
# Run net command
|
|
192
|
+
# Run net command with detected python
|
|
204
193
|
process = subprocess.run(
|
|
205
|
-
[
|
|
194
|
+
[python_exe, "-c", "from net.main import run; run()"],
|
|
206
195
|
env=env,
|
|
207
196
|
check=False
|
|
208
197
|
)
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
# Check for hanzo/net in standard location
|
|
17
|
+
net_path = Path.home() / "work" / "hanzo" / "net"
|
|
18
|
+
if not net_path.exists():
|
|
19
|
+
net_path = Path("/Users/z/work/hanzo/net")
|
|
20
|
+
|
|
21
|
+
if not net_path.exists():
|
|
22
|
+
# Try to import as package
|
|
23
|
+
try:
|
|
24
|
+
import net
|
|
25
|
+
return True, None, sys.executable
|
|
26
|
+
except ImportError:
|
|
27
|
+
return False, None, None
|
|
28
|
+
|
|
29
|
+
# Check for venv
|
|
30
|
+
venv_python = net_path / ".venv" / "bin" / "python"
|
|
31
|
+
if venv_python.exists():
|
|
32
|
+
# Check if venv has required packages
|
|
33
|
+
result = subprocess.run(
|
|
34
|
+
[str(venv_python), "-c", "import net, scapy, mlx, transformers"],
|
|
35
|
+
capture_output=True,
|
|
36
|
+
text=True
|
|
37
|
+
)
|
|
38
|
+
if result.returncode == 0:
|
|
39
|
+
return True, str(net_path), str(venv_python)
|
|
40
|
+
else:
|
|
41
|
+
# Venv exists but missing dependencies
|
|
42
|
+
return False, str(net_path), str(venv_python)
|
|
43
|
+
|
|
44
|
+
# No venv, check system Python
|
|
45
|
+
result = subprocess.run(
|
|
46
|
+
[sys.executable, "-c", "import scapy"],
|
|
47
|
+
capture_output=True,
|
|
48
|
+
text=True
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
if result.returncode == 0:
|
|
52
|
+
return True, str(net_path), sys.executable
|
|
53
|
+
else:
|
|
54
|
+
return False, str(net_path), None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def install_net_dependencies(net_path: str, python_exe: str = None) -> bool:
|
|
58
|
+
"""Install hanzo/net dependencies.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
net_path: Path to hanzo/net directory
|
|
62
|
+
python_exe: Python executable to use (optional)
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
True if installation successful
|
|
66
|
+
"""
|
|
67
|
+
if python_exe is None:
|
|
68
|
+
python_exe = sys.executable
|
|
69
|
+
|
|
70
|
+
# Install dependencies
|
|
71
|
+
result = subprocess.run(
|
|
72
|
+
[python_exe, "-m", "pip", "install", "-e", net_path],
|
|
73
|
+
capture_output=True,
|
|
74
|
+
text=True
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
return result.returncode == 0
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def get_missing_dependencies(python_exe: str = None) -> list:
|
|
81
|
+
"""Check which dependencies are missing for hanzo/net.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
python_exe: Python executable to check (default: sys.executable)
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
List of missing package names
|
|
88
|
+
"""
|
|
89
|
+
if python_exe is None:
|
|
90
|
+
python_exe = sys.executable
|
|
91
|
+
|
|
92
|
+
required_packages = [
|
|
93
|
+
"scapy", "mlx", "mlx_lm", "transformers", "tinygrad",
|
|
94
|
+
"aiohttp", "grpcio", "pydantic", "rich", "tqdm"
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
missing = []
|
|
98
|
+
for package in required_packages:
|
|
99
|
+
result = subprocess.run(
|
|
100
|
+
[python_exe, "-c", f"import {package}"],
|
|
101
|
+
capture_output=True,
|
|
102
|
+
text=True
|
|
103
|
+
)
|
|
104
|
+
if result.returncode != 0:
|
|
105
|
+
missing.append(package)
|
|
106
|
+
|
|
107
|
+
return missing
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|