diff --git a/.vscode/launch.json b/.vscode/launch.json index f134cede1f..2580698ec2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -24,8 +24,8 @@ "linux": { "python": "${workspaceFolder}/dist/server/engine", }, - "justMyCode": true, - "subProcess": false, + "justMyCode": false, + "subProcess": true, "program": "${workspaceFolder}/dist/server/ai/eaas.py", "args": [ // "--trace=debugOut,debugProtocol,servicePython" diff --git a/apps/vscode/package.json b/apps/vscode/package.json index 3569484091..00827773f3 100644 --- a/apps/vscode/package.json +++ b/apps/vscode/package.json @@ -265,6 +265,12 @@ "icon": "$(debug-disconnect)", "category": "RocketRide Pipeline" }, + { + "command": "rocketride.sidebar.files.stopPipeline", + "title": "Stop Pipeline", + "icon": "$(primitive-square)", + "category": "RocketRide Pipeline" + }, { "command": "rocketride.page.deploy.open", "title": "Open Deploy", @@ -307,7 +313,7 @@ "group": "inline@3" }, { - "command": "rocketride.sidebar.files.attachPipeline", + "command": "rocketride.sidebar.files.stopPipeline", "when": "view == rocketride.provider.files && viewItem =~ /^pipelineSource:running/ || view == rocketride.provider.files && viewItem == unknownTask", "group": "inline@1" } diff --git a/apps/vscode/src/connection/connection.ts b/apps/vscode/src/connection/connection.ts index 6bbd08ccae..53751ddae1 100644 --- a/apps/vscode/src/connection/connection.ts +++ b/apps/vscode/src/connection/connection.ts @@ -316,6 +316,18 @@ export class ConnectionManager extends EventEmitter { uri, module: 'CONN-EXT', onEvent: async (message: DAPMessage) => { + if (message.event === 'output') { + const body = message.body; + if (body?.output) { + const text = String(body.output).trimEnd(); + if (text) { + const source = body.__id ? `[${body.__id}] ` : ''; + this.logger.output(`${icons.receive} ${source}${text}`); + } + } + } else if (message.event?.startsWith('apaevt_')) { + this.logger.output(`${icons.info} ${message.event}: ${JSON.stringify(message.body)}`); + } this.emit('event', message); }, onDisconnected: async (reason?: string, hasError?: boolean) => { @@ -447,6 +459,13 @@ export class ConnectionManager extends EventEmitter { this.logger.output(`${icons.success} Connected to RocketRide server`); this.emit('connected'); + // Register global monitors for task lifecycle and output events + this.request('rrext_monitor', { + types: ['task', 'output'] + }, '*').catch(err => { + this.logger.error(`Failed to register global monitors: ${err}`); + }); + // Fetch and cache services list during connection phase this.refreshServices().catch(err => { this.logger.error(`Failed to fetch services on connect: ${err}`); diff --git a/apps/vscode/src/providers/PageEditorProvider.ts b/apps/vscode/src/providers/PageEditorProvider.ts index c14261e774..9b6d868c36 100644 --- a/apps/vscode/src/providers/PageEditorProvider.ts +++ b/apps/vscode/src/providers/PageEditorProvider.ts @@ -656,7 +656,7 @@ export class PageEditorProvider implements vscode.CustomTextEditorProvider { projectId: projectId, source: source, pipeline: projectTransformed - }, '*'); + }); } catch (error: unknown) { const message = error instanceof Error ? error.message : String(error); diff --git a/apps/vscode/src/providers/PageStatusProvider.ts b/apps/vscode/src/providers/PageStatusProvider.ts index d895cd4402..dd6fe37e3f 100644 --- a/apps/vscode/src/providers/PageStatusProvider.ts +++ b/apps/vscode/src/providers/PageStatusProvider.ts @@ -235,7 +235,7 @@ export class PageStatusProvider { await this.connectionManager.request('rrext_monitor', { projectId: projectId, source: sourceId, - types: ['summary'] + types: ['summary', 'flow'] }); // Mark as monitoring @@ -413,6 +413,12 @@ export class PageStatusProvider { private async handlePanelDisposal(projectId: string, sourceId: string): Promise { const key = `${projectId}.${sourceId}`; + // Mark as disposed immediately to prevent events from reaching the webview + const viewState = this.webviewPanels.get(key); + if (viewState) { + viewState.isDisposed = true; + } + // Stop monitoring before cleanup try { await this.stopMonitoring(projectId, sourceId); @@ -777,28 +783,23 @@ export class PageStatusProvider { // Read the pipeline file const fileContent = await vscode.workspace.fs.readFile(viewState.fileUri); - // Get it into a a string + // Get it into a string const pipelineText = Buffer.from(fileContent).toString('utf8'); // Convert to json const pipelineJson = JSON.parse(pipelineText); - // Substitute and .env settings + // Substitute .env settings const pipelineTransformed = ConfigManager.getInstance().substituteEnvVariables(pipelineJson); // Use DAP command to execute pipeline without debugging try { - const info = await this.connectionManager.request('execute', { + await this.connectionManager.request('execute', { projectId: viewState.projectId, source: viewState.sourceId, pipeline: pipelineTransformed, - args: [ - '--trace=servicePython,debugOut,debugProtocol' - ] - }, '*'); - - console.log(info); - + pipelineTraceLevel: 'full' + }); } catch (error: unknown) { this.logger.error(`Unable to execute pipeline: ${error}`); vscode.window.showErrorMessage(String(error)); diff --git a/apps/vscode/src/providers/SidebarFilesProvider.ts b/apps/vscode/src/providers/SidebarFilesProvider.ts index 7f98f9422f..e8e32800a5 100644 --- a/apps/vscode/src/providers/SidebarFilesProvider.ts +++ b/apps/vscode/src/providers/SidebarFilesProvider.ts @@ -193,17 +193,28 @@ export class SidebarFilesProvider implements vscode.TreeDataProvider { + if (!item) { + vscode.window.showErrorMessage('No pipeline selected'); + return; + } + + let projectId: string | undefined; + let sourceId: string | undefined; + + if (item.contextValue?.startsWith('pipelineSource')) { + const parsedFile = item.parsedFile || this.getParsedPipeline(item.resourceUri); + projectId = parsedFile?.projectId; + sourceId = item.sourceComponent?.id; + } else if (item.contextValue === 'unknownTask' && item.unknownTask) { + projectId = item.unknownTask.projectId; + sourceId = item.unknownTask.sourceId; + } + + if (!projectId || !sourceId) { + vscode.window.showErrorMessage('Could not determine pipeline to stop'); + return; + } + + try { + const response = await this.connectionManager.request('rrext_get_token', { + projectId: projectId, + source: sourceId + }) as GenericResponse | undefined; + + const token = response?.body?.token as string | undefined; + + await this.connectionManager.request('terminate', {}, token); + } catch (error: unknown) { + this.logger.error(`Unable to stop pipeline: ${error}`); + vscode.window.showErrorMessage(`Failed to stop pipeline: ${error}`); + } }) ]; @@ -327,10 +376,7 @@ export class SidebarFilesProvider implements vscode.TreeDataProvider { - // Turn on the task monitors - this.connectionManager.request('rrext_monitor', { - "types": ["task"] - }, '*'); + // Global task/output monitors are now registered in ConnectionManager.onConnectionEstablished }); // Listen for disconnected events diff --git a/c.bat b/c.bat deleted file mode 100644 index 73530759b0..0000000000 --- a/c.bat +++ /dev/null @@ -1,3 +0,0 @@ -call builder vscode:clean vscode:build -call code --uninstall-extension rocketride.rocketride -call code --install-extension dist\vscode\rocketride-0.0.1.vsix diff --git a/nodes/src/nodes/embedding_transformer/sentenceTransformer.py b/nodes/src/nodes/embedding_transformer/sentenceTransformer.py index d105686a7c..e4439101ba 100644 --- a/nodes/src/nodes/embedding_transformer/sentenceTransformer.py +++ b/nodes/src/nodes/embedding_transformer/sentenceTransformer.py @@ -91,8 +91,8 @@ def __init__(self, provider: str, connConfig: Dict[str, Any], bag: Dict[str, Any debug(f' Embedding size : {self._vectorSize}') debug(f' Embedding tokens : {self._tokenSize}') - # Output monitor status to show model loading finished - monitorStatus('Loading model complete', self._model) + # Clear the output, we are done loading + monitorStatus('') def getVectorSize(self) -> int: """Return the vector size of the embedding module.""" diff --git a/packages/ai/src/ai/common/dap/transport_stdio.py b/packages/ai/src/ai/common/dap/transport_stdio.py index 74787d53e5..9d6d7f362b 100644 --- a/packages/ai/src/ai/common/dap/transport_stdio.py +++ b/packages/ai/src/ai/common/dap/transport_stdio.py @@ -701,7 +701,7 @@ async def _process_message(self, channel: str, message: Optional[str]) -> None: # Parse debug command messages: '>DBG*operation*id*total_pipes*pipe_id' elif message.startswith('>DBG*'): try: - _, op, id, total_pipes, pipe_id = message.split('*', 4) + _, op, id, total_pipes, pipe_id, trace = message.split('*', 5) await self._transport_receive( { 'type': 'event', @@ -711,6 +711,7 @@ async def _process_message(self, channel: str, message: Optional[str]) -> None: 'id': int(id, 16), 'total_pipes': int(total_pipes, 16), 'pipe_id': pipe_id, + 'trace': trace }, } ) diff --git a/packages/ai/src/ai/modules/task/commands/cmd_monitor.py b/packages/ai/src/ai/modules/task/commands/cmd_monitor.py index d5d7f50183..7220e69b75 100644 --- a/packages/ai/src/ai/modules/task/commands/cmd_monitor.py +++ b/packages/ai/src/ai/modules/task/commands/cmd_monitor.py @@ -112,7 +112,7 @@ async def forward_event( async def _send_event(pref: EVENT_TYPE) -> None: # If this is not being listened for, skip the forwarding - if not (type & subscriber_preference): + if not (type & pref): return # Extract event details for DAP-compliant forwarding @@ -136,13 +136,7 @@ async def _send_event(pref: EVENT_TYPE) -> None: if control.apikey != self._account_info.apikey: return - # Check if any monitor is subscribed to this specific task or project - task_key = f't.{token}' - if task_key in self._monitors: - # Get the subscriber's event type for this specific token - subscriber_preference = self._monitors[task_key] - await _send_event(subscriber_preference) - + # Check if any monitor is subscribed to this project/source project_key = f'p.{control.project_id}.{control.source}' if project_key in self._monitors: # Get the subscriber's event type for this specific token @@ -158,7 +152,7 @@ async def _send_event(pref: EVENT_TYPE) -> None: async def _send_updates( self, - control: 'TASK_CONTROL', + control: 'TASK_CONTROL | None', prev: EVENT_TYPE, curr: EVENT_TYPE, project_id: str = None, @@ -275,27 +269,19 @@ async def set_monitor( event_id = None filter_name = '' - # If a token is specified, add it + # If a token is specified, resolve it to project_id/source elif token: # Only token can be specified if project_id or source: raise ValueError('You must specifiy either token or project_id/source, not both') - # Setup the key - event_key = f't.{token}' - - # If is ok if the task doesn't exist at this point in time... - try: - # Get the task - control = self._server.get_task_control(token) + # Resolve the token to a project key + control = self._server.get_task_control(token) - # The task is running, we can fill it in - event_id = control.id - filter_name = control.id - - except Exception: - event_id = None - filter_name = f'' + # Use the project key so subscribe/unsubscribe by token or project_id/source use the same key + event_key = f'p.{control.project_id}.{control.source}' + event_id = control.id + filter_name = control.id # If project/source we specified elif project_id and source: diff --git a/packages/ai/src/ai/modules/task/task_engine.py b/packages/ai/src/ai/modules/task/task_engine.py index 3831b5442d..a667a49777 100644 --- a/packages/ai/src/ai/modules/task/task_engine.py +++ b/packages/ai/src/ai/modules/task/task_engine.py @@ -237,7 +237,7 @@ def __init__( # Execution configuration self._threads = launch_args.get('threads', CONST_DEFAULT_MAX_THREADS) - self._trace = launch_args.get('trace', None) + self._pipelineTraceLevel = launch_args.get('pipelineTraceLevel', None) self._engine_process: Optional[asyncio.subprocess.Process] = None # Status tracking @@ -371,19 +371,22 @@ def _build_task(self) -> Dict[str, Any]: os.makedirs(data_path, exist_ok=True) - return { - 'config': { - 'keystore': 'kvsfile://data/keystore.json', - 'pipeline': { - 'version': self._pipeline.get('version', 1), - 'source': self._pipeline.get('source'), - 'project_id': self._pipeline.get('project_id'), - 'name': self._pipeline.get('name'), - 'description': self._pipeline.get('description'), - 'components': self._pipeline.get('components', []), - }, - 'threadCount': self._threads, + config = { + 'keystore': 'kvsfile://data/keystore.json', + 'pipeline': { + 'version': self._pipeline.get('version', 1), + 'source': self._pipeline.get('source'), + 'project_id': self._pipeline.get('project_id'), + 'name': self._pipeline.get('name'), + 'description': self._pipeline.get('description'), + 'components': self._pipeline.get('components', []), }, + 'threadCount': self._threads, + 'pipelineTraceLevel': self._pipelineTraceLevel or None + } + + return { + 'config': config, 'paths': {'base': data_path}, 'nodeId': '9a0b9f66-f693-4b3b-a85b-bb810261c26e', 'taskId': self.token, @@ -1435,9 +1438,6 @@ async def start_task(self) -> None: if modelserver: child_args.append(f'--modelserver={modelserver}') - if self._trace: - child_args.append(f'--trace={self._trace}') - user_args = self._launch_args.get('args', []) child_args.extend(user_args) diff --git a/packages/ai/src/ai/modules/task/task_server.py b/packages/ai/src/ai/modules/task/task_server.py index 114b24f98f..b5e65dc97e 100644 --- a/packages/ai/src/ai/modules/task/task_server.py +++ b/packages/ai/src/ai/modules/task/task_server.py @@ -1025,13 +1025,6 @@ def _return_results(control: TASK_CONTROL) -> str: if current_count > self._tasks_peak: self._tasks_peak = current_count - # Set up initial update summary monitoring if connection provided - if conn: - await conn.set_monitor( - token=control.token, - type=EVENT_TYPE.SUMMARY, - ) - # Start task execution await control.task.start_task() diff --git a/packages/client-python/src/rocketride/mixins/execution.py b/packages/client-python/src/rocketride/mixins/execution.py index 2430a9ae4c..49680353e7 100644 --- a/packages/client-python/src/rocketride/mixins/execution.py +++ b/packages/client-python/src/rocketride/mixins/execution.py @@ -150,6 +150,7 @@ async def use( use_existing: bool = None, args: List[str] = None, ttl: int = None, + pipelineTraceLevel: str = None, ) -> Dict[str, Any]: """ Start an RocketRide pipeline for processing data. @@ -172,6 +173,7 @@ async def use( use_existing: Whether to reuse existing pipeline with same token args: Command-line style arguments to pass to the pipeline ttl: Time-to-live in seconds for idle pipelines (optional, server default if not provided; use 0 for no timeout) + pipelineTraceLevel: Pipeline trace level ('none', 'metadata', 'summary', 'full'). When set, captures every lane write and invoke call in the response under '_trace'. Returns: Dict containing: @@ -277,6 +279,8 @@ async def use( arguments['threads'] = threads if use_existing is not None: arguments['useExisting'] = use_existing + if pipelineTraceLevel is not None: + arguments['pipelineTraceLevel'] = pipelineTraceLevel # Send execution request to server request = self.build_request(command='execute', arguments=arguments) diff --git a/packages/client-typescript/src/client/client.ts b/packages/client-typescript/src/client/client.ts index 365fd1e27e..b23059a1de 100644 --- a/packages/client-typescript/src/client/client.ts +++ b/packages/client-typescript/src/client/client.ts @@ -790,6 +790,8 @@ export class RocketRideClient extends DAPClient { useExisting?: boolean; args?: string[]; ttl?: number; + /** Pipeline trace level. When set, captures every lane write and invoke call in the response under '_trace'. */ + pipelineTraceLevel?: 'none' | 'metadata' | 'summary' | 'full'; } = {}): Promise & { token: string }> { const { token, @@ -799,7 +801,8 @@ export class RocketRideClient extends DAPClient { threads, useExisting, args, - ttl + ttl, + pipelineTraceLevel } = options; // Validate required parameters @@ -856,6 +859,9 @@ export class RocketRideClient extends DAPClient { if (useExisting !== undefined) { arguments_.useExisting = useExisting; } + if (pipelineTraceLevel !== undefined) { + arguments_.pipelineTraceLevel = pipelineTraceLevel; + } // Send execution request to server const request = this.buildRequest('execute', { arguments: arguments_ }); diff --git a/packages/server/engine-lib/engLib/python/init.cpp b/packages/server/engine-lib/engLib/python/init.cpp index 8b6f0ae5f7..c33bb1ebbc 100644 --- a/packages/server/engine-lib/engLib/python/init.cpp +++ b/packages/server/engine-lib/engLib/python/init.cpp @@ -22,7 +22,6 @@ // ============================================================================= #include - #include #ifdef _WIN32 #include // for _O_RDONLY @@ -112,7 +111,7 @@ Error setPaths() { for (auto devRoot : {"../..", "../../.."}) { auto pkgRoot = (root / devRoot / "packages").resolve(); - for (auto pkgPath : {"server/engine-lib/rocketride-python/lib", + for (auto pkgPath : {"server/engine-lib/rocketlib-python/lib", "client-python/src", "ai/src"}) paths.push_back((pkgRoot / pkgPath).resolve().str()); diff --git a/packages/server/engine-lib/engLib/store/core/binder.cpp b/packages/server/engine-lib/engLib/store/core/binder.cpp index ac609f0fa3..acb8a19b98 100644 --- a/packages/server/engine-lib/engLib/store/core/binder.cpp +++ b/packages/server/engine-lib/engLib/store/core/binder.cpp @@ -89,7 +89,8 @@ Error Binder::bind(const std::string &methodName, */ Error Binder::callMethods( Binder *pThis, const std::string &methodName, - std::function callback) noexcept { + std::function callback, + const json::Value &traceData) noexcept { Error ccode; // Ensure the instance is operating in target mode @@ -106,10 +107,23 @@ Error Binder::callMethods( if (it == pThis->methodMap.end() || !it->second) return {}; // No bound instances, return success + // Get the trace level + auto traceLevel = + pThis->m_pInstance->endpoint->config.pipelineTraceLevel; + // Iterate over bound instances and invoke the callback for (auto *pInstance : *(it->second)) { + // Build enter trace if tracing is enabled + json::Value enterTrace; + if (traceLevel > 0) { + enterTrace["lane"] = methodName.c_str(); + enterTrace["pipeId"] = pInstance->pipeId; + enterTrace["provider"] = pInstance->pipeType.logicalType; + if (traceData) enterTrace["data"] = traceData; + } + // Signal to the debugger we are entering a level - pThis->m_pInstance->pipe->debugger.debugEnter(pInstance); + pThis->m_pInstance->pipe->debugger.debugEnter(pInstance, enterTrace); // Break if we need to pThis->m_pInstance->pipe->debugger.debugBreak(pThis->m_pInstance, @@ -121,14 +135,37 @@ Error Binder::callMethods( pThis->m_pInstance->pipe->debugger.debugError( pThis->m_pInstance, pInstance, methodName, ccode); + // Build leave trace with error result + json::Value leaveTrace; + if (traceLevel > 0) { + leaveTrace["lane"] = methodName.c_str(); + leaveTrace["pipeId"] = pInstance->pipeId; + if (ccode.code() == Ec::PreventDefault) { + leaveTrace["result"] = "skip"; + } else { + leaveTrace["result"] = "error"; + leaveTrace["data"]["error"] = ccode.message(); + } + } + // Signal to the debugger we are leaving a level - pThis->m_pInstance->pipe->debugger.debugLeave(pInstance); + pThis->m_pInstance->pipe->debugger.debugLeave(pInstance, + leaveTrace); // Stop on the first error break; } else { + // Build leave trace with continue result + json::Value leaveTrace; + if (traceLevel > 0) { + leaveTrace["lane"] = methodName.c_str(); + leaveTrace["pipeId"] = pInstance->pipeId; + leaveTrace["result"] = "continue"; + } + // Signal to the debugger we are leaving a level - pThis->m_pInstance->pipe->debugger.debugLeave(pInstance); + pThis->m_pInstance->pipe->debugger.debugLeave(pInstance, + leaveTrace); } } return ccode; @@ -221,10 +258,16 @@ Error Binder::writeTag(const TAG *pTag) noexcept { * @return Error Returns an error code if any instance fails, otherwise success. */ Error Binder::writeText(const Utf16View &text) noexcept { - // Call the methods - return callMethods( - this, "text", - localfcn(auto pInstance)->Error { return pInstance->writeText(text); }); + auto call = localfcn(auto pInstance)->Error { + return pInstance->writeText(text); + }; + json::Value data; + auto traceLevel = m_pInstance->endpoint->config.pipelineTraceLevel; + if (traceLevel >= 2) { + data["length"] = (int)text.length(); + if (traceLevel >= 3) data["text"] = _tr(text).substr(0, 2000); + } + return callMethods(this, "text", call, data); } /** @@ -234,11 +277,16 @@ Error Binder::writeText(const Utf16View &text) noexcept { * @return Error Returns an error code if any instance fails, otherwise success. */ Error Binder::writeTable(const Utf16View &text) noexcept { - // Call the methods - return callMethods( - this, "table", localfcn(auto pInstance)->Error { - return pInstance->writeTable(text); - }); + auto call = localfcn(auto pInstance)->Error { + return pInstance->writeTable(text); + }; + json::Value data; + auto traceLevel = m_pInstance->endpoint->config.pipelineTraceLevel; + if (traceLevel >= 2) { + data["length"] = (int)text.length(); + if (traceLevel >= 3) data["table"] = _tr(text).substr(0, 2000); + } + return callMethods(this, "table", call, data); } /** @@ -265,11 +313,17 @@ Error Binder::writeWords(const WordVector &textWords) noexcept { */ Error Binder::writeAudio(const AVI_ACTION action, Text &mimeType, const pybind11::bytes &streamData) noexcept { - // Call the methods - return callMethods( - this, "audio", localfcn(auto pInstance)->Error { - return pInstance->writeAudio(action, mimeType, streamData); - }); + auto call = localfcn(auto pInstance)->Error { + return pInstance->writeAudio(action, mimeType, streamData); + }; + json::Value data; + if (m_pInstance->endpoint->config.pipelineTraceLevel >= 2) { + data["action"] = (int)action; + data["mimeType"] = mimeType; + engine::python::LockPython lock; + data["bufferSize"] = (int)PyBytes_GET_SIZE(streamData.ptr()); + } + return callMethods(this, "audio", call, data); } /** @@ -282,11 +336,17 @@ Error Binder::writeAudio(const AVI_ACTION action, Text &mimeType, */ Error Binder::writeVideo(const AVI_ACTION action, Text &mimeType, const pybind11::bytes &streamData) noexcept { - // Call the methods - return callMethods( - this, "video", localfcn(auto pInstance)->Error { - return pInstance->writeVideo(action, mimeType, streamData); - }); + auto call = localfcn(auto pInstance)->Error { + return pInstance->writeVideo(action, mimeType, streamData); + }; + json::Value data; + if (m_pInstance->endpoint->config.pipelineTraceLevel >= 2) { + data["action"] = (int)action; + data["mimeType"] = mimeType; + engine::python::LockPython lock; + data["bufferSize"] = (int)PyBytes_GET_SIZE(streamData.ptr()); + } + return callMethods(this, "video", call, data); } /** @@ -299,11 +359,17 @@ Error Binder::writeVideo(const AVI_ACTION action, Text &mimeType, */ Error Binder::writeImage(const AVI_ACTION action, Text &mimeType, const pybind11::bytes &streamData) noexcept { - // Call the methods - return callMethods( - this, "image", localfcn(auto pInstance)->Error { - return pInstance->writeImage(action, mimeType, streamData); - }); + auto call = localfcn(auto pInstance)->Error { + return pInstance->writeImage(action, mimeType, streamData); + }; + json::Value data; + if (m_pInstance->endpoint->config.pipelineTraceLevel >= 2) { + data["action"] = (int)action; + data["mimeType"] = mimeType; + engine::python::LockPython lock; + data["bufferSize"] = (int)PyBytes_GET_SIZE(streamData.ptr()); + } + return callMethods(this, "image", call, data); } /** @@ -313,11 +379,15 @@ Error Binder::writeImage(const AVI_ACTION action, Text &mimeType, * @return Error Returns an error code if any instance fails, otherwise success. */ Error Binder::writeQuestions(const pybind11::object &question) noexcept { - // Call the methods - return callMethods( - this, "questions", localfcn(auto pInstance)->Error { - return pInstance->writeQuestions(question); - }); + auto call = localfcn(auto pInstance)->Error { + return pInstance->writeQuestions(question); + }; + json::Value data; + if (m_pInstance->endpoint->config.pipelineTraceLevel >= 2) { + engine::python::LockPython lock; + data["type"] = std::string(py::str(question.get_type().attr("__name__"))).c_str(); + } + return callMethods(this, "questions", call, data); } /** @@ -327,11 +397,15 @@ Error Binder::writeQuestions(const pybind11::object &question) noexcept { * @return Error Returns an error code if any instance fails, otherwise success. */ Error Binder::writeAnswers(const pybind11::object &answers) noexcept { - // Call the methods - return callMethods( - this, "answers", localfcn(auto pInstance)->Error { - return pInstance->writeAnswers(answers); - }); + auto call = localfcn(auto pInstance)->Error { + return pInstance->writeAnswers(answers); + }; + json::Value data; + if (m_pInstance->endpoint->config.pipelineTraceLevel >= 2) { + engine::python::LockPython lock; + data["type"] = std::string(py::str(answers.get_type().attr("__name__"))).c_str(); + } + return callMethods(this, "answers", call, data); } /** @@ -343,12 +417,15 @@ Error Binder::writeAnswers(const pybind11::object &answers) noexcept { Error Binder::writeClassifications( const json::Value &classifications, const json::Value &classificationPolicy, const json::Value &classificationRules) noexcept { - // Call the methods - return callMethods( - this, "classifications", localfcn(auto pInstance)->Error { - return pInstance->writeClassifications( - classifications, classificationPolicy, classificationRules); - }); + auto call = localfcn(auto pInstance)->Error { + return pInstance->writeClassifications( + classifications, classificationPolicy, classificationRules); + }; + json::Value data; + if (m_pInstance->endpoint->config.pipelineTraceLevel >= 2) { + data["count"] = (int)classifications.size(); + } + return callMethods(this, "classifications", call, data); } /** @@ -359,11 +436,14 @@ Error Binder::writeClassifications( */ Error Binder::writeClassificationContext( const json::Value &classifications) noexcept { - // Call the methods - return callMethods( - this, "classificationContext", localfcn(auto pInstance)->Error { - return pInstance->writeClassificationContext(classifications); - }); + auto call = localfcn(auto pInstance)->Error { + return pInstance->writeClassificationContext(classifications); + }; + json::Value data; + if (m_pInstance->endpoint->config.pipelineTraceLevel >= 2) { + data["count"] = (int)classifications.size(); + } + return callMethods(this, "classificationContext", call, data); } /** @@ -373,11 +453,15 @@ Error Binder::writeClassificationContext( * @return Error Returns an error code if any instance fails, otherwise success. */ Error Binder::writeDocuments(const pybind11::object &documents) noexcept { - // Call the methods - return callMethods( - this, "documents", localfcn(auto pInstance)->Error { - return pInstance->writeDocuments(documents); - }); + auto call = localfcn(auto pInstance)->Error { + return pInstance->writeDocuments(documents); + }; + json::Value data; + if (m_pInstance->endpoint->config.pipelineTraceLevel >= 2) { + engine::python::LockPython lock; + data["count"] = (int)py::len(documents); + } + return callMethods(this, "documents", call, data); } /** diff --git a/packages/server/engine-lib/engLib/store/core/debugger.cpp b/packages/server/engine-lib/engLib/store/core/debugger.cpp index 8d78ad9672..ed57586759 100644 --- a/packages/server/engine-lib/engLib/store/core/debugger.cpp +++ b/packages/server/engine-lib/engLib/store/core/debugger.cpp @@ -47,7 +47,8 @@ std::unordered_map * * @param pInstance Pointer to the service instance being entered. */ -void Debugger::debugEnter(IServiceFilterInstance* pInstance) noexcept { +void Debugger::debugEnter(IServiceFilterInstance* pInstance, + const json::Value& trace) noexcept { m_recurseLevel++; // Track depth of recursive calls if (::engine::config::monitor()->isAppMonitor()) { @@ -55,7 +56,8 @@ void Debugger::debugEnter(IServiceFilterInstance* pInstance) noexcept { StackText msg; _tsbo(msg, {Format::HEX, {}, '*'}, "ENTER", pInstance->pipeId, pInstance->endpoint->getPipeCount(), - pInstance->pipeType.logicalType); + pInstance->pipeType.logicalType, + trace.stringify()); ::engine::config::monitor()->other("DBG", msg); } @@ -68,7 +70,8 @@ void Debugger::debugEnter(IServiceFilterInstance* pInstance) noexcept { * * @param pInstance Pointer to the service instance being exited. */ -void Debugger::debugLeave(IServiceFilterInstance* pInstance) noexcept { +void Debugger::debugLeave(IServiceFilterInstance* pInstance, + const json::Value& trace) noexcept { m_recurseLevel--; if (::engine::config::monitor()->isAppMonitor()) { @@ -76,7 +79,8 @@ void Debugger::debugLeave(IServiceFilterInstance* pInstance) noexcept { StackText msg; _tsbo(msg, {Format::HEX, {}, '*'}, "LEAVE", pInstance->pipeId, pInstance->endpoint->getPipeCount(), - pInstance->pipeType.logicalType); + pInstance->pipeType.logicalType, + trace.stringify()); ::engine::config::monitor()->other("DBG", msg); } diff --git a/packages/server/engine-lib/engLib/store/core/endpoint/endpoint.config.cpp b/packages/server/engine-lib/engLib/store/core/endpoint/endpoint.config.cpp index b8c3e22ff8..2aeea3923e 100644 --- a/packages/server/engine-lib/engLib/store/core/endpoint/endpoint.config.cpp +++ b/packages/server/engine-lib/engLib/store/core/endpoint/endpoint.config.cpp @@ -275,6 +275,16 @@ Error IServiceEndpoint::setConfig(const json::Value &_jobConfig, else config.exportUpdateBehavior = EXPORT_UPDATE_BEHAVIOR::UNKNOWN; + // Lookup the pipeline trace level + Text traceLevelStr; + config.taskConfig.lookupAssign("pipelineTraceLevel", traceLevelStr); + if (traceLevelStr == "metadata"_tv) + config.pipelineTraceLevel = 1; + else if (traceLevelStr == "summary"_tv) + config.pipelineTraceLevel = 2; + else if (traceLevelStr == "full"_tv) + config.pipelineTraceLevel = 3; + // Done return ccode; } diff --git a/packages/server/engine-lib/engLib/store/core/filter/filter.callbacks.target.cpp b/packages/server/engine-lib/engLib/store/core/filter/filter.callbacks.target.cpp index aa13226e91..6c90976f01 100644 --- a/packages/server/engine-lib/engLib/store/core/filter/filter.callbacks.target.cpp +++ b/packages/server/engine-lib/engLib/store/core/filter/filter.callbacks.target.cpp @@ -75,6 +75,9 @@ void IServiceFilterInstance::cb_control(std::string &classType, throw APERR(Ec::InvalidParam, "No control listeners registered for ", classType); + // Get the trace level + auto traceLevel = endpoint->config.pipelineTraceLevel; + // Walk the filters we need to call. We will call them in order, until // one doesn't throw. If we go through all of them and they all throw, we // will throw an invalid parameter error @@ -83,17 +86,47 @@ void IServiceFilterInstance::cb_control(std::string &classType, ServiceInstance filter = this->endpoint->m_instanceStacks[this->pipeId][filterId]; + // Build enter trace if tracing is enabled + json::Value enterTrace; + if (traceLevel > 0) { + enterTrace["lane"] = "invoke"; + enterTrace["pipeId"] = filter->pipeId; + enterTrace["provider"] = filter->pipeType.logicalType; + if (traceLevel >= 2) enterTrace["data"]["classType"] = classType.c_str(); + } + this->pipe->debugger.debugEnter(filter.get(), enterTrace); + // Call the control function ccode = filter->control(control); + // Build leave trace + json::Value leaveTrace; + if (traceLevel > 0) { + leaveTrace["lane"] = "invoke"; + leaveTrace["pipeId"] = filter->pipeId; + } + // If we succeeded, we are done - if (!ccode) return; + if (!ccode) { + if (traceLevel > 0) leaveTrace["result"] = "continue"; + this->pipe->debugger.debugLeave(filter.get(), leaveTrace); + return; + } // If it is preventDefault, continue on to the next driver - if (ccode.code() == Ec::PreventDefault) continue; + if (ccode.code() == Ec::PreventDefault) { + if (traceLevel > 0) leaveTrace["result"] = "skip"; + this->pipe->debugger.debugLeave(filter.get(), leaveTrace); + continue; + } // Throw the error - it is not 0, and it is not prevent default // so it is a terminal error + if (traceLevel > 0) { + leaveTrace["result"] = "error"; + leaveTrace["data"]["error"] = ccode.message(); + } + this->pipe->debugger.debugLeave(filter.get(), leaveTrace); throw ccode; } diff --git a/packages/server/engine-lib/engLib/store/headers/binder.hpp b/packages/server/engine-lib/engLib/store/headers/binder.hpp index c7b83d1d64..c1cf9e7e3c 100644 --- a/packages/server/engine-lib/engLib/store/headers/binder.hpp +++ b/packages/server/engine-lib/engLib/store/headers/binder.hpp @@ -92,7 +92,8 @@ class Binder { static Error callMethods( Binder *pThis, const std::string &methodName, - std::function fcn) noexcept; + std::function fcn, + const json::Value &traceData = {}) noexcept; //----------------------------------------------------------------- /// @details diff --git a/packages/server/engine-lib/engLib/store/headers/config.hpp b/packages/server/engine-lib/engLib/store/headers/config.hpp index 16d157078a..33c431fce0 100644 --- a/packages/server/engine-lib/engLib/store/headers/config.hpp +++ b/packages/server/engine-lib/engLib/store/headers/config.hpp @@ -172,5 +172,11 @@ struct IServiceConfig { pipeline::PipelineConfig pipeline; bool flatten = false; + + //----------------------------------------------------------------- + /// @details + /// Pipeline trace level: 0=none, 1=metadata, 2=summary, 3=full + //----------------------------------------------------------------- + int pipelineTraceLevel = 0; }; } // namespace engine::store diff --git a/packages/server/engine-lib/engLib/store/headers/debugger.hpp b/packages/server/engine-lib/engLib/store/headers/debugger.hpp index d84b84a787..180b436fb3 100644 --- a/packages/server/engine-lib/engLib/store/headers/debugger.hpp +++ b/packages/server/engine-lib/engLib/store/headers/debugger.hpp @@ -137,19 +137,25 @@ class Debugger { * @brief Called when a service instance is entered. * * Increments internal recursion tracking and logs entry. + * If trace is non-null, appends it to the monitor message. * * @param pInstance Pointer to the service instance being entered. + * @param trace Optional JSON trace data to append to the monitor message. */ - void debugEnter(IServiceFilterInstance* pInstance) noexcept; + void debugEnter(IServiceFilterInstance* pInstance, + const json::Value& trace = {}) noexcept; /** * @brief Called when a service instance is exited. * * Decrements internal recursion tracking and logs exit. + * If trace is non-null, appends it to the monitor message. * * @param pInstance Pointer to the service instance being exited. + * @param trace Optional JSON trace data to append to the monitor message. */ - void debugLeave(IServiceFilterInstance* pInstance) noexcept; + void debugLeave(IServiceFilterInstance* pInstance, + const json::Value& trace = {}) noexcept; /** * @brief Called when a logical "break" is triggered between two service diff --git a/packages/server/engine-lib/test/store/pipeline/pipeline_config.cpp b/packages/server/engine-lib/test/store/pipeline/pipeline_config.cpp index e095825ed8..114d9bd51b 100644 --- a/packages/server/engine-lib/test/store/pipeline/pipeline_config.cpp +++ b/packages/server/engine-lib/test/store/pipeline/pipeline_config.cpp @@ -136,7 +136,7 @@ TEST_CASE("PipelineConfig") { SECTION("multiple") { pipeline["components"].append(R"({ "id": "source_2", - "provider": "smb", + "provider": "filesys", "config": {} })"_json); @@ -511,7 +511,7 @@ TEST_CASE("PipelineConfig") { SECTION("chain") { pipeline["components"].append(R"({ "id": "source_2", - "provider": "smb", + "provider": "filesys", "config": {} })"_json); diff --git a/packages/server/engine-lib/test/store/tests/services.cpp b/packages/server/engine-lib/test/store/tests/services.cpp index cf595aace7..6f259458de 100644 --- a/packages/server/engine-lib/test/store/tests/services.cpp +++ b/packages/server/engine-lib/test/store/tests/services.cpp @@ -41,524 +41,4 @@ TEST_CASE("store::Services") { REQUIRE(schema.isMember("services")); REQUIRE(schema["services"].isObject()); } - - json::Value &services = schema["services"]; - - SECTION("SourcesAndTarget") { - REQUIRE(services["aws"]); - REQUIRE(services["aws"]["Source"]); - REQUIRE(services["aws"]["Target"]); - } - - // Source - SECTION("SourcesFields") { - json::Value awsSource = services["aws"].lookup("Source"); - - REQUIRE(awsSource["schema"]); - REQUIRE(awsSource["ui"]); - } - - SECTION("SourcesSchemaFields") { - json::Value awsSourceSchema = - services["aws"].lookup("Source").lookup( - "schema"); - - REQUIRE(awsSourceSchema["properties"]); - REQUIRE(awsSourceSchema["properties"].isObject()); - REQUIRE(awsSourceSchema["required"]); - REQUIRE(awsSourceSchema["required"].isArray()); - REQUIRE(awsSourceSchema["title"]); - REQUIRE(awsSourceSchema["title"].isString()); - REQUIRE(awsSourceSchema["type"]); - REQUIRE(awsSourceSchema["type"].isString()); - } - - SECTION("SourcesUIFields") { - json::Value awsSourceSchema = - services["aws"].lookup("Source").lookup( - "ui"); - - REQUIRE(awsSourceSchema["estimation"]); - REQUIRE(awsSourceSchema["estimation"].isObject()); - REQUIRE(awsSourceSchema["exclude"]); - REQUIRE(awsSourceSchema["exclude"].isObject()); - REQUIRE(awsSourceSchema["include"]); - REQUIRE(awsSourceSchema["include"].isObject()); - REQUIRE(awsSourceSchema["mode"]); - REQUIRE(awsSourceSchema["mode"].isObject()); - REQUIRE(awsSourceSchema["parameters"]); - REQUIRE(awsSourceSchema["parameters"].isObject()); - REQUIRE(awsSourceSchema["type"]); - REQUIRE(awsSourceSchema["type"].isObject()); - REQUIRE(awsSourceSchema["ui:order"]); - REQUIRE(awsSourceSchema["ui:order"].isArray()); - - json::Value name = awsSourceSchema.lookup("name"); - REQUIRE(name.isObject()); - REQUIRE(name.lookup("ui:readonlyOnEdit") == true); - } - - SECTION("SourcesSchemaPropertiesFields") { - json::Value awsSourceSchemaProps = - services["aws"] - .lookup("Source") - .lookup("schema") - .lookup("properties"); - - REQUIRE(awsSourceSchemaProps["estimation"]); - REQUIRE(awsSourceSchemaProps["estimation"].isObject()); - REQUIRE(awsSourceSchemaProps["exclude"]); - REQUIRE(awsSourceSchemaProps["exclude"].isObject()); - REQUIRE(awsSourceSchemaProps["include"]); - REQUIRE(awsSourceSchemaProps["include"].isObject()); - REQUIRE(awsSourceSchemaProps["mode"]); - REQUIRE(awsSourceSchemaProps["mode"].isObject()); - REQUIRE(awsSourceSchemaProps["name"]); - REQUIRE(awsSourceSchemaProps["name"].isObject()); - REQUIRE(awsSourceSchemaProps["parameters"]); - REQUIRE(awsSourceSchemaProps["parameters"].isObject()); - REQUIRE(awsSourceSchemaProps["type"]); - REQUIRE(awsSourceSchemaProps["type"].isObject()); - } - - SECTION("SourcesSchemaCostEstimationPropertiesFields") { - json::Value awsSourceSchemaEstimationProps = - services["aws"] - .lookup("Source") - .lookup("schema") - .lookup("properties") - .lookup("estimation") - .lookup("properties"); - - REQUIRE(awsSourceSchemaEstimationProps.isObject()); - json::Value accessCost = - awsSourceSchemaEstimationProps.lookup("accessCost"); - REQUIRE(accessCost.isObject()); - REQUIRE(accessCost.lookup("default")); - REQUIRE(accessCost.lookup("description")); - REQUIRE(accessCost.lookup("minimum")); - REQUIRE(accessCost.lookup("title")); - REQUIRE(accessCost.lookup("type")); - json::Value accessDelay = - awsSourceSchemaEstimationProps.lookup("accessDelay"); - REQUIRE(accessDelay.isObject()); - REQUIRE(accessDelay.lookup("default")); - REQUIRE(accessDelay.lookup("description")); - REQUIRE(accessDelay.lookup("minimum")); - REQUIRE(accessDelay.lookup("title")); - REQUIRE(accessDelay.lookup("type")); - json::Value accessRate = - awsSourceSchemaEstimationProps.lookup("accessRate"); - REQUIRE(accessRate.isObject()); - REQUIRE(accessRate.lookup("default")); - REQUIRE(accessRate.lookup("description")); - REQUIRE(accessRate.lookup("minimum")); - REQUIRE(accessRate.lookup("title")); - REQUIRE(accessRate.lookup("type")); - json::Value storeCost = - awsSourceSchemaEstimationProps.lookup("storeCost"); - REQUIRE(storeCost.isObject()); - REQUIRE(storeCost.lookup("default")); - REQUIRE(storeCost.lookup("description")); - REQUIRE(storeCost.lookup("minimum")); - REQUIRE(storeCost.lookup("title")); - REQUIRE(storeCost.lookup("type")); - } - - SECTION("SourcesSchemaExcludePropertiesFields") { - json::Value awsSourceSchemaExclude = - services["aws"] - .lookup("Source") - .lookup("schema") - .lookup("properties") - .lookup("exclude"); - - REQUIRE(awsSourceSchemaExclude.isObject()); - REQUIRE(awsSourceSchemaExclude.lookup("title") == - "Exclude paths"); - REQUIRE(awsSourceSchemaExclude.lookup("type") == "array"); - json::Value items = awsSourceSchemaExclude.lookup("items"); - REQUIRE(items.isObject()); - REQUIRE(items.lookup("properties").isObject()); - REQUIRE(items.lookup("properties") - .lookup("path") - .isObject()); - REQUIRE(items.lookup("required").isArray()); - REQUIRE(items.lookup("type") == "object"); - } - - SECTION("SourcesSchemaIncludePropertiesFields") { - json::Value awsSourceSchemaExclude = - services["aws"] - .lookup("Source") - .lookup("schema") - .lookup("properties") - .lookup("include"); - - REQUIRE(awsSourceSchemaExclude.isObject()); - REQUIRE(awsSourceSchemaExclude.lookup("title") == - "Include paths"); - REQUIRE(awsSourceSchemaExclude.lookup("type") == "array"); - json::Value items = awsSourceSchemaExclude.lookup("items"); - REQUIRE(items.isObject()); - REQUIRE(items.lookup("properties").isObject()); - REQUIRE(items.lookup("properties") - .lookup("path") - .isObject()); - - json::Value dependencies = items.lookup("dependencies"); - REQUIRE(dependencies.isObject()); - - // Only Index is the dependency - REQUIRE(dependencies.lookup("index").isObject()); - json::Value oneOf = - dependencies.lookup("index").lookup( - "oneOf"); - REQUIRE(oneOf.isArray()); - REQUIRE(oneOf.size() >= 1); - json::Value properties = oneOf[0].lookup("properties"); - REQUIRE(properties.isObject()); - REQUIRE(properties.lookup("classify")); - REQUIRE(properties.lookup("ocr")); - } - - SECTION("SourcesSchemaModePropertiesFields") { - json::Value awsSourceSchemaMode = services["aws"] - .lookup("Source") - .lookup("schema") - .lookup("properties") - .lookup("mode"); - - REQUIRE(awsSourceSchemaMode.isObject()); - REQUIRE(awsSourceSchemaMode.lookup("default") == "Source"); - REQUIRE(awsSourceSchemaMode.lookup("type") == "string"); - } - - SECTION("SourcesSchemaModePropertiesFields") { - json::Value awsSourceSchemaMode = services["aws"] - .lookup("Source") - .lookup("schema") - .lookup("properties") - .lookup("mode"); - - REQUIRE(awsSourceSchemaMode.isObject()); - REQUIRE(awsSourceSchemaMode.lookup("default") == "Source"); - REQUIRE(awsSourceSchemaMode.lookup("type") == "string"); - } - - SECTION("SourcesSchemaNamePropertiesFields") { - json::Value awsSourceSchemaName = services["aws"] - .lookup("Source") - .lookup("schema") - .lookup("properties") - .lookup("name"); - - REQUIRE(awsSourceSchemaName.isObject()); - REQUIRE(awsSourceSchemaName.lookup("title") == - "Data Catalog Name"); - REQUIRE(awsSourceSchemaName.lookup("type") == "string"); - REQUIRE(awsSourceSchemaName.lookup("minLength") == 2); - REQUIRE(awsSourceSchemaName.lookup("maxLength") == 32); - } - - SECTION("SourcesSchemaParametersPropertiesFields") { - json::Value awsSourceSchemaParameters = - services["aws"] - .lookup("Source") - .lookup("schema") - .lookup("properties") - .lookup("parameters"); - - REQUIRE(awsSourceSchemaParameters.isObject()); - REQUIRE(awsSourceSchemaParameters.lookup("title") == - "Parameters"); - REQUIRE(awsSourceSchemaParameters.lookup("type") == "object"); - REQUIRE(awsSourceSchemaParameters.lookup("required") - .isArray()); - - json::Value properties = - awsSourceSchemaParameters.lookup("properties"); - REQUIRE(properties.isObject()); - REQUIRE(properties.lookup("accessKey").isObject()); - REQUIRE(properties.lookup("region").isObject()); - REQUIRE(properties.lookup("secretKey").isObject()); - } - - SECTION("SourcesSchemaUIEstimationPropertiesFields") { - json::Value awsSourceUiEstimation = - services["aws"] - .lookup("Source") - .lookup("ui") - .lookup("estimation"); - - REQUIRE(awsSourceUiEstimation.isObject()); - json::Value uiOrder = - awsSourceUiEstimation.lookup("ui:order"); - REQUIRE(uiOrder.isArray()); - REQUIRE(uiOrder.size() == 4); - REQUIRE(uiOrder[0] == "accessDelay"); - REQUIRE(uiOrder[1] == "accessRate"); - REQUIRE(uiOrder[2] == "storeCost"); - REQUIRE(uiOrder[3] == "accessCost"); - } - - SECTION("SourcesSchemaUIExclude") { - json::Value awsSourceUiExclude = services["aws"] - .lookup("Source") - .lookup("ui") - .lookup("exclude"); - - REQUIRE(awsSourceUiExclude.isObject()); - json::Value uiOrder = - awsSourceUiExclude.lookup("ui:order"); - REQUIRE(uiOrder.isArray()); - REQUIRE(uiOrder.size() == 1); - REQUIRE(uiOrder[0] == "items"); - - json::Value items = awsSourceUiExclude.lookup("items"); - REQUIRE(items.isObject()); - json::Value itemsUiOrder = items.lookup("ui:order"); - REQUIRE(itemsUiOrder.isArray()); - REQUIRE(itemsUiOrder.size() == 1); - REQUIRE(itemsUiOrder[0] == "path"); - } - - SECTION("SourcesSchemaUIInclude") { - json::Value awsSourceUiInclude = services["aws"] - .lookup("Source") - .lookup("ui") - .lookup("include"); - - REQUIRE(awsSourceUiInclude.isObject()); - json::Value uiOrder = - awsSourceUiInclude.lookup("ui:order"); - REQUIRE(uiOrder.isArray()); - REQUIRE(uiOrder.size() == 1); - REQUIRE(uiOrder[0] == "items"); - - json::Value items = awsSourceUiInclude.lookup("items"); - REQUIRE(items.isObject()); - json::Value itemsUiOrder = items.lookup("ui:order"); - REQUIRE(itemsUiOrder.isArray()); - REQUIRE(itemsUiOrder.size() == 7); - REQUIRE(itemsUiOrder[0] == "path"); - REQUIRE(itemsUiOrder[1] == "permissions"); - REQUIRE(itemsUiOrder[2] == "signing"); - REQUIRE(itemsUiOrder[3] == "index"); - REQUIRE(itemsUiOrder[4] == "vectorize"); - REQUIRE(itemsUiOrder[5] == "classify"); - REQUIRE(itemsUiOrder[6] == "ocr"); - } - - SECTION("SourcesSchemaUIIncludeChip") { - json::Value awsSourceUiInclude = services["aws"] - .lookup("Source") - .lookup("ui") - .lookup("include"); - - REQUIRE(awsSourceUiInclude.isObject()); - json::Value uiOrder = - awsSourceUiInclude.lookup("ui:order"); - REQUIRE(uiOrder.isArray()); - REQUIRE(uiOrder.size() == 1); - REQUIRE(uiOrder[0] == "items"); - - json::Value items = awsSourceUiInclude.lookup("items"); - REQUIRE(items.isObject()); - REQUIRE(items.lookup("signing").lookup("chip") == - "Signing"); - REQUIRE(items.lookup("index").lookup("chip") == - "Index"); - REQUIRE(items.lookup("permissions").lookup("chip") == - "Permissions"); - REQUIRE(items.lookup("classify").lookup("chip") == - "Classify"); - REQUIRE(items.lookup("ocr").lookup("chip") == "OCR"); - } - - // Target - - SECTION("TargetFields") { - json::Value awsSource = services["aws"]["Target"]; - - REQUIRE(awsSource["schema"]); - REQUIRE(awsSource["ui"]); - } - - SECTION("TargetSchemaFields") { - json::Value awsSourceSchema = - services["aws"].lookup("Target").lookup( - "schema"); - - REQUIRE(awsSourceSchema["properties"]); - REQUIRE(awsSourceSchema["properties"].isObject()); - REQUIRE(awsSourceSchema["required"]); - REQUIRE(awsSourceSchema["required"].isArray()); - REQUIRE(awsSourceSchema["title"]); - REQUIRE(awsSourceSchema["title"].isString()); - REQUIRE(awsSourceSchema["type"]); - REQUIRE(awsSourceSchema["type"].isString()); - } - - SECTION("TargetUIFields") { - json::Value awsSourceSchema = - services["aws"].lookup("Target").lookup( - "ui"); - - // REQUIRE(awsSourceSchema["estimation"]); - // REQUIRE(awsSourceSchema["estimation"].isObject()); - REQUIRE(awsSourceSchema["mode"]); - REQUIRE(awsSourceSchema["mode"].isObject()); - REQUIRE(awsSourceSchema["parameters"]); - REQUIRE(awsSourceSchema["parameters"].isObject()); - REQUIRE(awsSourceSchema["type"]); - REQUIRE(awsSourceSchema["type"].isObject()); - REQUIRE(awsSourceSchema["ui:order"]); - REQUIRE(awsSourceSchema["ui:order"].isArray()); - } - - // SECTION("TargetSchemaCostEstimationPropertiesFields") { - - // json::Value value = *res; - // json::Value awsTargetSchemaEstimationProps = - // value["aws"].lookup("Target") - // .lookup("schema") - // .lookup("properties") - // .lookup("estimation") - // .lookup("properties"); - - // REQUIRE(awsTargetSchemaEstimationProps.isObject()); - // json::Value accessCost = - // awsTargetSchemaEstimationProps.lookup("accessCost"); - // REQUIRE(accessCost.isObject()); - // REQUIRE(accessCost.lookup("default")); - // REQUIRE(accessCost.lookup("description")); - // REQUIRE(accessCost.lookup("minimum")); - // REQUIRE(accessCost.lookup("title")); - // REQUIRE(accessCost.lookup("type")); - // json::Value accessDelay = - // awsTargetSchemaEstimationProps.lookup("accessDelay"); - // REQUIRE(accessDelay.isObject()); - // REQUIRE(accessDelay.lookup("default")); - // REQUIRE(accessDelay.lookup("description")); - // REQUIRE(accessDelay.lookup("minimum")); - // REQUIRE(accessDelay.lookup("title")); - // REQUIRE(accessDelay.lookup("type")); - // json::Value accessRate = - // awsTargetSchemaEstimationProps.lookup("accessRate"); - // REQUIRE(accessRate.isObject()); - // REQUIRE(accessRate.lookup("default")); - // REQUIRE(accessRate.lookup("description")); - // REQUIRE(accessRate.lookup("minimum")); - // REQUIRE(accessRate.lookup("title")); - // REQUIRE(accessRate.lookup("type")); - // json::Value storeCost = - // awsTargetSchemaEstimationProps.lookup("storeCost"); - // REQUIRE(storeCost.isObject()); - // REQUIRE(storeCost.lookup("default")); - // REQUIRE(storeCost.lookup("description")); - // REQUIRE(storeCost.lookup("minimum")); - // REQUIRE(storeCost.lookup("title")); - // REQUIRE(storeCost.lookup("type")); - // } - - SECTION("TargetSchemaModePropertiesFields") { - json::Value awsTargetSchemaMode = services["aws"] - .lookup("Target") - .lookup("schema") - .lookup("properties") - .lookup("mode"); - - REQUIRE(awsTargetSchemaMode.isObject()); - REQUIRE(awsTargetSchemaMode.lookup("default") == "Target"); - REQUIRE(awsTargetSchemaMode.lookup("type") == "string"); - } - - // SECTION("TargetSchemaNamePropertiesFields") { - - // json::Value value = *res; - // json::Value awsTargetSchemaName = - // value["aws"].lookup("Target") - // .lookup("schema") - // .lookup("properties") - // .lookup("name"); - - // REQUIRE(awsTargetSchemaName.isObject()); - // REQUIRE(awsTargetSchemaName.lookup("title") == "Service Name"); - // REQUIRE(awsTargetSchemaName.lookup("type") == "string"); - // REQUIRE(awsTargetSchemaName.lookup("minLength") == 2); - // REQUIRE(awsTargetSchemaName.lookup("maxLength") == 32); - // } - - SECTION("TargetSchemaParametersPropertiesFields") { - json::Value awsTargetSchemaParameters = - services["aws"] - .lookup("Target") - .lookup("schema") - .lookup("properties") - .lookup("parameters"); - - REQUIRE(awsTargetSchemaParameters.isObject()); - // REQUIRE(awsTargetSchemaParameters.lookup("title") == - // "Parameters"); - REQUIRE(awsTargetSchemaParameters.lookup("type") == "object"); - REQUIRE(awsTargetSchemaParameters.lookup("required") - .isArray()); - - json::Value properties = - awsTargetSchemaParameters.lookup("properties"); - REQUIRE(properties.isObject()); - REQUIRE(properties.lookup("accessKey").isObject()); - REQUIRE(properties.lookup("region").isObject()); - REQUIRE(properties.lookup("secretKey").isObject()); - REQUIRE(properties.lookup("storePath").isObject()); - } - - // SECTION("TargetUIEstimationPropertiesFields") { - - // json::Value value = *res; - // json::Value awsTargetUiEstimation = - // value["aws"].lookup("Target") - // .lookup("ui") - // .lookup("estimation"); - - // REQUIRE(awsTargetUiEstimation.isObject()); - // json::Value uiOrder = - // awsTargetUiEstimation.lookup("ui:order"); - // REQUIRE(uiOrder.isArray()); - // REQUIRE(uiOrder.size() == 4); - // REQUIRE(uiOrder[0] == "accessDelay"); - // REQUIRE(uiOrder[1] == "accessRate"); - // REQUIRE(uiOrder[2] == "storeCost"); - // REQUIRE(uiOrder[3] == "accessCost"); - // } - - SECTION("TargetUIParametersPropertiesFields") { - json::Value awsTargetUiEstimation = - services["aws"] - .lookup("Target") - .lookup("ui") - .lookup("parameters"); - - REQUIRE(awsTargetUiEstimation.isObject()); - json::Value uiOrder = - awsTargetUiEstimation.lookup("ui:order"); - REQUIRE(uiOrder.isArray()); - REQUIRE(uiOrder.size() == 4); - REQUIRE(uiOrder[0] == "storePath"); - REQUIRE(uiOrder[1] == "accessKey"); - REQUIRE(uiOrder[2] == "secretKey"); - REQUIRE(uiOrder[3] == "region"); - - json::Value accessKey = - awsTargetUiEstimation.lookup("accessKey"); - REQUIRE(accessKey.isObject()); - REQUIRE(accessKey.lookup("ui:secure") == true); - - json::Value secretKey = - awsTargetUiEstimation.lookup("secretKey"); - REQUIRE(secretKey.isObject()); - REQUIRE(secretKey.lookup("ui:secure") == true); - REQUIRE(secretKey.lookup("ui:widget") == "password"); - } } diff --git a/scripts/lib/download.js b/scripts/lib/download.js index 3c485c5bff..1e5c19fe2a 100644 --- a/scripts/lib/download.js +++ b/scripts/lib/download.js @@ -79,7 +79,7 @@ async function downloadGitHubFile(releaseTag, filename, task) { '--pattern', filename, '--dir', DOWNLOADS_DIR, '--clobber' - ], { task }); + ], { task, silent: true}); return path.join(DOWNLOADS_DIR, filename); } catch (err) { task.output = `GitHub CLI download failed ${releaseTag}/${filename}: ${err.message.trim().replace(/\n/g, ' ')}`; diff --git a/scripts/lib/exec.js b/scripts/lib/exec.js index 10e3b48a31..cdbae05af3 100644 --- a/scripts/lib/exec.js +++ b/scripts/lib/exec.js @@ -102,7 +102,8 @@ async function execCommand(command, args, options = {}) { collect = false, logModule = null, verbose = false, - stdio = undefined + stdio = undefined, + silent = false } = options; const inherit = stdio === 'inherit'; const ignoreStdio = stdio === 'ignore'; @@ -159,13 +160,15 @@ async function execCommand(command, args, options = {}) { } function logExecFailure(context, err, exitCode = null) { - console.error('[exec]', context, err instanceof Error ? err.message : String(err)); - if (exitCode != null) console.error('[exec] exitCode:', exitCode); - console.error('[exec] command:', spawnCmd); - console.error('[exec] args:', spawnArgs); - console.error('[exec] cwd:', cwd); - if (env != null && typeof env === 'object') { - console.error('[exec] env:', env); + if (!silent) { + console.error('[exec]', context, err instanceof Error ? err.message : String(err)); + if (exitCode != null) console.error('[exec] exitCode:', exitCode); + console.error('[exec] command:', spawnCmd); + console.error('[exec] args:', spawnArgs); + console.error('[exec] cwd:', cwd); + if (env != null && typeof env === 'object') { + console.error('[exec] env:', env); + } } }