Spaces:
Runtime error
Runtime error
chore: better default repo_type for Space uploads
Browse files
app.py
CHANGED
|
@@ -115,8 +115,18 @@ def upload_recordings(paths: Sequence[str]) -> Tuple[int, Optional[str]]:
|
|
| 115 |
api = HfApi(token=token)
|
| 116 |
uploaded = 0
|
| 117 |
commit_msg = f"Add recordings {int(time.time())}"
|
| 118 |
-
# repo_type
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
if repo_type not in {"dataset", "space", "model"}:
|
| 121 |
repo_type = "dataset"
|
| 122 |
try:
|
|
|
|
| 115 |
api = HfApi(token=token)
|
| 116 |
uploaded = 0
|
| 117 |
commit_msg = f"Add recordings {int(time.time())}"
|
| 118 |
+
# Determine repo_type. If user provided HF_UPLOAD_REPO, default to dataset.
|
| 119 |
+
# If we inferred the current Space id, default to space so it "just works".
|
| 120 |
+
repo_type_env = os.getenv("HF_UPLOAD_REPO_TYPE")
|
| 121 |
+
if repo_type_env:
|
| 122 |
+
repo_type = repo_type_env.lower()
|
| 123 |
+
else:
|
| 124 |
+
if os.getenv("HF_UPLOAD_REPO"):
|
| 125 |
+
repo_type = "dataset"
|
| 126 |
+
elif os.getenv("SPACE_ID") or os.getenv("REPO_ID"):
|
| 127 |
+
repo_type = "space"
|
| 128 |
+
else:
|
| 129 |
+
repo_type = "dataset"
|
| 130 |
if repo_type not in {"dataset", "space", "model"}:
|
| 131 |
repo_type = "dataset"
|
| 132 |
try:
|