Spaces:
Running
Running
Documentation Update
Browse files
src/gradio_user_history/__init__.py
CHANGED
@@ -17,8 +17,10 @@ Useful links:
|
|
17 |
- Source file: https://huggingface.co/spaces/Wauplin/gradio-user-history/blob/main/user_history.py
|
18 |
- Discussions: https://huggingface.co/spaces/Wauplin/gradio-user-history/discussions
|
19 |
- Development Updates: https://huggingface.co/spaces/Surn/gradio-user-history/
|
|
|
|
|
20 |
"""
|
21 |
from ._user_history import render, save_image, save_file, setup # noqa: F401
|
22 |
|
23 |
|
24 |
-
__version__ = "0.3.
|
|
|
17 |
- Source file: https://huggingface.co/spaces/Wauplin/gradio-user-history/blob/main/user_history.py
|
18 |
- Discussions: https://huggingface.co/spaces/Wauplin/gradio-user-history/discussions
|
19 |
- Development Updates: https://huggingface.co/spaces/Surn/gradio-user-history/
|
20 |
+
|
21 |
+
Update by Surn (Charles Fettinger)
|
22 |
"""
|
23 |
from ._user_history import render, save_image, save_file, setup # noqa: F401
|
24 |
|
25 |
|
26 |
+
__version__ = "0.3.6"
|
src/gradio_user_history/_user_history.py
CHANGED
@@ -24,6 +24,15 @@ from tqdm import tqdm
|
|
24 |
user_profile = gr.State(None)
|
25 |
|
26 |
def get_profile() -> gr.OAuthProfile | None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
global user_profile
|
28 |
"""Return the user profile if logged in, None otherwise."""
|
29 |
|
@@ -355,7 +364,15 @@ class _UserHistory(object):
|
|
355 |
|
356 |
|
357 |
def _fetch_user_history(profile: gr.OAuthProfile | None) -> List[Tuple[str, str]]:
|
358 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
# Cannot load history for logged out users
|
360 |
global user_profile
|
361 |
if profile is None:
|
@@ -385,7 +402,15 @@ def _fetch_user_history(profile: gr.OAuthProfile | None) -> List[Tuple[str, str]
|
|
385 |
|
386 |
|
387 |
def _export_user_history(profile: gr.OAuthProfile | None) -> Dict | None:
|
388 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
# Cannot load history for logged out users
|
390 |
if profile is None:
|
391 |
return None
|
@@ -406,7 +431,15 @@ def _export_user_history(profile: gr.OAuthProfile | None) -> Dict | None:
|
|
406 |
|
407 |
|
408 |
def _delete_user_history(profile: gr.OAuthProfile | None) -> None:
|
409 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
# Cannot load history for logged out users
|
411 |
if profile is None:
|
412 |
return
|
|
|
24 |
user_profile = gr.State(None)
|
25 |
|
26 |
def get_profile() -> gr.OAuthProfile | None:
|
27 |
+
"""
|
28 |
+
Retrieve the currently logged-in user's profile.
|
29 |
+
|
30 |
+
This function returns the user profile stored in the global Gradio state.
|
31 |
+
If no user is logged in, it returns None.
|
32 |
+
|
33 |
+
Returns:
|
34 |
+
gr.OAuthProfile | None: The currently logged-in user's profile, or None if no user is logged in.
|
35 |
+
"""
|
36 |
global user_profile
|
37 |
"""Return the user profile if logged in, None otherwise."""
|
38 |
|
|
|
364 |
|
365 |
|
366 |
def _fetch_user_history(profile: gr.OAuthProfile | None) -> List[Tuple[str, str]]:
|
367 |
+
"""
|
368 |
+
Return saved history for the given user.
|
369 |
+
|
370 |
+
Args:
|
371 |
+
profile (gr.OAuthProfile | None): The user profile.
|
372 |
+
|
373 |
+
Returns:
|
374 |
+
List[Tuple[str, str]]: A list of tuples, where each tuple contains the path to an image and its label.
|
375 |
+
"""
|
376 |
# Cannot load history for logged out users
|
377 |
global user_profile
|
378 |
if profile is None:
|
|
|
402 |
|
403 |
|
404 |
def _export_user_history(profile: gr.OAuthProfile | None) -> Dict | None:
|
405 |
+
"""
|
406 |
+
Zip all history for the given user, if it exists, and return it as a downloadable file.
|
407 |
+
|
408 |
+
Args:
|
409 |
+
profile (gr.OAuthProfile | None): The user profile.
|
410 |
+
|
411 |
+
Returns:
|
412 |
+
Dict | None: A Gradio update dictionary with the path to the zip file if successful, or None if the user is not logged in or user history is not initialized.
|
413 |
+
"""
|
414 |
# Cannot load history for logged out users
|
415 |
if profile is None:
|
416 |
return None
|
|
|
431 |
|
432 |
|
433 |
def _delete_user_history(profile: gr.OAuthProfile | None) -> None:
|
434 |
+
"""
|
435 |
+
Delete all history for the given user.
|
436 |
+
|
437 |
+
Args:
|
438 |
+
profile (gr.OAuthProfile | None): The user profile.
|
439 |
+
|
440 |
+
Returns:
|
441 |
+
None
|
442 |
+
"""
|
443 |
# Cannot load history for logged out users
|
444 |
if profile is None:
|
445 |
return
|