def test_cai_grpc_converter(logger, log_store): condition_one: str = "'stop_phrases_config|stop_phrase_files': '<TRUNCATED!>'" condition_two: str = "'stop_phrases_config|stop_phrase_files|nested': 'test'" logger.addHandler(log_store) logger.grpc({"message": "Test log", "tags": ["test_tag"]}) for log in log_store.messages["grpc"]: assert "{'message': 'Test log', 'tags': ['test_tag']}" in log log_store.reset() logger.grpc(_Resources.test_grpc_request, max_level=2) for log in log_store.messages["grpc"]: assert condition_one in log assert condition_two not in log assert "'tags': ['test', 'grpc']}" in log log_store.reset() logger.grpc(_Resources.test_grpc_request, max_level=3) for log in log_store.messages["grpc"]: assert condition_one not in log assert condition_two in log assert "'tags': ['test', 'grpc']}" in log log_store.reset() logger.grpc(_Resources.test_grpc_request) for log in log_store.messages["grpc"]: assert condition_one not in log assert condition_two in log assert "'tags': ['test', 'grpc']}" in log # not grpc logger logger.info(_Resources.test_grpc_request) for log in log_store.messages["info"]: assert "original" not in log assert "'tags': ['test']}" in log assert "'tags': ['test', 'grpc']}" not in log
def _setup_server(self) -> None: logger.info("attempting to setup server...") self.server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) self._add_services() self._setup_reflection() self.server.add_insecure_port(f"[::]:{PORT}") # type: ignore logger.info(f"SERVING SERVER AT SERVING PORT {PORT}") self.server.start() # type: ignore
def CheckLogin(self, request: Empty, context: grpc.ServicerContext) -> Empty: """ [AUTO-GENERATED FUNCTION] Missing associated documentation comment in .proto file. """ logger.info("relaying CheckLogin() to nlu-client...") response = self.client.services.users.check_login() return response
def ListUsers(self, request: user_pb2.ListUsersRequest, context: grpc.ServicerContext) -> user_pb2.ListUsersResponse: """ [AUTO-GENERATED FUNCTION] Missing associated documentation comment in .proto file. """ logger.info("relaying ListUsers() to nlu-client...") response = self.client.services.users.list_users(request=request) return response
def DeleteUser(self, request: user_pb2.GetUserRequest, context: grpc.ServicerContext) -> Empty: """ [AUTO-GENERATED FUNCTION] Missing associated documentation comment in .proto file. """ logger.info("relaying DeleteUser() to nlu-client...") response = self.client.services.users.delete_user(request=request) return response
def UpdateServerRole(self, request: user_pb2.UpdateServerRoleRequest, context: grpc.ServicerContext) -> user_pb2.ServerRole: """ [AUTO-GENERATED FUNCTION] Missing associated documentation comment in .proto file. """ logger.info("relaying UpdateServerRole() to nlu-client...") response = self.client.services.users.update_server_role(request=request) return response
def CreateIntent(self, request: intent_pb2.CreateIntentRequest, context: grpc.ServicerContext) -> intent_pb2.Intent: """ [AUTO-GENERATED FUNCTION] Creates an intent in the specified agent. """ logger.info("relaying CreateIntent() to nlu-client...") response = self.client.services.intents.create_intent(request=request) return response
def ListIntents(self, request: intent_pb2.ListIntentsRequest, context: grpc.ServicerContext) -> intent_pb2.ListIntentsResponse: """ [AUTO-GENERATED FUNCTION] Returns the list of all intents in the specified agent. """ logger.info("relaying ListIntents() to nlu-client...") response = self.client.services.intents.list_intents(request=request) return response
def BatchDeleteIntents(self, request: intent_pb2.BatchDeleteIntentsRequest, context: grpc.ServicerContext) -> Operation: """ [AUTO-GENERATED FUNCTION] Deletes intents in the specified agent. """ logger.info("relaying BatchDeleteIntents() to nlu-client...") response = self.client.services.intents.batch_delete_intents(request=request) return response
def RunScraper(self, request: Empty, context: grpc.ServicerContext) -> qa_pb2.RunScraperResponse: """ [AUTO-GENERATED FUNCTION] Missing associated documentation comment in .proto file. """ logger.info("relaying RunScraper() to nlu-client...") response = self.qa_client.services.qa.run_scraper() return response
def GetAnswer(self, request: qa_pb2.GetAnswerRequest, context: grpc.ServicerContext) -> qa_pb2.GetAnswerResponse: """ [AUTO-GENERATED FUNCTION] Missing associated documentation comment in .proto file. """ logger.info("relaying GetAnswer() to nlu-client...") response = self.qa_client.services.qa.get_answer(request=request) return response
def DeleteIntent(self, request: intent_pb2.DeleteIntentRequest, context: grpc.ServicerContext) -> Empty: """ [AUTO-GENERATED FUNCTION] Deletes the specified intent. """ logger.info("relaying DeleteIntent() to nlu-client...") response = self.client.services.intents.delete_intent(request=request) return response
def GetIntent(self, request: intent_pb2.GetIntentRequest, context: grpc.ServicerContext) -> intent_pb2.Intent: """ [AUTO-GENERATED FUNCTION] Retrieves the specified intent. """ logger.info("relaying GetIntent() to nlu-client...") response = self.client.services.intents.get_intent(request=request) return response
def SetResources(self, request: agent_pb2.SetResourcesRequest, context: grpc.ServicerContext) -> Empty: """ [AUTO-GENERATED FUNCTION] Missing associated documentation comment in .proto file. """ logger.info("relaying SetResources() to nlu-client...") response = self.client.services.agents.set_resources(request=request) return response
def test_log(log_store): CONSOLE_TEXT = "console log" logger_console.addHandler(log_store) logger_console.debug(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["debug"] logger_console.info(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["info"] logger_console.warning(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["warning"] logger_console.error(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["error"] logger_console.critical(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["critical"] CONSOLE_TEXT = "debug log" logger_debug.addHandler(log_store) logger_debug.debug(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["debug"] logger_debug.info(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["info"] logger_debug.warning(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["warning"] logger_debug.error(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["error"] logger_debug.critical(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["critical"] CONSOLE_TEXT = "root log" logger_root.addHandler(log_store) logger_root.debug(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["debug"] logger_root.info(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["info"] logger_root.warning(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["warning"] logger_root.error(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["error"] logger_root.critical(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["critical"] assert len(log_store.messages["critical"]) == 3 log_store.reset() assert len(log_store.messages["critical"]) == 0 CONSOLE_TEXT = "root log 2" logger.addHandler(log_store) logger.debug(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["debug"] logger.info(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["info"] logger.warning(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["warning"] logger.error(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["error"] logger.critical(CONSOLE_TEXT) assert CONSOLE_TEXT in log_store.messages["critical"]
def UpdateAgent(self, request: agent_pb2.UpdateAgentRequest, context: grpc.ServicerContext) -> agent_pb2.Agent: """ [AUTO-GENERATED FUNCTION] Updates the specified agent. """ logger.info("relaying UpdateAgent() to nlu-client...") response = self.client.services.agents.update_agent(request=request) return response
def RestoreAgent(self, request: agent_pb2.RestoreAgentRequest, context: grpc.ServicerContext) -> Operation: """ [AUTO-GENERATED FUNCTION] Restores the specified agent from a ZIP file. """ logger.info("relaying RestoreAgent() to nlu-client...") response = self.client.services.agents.restore_agent(request=request) return response
def ExportAgent(self, request: agent_pb2.ExportAgentRequest, context: grpc.ServicerContext) -> Operation: """ [AUTO-GENERATED FUNCTION] Exports the specified agent to a ZIP file. """ logger.info("relaying ExportAgent() to nlu-client...") response = self.client.services.agents.export_agent(request=request) return response
def BuildCache(self, request: agent_pb2.BuildCacheRequest, context: grpc.ServicerContext) -> Operation: """ [AUTO-GENERATED FUNCTION] Builds cache for the specified agent. """ logger.info("relaying BuildCache() to nlu-client...") response = self.client.services.agents.build_cache(request=request) return response
def GetPlatformInfo( self, request: Empty, context: grpc.ServicerContext ) -> agent_pb2.GetPlatformInfoResponse: """ [AUTO-GENERATED FUNCTION] Missing associated documentation comment in .proto file. """ logger.info("relaying GetPlatformInfo() to nlu-client...") response = self.client.services.agents.get_platform_info() return response
def DeleteAllAgents(self, request: Empty, context: grpc.ServicerContext) -> Empty: """ [AUTO-GENERATED FUNCTION] Deletes all agents in the server (for development purposes only). """ logger.info("relaying DeleteAllAgents() to nlu-client...") response = self.client.services.agents.delete_all_agents() return response
def GetSession(self, request: session_pb2.GetSessionRequest, context: grpc.ServicerContext) -> session_pb2.Session: """ [AUTO-GENERATED FUNCTION] GetSession: returns a session(=conversation) from ondewo-kb """ logger.info("relaying GetSession() to nlu-client...") response = self.client.services.sessions.get_session(request=request) return response
def TrainAgent(self, request: agent_pb2.TrainAgentRequest, context: grpc.ServicerContext) -> Operation: """ [AUTO-GENERATED FUNCTION] Trains the specified agent. """ logger.info("relaying TrainAgent() to nlu-client...") response = self.client.services.agents.train_agent(request=request) return response
def AddSessionLabels(self, request: session_pb2.AddSessionLabelsRequest, context: grpc.ServicerContext) -> session_pb2.Session: """ [AUTO-GENERATED FUNCTION] Missing associated documentation comment in .proto file. """ logger.info("relaying AddSessionLabels() to nlu-client...") response = self.client.services.sessions.add_session_labels( request=request) return response
def ListSessions( self, request: session_pb2.ListSessionsRequest, context: grpc.ServicerContext) -> session_pb2.ListSessionsResponse: """ [AUTO-GENERATED FUNCTION] *** SESSION RELATED ENDPOINTS *** // """ logger.info("relaying ListSessions() to nlu-client...") response = self.client.services.sessions.list_sessions(request=request) return response
def DetectIntent( self, request: session_pb2.DetectIntentRequest, context: grpc.ServicerContext) -> session_pb2.DetectIntentResponse: """ [AUTO-GENERATED FUNCTION] Processes a natural language query and returns structured, actionable data """ logger.info("relaying DetectIntent() to nlu-client...") response = self.client.services.sessions.detect_intent(request=request) return response
def DeleteSession(self, request: session_pb2.DeleteSessionRequest, context: grpc.ServicerContext) -> Empty: """ [AUTO-GENERATED FUNCTION] DeleteSession: delete a session(=conversation) from ondewo-kb (for testing only) """ logger.info("relaying DeleteSession() to nlu-client...") response = self.client.services.sessions.delete_session( request=request) return response
def TrackSessionStep(self, request: session_pb2.TrackSessionStepRequest, context: grpc.ServicerContext) -> session_pb2.Session: """ [AUTO-GENERATED FUNCTION] TrackSessionStep: append to an existing session; creates it if not existing """ logger.info("relaying TrackSessionStep() to nlu-client...") response = self.client.services.sessions.track_session_step( request=request) return response
def CreateContext(self, request: context_pb2.CreateContextRequest, context: grpc.ServicerContext) -> context_pb2.Context: """ [AUTO-GENERATED FUNCTION] Creates a context. """ logger.info("relaying CreateContext() to nlu-client...") response = self.client.services.contexts.create_context( request=request) return response
def DeleteAllContexts(self, request: context_pb2.DeleteAllContextsRequest, context: grpc.ServicerContext) -> Empty: """ [AUTO-GENERATED FUNCTION] Deletes all active contexts in the specified session. """ logger.info("relaying DeleteAllContexts() to nlu-client...") response = self.client.services.contexts.delete_all_contexts( request=request) return response