Spaces:
Sleeping
Sleeping
File size: 3,875 Bytes
99cf7cf 221f6de f0435c4 221f6de f0435c4 221f6de f0435c4 221f6de f0435c4 221f6de f0435c4 221f6de f0435c4 221f6de | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | ---
title: DailyRA
emoji: π
colorFrom: gray
colorTo: yellow
sdk: docker
pinned: false
---
# ζ₯欑RA (Daily Risk Assessment)
A Streamlit application for daily risk assessment in construction and industrial settings, with automatic safety rule generation.
## π Features
- **Daily Risk Assessment Form**: Input work details, hazards, and mitigation measures
- **Automatic Rule Generation**: AI-powered safety rule extraction based on object relationships
- **Database Storage**: Persistent storage using Supabase PostgreSQL
- **Modern Dependency Management**: Uses `uv` for fast package management
## π¦ Technology Stack
- **Frontend**: Streamlit
- **Database**: Supabase (PostgreSQL)
- **NLP**: SudachiPy (Japanese tokenization)
- **ML**: Sentence Transformers
- **Package Manager**: uv
## π Quick Start
See [DEPLOYMENT.md](./DEPLOYMENT.md) for detailed setup instructions.
### Local Development
```bash
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install package in editable mode (installs dependencies + package)
uv pip install -e .
# Set up environment variables
cp env.example .env
# Edit .env with your Supabase credentials
# Run the app
streamlit run src/daily_ra/app.py
```
### Docker
```bash
docker build -t daily-ra .
docker run -p 7860:7860 --env-file .env daily-ra
```
## π¦ Using UV
### Common Commands
```bash
# Install dependencies from pyproject.toml
uv pip install -e .
# Add a new package
uv add requests
# Add with version constraint
uv add "pandas>=2.0.0"
# Remove a package
uv remove package-name
# Update all packages
uv pip install --upgrade -e .
```
# Deployment Guide
## π¦ Setup Instructions
### 1οΈβ£ **Set Up Supabase Database**
1. Go to your Supabase project dashboard
2. Open the SQL Editor
3. Copy and paste the contents of `schema.sql`
4. Run the SQL to create the tables
### 2οΈβ£ **Local Development**
1. Install uv (if not already installed):
```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```
2. Create a `.env` file in the project root (use `env.example` as template):
```bash
cp env.example .env
```
3. Fill in your Supabase connection details in `.env`:
```
HOST=aws-1-ap-northeast-1.pooler.supabase.com
PORT=5432
DATABASE=postgres
USERNAME=postgres.vvkubjwatpdqnkmgmntf
PASSWORD=your-actual-password
POOL_NAME=vvkubjwatpdqnkmgmntf
```
4. Install package in editable mode:
```bash
uv pip install -e .
```
5. Run the app locally:
```bash
streamlit run src/daily_ra/app.py
```
### 3οΈβ£ **Deploy to Hugging Face Spaces**
1. Push your code to the Hugging Face Space repository
2. Go to your Space Settings β **Repository secrets**
3. Add the following secrets (get these from your Supabase project settings):
- `HOST` = `aws-1-ap-northeast-1.pooler.supabase.com` (your pooler host)
- `PORT` = `5432`
- `DATABASE` = `postgres`
- `USERNAME` = `postgres.vvkubjwatpdqnkmgmntf` (format: postgres.YOUR_PROJECT_REF)
- `PASSWORD` = `your-actual-password`
4. The app will automatically rebuild and deploy
---
## π Troubleshooting
### Connection Issues
- Verify your Supabase password is correct
- Check that your IP is not blocked in Supabase settings
- Ensure connection pooling is enabled in Supabase
### Table Errors
- Make sure you've run the `schema.sql` in Supabase SQL Editor
- Verify the table names match exactly
### Environment Variables
- On Hugging Face Spaces, use **Repository secrets** (not .env file)
- Variable names must match exactly: `HOST`, `PORT`, `DATABASE`, `USERNAME`, `PASSWORD`, `POOL_NAME`
---
## π Database Tables
### `daily_ra` Table
Stores daily risk assessment entries with work details, hazards, and mitigation measures.
### `rule_base` Table
Stores automatically generated safety rules based on object relationships and potential risks.
|