Apply documentation changes based on PR review.

This commit is contained in:
Marek Wolan
2024-03-05 11:21:49 +00:00
parent d0225bf3e1
commit a7bfc56b98
4 changed files with 10 additions and 18 deletions

View File

@@ -29,7 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed the order of service health state
- Fixed an issue where starting a node didn't start the services on it
- Added support for SQL INSERT command.
- Added ability to log each agent's action choices each step to a JSON file.
- Added ability to log each agent's action choices in each step to a JSON file.

View File

@@ -18,7 +18,6 @@ This section configures how PrimAITE saves data during simulation and training.
checkpoint_interval: 10
# save_logs: True
# save_transactions: False
# save_tensorboard_logs: False
save_agent_actions: True
save_step_metadata: False
save_pcap_logs: False
@@ -56,21 +55,12 @@ Defines how often to save the policy during training.
*currently unused*.
``save_transactions``
---------------------
*currently unused*.
``save_tensorboard_logs``
-------------------------
*currently unused*.
``save_agent_actions``
Optional. Default value is ``True``.
If ``True``, this will create a JSON file each episode detailing every agent's action each step in that episode, formatted according to the CAOS format. This includes scripted, RL, and red agents.
If ``True``, this will create a JSON file each episode detailing every agent's action in each step of that episode, formatted according to the CAOS format. This includes scripted, RL, and red agents.
``save_step_metadata``
----------------------

View File

@@ -15,7 +15,7 @@ class PrimaiteIO:
"""
Class for managing session IO.
Currently it's handling path generation, but could expand to handle loading, transaction, tensorboard, and so on.
Currently it's handling path generation, but could expand to handle loading, transaction, and so on.
"""
class Settings(BaseModel):
@@ -27,8 +27,6 @@ class PrimaiteIO:
"""Whether to save logs"""
save_agent_actions: bool = True
"""Whether to save a log of all agents' actions every step."""
save_transactions: bool = True
"""Whether to save transactions, If true, the session path will have a transactions folder."""
save_step_metadata: bool = False
"""Whether to save the RL agents' action, environment state, and other data at every single step."""
save_pcap_logs: bool = False
@@ -37,6 +35,12 @@ class PrimaiteIO:
"""Whether to save system logs."""
def __init__(self, settings: Optional[Settings] = None) -> None:
"""
Init the PrimaiteIO object.
Note: Instantiating this object creates a new directory for outputs, and sets the global SIM_OUTPUT variable.
It is intended that this object is instantiated when a new environment is created.
"""
self.settings = settings or PrimaiteIO.Settings()
self.session_path: Path = self.generate_session_path()
# set global SIM_OUTPUT path
@@ -45,8 +49,6 @@ class PrimaiteIO:
SIM_OUTPUT.save_sys_logs = self.settings.save_sys_logs
self.agent_action_log: List[Dict] = []
# warning TODO: must be careful not to re-initialise sessionIO because it will create a new path each time it's
# possible refactor needed
def generate_session_path(self, timestamp: Optional[datetime] = None) -> Path:
"""Create a folder for the session and return the path to it."""

View File

@@ -61,7 +61,7 @@ class PrimaiteSession:
"""Primaite Game object for managing main simulation loop and agents."""
self.save_checkpoints: bool = False
"""Whether to save chcekpoints."""
"""Whether to save checkpoints."""
self.checkpoint_interval: int = 10
"""If save_checkpoints is true, checkpoints will be saved every checkpoint_interval episodes."""