Spaces:
Sleeping
Sleeping
baseline08_beta01.2_28Sept25:fixing oauth_token, log in
Browse files- llm/llm_login.py +2 -2
- ui/gradio_ui.py +6 -3
llm/llm_login.py
CHANGED
|
@@ -41,7 +41,7 @@ def login_huggingface(token: Optional[str] = None):
|
|
| 41 |
logger.info("βοΈ hf_login already", extra={"mode": "HF Oauth"})
|
| 42 |
#return True
|
| 43 |
else:
|
| 44 |
-
login()
|
| 45 |
sleep(5) ##SMY pause for login. Helpful: pool async opex
|
| 46 |
logger.info("βοΈ hf_login already", extra={"mode": "cli"})
|
| 47 |
#return True
|
|
@@ -54,7 +54,7 @@ def login_huggingface(token: Optional[str] = None):
|
|
| 54 |
token = fallback_token
|
| 55 |
logger.info("βοΈ hf_login through fallback", extra={"mode": "token"}) ##SMY: This only displays if token is provided
|
| 56 |
except Exception as exc_token:
|
| 57 |
-
logger.warning("β hf_login_failed", extra={"error": str(exc_token)})
|
| 58 |
else:
|
| 59 |
logger.warning("β hf_login_failed", extra={"error": str(exc)})
|
| 60 |
# Silent fallback; client will still work if token is passed directly
|
|
|
|
| 41 |
logger.info("βοΈ hf_login already", extra={"mode": "HF Oauth"})
|
| 42 |
#return True
|
| 43 |
else:
|
| 44 |
+
login() ##SMY: Not visible/interactive to users onH Space. #limitation
|
| 45 |
sleep(5) ##SMY pause for login. Helpful: pool async opex
|
| 46 |
logger.info("βοΈ hf_login already", extra={"mode": "cli"})
|
| 47 |
#return True
|
|
|
|
| 54 |
token = fallback_token
|
| 55 |
logger.info("βοΈ hf_login through fallback", extra={"mode": "token"}) ##SMY: This only displays if token is provided
|
| 56 |
except Exception as exc_token:
|
| 57 |
+
logger.warning("β hf_login_failed through fallback", extra={"error": str(exc_token)})
|
| 58 |
else:
|
| 59 |
logger.warning("β hf_login_failed", extra={"error": str(exc)})
|
| 60 |
# Silent fallback; client will still work if token is passed directly
|
ui/gradio_ui.py
CHANGED
|
@@ -82,17 +82,20 @@ def convert_batch(
|
|
| 82 |
Receives Gradio component values, starting with the list of uploaded file paths
|
| 83 |
"""
|
| 84 |
|
|
|
|
|
|
|
|
|
|
| 85 |
# get token from logged-in user:
|
| 86 |
api_token = get_login_token(api_token_gr)
|
| 87 |
|
| 88 |
try:
|
| 89 |
##SMY: might deprecate. To replace with oauth login from Gradio ui or integrate cleanly.
|
| 90 |
-
login_huggingface(api_token) ## attempt login if not already logged in. NB: HF CLI login prompt would not display in Process Worker.
|
| 91 |
|
| 92 |
if is_loggedin_huggingface() and (api_token is None or api_token == ""):
|
| 93 |
api_token = get_token() ##SMY: might be redundant
|
| 94 |
else:
|
| 95 |
-
login_huggingface()
|
| 96 |
# login: Update the Gradio UI to improve user-friendly eXperience
|
| 97 |
yield gr.update(interactive=False), f"login to HF: Processing files...", {"process": "Processing files"}, f"__init__.py"
|
| 98 |
|
|
@@ -792,7 +795,7 @@ def build_interface() -> gr.Blocks:
|
|
| 792 |
msg = do_logout_hf()
|
| 793 |
##debug
|
| 794 |
#msg = "β
Session Cleared. Remember to close browser." if "Clear Session & Logout of HF" in hf_login_logout_btn else "β οΈ Logout" # & Session Cleared"
|
| 795 |
-
return gr.update(value="Sign in to HuggingFace π€"), gr.update(value=""), gr.update(visible=True, value=msg),
|
| 796 |
#yield gr.update(value="Sign in to HuggingFace π€"), gr.update(value=""), gr.update(visible=True, value=msg)
|
| 797 |
|
| 798 |
#hf_login_logout_btn.click(fn=custom_do_logout, inputs=None, outputs=hf_login_logout_btn)
|
|
|
|
| 82 |
Receives Gradio component values, starting with the list of uploaded file paths
|
| 83 |
"""
|
| 84 |
|
| 85 |
+
# login: Update the Gradio UI to improve user-friendly eXperience - commencing
|
| 86 |
+
yield gr.update(interactive=False), f"Commencing Processing ... Getting login", {"process": "Commencing Processing"}, f"__init__.py"
|
| 87 |
+
|
| 88 |
# get token from logged-in user:
|
| 89 |
api_token = get_login_token(api_token_gr)
|
| 90 |
|
| 91 |
try:
|
| 92 |
##SMY: might deprecate. To replace with oauth login from Gradio ui or integrate cleanly.
|
| 93 |
+
#login_huggingface(api_token) ## attempt login if not already logged in. NB: HF CLI login prompt would not display in Process Worker.
|
| 94 |
|
| 95 |
if is_loggedin_huggingface() and (api_token is None or api_token == ""):
|
| 96 |
api_token = get_token() ##SMY: might be redundant
|
| 97 |
else:
|
| 98 |
+
login_huggingface(api_token)
|
| 99 |
# login: Update the Gradio UI to improve user-friendly eXperience
|
| 100 |
yield gr.update(interactive=False), f"login to HF: Processing files...", {"process": "Processing files"}, f"__init__.py"
|
| 101 |
|
|
|
|
| 795 |
msg = do_logout_hf()
|
| 796 |
##debug
|
| 797 |
#msg = "β
Session Cleared. Remember to close browser." if "Clear Session & Logout of HF" in hf_login_logout_btn else "β οΈ Logout" # & Session Cleared"
|
| 798 |
+
return gr.update(value="Sign in to HuggingFace π€"), gr.update(value=""), gr.update(visible=True, value=msg), state_api_token_arg
|
| 799 |
#yield gr.update(value="Sign in to HuggingFace π€"), gr.update(value=""), gr.update(visible=True, value=msg)
|
| 800 |
|
| 801 |
#hf_login_logout_btn.click(fn=custom_do_logout, inputs=None, outputs=hf_login_logout_btn)
|