Skip to content
Snippets Groups Projects
Commit 2f69d600 authored by Fabian Heinrich's avatar Fabian Heinrich
Browse files

Changed env_id in gameserver slightly for better naming of recording folder

parent 295bf344
No related branches found
No related tags found
No related merge requests found
Pipeline #49264 failed
......@@ -41,6 +41,7 @@ from cooperative_cuisine.utils import (
add_list_of_manager_ids_arguments,
disable_websocket_logging_arguments,
setup_logging,
UUID_CUTOFF,
)
log = logging.getLogger(__name__)
......@@ -162,8 +163,7 @@ class EnvironmentHandler:
"""
if environment_config.manager_id not in self.allowed_manager:
return 1
env_id = uuid.uuid4().hex
env_id = f"{environment_config.env_name}_env_{uuid.uuid4().hex[:UUID_CUTOFF]}" # todo uuid cutoff
if environment_config.number_players < 1:
raise HTTPException(
status_code=409, detail="Number players need to be positive."
......@@ -749,6 +749,7 @@ class CreateEnvironmentConfig(BaseModel):
environment_config: str # file content
layout_config: str # file content
seed: int
env_name: str
class ManageEnv(BaseModel):
......
......@@ -1472,6 +1472,7 @@ class PyGameGUI:
environment_config=environment_config,
layout_config=layout,
seed=seed,
env_name=layout_path.stem
).model_dump(mode="json")
# print(CreateEnvironmentConfig.model_validate_json(json_data=creation_json))
......
......@@ -18,6 +18,7 @@ import os
import random
import signal
import subprocess
import uuid
from pathlib import Path
from subprocess import Popen
from typing import Tuple, Any
......@@ -38,6 +39,7 @@ from cooperative_cuisine.utils import (
expand_path,
add_study_arguments,
deep_update,
UUID_CUTOFF,
)
log = logging.getLogger(__name__)
......@@ -108,6 +110,9 @@ class Study:
with open(study_config_path, "r") as file:
env_config_f = file.read()
self.study_id = uuid.uuid4().hex[:UUID_CUTOFF]
"""Unique ID of the study."""
self.study_config: StudyConfig = yaml.load(
str(env_config_f), Loader=yaml.Loader
)
......@@ -208,6 +213,7 @@ class Study:
environment_config=environment_config,
layout_config=layout,
seed=seed,
env_name=f"study_{self.study_id}_level_{self.current_level_idx}",
).model_dump(mode="json")
env_info = request_game_server(
......@@ -547,6 +553,7 @@ class StudyManager:
environment_config=environment_config,
layout_config=layout,
seed=1234567890,
env_name="tutorial",
).model_dump(mode="json")
# todo async
env_info = request_game_server(
......
......@@ -35,6 +35,9 @@ DEFAULT_SERVER_PORT = 8080
DEFAULT_GAME_PORT = 8000
"""Default game server port."""
UUID_CUTOFF = 8
"""The cutoff length for UUIDs."""
def expand_path(path: str, env_name: str = "") -> str:
"""Expand a path with VARIABLES to the path variables based on the user's OS or installation location of the Cooperative Cuisine.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment