Skip to content
This repository has been archived by the owner on Feb 6, 2025. It is now read-only.

Commit

Permalink
update to a90
Browse files Browse the repository at this point in the history
  • Loading branch information
chenchenplus committed Jan 27, 2025
1 parent a487fe7 commit 4a415d1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
16 changes: 11 additions & 5 deletions pycityagent/environment/sim/sim_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
__all__ = ["ControlSimEnv"]


def _generate_yaml_config(map_file: str, max_day: int, start_step: int, total_step: int) -> str:
def _generate_yaml_config(
map_file: str, max_day: int, start_step: int, total_step: int
) -> str:
map_file = os.path.abspath(map_file)
return f"""
input:
Expand Down Expand Up @@ -48,6 +50,7 @@ def __init__(
start_step: int,
total_step: int,
log_dir: str,
primary_node_ip: str,
min_step_time: int = 1000,
timeout: int = 5,
max_process: int = 32,
Expand All @@ -68,9 +71,12 @@ def __init__(
self._log_dir = log_dir
self._min_step_time = min_step_time
self._timeout = timeout
self._primary_node_ip = primary_node_ip
self._max_procs = max_process

self._sim_config = _generate_yaml_config(map_file, max_day, start_step, total_step)
self._sim_config = _generate_yaml_config(
map_file, max_day, start_step, total_step
)
# sim
self.sim_port = None
self._sim_proc = None
Expand Down Expand Up @@ -102,6 +108,7 @@ def reset(
self.sim_port = find_free_port()
config_base64 = encode_to_base64(self._sim_config)
os.environ["GOMAXPROCS"] = str(self._max_procs)
sim_addr = self._primary_node_ip.rstrip("/") + f":{self.sim_port}"
self._sim_proc = Popen(
[
"pycityagent-sim",
Expand All @@ -110,7 +117,7 @@ def reset(
"-job",
self._task_name,
"-listen",
f":{self.sim_port}",
sim_addr,
"-run.min_step_time",
f"{self._min_step_time}",
"-run.pause_after_one_day",
Expand All @@ -125,9 +132,8 @@ def reset(
# stdout=DEVNULL,
)
logging.info(
f"start pycityagent-sim at localhost:{self.sim_port}, PID={self._sim_proc.pid}"
f"start pycityagent-sim at {sim_addr}, PID={self._sim_proc.pid}"
)
sim_addr = f"http://localhost:{self.sim_port}"
atexit.register(self.close)
time.sleep(0.3)
else:
Expand Down
4 changes: 2 additions & 2 deletions pycityagent/environment/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ def __init__(self, config: dict, create_map: bool = False) -> None:
),
log_dir=config["simulator"].get("log_dir", "./log"),
min_step_time=config["simulator"].get("min_step_time", 1000),
primary_node_ip=config["simulator"].get("ad", "http://localhost"),
sim_addr=config["simulator"].get("server", None),
)
primary_node_ip = config["simulator"].get("ad", "http://localhost")
self.server_addr = primary_node_ip.rstrip("/")+f":{sim_env.sim_port}"
self.server_addr = sim_env.sim_addr
config["simulator"]["server"] = self.server_addr
config["simulator"]["_server_activated"] = True
# using local client
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pycityagent"
version = "2.0.0a89" # change it for each release
version = "2.0.0a90" # change it for each release
description = "LLM-based city environment agent building library"
authors = [
{ name = "Yuwei Yan", email = "[email protected]" },
Expand Down

0 comments on commit 4a415d1

Please sign in to comment.