CoolFace
Apppublic

enotkrutoy/CodeReviewAgent

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
modal_deploy.py64 linesDownload Raw Back to root
1# modal_deploy.py2from modal import Image, Stub, asgi_app3import sys4 5# Create a Modal image with the required dependencies6image = Image.debian_slim().pip_install_from_requirements("requirements.txt")7 8# Create a Modal Stub9stub = Stub("code-review-agent")10 11@stub.function(image=image, timeout=600)12@asgi_app()13def app():14    """15    Deploy the Code Review Agent as an ASGI app on Modal.16    17    This function sets up the Gradio application and returns it as an ASGI app18    that Modal can serve. The app will be accessible via a URL provided by Modal19    after deployment.20    21    Returns:22        ASGI application: The Gradio app as an ASGI application23    """24    import os25    import sys26    import logging27    from dotenv import load_dotenv28 29    # Add the project root to the Python path30    sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))31 32    # Import application modules33    from src.ui.gradio_app import create_gradio_app34    from src.core.agent_manager import AgentManager35 36    # Configure logging37    logging.basicConfig(38        level=logging.INFO,39        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'40    )41 42    # Load environment variables43    load_dotenv()44    45    # Create logs directory if it doesn't exist46    logs_dir = os.path.join(os.path.dirname(__file__), 'logs')47    os.makedirs(logs_dir, exist_ok=True)48 49    # Initialize the agent manager50    agent_manager = AgentManager()51 52    # Create the Gradio app53    gradio_app = create_gradio_app(agent_manager)54    55    # Return the Gradio app as an ASGI app56    return gradio_app.app57 58 59if __name__ == "__main__":60    # For local testing61    stub.serve()62    63    # For deployment64    # Run: modal deploy modal_deploy.py