Spaces:
Sleeping
Sleeping
File size: 2,084 Bytes
9e0d3ce 9b74099 9e0d3ce 9b74099 9e0d3ce 9b74099 9e0d3ce |
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
"""
Hugging Face Spaces entry point for Financial Research Agent
"""
import os
import sys
import logging
# Configure logging for Hugging Face
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)
logger = logging.getLogger(__name__)
# Debug: Print current directory and Python path
logger.info(f"Current working directory: {os.getcwd()}")
logger.info(f"__file__ location: {os.path.abspath(__file__)}")
logger.info(f"Python path: {sys.path}")
# Setup Python path
app_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, app_dir)
logger.info(f"Added to Python path: {app_dir}")
# Debug: Check if src directory exists
src_dir = os.path.join(app_dir, 'src')
logger.info(f"src directory exists: {os.path.exists(src_dir)}")
if os.path.exists(src_dir):
logger.info(f"src contents: {os.listdir(src_dir)}")
models_dir = os.path.join(src_dir, 'models')
logger.info(f"src/models exists: {os.path.exists(models_dir)}")
if os.path.exists(models_dir):
logger.info(f"src/models contents: {os.listdir(models_dir)}")
# Import after path setup
logger.info("Attempting to import AnalysisServer...")
from src.api.server import AnalysisServer
logger.info("Successfully imported AnalysisServer!")
def main():
"""Launch the Gradio interface for Hugging Face Spaces"""
try:
logger.info("Starting Financial Research Agent on Hugging Face Spaces...")
# Create and launch server
server = AnalysisServer()
# Launch with Hugging Face Spaces settings
interface = server.create_interface()
# Hugging Face Spaces specific configuration
interface.launch(
server_name="0.0.0.0",
server_port=7860, # HF Spaces default port
share=False, # No need for share on HF Spaces
show_error=True,
auth=None, # Can add auth later if needed
)
except Exception as e:
logger.error(f"Failed to start application: {str(e)}")
raise
if __name__ == "__main__":
main()
|