Skip to content

Commit 39bf127

Browse files
authored
fix: setting ollama host in conftest (#751)
* small fix to point conftest to ollama port if running * getting port also from env
1 parent d64b86f commit 39bf127

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

test/conftest.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,17 @@ def _check_ollama_available():
3737
"""
3838
import socket
3939

40+
host_str = os.environ.get("OLLAMA_HOST", "127.0.0.1:11434")
41+
# OLLAMA_HOST may be "host:port" or just "host" (bare IP without port)
42+
if ":" in host_str:
43+
host, port = host_str.rsplit(":", 1)
44+
port = int(port)
45+
else:
46+
host, port = host_str, int(os.environ.get("OLLAMA_PORT", 11434))
4047
try:
41-
# Try to connect to Ollama's default port
4248
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
4349
sock.settimeout(1)
44-
result = sock.connect_ex(("localhost", 11434))
50+
result = sock.connect_ex((host, port))
4551
sock.close()
4652
return result == 0
4753
except Exception:

0 commit comments

Comments
 (0)