diff --git a/src/primaite/notebooks/Training-an-SB3-Agent.ipynb b/src/primaite/notebooks/Training-an-SB3-Agent.ipynb index ee51aa58..bf272329 100644 --- a/src/primaite/notebooks/Training-an-SB3-Agent.ipynb +++ b/src/primaite/notebooks/Training-an-SB3-Agent.ipynb @@ -163,7 +163,7 @@ ], "metadata": { "kernelspec": { - "display_name": "venv", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -177,9 +177,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.8.10" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/src/primaite/simulator/system/services/database/database_service.py b/src/primaite/simulator/system/services/database/database_service.py index 0872074f..24ae9b63 100644 --- a/src/primaite/simulator/system/services/database/database_service.py +++ b/src/primaite/simulator/system/services/database/database_service.py @@ -43,10 +43,16 @@ class DatabaseService(Service): self._create_db_file() def install(self): + """ + Perform first-time setup of the DatabaseService. + + Installs an instance of FTPClient on the Node to enable database backup if it isn't installed already. + """ super().install() if not self.software_manager.software.get("FTPClient"): self.sys_log.info(f"{self.name}: Installing FTPClient to enable database backups") self.software_manager.install(FTPClient) + def configure_backup(self, backup_server: IPv4Address): """ Set up the database backup. @@ -77,9 +83,7 @@ class DatabaseService(Service): # send backup copy of database file to FTP server if not self.db_file: - self.sys_log.error( - f"{self.name}: Attempted to backup database file but it doesn't exist." - ) + self.sys_log.error(f"{self.name}: Attempted to backup database file but it doesn't exist.") return False response = ftp_client_service.send_file( @@ -170,11 +174,11 @@ class DatabaseService(Service): return str(uuid4()) def _process_connect( - self, - src_ip: IPv4Address, - connection_request_id: str, - password: Optional[str] = None, - session_id: Optional[str] = None, + self, + src_ip: IPv4Address, + connection_request_id: str, + password: Optional[str] = None, + session_id: Optional[str] = None, ) -> Dict[str, Union[int, Dict[str, bool]]]: """Process an incoming connection request. @@ -215,10 +219,10 @@ class DatabaseService(Service): } def _process_sql( - self, - query: Literal["SELECT", "DELETE", "INSERT", "ENCRYPT"], - query_id: str, - connection_id: Optional[str] = None, + self, + query: Literal["SELECT", "DELETE", "INSERT", "ENCRYPT"], + query_id: str, + connection_id: Optional[str] = None, ) -> Dict[str, Union[int, List[Any]]]: """ Executes the given SQL query and returns the result. diff --git a/tests/integration_tests/system/test_database_on_node.py b/tests/integration_tests/system/test_database_on_node.py index a0b47d2e..ea7d7aae 100644 --- a/tests/integration_tests/system/test_database_on_node.py +++ b/tests/integration_tests/system/test_database_on_node.py @@ -357,7 +357,8 @@ def test_client_connection_terminate_does_not_terminate_another_clients_connecti assert db_connection_b.query("SELECT") assert len(db_service.connections) == 1 + def test_database_server_install_ftp_client(): server = Server(hostname="db_server", ip_address="192.168.1.2", subnet_mask="255.255.255.0", start_up_duration=0) server.software_manager.install(DatabaseService) - assert server.software_manager.software.get("FTPClient") \ No newline at end of file + assert server.software_manager.software.get("FTPClient")