Skip to content

Commit

Permalink
allow running simulation without port assignment (#203)
Browse files Browse the repository at this point in the history
This fixes #202 by using the external_connection Container, which does
not require a port.

run pip install -e . to get the correct version of mango
  • Loading branch information
maurerle authored Sep 25, 2023
1 parent 8ede6e7 commit 5d9234d
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] | str = "world",
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 self.addr == "world":
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 5d9234d

Please sign in to comment.