Spaces:
Runtime error
Runtime error
Removed crete_repo argument from hugging face call and another arg
Browse files
app.py
CHANGED
|
@@ -70,18 +70,23 @@ def Dataset_Creator_Function(dataset_name: str, conversation_data: str) -> str:
|
|
| 70 |
# Initialize Hugging Face API
|
| 71 |
hf_api = HfApi(token=api_key)
|
| 72 |
|
| 73 |
-
#
|
| 74 |
try:
|
| 75 |
user_info = hf_api.whoami()
|
| 76 |
username = user_info.get("name", "Misfits-and-Machines") # fallback
|
| 77 |
except Exception as e:
|
| 78 |
return f"Error authenticating with Hugging Face: {str(e)}"
|
| 79 |
|
| 80 |
-
#
|
| 81 |
safe_dataset_name = dataset_name.replace(" ", "-").lower()
|
| 82 |
repo_id = f"{username}/{safe_dataset_name}"
|
| 83 |
|
| 84 |
-
print(f"Creating
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
# Build conversation object
|
| 87 |
conversation = {
|
|
@@ -93,19 +98,10 @@ def Dataset_Creator_Function(dataset_name: str, conversation_data: str) -> str:
|
|
| 93 |
# Create a Hugging Face dataset
|
| 94 |
dataset = Dataset.from_dict({"conversations": [conversation]})
|
| 95 |
|
| 96 |
-
#
|
| 97 |
-
try:
|
| 98 |
-
hf_api.create_repo(repo_id=repo_id, repo_type="dataset", exist_ok=True)
|
| 99 |
-
print(f"Repository {repo_id} created or already exists")
|
| 100 |
-
except Exception as repo_error:
|
| 101 |
-
print(f"Note: Repository creation returned: {str(repo_error)}")
|
| 102 |
-
|
| 103 |
-
# Push the dataset
|
| 104 |
dataset.push_to_hub(
|
| 105 |
repo_id=repo_id,
|
| 106 |
token=api_key,
|
| 107 |
-
create_repo=True,
|
| 108 |
-
repo_type="dataset",
|
| 109 |
commit_message="Add conversation dataset"
|
| 110 |
)
|
| 111 |
|
|
|
|
| 70 |
# Initialize Hugging Face API
|
| 71 |
hf_api = HfApi(token=api_key)
|
| 72 |
|
| 73 |
+
# Retrieve username for the repository name
|
| 74 |
try:
|
| 75 |
user_info = hf_api.whoami()
|
| 76 |
username = user_info.get("name", "Misfits-and-Machines") # fallback
|
| 77 |
except Exception as e:
|
| 78 |
return f"Error authenticating with Hugging Face: {str(e)}"
|
| 79 |
|
| 80 |
+
# Sanitize dataset name and create repo_id
|
| 81 |
safe_dataset_name = dataset_name.replace(" ", "-").lower()
|
| 82 |
repo_id = f"{username}/{safe_dataset_name}"
|
| 83 |
|
| 84 |
+
print(f"Creating or confirming repo: {repo_id}")
|
| 85 |
+
# Create or confirm the repository exists
|
| 86 |
+
try:
|
| 87 |
+
hf_api.create_repo(repo_id=repo_id, repo_type="dataset", exist_ok=True)
|
| 88 |
+
except Exception as repo_error:
|
| 89 |
+
print(f"Note: Repository creation returned: {str(repo_error)}")
|
| 90 |
|
| 91 |
# Build conversation object
|
| 92 |
conversation = {
|
|
|
|
| 98 |
# Create a Hugging Face dataset
|
| 99 |
dataset = Dataset.from_dict({"conversations": [conversation]})
|
| 100 |
|
| 101 |
+
# Push to the Hub without the unsupported arguments
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
dataset.push_to_hub(
|
| 103 |
repo_id=repo_id,
|
| 104 |
token=api_key,
|
|
|
|
|
|
|
| 105 |
commit_message="Add conversation dataset"
|
| 106 |
)
|
| 107 |
|