55import sys
66from pathlib import Path
77
8+ import os
89from ..utils .logs_server import serve_logs
910
1011
@@ -20,53 +21,33 @@ def logs_command(args):
2021 print ("Press Ctrl+C to stop the server" )
2122 print ("-" * 50 )
2223
23- # Setup Elasticsearch based on flags
24- elasticsearch_config = None
25- try :
26- if getattr (args , "use_env_elasticsearch_config" , False ):
27- # Use environment variables for configuration
28- print ("⚙️ Using environment variables for Elasticsearch config" )
29- from eval_protocol .pytest .remote_rollout_processor import (
30- create_elasticsearch_config_from_env ,
31- )
32-
33- elasticsearch_config = create_elasticsearch_config_from_env ()
34- # Ensure index exists with correct mapping, mirroring Docker setup path
35- try :
36- from eval_protocol .log_utils .elasticsearch_index_manager import (
37- ElasticsearchIndexManager ,
38- )
39-
40- index_manager = ElasticsearchIndexManager (
41- elasticsearch_config .url ,
42- elasticsearch_config .index_name ,
43- elasticsearch_config .api_key ,
44- )
45- created = index_manager .create_logging_index_mapping ()
46- if created :
47- print (
48- f"🧭 Verified Elasticsearch index '{ elasticsearch_config .index_name } ' mapping (created or already correct)"
49- )
50- else :
51- print (
52- f"⚠️ Could not verify/create mapping for index '{ elasticsearch_config .index_name } '. Searches may behave unexpectedly."
53- )
54- except Exception as e :
55- print (f"⚠️ Failed to ensure index mapping via IndexManager: { e } " )
56- elif not getattr (args , "disable_elasticsearch_setup" , False ):
57- # Default behavior: start or connect to local Elasticsearch via Docker helper
58- from eval_protocol .pytest .elasticsearch_setup import ElasticsearchSetup
24+ # Backend selection: Fireworks first when API key present, unless overridden
25+ use_fireworks = False
26+ if getattr (args , "use_fireworks" , False ):
27+ use_fireworks = True
28+ elif getattr (args , "use_elasticsearch" , False ):
29+ use_fireworks = False
30+ else :
31+ use_fireworks = bool (os .environ .get ("FIREWORKS_API_KEY" ))
5932
60- print ("🧰 Auto-configuring local Elasticsearch (Docker)" )
61- elasticsearch_config = ElasticsearchSetup ().setup_elasticsearch ()
62- else :
63- print ("🚫 Elasticsearch setup disabled; running without Elasticsearch integration" )
64- except Exception as e :
65- print (f"❌ Failed to configure Elasticsearch: { e } " )
66- return 1
33+ # Setup backend configs
34+ elasticsearch_config = None
35+ # Prefer explicit FW_TRACING_GATEWAY_BASE_URL, then GATEWAY_URL from env (remote validation),
36+ # finally default to public tracing.fireworks.ai
37+ fireworks_base_url = (
38+ os .environ .get ("FW_TRACING_GATEWAY_BASE_URL" )
39+ or os .environ .get ("GATEWAY_URL" )
40+ or "https://tracing.fireworks.ai"
41+ )
6742
6843 try :
69- serve_logs (port = args .port , elasticsearch_config = elasticsearch_config , debug = args .debug )
44+ serve_logs (
45+ port = args .port ,
46+ elasticsearch_config = elasticsearch_config ,
47+ debug = args .debug ,
48+ backend = "fireworks" if use_fireworks else "elasticsearch" ,
49+ fireworks_base_url = fireworks_base_url if use_fireworks else None ,
50+ )
7051 return 0
7152 except KeyboardInterrupt :
7253 print ("\n 🛑 Server stopped by user" )
0 commit comments