Spaces:
Running
Running
internomega-terrablue commited on
Commit Β·
3fb7184
1
Parent(s): c347aa1
Enabling logger with flush
Browse files- app.py +6 -6
- persistence/storage_service.py +5 -5
app.py
CHANGED
|
@@ -362,16 +362,16 @@ with gr.Blocks(css=CUSTOM_CSS, theme=dark_theme, title="NotebookLM") as demo:
|
|
| 362 |
|
| 363 |
# ββ Auth: on page load βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 364 |
def on_app_load(profile: gr.OAuthProfile | None):
|
| 365 |
-
print(f"[on_app_load] profile={profile}")
|
| 366 |
if profile is None:
|
| 367 |
return None, gr.update(visible=True), gr.update(visible=False)
|
| 368 |
-
print(f"[on_app_load] Loading data for user: {profile.username}")
|
| 369 |
state = StorageService.load_user_data(profile.username, profile.name)
|
| 370 |
if state is None:
|
| 371 |
-
print(f"[on_app_load] No saved data found β creating default")
|
| 372 |
state = create_default_user_data(profile.username, profile.name)
|
| 373 |
else:
|
| 374 |
-
print(f"[on_app_load] Loaded {len(state.notebooks)} notebook(s)")
|
| 375 |
return state, gr.update(visible=False), gr.update(visible=True)
|
| 376 |
|
| 377 |
demo.load(
|
|
@@ -444,14 +444,14 @@ with gr.Blocks(css=CUSTOM_CSS, theme=dark_theme, title="NotebookLM") as demo:
|
|
| 444 |
|
| 445 |
# ββ Sidebar: Save ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 446 |
def handle_save(state):
|
| 447 |
-
print(f"[handle_save] Called, state={state is not None}")
|
| 448 |
if not state:
|
| 449 |
return '<p style="color:#ef4444; font-size:0.8rem;">No data to save.</p>'
|
| 450 |
try:
|
| 451 |
StorageService.save_user_data(state)
|
| 452 |
return '<p style="color:#22c55e; font-size:0.8rem;">Saved successfully!</p>'
|
| 453 |
except Exception as e:
|
| 454 |
-
print(f"[handle_save] Error: {e}")
|
| 455 |
return f'<p style="color:#ef4444; font-size:0.8rem;">Save failed: {e}</p>'
|
| 456 |
|
| 457 |
save_btn.click(
|
|
|
|
| 362 |
|
| 363 |
# ββ Auth: on page load βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 364 |
def on_app_load(profile: gr.OAuthProfile | None):
|
| 365 |
+
print(f"[on_app_load] profile={profile}", flush=True)
|
| 366 |
if profile is None:
|
| 367 |
return None, gr.update(visible=True), gr.update(visible=False)
|
| 368 |
+
print(f"[on_app_load] Loading data for user: {profile.username}", flush=True)
|
| 369 |
state = StorageService.load_user_data(profile.username, profile.name)
|
| 370 |
if state is None:
|
| 371 |
+
print(f"[on_app_load] No saved data found β creating default", flush=True)
|
| 372 |
state = create_default_user_data(profile.username, profile.name)
|
| 373 |
else:
|
| 374 |
+
print(f"[on_app_load] Loaded {len(state.notebooks)} notebook(s)", flush=True)
|
| 375 |
return state, gr.update(visible=False), gr.update(visible=True)
|
| 376 |
|
| 377 |
demo.load(
|
|
|
|
| 444 |
|
| 445 |
# ββ Sidebar: Save ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 446 |
def handle_save(state):
|
| 447 |
+
print(f"[handle_save] Called, state={state is not None}", flush=True)
|
| 448 |
if not state:
|
| 449 |
return '<p style="color:#ef4444; font-size:0.8rem;">No data to save.</p>'
|
| 450 |
try:
|
| 451 |
StorageService.save_user_data(state)
|
| 452 |
return '<p style="color:#22c55e; font-size:0.8rem;">Saved successfully!</p>'
|
| 453 |
except Exception as e:
|
| 454 |
+
print(f"[handle_save] Error: {e}", flush=True)
|
| 455 |
return f'<p style="color:#ef4444; font-size:0.8rem;">Save failed: {e}</p>'
|
| 456 |
|
| 457 |
save_btn.click(
|
persistence/storage_service.py
CHANGED
|
@@ -33,7 +33,7 @@ class StorageService:
|
|
| 33 |
exist_ok=True,
|
| 34 |
)
|
| 35 |
StorageService._repo_ensured = True
|
| 36 |
-
print(f"[StorageService] Ensured dataset repo exists: {StorageService.REPO_ID}")
|
| 37 |
|
| 38 |
@staticmethod
|
| 39 |
def save_user_data(user_data: UserData) -> None:
|
|
@@ -61,7 +61,7 @@ class StorageService:
|
|
| 61 |
repo_id=StorageService.REPO_ID,
|
| 62 |
repo_type=StorageService.REPO_TYPE,
|
| 63 |
)
|
| 64 |
-
print(f"[StorageService] Saved user data for '{user_data.user_id}'")
|
| 65 |
finally:
|
| 66 |
if tmp_path:
|
| 67 |
try:
|
|
@@ -78,7 +78,7 @@ class StorageService:
|
|
| 78 |
try:
|
| 79 |
token = StorageService._get_token()
|
| 80 |
except RuntimeError:
|
| 81 |
-
print("[StorageService] HF_TOKEN not set β skipping load")
|
| 82 |
return None
|
| 83 |
|
| 84 |
try:
|
|
@@ -90,9 +90,9 @@ class StorageService:
|
|
| 90 |
)
|
| 91 |
with open(path, "r") as f:
|
| 92 |
data = json.load(f)
|
| 93 |
-
print(f"[StorageService] Loaded user data for '{user_id}'")
|
| 94 |
return UserData.from_dict(data)
|
| 95 |
except Exception as e:
|
| 96 |
# EntryNotFoundError or network errors β treat as new user
|
| 97 |
-
print(f"[StorageService] No existing data for '{user_id}': {e}")
|
| 98 |
return None
|
|
|
|
| 33 |
exist_ok=True,
|
| 34 |
)
|
| 35 |
StorageService._repo_ensured = True
|
| 36 |
+
print(f"[StorageService] Ensured dataset repo exists: {StorageService.REPO_ID}", flush=True)
|
| 37 |
|
| 38 |
@staticmethod
|
| 39 |
def save_user_data(user_data: UserData) -> None:
|
|
|
|
| 61 |
repo_id=StorageService.REPO_ID,
|
| 62 |
repo_type=StorageService.REPO_TYPE,
|
| 63 |
)
|
| 64 |
+
print(f"[StorageService] Saved user data for '{user_data.user_id}'", flush=True)
|
| 65 |
finally:
|
| 66 |
if tmp_path:
|
| 67 |
try:
|
|
|
|
| 78 |
try:
|
| 79 |
token = StorageService._get_token()
|
| 80 |
except RuntimeError:
|
| 81 |
+
print("[StorageService] HF_TOKEN not set β skipping load", flush=True)
|
| 82 |
return None
|
| 83 |
|
| 84 |
try:
|
|
|
|
| 90 |
)
|
| 91 |
with open(path, "r") as f:
|
| 92 |
data = json.load(f)
|
| 93 |
+
print(f"[StorageService] Loaded user data for '{user_id}'", flush=True)
|
| 94 |
return UserData.from_dict(data)
|
| 95 |
except Exception as e:
|
| 96 |
# EntryNotFoundError or network errors β treat as new user
|
| 97 |
+
print(f"[StorageService] No existing data for '{user_id}': {e}", flush=True)
|
| 98 |
return None
|