File size: 2,115 Bytes
405ca38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Browser Automation WebUI - Deployment Guide

## Deploying to Hugging Face Spaces

### Prerequisites
- A Hugging Face account
- Your code pushed to a Git repository

### Steps to Deploy

1. **Create a new Space on Hugging Face**
   - Go to https://huggingface.co/spaces
   - Click "Create new Space"
   - Choose "Gradio" as the SDK
   - Select your repository or create a new one

2. **File Structure for Deployment**
   ```
   web-ui/
   β”œβ”€β”€ app.py              # Main entry point (created)
   β”œβ”€β”€ requirements.txt    # Dependencies
   β”œβ”€β”€ src/               # Source code
   └── README.md          # Documentation
   ```

3. **Key Files for Deployment**
   - `app.py`: Main entry point that Gradio will use
   - `requirements.txt`: All necessary dependencies
   - `src/`: Your source code directory

### Troubleshooting the "Failed to canonicalize script path" Error

This error typically occurs when:
- Gradio can't find the main entry point
- Import paths are not properly configured
- File structure doesn't match deployment expectations

**Solution**: The `app.py` file has been created to serve as the proper entry point for Gradio deployment.

### Environment Variables

If your app requires environment variables, you can set them in the Hugging Face Space settings:
- Go to your Space settings
- Navigate to "Repository secrets"
- Add any required environment variables

### Local Testing

To test the deployment locally before pushing:

```bash
cd web-ui
python app.py
```

This should start the Gradio interface without the canonicalization error.

### Common Issues and Solutions

1. **Import Errors**: Make sure all imports use relative paths from the project root
2. **Missing Dependencies**: Ensure all packages are listed in `requirements.txt`
3. **Path Issues**: The `app.py` file includes proper path configuration

### Deployment Checklist

- [ ] `app.py` exists and is properly configured
- [ ] All dependencies are in `requirements.txt`
- [ ] All import paths are correct
- [ ] Environment variables are configured (if needed)
- [ ] Local testing works without errors