diff --git a/src/primaite/config/_package_data/data_manipulation.yaml b/src/primaite/config/_package_data/data_manipulation.yaml index 748b0d77..c561030a 100644 --- a/src/primaite/config/_package_data/data_manipulation.yaml +++ b/src/primaite/config/_package_data/data_manipulation.yaml @@ -11,16 +11,14 @@ training_config: - defender io_settings: - save_checkpoints: true - checkpoint_interval: 5 save_agent_actions: true save_step_metadata: false save_pcap_logs: false - save_sys_logs: true + save_sys_logs: false game: - max_episode_length: 256 + max_episode_length: 128 ports: - HTTP - POSTGRES_SERVER @@ -323,7 +321,7 @@ agents: folder_id: 0 file_id: 0 10: - action: "NODE_FILE_CHECKHASH" + action: "NODE_FILE_SCAN" # CHECKHASH replaced by SCAN - but the behaviour is the same in this context. options: node_id: 2 folder_id: 0 @@ -351,7 +349,7 @@ agents: node_id: 2 folder_id: 0 15: - action: "NODE_FOLDER_CHECKHASH" + action: "NODE_FOLDER_SCAN" # CHECKHASH replaced by SCAN - but the behaviour is the same in this context. options: node_id: 2 folder_id: 0 diff --git a/src/primaite/config/_package_data/data_manipulation_marl.yaml b/src/primaite/config/_package_data/data_manipulation_marl.yaml index be53d2c5..e4c93161 100644 --- a/src/primaite/config/_package_data/data_manipulation_marl.yaml +++ b/src/primaite/config/_package_data/data_manipulation_marl.yaml @@ -4,7 +4,7 @@ training_config: seed: 333 n_learn_episodes: 1 n_eval_episodes: 5 - max_steps_per_episode: 256 + max_steps_per_episode: 128 deterministic_eval: false n_agents: 2 agent_references: @@ -22,7 +22,7 @@ io_settings: game: - max_episode_length: 256 + max_episode_length: 128 ports: - ARP - DNS @@ -325,7 +325,7 @@ agents: folder_id: 0 file_id: 0 10: - action: "NODE_FILE_CHECKHASH" + action: "NODE_FILE_SCAN" # CHECKHASH replaced by SCAN - but the behaviour is the same in this context. options: node_id: 2 folder_id: 0 @@ -353,7 +353,7 @@ agents: node_id: 2 folder_id: 0 15: - action: "NODE_FOLDER_CHECKHASH" + action: "NODE_FOLDER_SCAN" # CHECKHASH replaced by SCAN - but the behaviour is the same in this context. options: node_id: 2 folder_id: 0 @@ -876,7 +876,7 @@ agents: folder_id: 0 file_id: 0 10: - action: "NODE_FILE_CHECKHASH" + action: "NODE_FILE_SCAN" # CHECKHASH replaced by SCAN - but the behaviour is the same in this context. options: node_id: 2 folder_id: 0 @@ -904,7 +904,7 @@ agents: node_id: 2 folder_id: 0 15: - action: "NODE_FOLDER_CHECKHASH" + action: "NODE_FOLDER_SCAN" # CHECKHASH replaced by SCAN - but the behaviour is the same in this context. options: node_id: 2 folder_id: 0 diff --git a/src/primaite/session/io.py b/src/primaite/session/io.py index ef77c63d..e57f88ae 100644 --- a/src/primaite/session/io.py +++ b/src/primaite/session/io.py @@ -92,5 +92,5 @@ class PrimaiteIO: @classmethod def from_config(cls, config: Dict) -> "PrimaiteIO": """Create an instance of PrimaiteIO based on a configuration dict.""" - new = cls() + new = cls(settings=cls.Settings(**config)) return new diff --git a/src/primaite/simulator/network/hardware/base.py b/src/primaite/simulator/network/hardware/base.py index a91a709c..3d8640a6 100644 --- a/src/primaite/simulator/network/hardware/base.py +++ b/src/primaite/simulator/network/hardware/base.py @@ -108,7 +108,7 @@ class NetworkInterface(SimComponent, ABC): """Reset the original state of the SimComponent.""" super().setup_for_episode(episode=episode) self.nmne = {} - if episode and self.pcap: + if episode and self.pcap and SIM_OUTPUT.save_pcap_logs: self.pcap.current_episode = episode self.pcap.setup_logger() self.enable() diff --git a/src/primaite/simulator/system/core/packet_capture.py b/src/primaite/simulator/system/core/packet_capture.py index 4916966d..cf38e94b 100644 --- a/src/primaite/simulator/system/core/packet_capture.py +++ b/src/primaite/simulator/system/core/packet_capture.py @@ -49,8 +49,9 @@ class PacketCapture: self.current_episode: int = 1 - self.setup_logger(outbound=False) - self.setup_logger(outbound=True) + if SIM_OUTPUT.save_pcap_logs: + self.setup_logger(outbound=False) + self.setup_logger(outbound=True) def setup_logger(self, outbound: bool = False): """Set up the logger configuration.""" @@ -108,8 +109,9 @@ class PacketCapture: :param frame: The PCAP frame to capture. """ - msg = frame.model_dump_json() - self.inbound_logger.log(level=60, msg=msg) # Log at custom log level > CRITICAL + if SIM_OUTPUT.save_pcap_logs: + msg = frame.model_dump_json() + self.inbound_logger.log(level=60, msg=msg) # Log at custom log level > CRITICAL def capture_outbound(self, frame): # noqa - I'll have a circular import and cant use if TYPE_CHECKING ;( """ @@ -117,5 +119,6 @@ class PacketCapture: :param frame: The PCAP frame to capture. """ - msg = frame.model_dump_json() - self.outbound_logger.log(level=60, msg=msg) # Log at custom log level > CRITICAL + if SIM_OUTPUT.save_pcap_logs: + msg = frame.model_dump_json() + self.outbound_logger.log(level=60, msg=msg) # Log at custom log level > CRITICAL diff --git a/tests/assets/configs/shared_rewards.yaml b/tests/assets/configs/shared_rewards.yaml index 91ff20e7..daffa585 100644 --- a/tests/assets/configs/shared_rewards.yaml +++ b/tests/assets/configs/shared_rewards.yaml @@ -11,12 +11,10 @@ training_config: - defender io_settings: - save_checkpoints: true - checkpoint_interval: 5 - save_agent_actions: true + save_agent_actions: false save_step_metadata: false save_pcap_logs: false - save_sys_logs: true + save_sys_logs: false game: diff --git a/tests/assets/configs/test_primaite_session.yaml b/tests/assets/configs/test_primaite_session.yaml index 199cf8cc..121cc7f1 100644 --- a/tests/assets/configs/test_primaite_session.yaml +++ b/tests/assets/configs/test_primaite_session.yaml @@ -11,8 +11,11 @@ training_config: - defender io_settings: - save_checkpoints: true - checkpoint_interval: 5 + save_agent_actions: true + save_step_metadata: true + save_pcap_logs: true + save_sys_logs: true + game: diff --git a/tests/e2e_integration_tests/test_primaite_session.py b/tests/e2e_integration_tests/test_primaite_session.py index da13dcd8..c45a4690 100644 --- a/tests/e2e_integration_tests/test_primaite_session.py +++ b/tests/e2e_integration_tests/test_primaite_session.py @@ -31,6 +31,7 @@ class TestPrimaiteSession: assert session.env.game.simulation.network assert len(session.env.game.simulation.network.nodes) == 10 + @pytest.mark.skip(reason="Session is not being maintained and will be removed in the subsequent beta release.") @pytest.mark.parametrize("temp_primaite_session", [[CFG_PATH]], indirect=True) def test_start_session(self, temp_primaite_session): """Make sure you can go all the way through the session without errors."""