Apply PR suggestions
This commit is contained in:
@@ -14,7 +14,7 @@ io_settings:
|
|||||||
save_checkpoints: true
|
save_checkpoints: true
|
||||||
checkpoint_interval: 5
|
checkpoint_interval: 5
|
||||||
save_step_metadata: false
|
save_step_metadata: false
|
||||||
save_pcap_logs: true
|
save_pcap_logs: false
|
||||||
save_sys_logs: true
|
save_sys_logs: true
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ io_settings:
|
|||||||
save_checkpoints: true
|
save_checkpoints: true
|
||||||
checkpoint_interval: 5
|
checkpoint_interval: 5
|
||||||
save_step_metadata: false
|
save_step_metadata: false
|
||||||
save_pcap_logs: true
|
save_pcap_logs: false
|
||||||
save_sys_logs: true
|
save_sys_logs: true
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ class PrimaiteGame:
|
|||||||
self.update_agents(sim_state)
|
self.update_agents(sim_state)
|
||||||
|
|
||||||
# Apply all actions to simulation as requests
|
# Apply all actions to simulation as requests
|
||||||
agent_actions = self.apply_agent_actions() # noqa
|
self.apply_agent_actions()
|
||||||
|
|
||||||
# Advance timestep
|
# Advance timestep
|
||||||
self.advance_timestep()
|
self.advance_timestep()
|
||||||
@@ -144,7 +144,7 @@ class PrimaiteGame:
|
|||||||
|
|
||||||
def update_agents(self, state: Dict) -> None:
|
def update_agents(self, state: Dict) -> None:
|
||||||
"""Update agents' observations and rewards based on the current state."""
|
"""Update agents' observations and rewards based on the current state."""
|
||||||
for name, agent in self.agents.items():
|
for _, agent in self.agents.items():
|
||||||
agent.update_observation(state)
|
agent.update_observation(state)
|
||||||
agent.update_reward(state)
|
agent.update_reward(state)
|
||||||
agent.reward_function.total_reward += agent.reward_function.current_reward
|
agent.reward_function.total_reward += agent.reward_function.current_reward
|
||||||
@@ -158,7 +158,7 @@ class PrimaiteGame:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
agent_actions = {}
|
agent_actions = {}
|
||||||
for name, agent in self.agents.items():
|
for _, agent in self.agents.items():
|
||||||
obs = agent.observation_manager.current_observation
|
obs = agent.observation_manager.current_observation
|
||||||
rew = agent.reward_function.current_reward
|
rew = agent.reward_function.current_reward
|
||||||
action_choice, options = agent.get_action(obs, rew)
|
action_choice, options = agent.get_action(obs, rew)
|
||||||
@@ -414,7 +414,9 @@ class PrimaiteGame:
|
|||||||
agent_settings=agent_settings,
|
agent_settings=agent_settings,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
_LOGGER.warning(f"agent type {agent_type} not found")
|
msg(f"Configuration error: {agent_type} is not a valid agent type.")
|
||||||
|
_LOGGER.error(msg)
|
||||||
|
raise ValueError(msg)
|
||||||
game.agents[agent_cfg["ref"]] = new_agent
|
game.agents[agent_cfg["ref"]] = new_agent
|
||||||
|
|
||||||
return game
|
return game
|
||||||
|
|||||||
@@ -1076,7 +1076,6 @@ class Router(NetworkNode):
|
|||||||
:param episode: The episode number for which the router is being reset.
|
:param episode: The episode number for which the router is being reset.
|
||||||
"""
|
"""
|
||||||
self.software_manager.arp.clear()
|
self.software_manager.arp.clear()
|
||||||
# self.acl.reset_component_for_episode(episode)
|
|
||||||
for i, _ in self.network_interface.items():
|
for i, _ in self.network_interface.items():
|
||||||
self.enable_port(i)
|
self.enable_port(i)
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class WebServer(Service):
|
|||||||
self.set_health_state(SoftwareHealthState.COMPROMISED)
|
self.set_health_state(SoftwareHealthState.COMPROMISED)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
except Exception: # TODO: refactor this. Likely to cause silent bugs.
|
except Exception: # TODO: refactor this. Likely to cause silent bugs. (ADO ticket #2345 )
|
||||||
# something went wrong on the server
|
# something went wrong on the server
|
||||||
response.status_code = HttpStatusCode.INTERNAL_SERVER_ERROR
|
response.status_code = HttpStatusCode.INTERNAL_SERVER_ERROR
|
||||||
return response
|
return response
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ from primaite.game.game import PrimaiteGame
|
|||||||
from primaite.session.environment import PrimaiteGymEnv
|
from primaite.session.environment import PrimaiteGymEnv
|
||||||
|
|
||||||
|
|
||||||
# @pytest.mark.skip(reason="no way of currently testing this")
|
|
||||||
def test_sb3_compatibility():
|
def test_sb3_compatibility():
|
||||||
"""Test that the Gymnasium environment can be used with an SB3 agent."""
|
"""Test that the Gymnasium environment can be used with an SB3 agent."""
|
||||||
with open(example_config_path(), "r") as f:
|
with open(example_config_path(), "r") as f:
|
||||||
|
|||||||
Reference in New Issue
Block a user