Skip to content

Commit

Permalink
several changes for release
Browse files Browse the repository at this point in the history
-switch back to non git mango agents release
-as PyPi doesn't allow git dependencies
-change to simple port change check
-to enable parallel runs
  • Loading branch information
nick-harder committed Sep 29, 2023
1 parent b6e1e9c commit c60c6a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
24 changes: 11 additions & 13 deletions assume/world.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import calendar
import logging
import socket
import sys
import time
from datetime import datetime
Expand Down Expand Up @@ -38,15 +39,16 @@
class World:
def __init__(
self,
addr: tuple[str, int] | str = "world",
ifac_addr: str = "0.0.0.0",
port: int = 9099,
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 = addr
self.addr = (ifac_addr, port)
self.container = None

self.export_csv_path = export_csv_path
Expand Down Expand Up @@ -124,20 +126,16 @@ async def setup(
if isinstance(self.container, Container) and self.container.running:
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"
# check if self.addr is already in use and increase port by one if true
while (
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex(self.addr) == 0
):
self.addr = (self.addr[0], self.addr[1] + 1)

Check warning on line 133 in assume/world.py

View check run for this annotation

Codecov / codecov/patch

assume/world.py#L133

Added line #L133 was not covered by tests

self.container = await create_container(
connection_type=connection_type,
codec=mango_codec_factory(),
addr=self.addr,
clock=self.clock,
addr=self.addr, clock=self.clock, codec=mango_codec_factory()
)

await self.setup_learning()
await self.setup_output_agent(simulation_id, save_frequency_hours)

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "assume-framework"
version = "0.1.0"
version = "0.1.1"
description = "ASSUME - Agent-Based Electricity Markets Simulation Toolbox"
authors = ["ASSUME Developers <[email protected]>"]
license = "LICENSE"
Expand Down Expand Up @@ -28,7 +28,7 @@ packages = [
[tool.poetry.dependencies]
python = "^3.10"
paho-mqtt = "^1.5.1"
mango-agents = {git = "https://gitlab.com/maurerle/mango"}
mango-agents = "^1.1.1"
tqdm = "^4.64.1"
python-dateutil = "^2.8.2"
sqlalchemy = "^2.0.9"
Expand Down

0 comments on commit c60c6a8

Please sign in to comment.