MonkMiner commited on
Commit
ba339f9
·
verified ·
1 Parent(s): 97a7e44

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -117,12 +117,20 @@ class BasicAgent:
117
 
118
 
119
  def _get_space_repo_id() -> str:
120
- # HF Spaces commonly exposes one of these
121
- return (
122
- os.getenv("SPACE_REPO_NAME") # often "username/space"
123
- or os.getenv("SPACE_ID")
124
- or ""
125
- ).strip()
 
 
 
 
 
 
 
 
126
 
127
 
128
  def run_and_submit_all(profile: gr.OAuthProfile | None) -> tuple[str, pd.DataFrame]:
 
117
 
118
 
119
  def _get_space_repo_id() -> str:
120
+ # Preferred: full id
121
+ space_id = (os.getenv("SPACE_ID") or "").strip()
122
+ if space_id and "/" in space_id:
123
+ return space_id
124
+
125
+ # Fallback: author + repo name
126
+ author = (os.getenv("SPACE_AUTHOR_NAME") or "").strip()
127
+ repo = (os.getenv("SPACE_REPO_NAME") or "").strip()
128
+ if author and repo:
129
+ return f"{author}/{repo}"
130
+
131
+ # Fallback: host sometimes exists like "monkminer-final-assignment-template.hf.space"
132
+ # (Not always reversible reliably, so only last resort)
133
+ return ""
134
 
135
 
136
  def run_and_submit_all(profile: gr.OAuthProfile | None) -> tuple[str, pd.DataFrame]: