Spaces:
Sleeping
Sleeping
Download app.py from point9/PredictiveMaintanenceAgent: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/spaces/point9/PredictiveMaintanenceAgent/resolve/main/app.py
- Command line
-
hf download hf://spaces/point9/PredictiveMaintanenceAgent/app.py
-
curl -L -o app.py https://huggingface.co/spaces/point9/PredictiveMaintanenceAgent/resolve/main/app.py
1.2 kB
| from fastapi import FastAPI, HTTPException | |
| import logging | |
| from src.config import Config | |
| from src.models import SensorData, AnalysisResponse | |
| from src.services import AnalysisService | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger(__name__) | |
| config = Config() | |
| app = FastAPI(title=config.APP_TITLE, version=config.APP_VERSION) | |
| service = AnalysisService(config) | |
| async def analyze_sensor_data(data: SensorData): | |
| try: | |
| logger.info(f"Processing request with {len(data.vdc1)} voltage and {len(data.idc1)} current data points") | |
| ml_output, agent_output = service.analyze(data.vdc1, data.idc1, data.pvt, data.api_key, data.asset_id) | |
| return AnalysisResponse(ml_output=ml_output, agent_output=agent_output) | |
| except HTTPException: | |
| raise | |
| except Exception as e: | |
| logger.error(f"Error processing request: {e}") | |
| raise HTTPException(status_code=500, detail=str(e)) | |
| async def root(): | |
| return {"message": "Solar PV Predictive Maintenance", "endpoint": "/analyze (POST)"} | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run(app, host=config.HOST, port=config.PORT) |