From 4c6ae135cdf93a2ccc83f94ab578654112001661 Mon Sep 17 00:00:00 2001 From: Marek Wolan Date: Fri, 2 Feb 2024 14:48:49 +0000 Subject: [PATCH] Fix typos --- src/primaite/game/agent/actions.py | 20 +++++++++---------- src/primaite/game/agent/rewards.py | 4 ++-- .../simulator/network/hardware/base.py | 3 ++- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/primaite/game/agent/actions.py b/src/primaite/game/agent/actions.py index 6123da50..d5b78a16 100644 --- a/src/primaite/game/agent/actions.py +++ b/src/primaite/game/agent/actions.py @@ -398,8 +398,8 @@ class NetworkACLAddRuleAction(AbstractAction): :param manager: Reference to the ActionManager which created this action. :type manager: ActionManager - :param target_router_name: hostname of the router to which the ACL rule should be added. - :type target_router_name: str + :param target_router_hostname: hostname of the router to which the ACL rule should be added. + :type target_router_hostname: str :param max_acl_rules: Maximum number of ACL rules that can be added to the router. :type max_acl_rules: int :param num_ips: Number of IP addresses in the simulation. @@ -508,8 +508,8 @@ class NetworkACLRemoveRuleAction(AbstractAction): :param manager: Reference to the ActionManager which created this action. :type manager: ActionManager - :param target_router_name: Hostname of the router from which the ACL rule should be removed. - :type target_router_name: str + :param target_router_hostname: Hostname of the router from which the ACL rule should be removed. + :type target_router_hostname: str :param max_acl_rules: Maximum number of ACL rules that can be added to the router. :type max_acl_rules: int """ @@ -629,7 +629,7 @@ class ActionManager: 'type' and 'options' for passing any options to the action class's init method :type actions: List[dict] :param nodes: Extra configuration for each node. - :type nodes: Dict + :type nodes: List[Dict] :param max_folders_per_node: Maximum number of folders per node. Used for calculating action shape. :type max_folders_per_node: int :param max_files_per_folder: Maximum number of files per folder. Used for calculating action shape. @@ -679,24 +679,24 @@ class ActionManager: """ # Populate lists of apps, services, files, folders, etc on nodes. - for n in nodes: - app_list = [a["application_name"] for a in n.get("applications", [])] + for node in nodes: + app_list = [a["application_name"] for a in node.get("applications", [])] while len(app_list) < max_applications_per_node: app_list.append(None) self.application_names.append(app_list) - svc_list = [s["service_name"] for s in n.get("services", [])] + svc_list = [s["service_name"] for s in node.get("services", [])] while len(svc_list) < max_services_per_node: svc_list.append(None) self.service_names.append(svc_list) - folder_list = [f["folder_name"] for f in n.get("folders", [])] + folder_list = [f["folder_name"] for f in node.get("folders", [])] while len(folder_list) < max_folders_per_node: folder_list.append(None) self.folder_names.append(folder_list) file_sublist = [] - for folder in n.get("folders", [{"files": []}]): + for folder in node.get("folders", [{"files": []}]): file_list = [f["file_name"] for f in folder.get("files", [])] while len(file_list) < max_files_per_folder: file_list.append(None) diff --git a/src/primaite/game/agent/rewards.py b/src/primaite/game/agent/rewards.py index 0b292bcb..8944a184 100644 --- a/src/primaite/game/agent/rewards.py +++ b/src/primaite/game/agent/rewards.py @@ -218,7 +218,7 @@ class RewardFunction: self.current_reward: float = 0.0 self.total_reward: float = 0.0 - def regsiter_component(self, component: AbstractReward, weight: float = 1.0) -> None: + def register_component(self, component: AbstractReward, weight: float = 1.0) -> None: """Add a reward component to the reward function. :param component: Instance of a reward component. @@ -260,5 +260,5 @@ class RewardFunction: weight = rew_component_cfg.get("weight", 1.0) rew_class = cls.__rew_class_identifiers[rew_type] rew_instance = rew_class.from_config(config=rew_component_cfg.get("options", {}), game=game) - new.regsiter_component(component=rew_instance, weight=weight) + new.register_component(component=rew_instance, weight=weight) return new diff --git a/src/primaite/simulator/network/hardware/base.py b/src/primaite/simulator/network/hardware/base.py index 8e4c1d76..5334021a 100644 --- a/src/primaite/simulator/network/hardware/base.py +++ b/src/primaite/simulator/network/hardware/base.py @@ -1388,7 +1388,8 @@ class Node(SimComponent): nic.parent = None nic.disable() self.sys_log.info(f"Disconnected NIC {nic}") - self._nic_request_manager.remove_request(nic_num) + if nic_num != -1: + self._nic_request_manager.remove_request(nic_num) else: msg = f"Cannot disconnect NIC {nic} as it is not connected" self.sys_log.logger.error(msg)