Spaces:
Starting
on
T4
Starting
on
T4
Commit
·
f4fae5e
1
Parent(s):
35fe627
feat: fix bug
Browse files- web_server.py +16 -2
web_server.py
CHANGED
@@ -21,6 +21,7 @@ import numpy as np
|
|
21 |
import gymnasium
|
22 |
import uvicorn
|
23 |
import psutil
|
|
|
24 |
|
25 |
from sim.utils.sim_utils import traj2control, traj_transform_to_global
|
26 |
from sim.utils.score_calculator import hugsim_evaluate
|
@@ -126,6 +127,7 @@ def update_submission_status(team_id: str, submission_id: str, status: int):
|
|
126 |
|
127 |
|
128 |
def delete_client_space(client_space_id: str):
|
|
|
129 |
hf_api.delete_repo(
|
130 |
repo_id=client_space_id,
|
131 |
repo_type="space"
|
@@ -163,7 +165,7 @@ class EnvHandler:
|
|
163 |
"""
|
164 |
Close the environment and release resources.
|
165 |
"""
|
166 |
-
self.env
|
167 |
self._log("Environment closed.")
|
168 |
|
169 |
def reset_env(self):
|
@@ -303,6 +305,18 @@ class EnvHandlerManager:
|
|
303 |
self._env_handlers[env_id] = self._generate_env_handler(env_id)
|
304 |
return self._env_handlers[env_id]
|
305 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
306 |
|
307 |
app = FastAPI()
|
308 |
|
@@ -379,7 +393,7 @@ def execute_action_endpoint(
|
|
379 |
done = env_handler.execute_action(plan_traj)
|
380 |
if done:
|
381 |
token_info = get_token_info(auth_token)
|
382 |
-
env_manager.
|
383 |
delete_client_space(token_info["client_space_id"])
|
384 |
update_submission_status(token_info["team_id"], token_info["submission_id"], SubmissionStatus.SUCCESS.value)
|
385 |
hf_api.upload_folder(
|
|
|
21 |
import gymnasium
|
22 |
import uvicorn
|
23 |
import psutil
|
24 |
+
import torch
|
25 |
|
26 |
from sim.utils.sim_utils import traj2control, traj_transform_to_global
|
27 |
from sim.utils.score_calculator import hugsim_evaluate
|
|
|
127 |
|
128 |
|
129 |
def delete_client_space(client_space_id: str):
|
130 |
+
return
|
131 |
hf_api.delete_repo(
|
132 |
repo_id=client_space_id,
|
133 |
repo_type="space"
|
|
|
165 |
"""
|
166 |
Close the environment and release resources.
|
167 |
"""
|
168 |
+
del self.env
|
169 |
self._log("Environment closed.")
|
170 |
|
171 |
def reset_env(self):
|
|
|
305 |
self._env_handlers[env_id] = self._generate_env_handler(env_id)
|
306 |
return self._env_handlers[env_id]
|
307 |
|
308 |
+
def close_env_handler(self, env_id: str):
|
309 |
+
"""
|
310 |
+
Close the environment handler for the given environment ID.
|
311 |
+
Args:
|
312 |
+
env_id (str): The environment ID.
|
313 |
+
"""
|
314 |
+
with self._lock:
|
315 |
+
env = self._env_handlers.pop(env_id, None)
|
316 |
+
if env is not None:
|
317 |
+
env.close()
|
318 |
+
torch.cuda.empty_cache()
|
319 |
+
|
320 |
|
321 |
app = FastAPI()
|
322 |
|
|
|
393 |
done = env_handler.execute_action(plan_traj)
|
394 |
if done:
|
395 |
token_info = get_token_info(auth_token)
|
396 |
+
env_manager.close_env_handler(token_info["submission_id"])
|
397 |
delete_client_space(token_info["client_space_id"])
|
398 |
update_submission_status(token_info["team_id"], token_info["submission_id"], SubmissionStatus.SUCCESS.value)
|
399 |
hf_api.upload_folder(
|