surahj commited on
Commit
46bfbfe
·
1 Parent(s): 64f3974

Fix deployment

Browse files
Files changed (6) hide show
  1. Procfile +1 -0
  2. deploy.py +16 -0
  3. render.yaml +10 -0
  4. requirements.txt +2 -1
  5. runtime.txt +1 -0
  6. src/app.py +11 -1
Procfile ADDED
@@ -0,0 +1 @@
 
 
1
+ web: python src/app.py
deploy.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Deployment script for Render deployment
4
+ """
5
+
6
+ import os
7
+ import sys
8
+ from src.app import main
9
+
10
+ if __name__ == "__main__":
11
+ # Set environment variables for production
12
+ os.environ.setdefault("GRADIO_SERVER_NAME", "0.0.0.0")
13
+ os.environ.setdefault("GRADIO_SERVER_PORT", os.environ.get("PORT", "7860"))
14
+
15
+ # Launch the application
16
+ main()
render.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ services:
2
+ - type: web
3
+ name: electricity-consumption-predictor
4
+ env: python
5
+ plan: free
6
+ buildCommand: pip install -r requirements.txt
7
+ startCommand: python src/app.py
8
+ envVars:
9
+ - key: PYTHON_VERSION
10
+ value: 3.10.12
requirements.txt CHANGED
@@ -4,4 +4,5 @@ numpy==1.24.3
4
  gradio==3.40.1
5
  pytest==7.4.0
6
  pytest-cov==4.1.0
7
- joblib==1.3.2
 
 
4
  gradio==3.40.1
5
  pytest==7.4.0
6
  pytest-cov==4.1.0
7
+ joblib==1.3.2
8
+ gunicorn==21.2.0
runtime.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ python-3.10.12
src/app.py CHANGED
@@ -366,7 +366,17 @@ def main():
366
  """Main function to launch the application."""
367
  app = ElectricityPredictorApp()
368
  interface = app.create_interface()
369
- interface.launch(share=False, server_name="0.0.0.0", server_port=7860)
 
 
 
 
 
 
 
 
 
 
370
 
371
 
372
  if __name__ == "__main__":
 
366
  """Main function to launch the application."""
367
  app = ElectricityPredictorApp()
368
  interface = app.create_interface()
369
+
370
+ # Get port from environment variable (for Render deployment)
371
+ port = int(os.environ.get("PORT", 7860))
372
+
373
+ # Launch the interface
374
+ interface.launch(
375
+ server_name="0.0.0.0", # Allow external connections
376
+ server_port=port, # Use environment port
377
+ share=False, # Don't create public link
378
+ debug=False, # Disable debug mode for production
379
+ )
380
 
381
 
382
  if __name__ == "__main__":