Spaces:
Sleeping
Sleeping
Jesse Liu commited on
Commit ·
a25d70c
1
Parent(s): 511ed70
Sync latest app + data (clinician groups, jsonl)
Browse files- hf_storage.py +58 -0
hf_storage.py
CHANGED
|
@@ -274,6 +274,64 @@ class HuggingFaceStorage:
|
|
| 274 |
)
|
| 275 |
print(f"[HF CSV] CSV upload successful ({len(csv_data)} rows total)")
|
| 276 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
# Clean up
|
| 278 |
os.unlink(temp_path)
|
| 279 |
|
|
|
|
| 274 |
)
|
| 275 |
print(f"[HF CSV] CSV upload successful ({len(csv_data)} rows total)")
|
| 276 |
|
| 277 |
+
# Also try to upload a README.md if it doesn't exist (for dataset card)
|
| 278 |
+
try:
|
| 279 |
+
try:
|
| 280 |
+
self.api.hf_hub_download(
|
| 281 |
+
repo_id=self.repo_id,
|
| 282 |
+
filename="README.md",
|
| 283 |
+
repo_type=self.repo_type,
|
| 284 |
+
cache_dir=tempfile.gettempdir()
|
| 285 |
+
)
|
| 286 |
+
print(f"[HF CSV] README.md already exists")
|
| 287 |
+
except Exception:
|
| 288 |
+
# README doesn't exist, create one
|
| 289 |
+
readme_content = """---
|
| 290 |
+
license: apache-2.0
|
| 291 |
+
---
|
| 292 |
+
|
| 293 |
+
# Patient Evaluations Dataset
|
| 294 |
+
|
| 295 |
+
This dataset contains clinician evaluations of AI-generated patient summaries.
|
| 296 |
+
|
| 297 |
+
## Dataset Structure
|
| 298 |
+
|
| 299 |
+
The dataset contains a CSV file (`patient_evaluations_master.csv`) with evaluation data.
|
| 300 |
+
|
| 301 |
+
## Columns
|
| 302 |
+
|
| 303 |
+
- `timestamp`: Evaluation timestamp
|
| 304 |
+
- `patient_id`: Patient identifier
|
| 305 |
+
- `expert_name`: Clinician identifier
|
| 306 |
+
- `overall_rating`: Overall quality rating (1-10)
|
| 307 |
+
- `clinical_accuracy`: Clinical accuracy rating (1-10)
|
| 308 |
+
- `completeness_coverage`: Completeness/coverage rating (1-10)
|
| 309 |
+
- `clinical_relevance`: Clinical relevance rating (1-10)
|
| 310 |
+
- `clarity_structure`: Clarity and structure rating (1-10)
|
| 311 |
+
- `reasoning_risk`: Reasoning/risk stratification rating (1-10)
|
| 312 |
+
- `actionability`: Actionability rating (1-10)
|
| 313 |
+
- `hallucination`: Hallucination severity (1-10)
|
| 314 |
+
- `critical_omission`: Critical omission severity (1-10)
|
| 315 |
+
- `feedback`: Overall feedback text
|
| 316 |
+
- `hallucination_comments`: Comments about hallucinations
|
| 317 |
+
- `critical_omission_comments`: Comments about critical omissions
|
| 318 |
+
"""
|
| 319 |
+
with tempfile.NamedTemporaryFile(mode='w', suffix='.md', delete=False, encoding='utf-8') as f:
|
| 320 |
+
f.write(readme_content)
|
| 321 |
+
readme_path = f.name
|
| 322 |
+
|
| 323 |
+
self.api.upload_file(
|
| 324 |
+
path_or_fileobj=readme_path,
|
| 325 |
+
path_in_repo="README.md",
|
| 326 |
+
repo_id=self.repo_id,
|
| 327 |
+
repo_type=self.repo_type,
|
| 328 |
+
commit_message="Add README.md for dataset card"
|
| 329 |
+
)
|
| 330 |
+
os.unlink(readme_path)
|
| 331 |
+
print(f"[HF CSV] Created README.md for dataset card")
|
| 332 |
+
except Exception as e:
|
| 333 |
+
print(f"[HF CSV] Warning: Could not create/update README.md: {e}")
|
| 334 |
+
|
| 335 |
# Clean up
|
| 336 |
os.unlink(temp_path)
|
| 337 |
|