Emmanuel Frimpong Asante commited on
Commit
ff5b28f
·
1 Parent(s): 57b48f3

update space

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. .idea/workspace.xml +12 -3
  3. app.py +27 -22
.gitignore CHANGED
@@ -1 +1,2 @@
1
  .venv
 
 
1
  .venv
2
+ .idea
.idea/workspace.xml CHANGED
@@ -5,8 +5,9 @@
5
  </component>
6
  <component name="ChangeListManager">
7
  <list default="true" id="27c9ae1a-a6fa-4472-8bcd-a7087620894b" name="Changes" comment="update space">
 
8
  <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/config.ini" beforeDir="false" afterPath="$PROJECT_DIR$/config.ini" afterDir="false" />
10
  </list>
11
  <option name="SHOW_DIALOG" value="false" />
12
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -117,7 +118,7 @@
117
  <updated>1730314341192</updated>
118
  <workItem from="1730314342338" duration="21228000" />
119
  <workItem from="1730338434025" duration="11075000" />
120
- <workItem from="1730305361670" duration="495000" />
121
  </task>
122
  <task id="LOCAL-00001" summary="Add application file">
123
  <option name="closed" value="true" />
@@ -495,7 +496,15 @@
495
  <option name="project" value="LOCAL" />
496
  <updated>1730364957676</updated>
497
  </task>
498
- <option name="localTasksCounter" value="48" />
 
 
 
 
 
 
 
 
499
  <servers />
500
  </component>
501
  <component name="TypeScriptGeneratedFilesManager">
 
5
  </component>
6
  <component name="ChangeListManager">
7
  <list default="true" id="27c9ae1a-a6fa-4472-8bcd-a7087620894b" name="Changes" comment="update space">
8
+ <change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
9
  <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
10
+ <change beforePath="$PROJECT_DIR$/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
11
  </list>
12
  <option name="SHOW_DIALOG" value="false" />
13
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
 
118
  <updated>1730314341192</updated>
119
  <workItem from="1730314342338" duration="21228000" />
120
  <workItem from="1730338434025" duration="11075000" />
121
+ <workItem from="1730305361670" duration="2073000" />
122
  </task>
123
  <task id="LOCAL-00001" summary="Add application file">
124
  <option name="closed" value="true" />
 
496
  <option name="project" value="LOCAL" />
497
  <updated>1730364957676</updated>
498
  </task>
499
+ <task id="LOCAL-00048" summary="update space">
500
+ <option name="closed" value="true" />
501
+ <created>1730373088622</created>
502
+ <option name="number" value="00048" />
503
+ <option name="presentableId" value="LOCAL-00048" />
504
+ <option name="project" value="LOCAL" />
505
+ <updated>1730373088622</updated>
506
+ </task>
507
+ <option name="localTasksCounter" value="49" />
508
  <servers />
509
  </component>
510
  <component name="TypeScriptGeneratedFilesManager">
app.py CHANGED
@@ -9,10 +9,9 @@ from fastapi.responses import HTMLResponse
9
  from fastapi.staticfiles import StaticFiles
10
  import tensorflow as tf
11
  from routes.authentication import auth_router
12
- from routes.disease_detection import disease_router
13
- from routes.health_dashboard import dashboard_router
14
- from services.disease_detection_service import load_disease_model, load_llama_model
15
- from services.health_monitoring_service import evaluate_health_data, get_health_alerts, send_alerts
16
  from huggingface_hub import login
17
 
18
  # Setup logging
@@ -40,12 +39,18 @@ else:
40
  logger.error("Static directory not found.")
41
  raise HTTPException(status_code=500, detail="Static directory not found.")
42
 
 
 
 
 
 
 
43
 
44
 
45
  # Include routers for authentication, disease detection, and health dashboard
46
  app.include_router(auth_router, prefix="/auth", tags=["Authentication"])
47
- app.include_router(disease_router, prefix="/disease", tags=["Disease Detection"])
48
- app.include_router(dashboard_router, prefix="/dashboard", tags=["Dashboard"])
49
 
50
  @app.get("/", response_class=HTMLResponse)
51
  async def landing_page(request: Request):
@@ -60,19 +65,19 @@ health_metrics = {
60
  "reduced_feed_intake_percentage": 12
61
  }
62
 
63
- def monitor_health():
64
- """Evaluate health data and log notifications if thresholds are crossed."""
65
- while True:
66
- # Evaluate health metrics and send alerts
67
- notifications = evaluate_health_data(health_metrics)
68
- if notifications["notifications"]:
69
- logger.info(f"Health Notifications: {notifications['notifications']}")
70
- # Optionally, send alerts to the farmer
71
- send_alerts(notifications["notifications"], os.getenv("FARMER_EMAIL"))
72
- time.sleep(3600) # Run every hour
73
-
74
- @app.on_event("startup")
75
- async def startup_event():
76
- """Initialize background health monitoring on startup."""
77
- logger.info("Starting background health monitoring.")
78
- BackgroundTasks().add_task(monitor_health)
 
9
  from fastapi.staticfiles import StaticFiles
10
  import tensorflow as tf
11
  from routes.authentication import auth_router
12
+ # from routes.disease_detection import disease_router
13
+ # from routes.health_dashboard import dashboard_router
14
+ # from services.health_monitoring_service import evaluate_health_data, get_health_alerts, send_alerts
 
15
  from huggingface_hub import login
16
 
17
  # Setup logging
 
39
  logger.error("Static directory not found.")
40
  raise HTTPException(status_code=500, detail="Static directory not found.")
41
 
42
+ # Load Hugging Face Token
43
+ HF_TOKEN = os.environ.get('HF_Token')
44
+ if HF_TOKEN:
45
+ login(token=HF_TOKEN, add_to_git_credential=True)
46
+ else:
47
+ logger.warning("Hugging Face token not found in environment variables.")
48
 
49
 
50
  # Include routers for authentication, disease detection, and health dashboard
51
  app.include_router(auth_router, prefix="/auth", tags=["Authentication"])
52
+ # app.include_router(disease_router, prefix="/disease", tags=["Disease Detection"])
53
+ # app.include_router(dashboard_router, prefix="/dashboard", tags=["Dashboard"])
54
 
55
  @app.get("/", response_class=HTMLResponse)
56
  async def landing_page(request: Request):
 
65
  "reduced_feed_intake_percentage": 12
66
  }
67
 
68
+ # def monitor_health():
69
+ # """Evaluate health data and log notifications if thresholds are crossed."""
70
+ # while True:
71
+ # # Evaluate health metrics and send alerts
72
+ # notifications = evaluate_health_data(health_metrics)
73
+ # if notifications["notifications"]:
74
+ # logger.info(f"Health Notifications: {notifications['notifications']}")
75
+ # # Optionally, send alerts to the farmer
76
+ # send_alerts(notifications["notifications"], os.getenv("FARMER_EMAIL"))
77
+ # time.sleep(3600) # Run every hour
78
+ #
79
+ # @app.on_event("startup")
80
+ # async def startup_event():
81
+ # """Initialize background health monitoring on startup."""
82
+ # logger.info("Starting background health monitoring.")
83
+ # BackgroundTasks().add_task(monitor_health)