Skip to content

Commit

Permalink
allow running simulation without port assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
maurerle committed Sep 25, 2023
1 parent 8ede6e7 commit 1990b25
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions assume/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,15 @@
class World:
def __init__(
self,
ifac_addr: str = "0.0.0.0",
port: int = 9099,
addr: tuple[str, int] = None,
database_uri: str = "",
export_csv_path: str = "",
log_level: str = "INFO",
additional_clearing_mechanisms: dict = {},
):
logging.getLogger("assume").setLevel(log_level)
self.logger = logging.getLogger(__name__)
self.addr = (ifac_addr, port)
self.addr = addr
self.container = None

self.export_csv_path = export_csv_path
Expand Down Expand Up @@ -127,8 +126,18 @@ async def setup(
await self.container.shutdown()

# create new container
if not self.addr:
connection_type = "external_connection"
elif isinstance(self.addr, tuple):
connection_type = "tcp"
else:
connection_type = "mqtt"

self.container = await create_container(
addr=self.addr, clock=self.clock, codec=mango_codec_factory()
connection_type=connection_type,
codec=mango_codec_factory(),
addr=self.addr,
clock=self.clock,
)
await self.setup_learning()
await self.setup_output_agent(simulation_id, save_frequency_hours)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ packages = [
[tool.poetry.dependencies]
python = "^3.10"
paho-mqtt = "^1.5.1"
mango-agents = "^1.1.1"
mango-agents = {git = "https://gitlab.com/maurerle/mango"}
tqdm = "^4.64.1"
python-dateutil = "^2.8.2"
sqlalchemy = "^2.0.9"
Expand Down

0 comments on commit 1990b25

Please sign in to comment.