Upload folder using huggingface_hub
Browse files- README.md +16 -0
- setup_instructions.md +4 -6
- upload_dataset.py +28 -28
README.md
CHANGED
|
@@ -83,6 +83,22 @@ This dataset is designed for:
|
|
| 83 |
- Human-AI agreement studies
|
| 84 |
- Cultural representation research
|
| 85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
## Authors
|
| 87 |
|
| 88 |
**Equal Contribution:** Huichan Seo, Sieun Choi, Minki Hong
|
|
|
|
| 83 |
- Human-AI agreement studies
|
| 84 |
- Cultural representation research
|
| 85 |
|
| 86 |
+
### Loading the Dataset
|
| 87 |
+
|
| 88 |
+
```python
|
| 89 |
+
from datasets import load_dataset
|
| 90 |
+
|
| 91 |
+
# Load specific dataset configurations
|
| 92 |
+
add_attribution = load_dataset("seochan99/ecb-datasets", "add_attribution")
|
| 93 |
+
country_swap = load_dataset("seochan99/ecb-datasets", "country_swap")
|
| 94 |
+
multi_loop_edits = load_dataset("seochan99/ecb-datasets", "multi_loop_edits")
|
| 95 |
+
|
| 96 |
+
# Access data
|
| 97 |
+
print(add_attribution["train"][0]) # First example from add_attribution
|
| 98 |
+
print(country_swap["train"][0]) # First example from country_swap
|
| 99 |
+
print(multi_loop_edits["train"][0]) # First example from multi_loop_edits
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
## Authors
|
| 103 |
|
| 104 |
**Equal Contribution:** Huichan Seo, Sieun Choi, Minki Hong
|
setup_instructions.md
CHANGED
|
@@ -52,12 +52,10 @@ The uploaded dataset can be used as follows:
|
|
| 52 |
```python
|
| 53 |
from datasets import load_dataset
|
| 54 |
|
| 55 |
-
# Load dataset
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
add_attribution = dataset["add_attribution"]
|
| 60 |
-
country_swap = dataset["country_swap"]
|
| 61 |
```
|
| 62 |
|
| 63 |
## 5. Troubleshooting
|
|
|
|
| 52 |
```python
|
| 53 |
from datasets import load_dataset
|
| 54 |
|
| 55 |
+
# Load specific dataset configurations
|
| 56 |
+
add_attribution = load_dataset("seochan99/ecb-datasets", "add_attribution")
|
| 57 |
+
country_swap = load_dataset("seochan99/ecb-datasets", "country_swap")
|
| 58 |
+
multi_loop_edits = load_dataset("seochan99/ecb-datasets", "multi_loop_edits")
|
|
|
|
|
|
|
| 59 |
```
|
| 60 |
|
| 61 |
## 5. Troubleshooting
|
upload_dataset.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
-
|
| 4 |
"""
|
| 5 |
|
| 6 |
import os
|
|
@@ -11,83 +11,83 @@ from huggingface_hub.utils import RepositoryNotFoundError
|
|
| 11 |
|
| 12 |
def upload_dataset(username, dataset_name, dataset_path):
|
| 13 |
"""
|
| 14 |
-
|
| 15 |
|
| 16 |
Args:
|
| 17 |
-
username (str):
|
| 18 |
-
dataset_name (str):
|
| 19 |
-
dataset_path (str):
|
| 20 |
"""
|
| 21 |
|
| 22 |
repo_id = f"{username}/{dataset_name}"
|
| 23 |
api = HfApi()
|
| 24 |
|
| 25 |
try:
|
| 26 |
-
#
|
| 27 |
-
print(f"
|
| 28 |
create_repo(
|
| 29 |
repo_id=repo_id,
|
| 30 |
repo_type="dataset",
|
| 31 |
exist_ok=True
|
| 32 |
)
|
| 33 |
-
print("✅
|
| 34 |
|
| 35 |
except Exception as e:
|
| 36 |
-
print(f"❌
|
| 37 |
return False
|
| 38 |
|
| 39 |
try:
|
| 40 |
-
#
|
| 41 |
-
print(f"
|
| 42 |
api.upload_folder(
|
| 43 |
folder_path=dataset_path,
|
| 44 |
repo_id=repo_id,
|
| 45 |
repo_type="dataset"
|
| 46 |
)
|
| 47 |
-
print("✅
|
| 48 |
-
print(f"🌐
|
| 49 |
return True
|
| 50 |
|
| 51 |
except Exception as e:
|
| 52 |
-
print(f"❌
|
| 53 |
return False
|
| 54 |
|
| 55 |
def main():
|
| 56 |
if len(sys.argv) != 3:
|
| 57 |
-
print("
|
| 58 |
-
print("
|
| 59 |
sys.exit(1)
|
| 60 |
|
| 61 |
username = sys.argv[1]
|
| 62 |
dataset_name = sys.argv[2]
|
| 63 |
-
dataset_path = "." #
|
| 64 |
|
| 65 |
print("=" * 50)
|
| 66 |
-
print("
|
| 67 |
print("=" * 50)
|
| 68 |
-
print(f"
|
| 69 |
-
print(f"
|
| 70 |
-
print(f"
|
| 71 |
print("=" * 50)
|
| 72 |
|
| 73 |
-
#
|
| 74 |
try:
|
| 75 |
api = HfApi()
|
| 76 |
user_info = api.whoami()
|
| 77 |
-
print(f"✅
|
| 78 |
except Exception as e:
|
| 79 |
-
print("❌
|
| 80 |
-
print("
|
| 81 |
print("python -c \"from huggingface_hub import login; login()\"")
|
| 82 |
sys.exit(1)
|
| 83 |
|
| 84 |
-
#
|
| 85 |
success = upload_dataset(username, dataset_name, dataset_path)
|
| 86 |
|
| 87 |
if success:
|
| 88 |
-
print("\n🎉
|
| 89 |
else:
|
| 90 |
-
print("\n💥
|
| 91 |
sys.exit(1)
|
| 92 |
|
| 93 |
if __name__ == "__main__":
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
+
Hugging Face Dataset Upload Script
|
| 4 |
"""
|
| 5 |
|
| 6 |
import os
|
|
|
|
| 11 |
|
| 12 |
def upload_dataset(username, dataset_name, dataset_path):
|
| 13 |
"""
|
| 14 |
+
Upload dataset to Hugging Face.
|
| 15 |
|
| 16 |
Args:
|
| 17 |
+
username (str): Hugging Face username
|
| 18 |
+
dataset_name (str): Dataset name
|
| 19 |
+
dataset_path (str): Local dataset path
|
| 20 |
"""
|
| 21 |
|
| 22 |
repo_id = f"{username}/{dataset_name}"
|
| 23 |
api = HfApi()
|
| 24 |
|
| 25 |
try:
|
| 26 |
+
# Create repository
|
| 27 |
+
print(f"Creating repository: {repo_id}")
|
| 28 |
create_repo(
|
| 29 |
repo_id=repo_id,
|
| 30 |
repo_type="dataset",
|
| 31 |
exist_ok=True
|
| 32 |
)
|
| 33 |
+
print("✅ Repository created successfully")
|
| 34 |
|
| 35 |
except Exception as e:
|
| 36 |
+
print(f"❌ Repository creation failed: {e}")
|
| 37 |
return False
|
| 38 |
|
| 39 |
try:
|
| 40 |
+
# Upload dataset
|
| 41 |
+
print(f"Uploading dataset: {dataset_path}")
|
| 42 |
api.upload_folder(
|
| 43 |
folder_path=dataset_path,
|
| 44 |
repo_id=repo_id,
|
| 45 |
repo_type="dataset"
|
| 46 |
)
|
| 47 |
+
print("✅ Dataset upload completed")
|
| 48 |
+
print(f"🌐 Dataset URL: https://huggingface.co/datasets/{repo_id}")
|
| 49 |
return True
|
| 50 |
|
| 51 |
except Exception as e:
|
| 52 |
+
print(f"❌ Dataset upload failed: {e}")
|
| 53 |
return False
|
| 54 |
|
| 55 |
def main():
|
| 56 |
if len(sys.argv) != 3:
|
| 57 |
+
print("Usage: python upload_dataset.py <username> <dataset-name>")
|
| 58 |
+
print("Example: python upload_dataset.py seochan99 ecb-datasets")
|
| 59 |
sys.exit(1)
|
| 60 |
|
| 61 |
username = sys.argv[1]
|
| 62 |
dataset_name = sys.argv[2]
|
| 63 |
+
dataset_path = "." # Current directory
|
| 64 |
|
| 65 |
print("=" * 50)
|
| 66 |
+
print("Hugging Face Dataset Upload")
|
| 67 |
print("=" * 50)
|
| 68 |
+
print(f"Username: {username}")
|
| 69 |
+
print(f"Dataset Name: {dataset_name}")
|
| 70 |
+
print(f"Local Path: {os.path.abspath(dataset_path)}")
|
| 71 |
print("=" * 50)
|
| 72 |
|
| 73 |
+
# Check authentication
|
| 74 |
try:
|
| 75 |
api = HfApi()
|
| 76 |
user_info = api.whoami()
|
| 77 |
+
print(f"✅ Logged in as: {user_info['name']}")
|
| 78 |
except Exception as e:
|
| 79 |
+
print("❌ Not logged in to Hugging Face.")
|
| 80 |
+
print("Please login using:")
|
| 81 |
print("python -c \"from huggingface_hub import login; login()\"")
|
| 82 |
sys.exit(1)
|
| 83 |
|
| 84 |
+
# Execute upload
|
| 85 |
success = upload_dataset(username, dataset_name, dataset_path)
|
| 86 |
|
| 87 |
if success:
|
| 88 |
+
print("\n🎉 Upload completed successfully!")
|
| 89 |
else:
|
| 90 |
+
print("\n💥 Error occurred during upload.")
|
| 91 |
sys.exit(1)
|
| 92 |
|
| 93 |
if __name__ == "__main__":
|