Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion apps/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
Expand Down
19 changes: 19 additions & 0 deletions apps/vscode/src/connection/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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}`);
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/src/providers/PageEditorProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 12 additions & 11 deletions apps/vscode/src/providers/PageStatusProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -413,6 +413,12 @@ export class PageStatusProvider {
private async handlePanelDisposal(projectId: string, sourceId: string): Promise<void> {
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);
Expand Down Expand Up @@ -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));
Expand Down
74 changes: 60 additions & 14 deletions apps/vscode/src/providers/SidebarFilesProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,28 @@ export class SidebarFilesProvider implements vscode.TreeDataProvider<PipelineFil
vscode.window.showErrorMessage('No pipeline selected');
return;
}
const sourceId = item.sourceComponent?.id || '';
const config: vscode.DebugConfiguration = {
type: 'rocketride',
request: 'launch',
name: `Run ${item.label}`,
file: item.resourceUri.fsPath,
source: sourceId,
noDebug: true
};

try {
await vscode.debug.startDebugging(undefined, config);
// Read the pipeline file
const fileContent = await vscode.workspace.fs.readFile(item.resourceUri);
const pipelineText = Buffer.from(fileContent).toString('utf8');
const pipelineJson = JSON.parse(pipelineText);

// Substitute .env settings
const pipelineTransformed = ConfigManager.getInstance().substituteEnvVariables(pipelineJson);

// Get project and source identifiers
const parsedFile = item.parsedFile || this.getParsedPipeline(item.resourceUri);
const projectId = parsedFile?.projectId;
const sourceId = item.sourceComponent?.id || '';

// Use DAP command to execute pipeline without debugging
await this.connectionManager.request('execute', {
projectId: projectId,
source: sourceId,
pipeline: pipelineTransformed,
pipelineTraceLevel: 'full'
});
} catch (error) {
vscode.window.showErrorMessage(`Failed to run pipeline: ${error}`);
}
Expand Down Expand Up @@ -308,6 +319,44 @@ export class SidebarFilesProvider implements vscode.TreeDataProvider<PipelineFil
} catch (error) {
vscode.window.showErrorMessage(`Failed to attach to pipeline: ${error}`);
}
}),

vscode.commands.registerCommand('rocketride.sidebar.files.stopPipeline', async (item?: PipelineFileItem) => {
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}`);
}
})
];

Expand All @@ -327,10 +376,7 @@ export class SidebarFilesProvider implements vscode.TreeDataProvider<PipelineFil

// Listen for connected events
const connectedEventListener = this.connectionManager.addListener('connected', _e => {
// 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
Expand Down
3 changes: 0 additions & 3 deletions c.bat

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
3 changes: 2 additions & 1 deletion packages/ai/src/ai/common/dap/transport_stdio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
},
}
)
Expand Down
34 changes: 10 additions & 24 deletions packages/ai/src/ai/modules/task/commands/cmd_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -275,27 +269,19 @@ async def set_monitor(
event_id = None
filter_name = '<all>'

# 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'<Token:{token[:8]}>'
# 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:
Expand Down
32 changes: 16 additions & 16 deletions packages/ai/src/ai/modules/task/task_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand Down
7 changes: 0 additions & 7 deletions packages/ai/src/ai/modules/task/task_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Loading
Loading