-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathlogs.py
More file actions
54 lines (45 loc) Β· 1.97 KB
/
logs.py
File metadata and controls
54 lines (45 loc) Β· 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
CLI command for serving logs with file watching and real-time updates.
"""
import sys
from pathlib import Path
from ..utils.logs_server import serve_logs
def logs_command(args):
"""Serve logs with file watching and real-time updates"""
port = args.port
print("π Starting Eval Protocol Logs Server")
print(f"π URL: http://localhost:{port}")
print(f"π WebSocket: ws://localhost:{port}/ws")
print(f"π Watching paths: {['current directory']}")
print(f"π Debug mode: {args.debug}")
print("Press Ctrl+C to stop the server")
print("-" * 50)
# Setup Elasticsearch based on flags
elasticsearch_config = None
try:
if getattr(args, "use_env_elasticsearch_config", False):
# Use environment variables for configuration
print("βοΈ Using environment variables for Elasticsearch config")
from eval_protocol.pytest.remote_rollout_processor import (
create_elasticsearch_config_from_env,
)
elasticsearch_config = create_elasticsearch_config_from_env()
elif not getattr(args, "disable_elasticsearch_setup", False):
# Default behavior: start or connect to local Elasticsearch via Docker helper
from eval_protocol.pytest.elasticsearch_setup import ElasticsearchSetup
print("π§° Auto-configuring local Elasticsearch (Docker)")
elasticsearch_config = ElasticsearchSetup().setup_elasticsearch()
else:
print("π« Elasticsearch setup disabled; running without Elasticsearch integration")
except Exception as e:
print(f"β Failed to configure Elasticsearch: {e}")
return 1
try:
serve_logs(port=args.port, elasticsearch_config=elasticsearch_config, debug=args.debug)
return 0
except KeyboardInterrupt:
print("\nπ Server stopped by user")
return 0
except Exception as e:
print(f"β Error starting server: {e}")
return 1