Pull requests / #2878
#2878 tools: give the bench's start branch back the `port` local it reads (#2872)
open · @ctr-137 · 0 Kommentare · Auf GitHub
Beschreibung
`./bench.sh` with no `--url` dies before it starts the model:
```
File "tools/strata_bench.py", line 990, in main
say(f"Starting {cfg_path.name} on port {port} (loading takes 1-3 minutes; the PC may be slow meanwhile) ...")
NameError: name 'port' is not defined
```
69fe4055 (#2330) replaced
```python
port = a.port or int(cfg.get("port", 8080))
base = f"http://127.0.0.1:{port}"
```
with `base = server_base(cfg.get("host"), a.port or int(cfg.get("port", 8080)))`, which removed the only
assignment of the local `port` - but the branch that starts its own server still reads it three times: the
"Port N is used by something that is not Strata" message, the "Starting ... on port N" message, and
`start_server(cfg_path, port, ...)`. `--url` skips the branch, so it never tripped there.
This keeps the #2330 behaviour - the poll still goes to `server_base(cfg host, port)`, so a `0.0.0.0` bind is
polled on loopback - and changes nothing else in the branch.
### What I changed
- `tools/strata_bench.py`: restore the local, keep `server_base()`.
- `tools/test_bench_host.py`: a `StartsItsOwnServer` class that drives `main()` into the branch with
`start_server` and `wait_ready` stubbed out. The existing tests here only called `server_base()`
directly, which is why the missing local got through.
It checks the port the server is given, the address polled (`--port` overriding the config, and loopback for
the config's `0.0.0.0`), and the foreign-service-on-the-port case.
### How I checked
On main today the new tests fail with the reported traceback at `strata_bench.py:990`; on this branch all 8
tests in `tools/test_bench_host.py` pass (`python -m unittest tools.test_bench_host`). No GPU is needed.
Fixes #2872. #2864 is the same report and should close with it.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Mehr auf der Site
Links zu Install, Modellen, Releases.