Spaces:
Sleeping
Sleeping
Faham
commited on
Commit
Β·
4a645e8
1
Parent(s):
cbe3f57
UPDATE: deploymet changed from railways to huggingface spcae
Browse files- .github/workflows/deploy-to-hf-space.yml +28 -0
- Dockerfile +6 -5
- README.md +11 -0
- railway.toml +0 -16
- start_services.py +5 -5
- update_mcp_urls.py +4 -4
.github/workflows/deploy-to-hf-space.yml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync to Hugging Face Space
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches: [main] # Trigger on push to the 'main' branch
|
| 6 |
+
|
| 7 |
+
# Allow manual workflow dispatch
|
| 8 |
+
workflow_dispatch:
|
| 9 |
+
|
| 10 |
+
jobs:
|
| 11 |
+
sync-to-space:
|
| 12 |
+
runs-on: ubuntu-latest
|
| 13 |
+
steps:
|
| 14 |
+
- name: Checkout repository
|
| 15 |
+
uses: actions/checkout@v3
|
| 16 |
+
with:
|
| 17 |
+
fetch-depth: 0
|
| 18 |
+
lfs: true
|
| 19 |
+
|
| 20 |
+
# - name: Check large files
|
| 21 |
+
# uses: ActionsDesk/lfs-warning@v2.0
|
| 22 |
+
# with:
|
| 23 |
+
# filesizelimit: 10485760 # 10MB limit for HF Spaces
|
| 24 |
+
|
| 25 |
+
- name: Push to hub
|
| 26 |
+
env:
|
| 27 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 28 |
+
run: git push https://${{ secrets.HF_USERNAME }}:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/${{ secrets.HF_USERNAME }}/${{secrets.SPACE_NAME }} main
|
Dockerfile
CHANGED
|
@@ -7,8 +7,9 @@ WORKDIR /app
|
|
| 7 |
# Set environment variables
|
| 8 |
ENV PYTHONUNBUFFERED=1
|
| 9 |
ENV PYTHONDONTWRITEBYTECODE=1
|
| 10 |
-
ENV STREAMLIT_SERVER_PORT=
|
| 11 |
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
|
|
|
|
| 12 |
|
| 13 |
# Install system dependencies in one layer
|
| 14 |
RUN apt-get update && apt-get install -y \
|
|
@@ -37,12 +38,12 @@ RUN useradd -m -u 1000 streamlit && \
|
|
| 37 |
chown -R streamlit:streamlit /app
|
| 38 |
USER streamlit
|
| 39 |
|
| 40 |
-
# Expose port (
|
| 41 |
-
EXPOSE
|
| 42 |
|
| 43 |
# Health check
|
| 44 |
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
| 45 |
-
CMD curl -f http://localhost
|
| 46 |
|
| 47 |
-
# Run the application
|
| 48 |
CMD ["python", "start_services.py"]
|
|
|
|
| 7 |
# Set environment variables
|
| 8 |
ENV PYTHONUNBUFFERED=1
|
| 9 |
ENV PYTHONDONTWRITEBYTECODE=1
|
| 10 |
+
ENV STREAMLIT_SERVER_PORT=7860
|
| 11 |
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
|
| 12 |
+
ENV PORT=7860
|
| 13 |
|
| 14 |
# Install system dependencies in one layer
|
| 15 |
RUN apt-get update && apt-get install -y \
|
|
|
|
| 38 |
chown -R streamlit:streamlit /app
|
| 39 |
USER streamlit
|
| 40 |
|
| 41 |
+
# Expose port (Hugging Face Spaces uses port 7860)
|
| 42 |
+
EXPOSE 7860
|
| 43 |
|
| 44 |
# Health check
|
| 45 |
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
| 46 |
+
CMD curl -f http://localhost:7860/_stcore/health || exit 1
|
| 47 |
|
| 48 |
+
# Run the application
|
| 49 |
CMD ["python", "start_services.py"]
|
README.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# QueryStockAI
|
| 2 |
|
| 3 |
A comprehensive financial analysis tool that provides stock data, news analysis, and AI-powered insights through an interactive Streamlit web interface. Features advanced machine learning-based stock price predictions using Ridge Regression with comprehensive technical indicators and an AI agent which answers user's queries based on stock dayta and news sentiment.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: QueryStockAI
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
license: mit
|
| 9 |
+
short_description: AI-powered financial analysis and trading assistant
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
# QueryStockAI
|
| 13 |
|
| 14 |
A comprehensive financial analysis tool that provides stock data, news analysis, and AI-powered insights through an interactive Streamlit web interface. Features advanced machine learning-based stock price predictions using Ridge Regression with comprehensive technical indicators and an AI agent which answers user's queries based on stock dayta and news sentiment.
|
railway.toml
DELETED
|
@@ -1,16 +0,0 @@
|
|
| 1 |
-
[build]
|
| 2 |
-
builder = "DOCKERFILE"
|
| 3 |
-
dockerfilePath = "Dockerfile"
|
| 4 |
-
|
| 5 |
-
[deploy]
|
| 6 |
-
startCommand = "python start_services.py"
|
| 7 |
-
healthcheckPath = "/_stcore/health"
|
| 8 |
-
healthcheckTimeout = 300
|
| 9 |
-
restartPolicyType = "ON_FAILURE"
|
| 10 |
-
restartPolicyMaxRetries = 10
|
| 11 |
-
|
| 12 |
-
[env]
|
| 13 |
-
GROQ_API_KEY = ""
|
| 14 |
-
MODEL = ""
|
| 15 |
-
NEWS_SERVER_URL = "http://localhost:8002/mcp"
|
| 16 |
-
STOCK_SERVER_URL = "http://localhost:8001/mcp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
start_services.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
-
Startup script to run all services on
|
| 4 |
This script launches:
|
| 5 |
-
1. Streamlit app on $PORT (main port)
|
| 6 |
2. MCP Stock Server on $PORT + 1
|
| 7 |
3. MCP News Server on $PORT + 2
|
| 8 |
"""
|
|
@@ -17,8 +17,8 @@ from pathlib import Path
|
|
| 17 |
|
| 18 |
|
| 19 |
def get_port():
|
| 20 |
-
"""Get the main port from
|
| 21 |
-
port = os.environ.get("PORT", "
|
| 22 |
return int(port)
|
| 23 |
|
| 24 |
|
|
@@ -91,7 +91,7 @@ def main():
|
|
| 91 |
print(f"β Error: {file} not found!")
|
| 92 |
sys.exit(1)
|
| 93 |
|
| 94 |
-
# Update MCP server URLs in Home.py for
|
| 95 |
try:
|
| 96 |
print("π Updating MCP server URLs...")
|
| 97 |
subprocess.run([sys.executable, "update_mcp_urls.py"], check=True)
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
+
Startup script to run all services on Hugging Face Spaces deployment.
|
| 4 |
This script launches:
|
| 5 |
+
1. Streamlit app on $PORT (main port, 7860 for HF Spaces)
|
| 6 |
2. MCP Stock Server on $PORT + 1
|
| 7 |
3. MCP News Server on $PORT + 2
|
| 8 |
"""
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
def get_port():
|
| 20 |
+
"""Get the main port from environment (Hugging Face Spaces uses 7860)."""
|
| 21 |
+
port = os.environ.get("PORT", "7860")
|
| 22 |
return int(port)
|
| 23 |
|
| 24 |
|
|
|
|
| 91 |
print(f"β Error: {file} not found!")
|
| 92 |
sys.exit(1)
|
| 93 |
|
| 94 |
+
# Update MCP server URLs in Home.py for Hugging Face Spaces deployment
|
| 95 |
try:
|
| 96 |
print("π Updating MCP server URLs...")
|
| 97 |
subprocess.run([sys.executable, "update_mcp_urls.py"], check=True)
|
update_mcp_urls.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
-
Script to update MCP server URLs for
|
| 4 |
This script modifies the MCP client configuration in Home.py to use the correct ports.
|
| 5 |
"""
|
| 6 |
|
|
@@ -9,13 +9,13 @@ import re
|
|
| 9 |
|
| 10 |
|
| 11 |
def get_port():
|
| 12 |
-
"""Get the main port from
|
| 13 |
-
port = os.environ.get("PORT", "
|
| 14 |
return int(port)
|
| 15 |
|
| 16 |
|
| 17 |
def update_home_py():
|
| 18 |
-
"""Update Home.py to use correct MCP server URLs for
|
| 19 |
port = get_port()
|
| 20 |
|
| 21 |
# Calculate the ports for MCP servers
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
+
Script to update MCP server URLs for Hugging Face Spaces deployment.
|
| 4 |
This script modifies the MCP client configuration in Home.py to use the correct ports.
|
| 5 |
"""
|
| 6 |
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
def get_port():
|
| 12 |
+
"""Get the main port from environment (Hugging Face Spaces uses 7860)."""
|
| 13 |
+
port = os.environ.get("PORT", "7860")
|
| 14 |
return int(port)
|
| 15 |
|
| 16 |
|
| 17 |
def update_home_py():
|
| 18 |
+
"""Update Home.py to use correct MCP server URLs for Hugging Face Spaces deployment."""
|
| 19 |
port = get_port()
|
| 20 |
|
| 21 |
# Calculate the ports for MCP servers
|