Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow running simulation without port assignment #203

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
await self.container.shutdown()

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

Check warning on line 132 in assume/world.py

View check run for this annotation

Codecov / codecov/patch

assume/world.py#L131-L132

Added lines #L131 - L132 were not covered by tests
else:
connection_type = "mqtt"

Check warning on line 134 in assume/world.py

View check run for this annotation

Codecov / codecov/patch

assume/world.py#L134

Added line #L134 was not covered by tests

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