From 8d9ffab5148036cfafb8fb895dda2ae7aa2fbbde Mon Sep 17 00:00:00 2001 From: Charlie Crane Date: Wed, 1 May 2024 12:04:11 +0100 Subject: [PATCH 01/10] #2464 - Correcting Python versioning pre-req range on README.md as we do not currently support Python3.11 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2265538a..927aa17c 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Currently, the PrimAITE wheel can only be installed from GitHub. This may change #### Windows (PowerShell) **Prerequisites:** -* Manual install of Python >= 3.8 < 3.12 +* Manual install of Python >= 3.8 < 3.11 **Install:** @@ -51,7 +51,7 @@ primaite setup #### Unix **Prerequisites:** -* Manual install of Python >= 3.8 < 3.12 +* Manual install of Python >= 3.8 < 3.11 ``` bash sudo add-apt-repository ppa:deadsnakes/ppa From efdc9794958fdead42b0e9b46f0fdf9efaa23c0f Mon Sep 17 00:00:00 2001 From: Charlie Crane Date: Wed, 1 May 2024 14:33:38 +0100 Subject: [PATCH 02/10] #2464 Changing pyproject.toml to allow the use of python 3.11 and tweaking the pipeline to use python 3.11. Seeing what happens... --- .azure/azure-ci-build-pipeline.yaml | 47 +++++++++++++++++++---------- pyproject.toml | 2 +- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/.azure/azure-ci-build-pipeline.yaml b/.azure/azure-ci-build-pipeline.yaml index e9139d5b..41e27931 100644 --- a/.azure/azure-ci-build-pipeline.yaml +++ b/.azure/azure-ci-build-pipeline.yaml @@ -19,28 +19,43 @@ parameters: # img: 'ubuntu-latest' # every_time: false # publish_coverage: false - - job_name: 'UbuntuPython310' - py: '3.10' + # - job_name: 'UbuntuPython310' + # py: '3.10' + # img: 'ubuntu-latest' + # every_time: true + # publish_coverage: true + - job_name: 'UbuntuPython311 TEST' + py: '3.11' img: 'ubuntu-latest' every_time: true publish_coverage: true - - job_name: 'WindowsPython38' - py: '3.8' + # - job_name: 'WindowsPython38' + # py: '3.8' + # img: 'windows-latest' + # every_time: false + # publish_coverage: false + # - job_name: 'WindowsPython310' + # py: '3.10' + # img: 'windows-latest' + # every_time: false + # publish_coverage: false + - job_name: 'WindowsPython311 TEST' + py: '3.11' img: 'windows-latest' every_time: false publish_coverage: false - - job_name: 'WindowsPython310' - py: '3.10' - img: 'windows-latest' - every_time: false - publish_coverage: false - - job_name: 'MacOSPython38' - py: '3.8' - img: 'macOS-latest' - every_time: false - publish_coverage: false - - job_name: 'MacOSPython310' - py: '3.10' + # - job_name: 'MacOSPython38' + # py: '3.8' + # img: 'macOS-latest' + # every_time: false + # publish_coverage: false + # - job_name: 'MacOSPython310' + # py: '3.10' + # img: 'macOS-latest' + # every_time: false + # publish_coverage: false + - job_name: 'MacOSPython311 TEST' + py: '3.11' img: 'macOS-latest' every_time: false publish_coverage: false diff --git a/pyproject.toml b/pyproject.toml index 333132bc..fd75252c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "primaite" description = "PrimAITE (Primary-level AI Training Environment) is a simulation environment for training AI under the ARCD programme." authors = [{name="Defence Science and Technology Laboratory UK", email="oss@dstl.gov.uk"}] license = {file = "LICENSE"} -requires-python = ">=3.8, <3.11" +requires-python = ">=3.8, <3.12" dynamic = ["version", "readme"] classifiers = [ "License :: OSI Approved :: MIT License", From 392b83fc64241d28cc25b125442cdedd8bac6483 Mon Sep 17 00:00:00 2001 From: Charlie Crane Date: Wed, 1 May 2024 14:34:38 +0100 Subject: [PATCH 03/10] #2464 - Correcting use of spaces in pipeline job names --- .azure/azure-ci-build-pipeline.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.azure/azure-ci-build-pipeline.yaml b/.azure/azure-ci-build-pipeline.yaml index 41e27931..e190471d 100644 --- a/.azure/azure-ci-build-pipeline.yaml +++ b/.azure/azure-ci-build-pipeline.yaml @@ -24,7 +24,7 @@ parameters: # img: 'ubuntu-latest' # every_time: true # publish_coverage: true - - job_name: 'UbuntuPython311 TEST' + - job_name: 'UbuntuPython311_TEST' py: '3.11' img: 'ubuntu-latest' every_time: true @@ -39,7 +39,7 @@ parameters: # img: 'windows-latest' # every_time: false # publish_coverage: false - - job_name: 'WindowsPython311 TEST' + - job_name: 'WindowsPython311_TEST' py: '3.11' img: 'windows-latest' every_time: false @@ -54,7 +54,7 @@ parameters: # img: 'macOS-latest' # every_time: false # publish_coverage: false - - job_name: 'MacOSPython311 TEST' + - job_name: 'MacOSPython311_TEST' py: '3.11' img: 'macOS-latest' every_time: false From 57cff8d4e3094008d02ff5d7805de2e400d1528f Mon Sep 17 00:00:00 2001 From: Charlie Crane Date: Wed, 1 May 2024 16:01:08 +0100 Subject: [PATCH 04/10] #2464 - Seeing if python 3.12 will also run... --- .azure/azure-ci-build-pipeline.yaml | 12 ++++++------ pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.azure/azure-ci-build-pipeline.yaml b/.azure/azure-ci-build-pipeline.yaml index e190471d..1a7b4870 100644 --- a/.azure/azure-ci-build-pipeline.yaml +++ b/.azure/azure-ci-build-pipeline.yaml @@ -24,8 +24,8 @@ parameters: # img: 'ubuntu-latest' # every_time: true # publish_coverage: true - - job_name: 'UbuntuPython311_TEST' - py: '3.11' + - job_name: 'UbuntuPython312_TEST' + py: '3.12' img: 'ubuntu-latest' every_time: true publish_coverage: true @@ -39,8 +39,8 @@ parameters: # img: 'windows-latest' # every_time: false # publish_coverage: false - - job_name: 'WindowsPython311_TEST' - py: '3.11' + - job_name: 'WindowsPython312_TEST' + py: '3.12' img: 'windows-latest' every_time: false publish_coverage: false @@ -54,8 +54,8 @@ parameters: # img: 'macOS-latest' # every_time: false # publish_coverage: false - - job_name: 'MacOSPython311_TEST' - py: '3.11' + - job_name: 'MacOSPython312_TEST' + py: '3.12' img: 'macOS-latest' every_time: false publish_coverage: false diff --git a/pyproject.toml b/pyproject.toml index fd75252c..c71b55a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "primaite" description = "PrimAITE (Primary-level AI Training Environment) is a simulation environment for training AI under the ARCD programme." authors = [{name="Defence Science and Technology Laboratory UK", email="oss@dstl.gov.uk"}] license = {file = "LICENSE"} -requires-python = ">=3.8, <3.12" +requires-python = ">=3.8, <3.13" dynamic = ["version", "readme"] classifiers = [ "License :: OSI Approved :: MIT License", From c2cc5228ae981650b210744883441cde311ffd65 Mon Sep 17 00:00:00 2001 From: Charlie Crane Date: Wed, 1 May 2024 16:20:01 +0100 Subject: [PATCH 05/10] #2464 - Linting changes to see if the python 3.12 pipeline will pass --- src/primaite/game/agent/rewards.py | 2 +- src/primaite/simulator/network/container.py | 2 +- src/primaite/simulator/network/hardware/base.py | 6 +++--- src/primaite/simulator/network/protocols/icmp.py | 4 ++-- src/primaite/simulator/system/services/dns/dns_client.py | 2 +- src/primaite/simulator/system/services/ftp/ftp_service.py | 2 +- src/primaite/simulator/system/services/icmp/icmp.py | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/primaite/game/agent/rewards.py b/src/primaite/game/agent/rewards.py index 0222bfcc..36a984dd 100644 --- a/src/primaite/game/agent/rewards.py +++ b/src/primaite/game/agent/rewards.py @@ -231,7 +231,7 @@ class WebpageUnavailablePenalty(AbstractReward): # If the last request did actually go through, then check if the webpage also loaded web_browser_state = access_from_nested_dict(state, self.location_in_state) - if web_browser_state is NOT_PRESENT_IN_STATE or "history" not in web_browser_state: + if web_browser_state is NOT_PRESENT_IN_STATE or "history" not in web_browser_state: # noqa _LOGGER.debug( "Web browser reward could not be calculated because the web browser history on node", f"{self._node} was not reported in the simulation state. Returning 0.0", diff --git a/src/primaite/simulator/network/container.py b/src/primaite/simulator/network/container.py index 17308c97..717d04b3 100644 --- a/src/primaite/simulator/network/container.py +++ b/src/primaite/simulator/network/container.py @@ -248,7 +248,7 @@ class Network(SimComponent): hostname_b = node_b.hostname if node_b else None port_a = link.endpoint_a.port_num port_b = link.endpoint_b.port_num - link_key = f"{hostname_a}:eth-{port_a}<->{hostname_b}:eth-{port_b}" + link_key = f"{hostname_a}: eth-{port_a}<->{hostname_b}: eth-{port_b}" state["links"][link_key] = link.describe_state() state["links"][link_key]["hostname_a"] = hostname_a state["links"][link_key]["hostname_b"] = hostname_b diff --git a/src/primaite/simulator/network/hardware/base.py b/src/primaite/simulator/network/hardware/base.py index 78a0bf2d..27a31e84 100644 --- a/src/primaite/simulator/network/hardware/base.py +++ b/src/primaite/simulator/network/hardware/base.py @@ -56,7 +56,7 @@ def generate_mac_address(oui: Optional[str] = None) -> str: if oui: oui_pattern = re.compile(r"^([0-9A-Fa-f]{2}[:-]){2}[0-9A-Fa-f]{2}$") if not oui_pattern.match(oui): - msg = f"Invalid oui. The oui should be in the format xx:xx:xx, where x is a hexadecimal digit, got '{oui}'" + msg = f"Invalid oui. The oui should be in the format xx:xx:xx, where x is a hexadecimal digit, got '{oui}'" # noqa _LOGGER.error(msg) raise ValueError(msg) oui_bytes = [int(chunk, 16) for chunk in oui.split(":")] @@ -64,7 +64,7 @@ def generate_mac_address(oui: Optional[str] = None) -> str: else: mac = random_bytes - return ":".join(f"{b:02x}" for b in mac) + return ":".join(f"{b:02x}" for b in mac) # noqa class NetworkInterface(SimComponent, ABC): @@ -599,7 +599,7 @@ class Link(SimComponent): @property def current_load_percent(self) -> str: """Get the current load formatted as a percentage string.""" - return f"{self.current_load / self.bandwidth:.5f}%" + return f"{self.current_load / self.bandwidth:.5f}%" # noqa def endpoint_up(self): """Let the Link know and endpoint has been brought up.""" diff --git a/src/primaite/simulator/network/protocols/icmp.py b/src/primaite/simulator/network/protocols/icmp.py index 35b0a05d..b891fe5a 100644 --- a/src/primaite/simulator/network/protocols/icmp.py +++ b/src/primaite/simulator/network/protocols/icmp.py @@ -100,7 +100,7 @@ class ICMPPacket(BaseModel): icmp_type = info.data["icmp_type"] if get_icmp_type_code_description(icmp_type, v): return v - msg = f"No Matching ICMP code for type:{icmp_type.name}, code:{v}" + msg = f"No Matching ICMP code for type: {icmp_type.name}, code: {v}" _LOGGER.error(msg) raise ValueError(msg) @@ -109,6 +109,6 @@ class ICMPPacket(BaseModel): description = get_icmp_type_code_description(self.icmp_type, self.icmp_code) if description: return description - msg = f"No Matching ICMP code for type:{self.icmp_type.name}, code:{self.icmp_code}" + msg = f"No Matching ICMP code for type: {self.icmp_type.name}, code: {self.icmp_code}" _LOGGER.error(msg) raise ValueError(msg) diff --git a/src/primaite/simulator/system/services/dns/dns_client.py b/src/primaite/simulator/system/services/dns/dns_client.py index 063ff74f..1baef868 100644 --- a/src/primaite/simulator/system/services/dns/dns_client.py +++ b/src/primaite/simulator/system/services/dns/dns_client.py @@ -81,7 +81,7 @@ class DNSClient(Service): # check if the domain is already in the DNS cache if target_domain in self.dns_cache: self.sys_log.info( - f"{self.name}: Domain lookup for {target_domain} successful," + f"{self.name}: Domain lookup for {target_domain} successful, " f"resolves to {self.dns_cache[target_domain]}" ) return True diff --git a/src/primaite/simulator/system/services/ftp/ftp_service.py b/src/primaite/simulator/system/services/ftp/ftp_service.py index 70ba74d7..75c8daab 100644 --- a/src/primaite/simulator/system/services/ftp/ftp_service.py +++ b/src/primaite/simulator/system/services/ftp/ftp_service.py @@ -147,7 +147,7 @@ class FTPServiceABC(Service, ABC): retrieved_file: File = self.file_system.get_file(folder_name=folder_name, file_name=file_name) # if file does not exist, return an error - if not retrieved_file: + if not retrieved_file: # noqa self.sys_log.error( f"File {payload.ftp_command_args['dest_folder_name']}/" f"{payload.ftp_command_args['dest_file_name']} does not exist in {self.sys_log.hostname}" diff --git a/src/primaite/simulator/system/services/icmp/icmp.py b/src/primaite/simulator/system/services/icmp/icmp.py index c4b4173f..14aa47e4 100644 --- a/src/primaite/simulator/system/services/icmp/icmp.py +++ b/src/primaite/simulator/system/services/icmp/icmp.py @@ -60,7 +60,7 @@ class ICMP(Service): if target_ip_address.is_loopback: self.sys_log.info("Pinging loopback address") return any(network_interface.enabled for network_interface in self.network_interfaces.values()) - self.sys_log.info(f"Pinging {target_ip_address}:", to_terminal=True) + self.sys_log.info(f"Pinging {target_ip_address}: ", to_terminal=True) sequence, identifier = 0, None while sequence < pings: sequence, identifier = self._send_icmp_echo_request(target_ip_address, sequence, identifier, pings) From a2482dc7446712e658cba58674f7867bc4058af9 Mon Sep 17 00:00:00 2001 From: Charlie Crane Date: Wed, 1 May 2024 16:22:26 +0100 Subject: [PATCH 06/10] #2464 - Forgot to save and add a file that would cause flake8 failure --- src/primaite/simulator/network/hardware/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/primaite/simulator/network/hardware/base.py b/src/primaite/simulator/network/hardware/base.py index 27a31e84..1d305598 100644 --- a/src/primaite/simulator/network/hardware/base.py +++ b/src/primaite/simulator/network/hardware/base.py @@ -652,7 +652,7 @@ class Link(SimComponent): # Load the frame size on the link self.current_load += frame_size _LOGGER.debug( - f"Added {frame_size:.3f} Mbits to {self}, current load {self.current_load:.3f} Mbits " + f"Added {frame_size:.3f} Mbits to {self}, current load {self.current_load:.3f} Mbits " # noqa f"({self.current_load_percent})" ) return True From 0fd85722aeae3d9bff062f33c18a5bf2a5aa92af Mon Sep 17 00:00:00 2001 From: Charlie Crane Date: Wed, 1 May 2024 16:37:16 +0100 Subject: [PATCH 07/10] #2464 I missed a linting error --- .flake8 | 1 + docs/conf.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.flake8 b/.flake8 index c2d9e4bb..ba2f3864 100644 --- a/.flake8 +++ b/.flake8 @@ -7,6 +7,7 @@ extend-ignore = D104 E203 E712 + E713 D401 F811 ANN002 diff --git a/docs/conf.py b/docs/conf.py index a666e460..93e8a447 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -30,8 +30,7 @@ release = version # set global variables rst_prolog = f""" -.. |VERSION| replace:: {release} -""" +.. |VERSION| replace:: {release} """ # noqa html_title = f"{project} v{release} docs" From d25a8aa0efab14ef295a28b78ddceffce49034fa Mon Sep 17 00:00:00 2001 From: Charlie Crane Date: Wed, 1 May 2024 17:06:58 +0100 Subject: [PATCH 08/10] #2464 - Reverting changes from Python3.12 investigations, updating README and prproject.toml so that python 3.11 is allowed --- .azure/azure-ci-build-pipeline.yaml | 57 +++++++------------ README.md | 2 +- docs/conf.py | 3 +- pyproject.toml | 3 +- src/primaite/game/agent/rewards.py | 2 +- src/primaite/simulator/network/container.py | 2 +- .../simulator/network/hardware/base.py | 8 +-- .../simulator/network/protocols/icmp.py | 4 +- .../system/services/dns/dns_client.py | 2 +- .../system/services/ftp/ftp_service.py | 2 +- .../simulator/system/services/icmp/icmp.py | 2 +- 11 files changed, 37 insertions(+), 50 deletions(-) diff --git a/.azure/azure-ci-build-pipeline.yaml b/.azure/azure-ci-build-pipeline.yaml index 1a7b4870..f0a1793e 100644 --- a/.azure/azure-ci-build-pipeline.yaml +++ b/.azure/azure-ci-build-pipeline.yaml @@ -14,48 +14,33 @@ parameters: - name: matrix type: object default: - # - job_name: 'UbuntuPython38' - # py: '3.8' - # img: 'ubuntu-latest' - # every_time: false - # publish_coverage: false - # - job_name: 'UbuntuPython310' - # py: '3.10' - # img: 'ubuntu-latest' - # every_time: true - # publish_coverage: true - - job_name: 'UbuntuPython312_TEST' - py: '3.12' + - job_name: 'UbuntuPython38' + py: '3.8' + img: 'ubuntu-latest' + every_time: false + publish_coverage: false + - job_name: 'UbuntuPython311' + py: '3.11' img: 'ubuntu-latest' every_time: true publish_coverage: true - # - job_name: 'WindowsPython38' - # py: '3.8' - # img: 'windows-latest' - # every_time: false - # publish_coverage: false - # - job_name: 'WindowsPython310' - # py: '3.10' - # img: 'windows-latest' - # every_time: false - # publish_coverage: false - - job_name: 'WindowsPython312_TEST' - py: '3.12' + - job_name: 'WindowsPython38' + py: '3.8' img: 'windows-latest' every_time: false publish_coverage: false - # - job_name: 'MacOSPython38' - # py: '3.8' - # img: 'macOS-latest' - # every_time: false - # publish_coverage: false - # - job_name: 'MacOSPython310' - # py: '3.10' - # img: 'macOS-latest' - # every_time: false - # publish_coverage: false - - job_name: 'MacOSPython312_TEST' - py: '3.12' + - job_name: 'WindowsPython311' + py: '3.11' + img: 'windows-latest' + every_time: false + publish_coverage: false + - job_name: 'MacOSPython38' + py: '3.8' + img: 'macOS-latest' + every_time: false + publish_coverage: false + - job_name: 'MacOSPython311' + py: '3.11' img: 'macOS-latest' every_time: false publish_coverage: false diff --git a/README.md b/README.md index 927aa17c..c57d9c6b 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ primaite setup #### Unix **Prerequisites:** -* Manual install of Python >= 3.8 < 3.11 +* Manual install of Python >= 3.8 < 3.12 ``` bash sudo add-apt-repository ppa:deadsnakes/ppa diff --git a/docs/conf.py b/docs/conf.py index 93e8a447..a666e460 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -30,7 +30,8 @@ release = version # set global variables rst_prolog = f""" -.. |VERSION| replace:: {release} """ # noqa +.. |VERSION| replace:: {release} +""" html_title = f"{project} v{release} docs" diff --git a/pyproject.toml b/pyproject.toml index c71b55a6..2619da90 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "primaite" description = "PrimAITE (Primary-level AI Training Environment) is a simulation environment for training AI under the ARCD programme." authors = [{name="Defence Science and Technology Laboratory UK", email="oss@dstl.gov.uk"}] license = {file = "LICENSE"} -requires-python = ">=3.8, <3.13" +requires-python = ">=3.8, <3.12" dynamic = ["version", "readme"] classifiers = [ "License :: OSI Approved :: MIT License", @@ -20,6 +20,7 @@ classifiers = [ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3 :: Only", ] diff --git a/src/primaite/game/agent/rewards.py b/src/primaite/game/agent/rewards.py index 36a984dd..0222bfcc 100644 --- a/src/primaite/game/agent/rewards.py +++ b/src/primaite/game/agent/rewards.py @@ -231,7 +231,7 @@ class WebpageUnavailablePenalty(AbstractReward): # If the last request did actually go through, then check if the webpage also loaded web_browser_state = access_from_nested_dict(state, self.location_in_state) - if web_browser_state is NOT_PRESENT_IN_STATE or "history" not in web_browser_state: # noqa + if web_browser_state is NOT_PRESENT_IN_STATE or "history" not in web_browser_state: _LOGGER.debug( "Web browser reward could not be calculated because the web browser history on node", f"{self._node} was not reported in the simulation state. Returning 0.0", diff --git a/src/primaite/simulator/network/container.py b/src/primaite/simulator/network/container.py index 717d04b3..17308c97 100644 --- a/src/primaite/simulator/network/container.py +++ b/src/primaite/simulator/network/container.py @@ -248,7 +248,7 @@ class Network(SimComponent): hostname_b = node_b.hostname if node_b else None port_a = link.endpoint_a.port_num port_b = link.endpoint_b.port_num - link_key = f"{hostname_a}: eth-{port_a}<->{hostname_b}: eth-{port_b}" + link_key = f"{hostname_a}:eth-{port_a}<->{hostname_b}:eth-{port_b}" state["links"][link_key] = link.describe_state() state["links"][link_key]["hostname_a"] = hostname_a state["links"][link_key]["hostname_b"] = hostname_b diff --git a/src/primaite/simulator/network/hardware/base.py b/src/primaite/simulator/network/hardware/base.py index 1d305598..78a0bf2d 100644 --- a/src/primaite/simulator/network/hardware/base.py +++ b/src/primaite/simulator/network/hardware/base.py @@ -56,7 +56,7 @@ def generate_mac_address(oui: Optional[str] = None) -> str: if oui: oui_pattern = re.compile(r"^([0-9A-Fa-f]{2}[:-]){2}[0-9A-Fa-f]{2}$") if not oui_pattern.match(oui): - msg = f"Invalid oui. The oui should be in the format xx:xx:xx, where x is a hexadecimal digit, got '{oui}'" # noqa + msg = f"Invalid oui. The oui should be in the format xx:xx:xx, where x is a hexadecimal digit, got '{oui}'" _LOGGER.error(msg) raise ValueError(msg) oui_bytes = [int(chunk, 16) for chunk in oui.split(":")] @@ -64,7 +64,7 @@ def generate_mac_address(oui: Optional[str] = None) -> str: else: mac = random_bytes - return ":".join(f"{b:02x}" for b in mac) # noqa + return ":".join(f"{b:02x}" for b in mac) class NetworkInterface(SimComponent, ABC): @@ -599,7 +599,7 @@ class Link(SimComponent): @property def current_load_percent(self) -> str: """Get the current load formatted as a percentage string.""" - return f"{self.current_load / self.bandwidth:.5f}%" # noqa + return f"{self.current_load / self.bandwidth:.5f}%" def endpoint_up(self): """Let the Link know and endpoint has been brought up.""" @@ -652,7 +652,7 @@ class Link(SimComponent): # Load the frame size on the link self.current_load += frame_size _LOGGER.debug( - f"Added {frame_size:.3f} Mbits to {self}, current load {self.current_load:.3f} Mbits " # noqa + f"Added {frame_size:.3f} Mbits to {self}, current load {self.current_load:.3f} Mbits " f"({self.current_load_percent})" ) return True diff --git a/src/primaite/simulator/network/protocols/icmp.py b/src/primaite/simulator/network/protocols/icmp.py index b891fe5a..35b0a05d 100644 --- a/src/primaite/simulator/network/protocols/icmp.py +++ b/src/primaite/simulator/network/protocols/icmp.py @@ -100,7 +100,7 @@ class ICMPPacket(BaseModel): icmp_type = info.data["icmp_type"] if get_icmp_type_code_description(icmp_type, v): return v - msg = f"No Matching ICMP code for type: {icmp_type.name}, code: {v}" + msg = f"No Matching ICMP code for type:{icmp_type.name}, code:{v}" _LOGGER.error(msg) raise ValueError(msg) @@ -109,6 +109,6 @@ class ICMPPacket(BaseModel): description = get_icmp_type_code_description(self.icmp_type, self.icmp_code) if description: return description - msg = f"No Matching ICMP code for type: {self.icmp_type.name}, code: {self.icmp_code}" + msg = f"No Matching ICMP code for type:{self.icmp_type.name}, code:{self.icmp_code}" _LOGGER.error(msg) raise ValueError(msg) diff --git a/src/primaite/simulator/system/services/dns/dns_client.py b/src/primaite/simulator/system/services/dns/dns_client.py index 1baef868..063ff74f 100644 --- a/src/primaite/simulator/system/services/dns/dns_client.py +++ b/src/primaite/simulator/system/services/dns/dns_client.py @@ -81,7 +81,7 @@ class DNSClient(Service): # check if the domain is already in the DNS cache if target_domain in self.dns_cache: self.sys_log.info( - f"{self.name}: Domain lookup for {target_domain} successful, " + f"{self.name}: Domain lookup for {target_domain} successful," f"resolves to {self.dns_cache[target_domain]}" ) return True diff --git a/src/primaite/simulator/system/services/ftp/ftp_service.py b/src/primaite/simulator/system/services/ftp/ftp_service.py index 75c8daab..70ba74d7 100644 --- a/src/primaite/simulator/system/services/ftp/ftp_service.py +++ b/src/primaite/simulator/system/services/ftp/ftp_service.py @@ -147,7 +147,7 @@ class FTPServiceABC(Service, ABC): retrieved_file: File = self.file_system.get_file(folder_name=folder_name, file_name=file_name) # if file does not exist, return an error - if not retrieved_file: # noqa + if not retrieved_file: self.sys_log.error( f"File {payload.ftp_command_args['dest_folder_name']}/" f"{payload.ftp_command_args['dest_file_name']} does not exist in {self.sys_log.hostname}" diff --git a/src/primaite/simulator/system/services/icmp/icmp.py b/src/primaite/simulator/system/services/icmp/icmp.py index 14aa47e4..c4b4173f 100644 --- a/src/primaite/simulator/system/services/icmp/icmp.py +++ b/src/primaite/simulator/system/services/icmp/icmp.py @@ -60,7 +60,7 @@ class ICMP(Service): if target_ip_address.is_loopback: self.sys_log.info("Pinging loopback address") return any(network_interface.enabled for network_interface in self.network_interfaces.values()) - self.sys_log.info(f"Pinging {target_ip_address}: ", to_terminal=True) + self.sys_log.info(f"Pinging {target_ip_address}:", to_terminal=True) sequence, identifier = 0, None while sequence < pings: sequence, identifier = self._send_icmp_echo_request(target_ip_address, sequence, identifier, pings) From ec582c0002c18010f524cd83d0180a8ff27a7922 Mon Sep 17 00:00:00 2001 From: Charlie Crane Date: Wed, 1 May 2024 17:08:08 +0100 Subject: [PATCH 09/10] #2464 - Reverting flake8 change --- .flake8 | 1 - 1 file changed, 1 deletion(-) diff --git a/.flake8 b/.flake8 index ba2f3864..c2d9e4bb 100644 --- a/.flake8 +++ b/.flake8 @@ -7,7 +7,6 @@ extend-ignore = D104 E203 E712 - E713 D401 F811 ANN002 From 5cfa9c7fa261ac5c9caa5f8c8c46aff41dce54ca Mon Sep 17 00:00:00 2001 From: Charlie Crane Date: Thu, 2 May 2024 08:54:37 +0100 Subject: [PATCH 10/10] #2464 - Version typo in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c57d9c6b..2265538a 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Currently, the PrimAITE wheel can only be installed from GitHub. This may change #### Windows (PowerShell) **Prerequisites:** -* Manual install of Python >= 3.8 < 3.11 +* Manual install of Python >= 3.8 < 3.12 **Install:**