Skip to content
Snippets Groups Projects
Commit cbb28a87 authored by shinedday's avatar shinedday
Browse files

Improve agent creation

parent ab99a715
Branches
No related tags found
No related merge requests found
No preview for this file type
......@@ -76,7 +76,7 @@ class BaseAgent:
def to_canvas(self) -> dict:
"""
To override if the canvas is used, automatically called each cycle
To override if the canvas is used, automatically called each cycle.
the dict must contains :
* 'x', 'y' keys -> int values
* 'id' of the agent (self.id) -> int value
......
......@@ -29,6 +29,7 @@ class Amas(Schedulable, BaseAmas):
broker_password: str = str(arguments.get("broker_password"))
iot_path: str = str(arguments.get("iot_path"))
true_client = [RemoteClient(i.get("hostname"), i.get("user"), i.get("password")) for i in literal_eval(clients)]
experiment_folder: str = str(arguments.get("experiment_folder"))
Schedulable.__init__(self, broker_ip, "Amas", broker_username, broker_password)
self.subscribe("scheduler/schedulable/wakeup", self.wake_up)
......@@ -38,7 +39,8 @@ class Amas(Schedulable, BaseAmas):
broker_password,
seed,
iot_path,
true_client)
true_client,
experiment_folder)
self.client.publish("amas/action_done", "")
......
......@@ -28,6 +28,7 @@ class AsyncAmas(AsyncControlable, BaseAmas):
broker_password: str = str(arguments.get("broker_password"))
iot_path: str = str(arguments.get("iot_path"))
wait_delay: float = float(arguments.get("wait_delay"))
experiment_folder: str = str(arguments.get("experiment_folder"))
true_client = [RemoteClient(i.get("hostname"), i.get("user"), i.get("password")) for i in literal_eval(clients)]
......@@ -45,7 +46,8 @@ class AsyncAmas(AsyncControlable, BaseAmas):
broker_password,
seed,
iot_path,
true_client)
true_client,
experiment_folder)
self.push_agent()
......
......@@ -19,12 +19,15 @@ class BaseAmas(SSHClient):
broker_password: str,
seed: int,
iot_path: str,
clients: List[RemoteClient]
clients: List[RemoteClient],
experiment_folder: str
):
self.broker_ip: str = broker_ip
self.broker_username: str = broker_username
self.broker_password: str = broker_password
self.experiment_folder = experiment_folder
self.next_id: int = 0
self.seed: int = seed
......@@ -52,7 +55,6 @@ class BaseAmas(SSHClient):
def add_agent(
self,
experience_name: str,
client_ip: str = None,
agent_name: str = "agent.py",
args: List = None
......@@ -79,7 +81,7 @@ class BaseAmas(SSHClient):
}
command = "nohup python "
command += "\'" + self.iot_path + experience_name + "/" + agent_name + "\' \'"
command += "\'" + self.iot_path + self.experiment_folder + "/" + agent_name + "\' \'"
command += json.dumps(arg_dict) + "\' "
for arg in args:
command += str(arg) + " "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment