File size: 6,747 Bytes
61d29fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# βœ… HuggingFace Dataset Sharing Added!

## What's New

You can now **publish your jurisdiction discovery datasets to HuggingFace Hub** for public sharing and collaboration!

---

## 🎯 New Capabilities

### 1. **HuggingFace Publisher Module**
- File: [pipeline/huggingface_publisher.py](../pipeline/huggingface_publisher.py)
- Publishes datasets to HuggingFace Hub
- Supports all discovery data layers (Bronze/Silver/Gold)

### 2. **CLI Command**
```bash
python main.py publish-to-hf --dataset all
```

### 3. **5 Publishable Datasets**
- `census-gid` - Census Bureau GID (90,735 jurisdictions)
- `gov-domains` - CISA .gov domains (15,000+)
- `nces-schools` - NCES school districts (13,000+)
- `discovered-urls` - Discovered URLs with metadata
- `scraping-targets` - Prioritized scraping targets

---

## πŸ“¦ Files Added/Updated

### New Files
- βœ… [pipeline/huggingface_publisher.py](../pipeline/huggingface_publisher.py) - HuggingFace publisher (~400 lines)
- βœ… [docs/HUGGINGFACE_PUBLISHING.md](HUGGINGFACE_PUBLISHING.md) - Complete publishing guide

### Updated Files
- βœ… [requirements.txt](../requirements.txt) - Added `datasets>=2.16.0` and `huggingface-hub>=0.20.0`
- βœ… [config/settings.py](../config/settings.py) - Added `huggingface_token`, `hf_organization`, `hf_dataset_prefix`
- βœ… [.env.example](../.env.example) - Added HuggingFace configuration
- βœ… [main.py](../main.py) - Added `publish-to-hf` CLI command
- βœ… [README.md](../README.md) - Added HuggingFace publishing section

---

## πŸš€ Quick Start

### 1. Get HuggingFace Token

Visit: https://huggingface.co/settings/tokens

Create a **Write** token

### 2. Configure

Add to `.env`:
```bash
HUGGINGFACE_TOKEN=hf_your_write_token_here
HF_ORGANIZATION=CommunityOne
HF_DATASET_PREFIX=oral-health-policy-pulse
```

### 3. Install Dependencies

```bash
pip install datasets huggingface-hub
```

### 4. Publish

```bash
# Publish all datasets
python main.py publish-to-hf --dataset all

# Or publish individually
python main.py publish-to-hf --dataset census
python main.py publish-to-hf --dataset discovered-urls
```

---

## πŸ“Š What Gets Published

### Dataset URLs

Your datasets will be available at:
- https://huggingface.co/datasets/CommunityOne/oral-health-policy-pulse-census-gid
- https://huggingface.co/datasets/CommunityOne/oral-health-policy-pulse-gov-domains
- https://huggingface.co/datasets/CommunityOne/oral-health-policy-pulse-nces-schools
- https://huggingface.co/datasets/CommunityOne/oral-health-policy-pulse-discovered-urls
- https://huggingface.co/datasets/CommunityOne/oral-health-policy-pulse-scraping-targets

### Public Access

Anyone can load your datasets:

```python
from datasets import load_dataset

# Load census data
census = load_dataset("CommunityOne/oral-health-policy-pulse-census-gid")

# Load discovered URLs
urls = load_dataset("CommunityOne/oral-health-policy-pulse-discovered-urls")

# Access specific split
counties = census["counties"]
print(f"Total counties: {len(counties)}")
```

---

## πŸ’‘ Use Cases

### For Researchers
```python
# Analyze jurisdiction coverage
from datasets import load_dataset
import pandas as pd

census = load_dataset("CommunityOne/oral-health-policy-pulse-census-gid")
df = pd.DataFrame(census["municipalities"])

# Cities by state
df.groupby("state_name")["population"].sum().sort_values(ascending=False)
```

### For Civic Hackers
```python
# Get all county .gov domains
domains = load_dataset("CommunityOne/oral-health-policy-pulse-gov-domains")
counties = domains.filter(lambda x: x['Domain Type'] == 'County')
```

### For Data Scientists
```python
# High-confidence discovered URLs
urls = load_dataset("CommunityOne/oral-health-policy-pulse-discovered-urls")
high_conf = urls.filter(lambda x: x['confidence_score'] > 0.8)
```

---

## πŸ”„ Update Workflow

### After Each Discovery Run

```bash
# Run discovery
python main.py discover-jurisdictions

# Publish updated datasets
python main.py publish-to-hf --dataset discovered-urls
python main.py publish-to-hf --dataset scraping-targets
```

### Monthly Source Data Updates

```bash
# Re-ingest source data
python main.py discover-jurisdictions

# Publish refreshed datasets
python main.py publish-to-hf --dataset census
python main.py publish-to-hf --dataset gov-domains
python main.py publish-to-hf --dataset nces-schools
```

---

## 🎯 CLI Options

```bash
# Publish all datasets
python main.py publish-to-hf --dataset all

# Publish specific dataset
python main.py publish-to-hf --dataset census
python main.py publish-to-hf --dataset gov-domains
python main.py publish-to-hf --dataset nces-schools
python main.py publish-to-hf --dataset discovered-urls
python main.py publish-to-hf --dataset scraping-targets

# Make datasets private
python main.py publish-to-hf --dataset all --private

# Sample census data (faster for testing)
python main.py publish-to-hf --dataset census --sample
```

---

## πŸ”’ Privacy & Security

### What's Safe to Publish

βœ… **Public Data:**
- Census Bureau GID (already public)
- CISA .gov domains (already public)
- NCES school districts (already public)
- Discovered government URLs (public websites)
- Scraping targets (public information)

⚠️ **Use `--private` for:**
- Scraped meeting minutes content
- Internal analysis results
- Custom annotations

❌ **Never Publish:**
- Personal information (PII)
- API keys or tokens
- Internal comments/notes

### Token Security

- Store token in `.env` file (gitignored)
- Use write token (not fine-grained)
- Revoke token if compromised

---

## πŸ“š Documentation

Complete guide: [HUGGINGFACE_PUBLISHING.md](HUGGINGFACE_PUBLISHING.md)

Covers:
- Detailed setup instructions
- Dataset structure and schemas
- Programmatic publishing in Python
- Loading datasets in Python/R
- Collaboration features
- Troubleshooting

---

## 🌍 Community Impact

**By publishing your datasets, you enable:**
- πŸ“Š Reproducible research on government accessibility
- 🀝 Cross-project collaboration
- πŸ” Discovery of missing government websites
- πŸ“ˆ Tracking government digital infrastructure over time
- πŸŽ“ Educational use for civic tech training

**Your jurisdiction discovery data helps the entire civic tech community!** πŸ™

---

## βœ… Benefits

| Feature | Before | After |
|---------|--------|-------|
| **Data Storage** | Local only | Local + HuggingFace Hub |
| **Data Sharing** | Manual export | One-command publish |
| **Collaboration** | Email/Dropbox | Public datasets w/ versioning |
| **Discovery** | None | Searchable on HuggingFace |
| **Access** | Your team only | Anyone worldwide |
| **Versioning** | Manual | Automatic Git-style tracking |

---

**Ready to share your jurisdiction discovery data with the world!** 🌍🦷✨