#2869 - Actioning review comments

This commit is contained in:
Charlie Crane
2025-01-13 10:26:48 +00:00
parent c16abdfd30
commit 511abea59c
5 changed files with 7 additions and 16 deletions

View File

@@ -20,7 +20,6 @@ The inheritance structure of agents within PrimAITE are shown below. When develo
All agent types within PrimAITE are listed under the ``_registry`` attribute of the parent class, ``AbstractAgent``. All agent types within PrimAITE are listed under the ``_registry`` attribute of the parent class, ``AbstractAgent``.
# TODO: Turn this into an inheritance diagram # TODO: Turn this into an inheritance diagram
# TODO: Would this be necessary?
AbstractAgent AbstractAgent
| |
@@ -61,7 +60,7 @@ AbstractAgent
class ConfigSchema(AbstractAgent.ConfigSchema): class ConfigSchema(AbstractAgent.ConfigSchema):
"""ExampleAgent configuration schema""" """ExampleAgent configuration schema"""
agent_name: str = "ExampleAgent type: str = "ExampleAgent
"""Name of agent""" """Name of agent"""
starting_host: int starting_host: int
"""Host node that this agent should start from in the given environment.""" """Host node that this agent should start from in the given environment."""
@@ -97,7 +96,6 @@ AbstractAgent
start_step: 25 start_step: 25
frequency: 20 frequency: 20
variance: 5 variance: 5
agent_name: "Example Agent"
starting_host: "Server_1" starting_host: "Server_1"

View File

@@ -21,9 +21,10 @@ class _NotJSONFilter(logging.Filter):
class AgentLog: class AgentLog:
""" """
A Agent Log class is a simple logger dedicated to managing and writing logging updates and information for an agent. An Agent Log class is a simple logger dedicated to managing and writing updates and information for an agent.
Each log message is written to a file located at: <simulation output directory>/agent_name/agent_name.log Each log message is written to a file located at:
<simulation output directory>/agent_name/agent_name.log
""" """
def __init__(self, agent_name: Optional[str]): def __init__(self, agent_name: Optional[str]):

View File

@@ -115,6 +115,8 @@ class AbstractAgent(BaseModel):
@classmethod @classmethod
def from_config(cls, config: Dict) -> "AbstractAgent": def from_config(cls, config: Dict) -> "AbstractAgent":
"""Creates an agent component from a configuration dictionary.""" """Creates an agent component from a configuration dictionary."""
if config["type"] not in cls._registry:
return ValueError(f"Invalid Agent Type: {config['type']}")
obj = cls( obj = cls(
config=cls.ConfigSchema(**config["agent_settings"]), config=cls.ConfigSchema(**config["agent_settings"]),
action_manager=ActionManager.from_config(config["game"], config["action_manager"]), action_manager=ActionManager.from_config(config["game"], config["action_manager"]),

View File

@@ -21,7 +21,7 @@ class ProbabilisticAgent(AbstractScriptedAgent, identifier="ProbabilisticAgent")
class ConfigSchema(AbstractScriptedAgent.ConfigSchema): class ConfigSchema(AbstractScriptedAgent.ConfigSchema):
"""Configuration schema for Probabilistic Agent.""" """Configuration schema for Probabilistic Agent."""
agent_name: str = "ProbabilisticAgent" type: str = "ProbabilisticAgent"
action_probabilities: Dict[int, float] = None action_probabilities: Dict[int, float] = None
"""Probability to perform each action in the action map. The sum of probabilities should sum to 1.""" """Probability to perform each action in the action map. The sum of probabilities should sum to 1."""

View File

@@ -61,16 +61,6 @@ def test_probabilistic_agent():
reward_function_cfg = {} reward_function_cfg = {}
# pa = ProbabilisticAgent(
# agent_name="test_agent",
# action_space=action_space,
# observation_space=observation_space,
# reward_function=reward_function,
# settings={
# "action_probabilities": {0: P_DO_NOTHING, 1: P_NODE_APPLICATION_EXECUTE, 2: P_NODE_FILE_DELETE},
# },
# )
pa_config = { pa_config = {
"agent_name": "test_agent", "agent_name": "test_agent",
"game": PrimaiteGame(), "game": PrimaiteGame(),