Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Clémentine
commited on
Commit
·
c869604
1
Parent(s):
5b3b8d7
update session on load
Browse files- yourbench_space/app.py +9 -2
yourbench_space/app.py
CHANGED
|
@@ -130,11 +130,18 @@ def run_evaluation_pipeline(oauth_token: gr.OAuthToken | None, org_name, eval_na
|
|
| 130 |
return status
|
| 131 |
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
with gr.Blocks(theme=gr.themes.Default()) as app:
|
| 134 |
# We initialize the session state with the user randomly generated uuid
|
| 135 |
# Using uuid4 makes collision cases extremely unlikely even for concurrent users
|
| 136 |
-
session_state = gr.State(
|
| 137 |
-
|
| 138 |
|
| 139 |
gr.Markdown(project_description)
|
| 140 |
|
|
|
|
| 130 |
return status
|
| 131 |
|
| 132 |
|
| 133 |
+
def init_session():
|
| 134 |
+
"""Update session on load"""
|
| 135 |
+
uuid = str(uuid.uuid4())
|
| 136 |
+
MANAGERS.create(uuid)
|
| 137 |
+
return gr.State(uuid, delete_callback=lambda uid: MANAGERS.remove(uid))
|
| 138 |
+
|
| 139 |
+
|
| 140 |
with gr.Blocks(theme=gr.themes.Default()) as app:
|
| 141 |
# We initialize the session state with the user randomly generated uuid
|
| 142 |
# Using uuid4 makes collision cases extremely unlikely even for concurrent users
|
| 143 |
+
session_state = gr.State()
|
| 144 |
+
app.load(init_session, outputs=session_state)
|
| 145 |
|
| 146 |
gr.Markdown(project_description)
|
| 147 |
|