Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Clémentine
commited on
Commit
·
9f37bbf
1
Parent(s):
8ac5b07
fix
Browse files- yourbench_space/app.py +2 -3
- yourbench_space/utils.py +3 -3
yourbench_space/app.py
CHANGED
|
@@ -73,12 +73,11 @@ def update_process_status(uuid: str):
|
|
| 73 |
return gr.update(value=True, label="Process Status: Running")
|
| 74 |
|
| 75 |
def prepare_task(uuid: str, oauth_token: gr.OAuthToken | None, hf_dataset_name: str, _=None):
|
| 76 |
-
manager = MANAGERS.get(uuid)
|
| 77 |
new_env = os.environ.copy()
|
| 78 |
if oauth_token:
|
| 79 |
new_env["HF_TOKEN"] = oauth_token.token
|
| 80 |
new_env["DATASET_PREFIX"] = hf_dataset_name
|
| 81 |
-
|
| 82 |
|
| 83 |
|
| 84 |
def update_hf_org_dropdown(oauth_token: gr.OAuthToken | None):
|
|
@@ -232,7 +231,7 @@ with gr.Blocks(theme=gr.themes.Default()) as app:
|
|
| 232 |
answers_df = gr.DataFrame()
|
| 233 |
|
| 234 |
stages_table.change(
|
| 235 |
-
update_dataset, inputs=[stages_table, hf_org_dropdown, hf_dataset_name
|
| 236 |
)
|
| 237 |
|
| 238 |
log_timer = gr.Timer(1.0, active=True)
|
|
|
|
| 73 |
return gr.update(value=True, label="Process Status: Running")
|
| 74 |
|
| 75 |
def prepare_task(uuid: str, oauth_token: gr.OAuthToken | None, hf_dataset_name: str, _=None):
|
|
|
|
| 76 |
new_env = os.environ.copy()
|
| 77 |
if oauth_token:
|
| 78 |
new_env["HF_TOKEN"] = oauth_token.token
|
| 79 |
new_env["DATASET_PREFIX"] = hf_dataset_name
|
| 80 |
+
MANAGERS.start_process(uuid, custom_env=new_env)
|
| 81 |
|
| 82 |
|
| 83 |
def update_hf_org_dropdown(oauth_token: gr.OAuthToken | None):
|
|
|
|
| 231 |
answers_df = gr.DataFrame()
|
| 232 |
|
| 233 |
stages_table.change(
|
| 234 |
+
update_dataset, inputs=[stages_table, hf_org_dropdown, hf_dataset_name], outputs=[ingestion_df, summarization_df, single_hop, answers_df]
|
| 235 |
)
|
| 236 |
|
| 237 |
log_timer = gr.Timer(1.0, active=True)
|
yourbench_space/utils.py
CHANGED
|
@@ -52,7 +52,7 @@ def save_files(uuid: str, files: List[pathlib.Path]) -> str:
|
|
| 52 |
else "No files were saved"
|
| 53 |
)
|
| 54 |
|
| 55 |
-
def update_dataset(stages, hf_org, hf_prefix, oauth_token: gr.OAuthToken):
|
| 56 |
"""
|
| 57 |
Updates the dataset based on the provided stages and dataset configuration.
|
| 58 |
"""
|
|
@@ -105,9 +105,9 @@ class SubprocessManagerGroup:
|
|
| 105 |
uid = SubprocessManagerGroup.grab_uuid(uid)
|
| 106 |
del self.managers[uid]
|
| 107 |
|
| 108 |
-
def start_process(self, uid: Union[str, gr.State]):
|
| 109 |
uid = SubprocessManagerGroup.grab_uuid(uid)
|
| 110 |
-
self.managers[uid].start_process()
|
| 111 |
|
| 112 |
def stop_process(self, uid: Union[str, gr.State]):
|
| 113 |
uid = SubprocessManagerGroup.grab_uuid(uid)
|
|
|
|
| 52 |
else "No files were saved"
|
| 53 |
)
|
| 54 |
|
| 55 |
+
def update_dataset(stages: list, hf_org: str, hf_prefix: str, oauth_token: gr.OAuthToken):
|
| 56 |
"""
|
| 57 |
Updates the dataset based on the provided stages and dataset configuration.
|
| 58 |
"""
|
|
|
|
| 105 |
uid = SubprocessManagerGroup.grab_uuid(uid)
|
| 106 |
del self.managers[uid]
|
| 107 |
|
| 108 |
+
def start_process(self, uid: Union[str, gr.State], custom_env: dict | None):
|
| 109 |
uid = SubprocessManagerGroup.grab_uuid(uid)
|
| 110 |
+
self.managers[uid].start_process(custom_env=custom_env)
|
| 111 |
|
| 112 |
def stop_process(self, uid: Union[str, gr.State]):
|
| 113 |
uid = SubprocessManagerGroup.grab_uuid(uid)
|