diff --git a/packages/safe-ds-lang/src/language/runner/safe-ds-runner.ts b/packages/safe-ds-lang/src/language/runner/safe-ds-runner.ts index 01065aa2c..a1bbab72c 100644 --- a/packages/safe-ds-lang/src/language/runner/safe-ds-runner.ts +++ b/packages/safe-ds-lang/src/language/runner/safe-ds-runner.ts @@ -15,8 +15,7 @@ import { BasicSourceMapConsumer, SourceMapConsumer } from 'source-map'; import treeKill from 'tree-kill'; import { SafeDsAnnotations } from '../builtins/safe-ds-annotations.js'; import { SafeDsPythonGenerator } from '../generation/safe-ds-python-generator.js'; -import { isSdsModule, isSdsPipeline } from '../generated/ast.js'; -import { getModuleMembers } from '../helpers/nodeProperties.js'; +import { isSdsModule } from '../generated/ast.js'; import semver from 'semver'; // Most of the functionality cannot be tested automatically as a functioning runner setup would always be required @@ -281,13 +280,15 @@ export class SafeDsRunner { * Execute a Safe-DS pipeline on the python runner. * If a valid target placeholder is provided, the pipeline is only executed partially, to calculate the result of the placeholder. * - * @param pipelineDocument Document containing the main Safe-DS pipeline to execute. * @param id A unique id that is used in further communication with this pipeline. + * @param pipelineDocument Document containing the main Safe-DS pipeline to execute. + * @param pipelineName Name of the pipeline that should be run * @param targetPlaceholder The name of the target placeholder, used to do partial execution. If no value or undefined is provided, the entire pipeline is run. */ public async executePipeline( - pipelineDocument: LangiumDocument, id: string, + pipelineDocument: LangiumDocument, + pipelineName: string, targetPlaceholder: string | undefined = undefined, ) { if (!this.isPythonServerAvailable()) { @@ -305,13 +306,6 @@ export class SafeDsRunner { // Pipeline / Module name handling const mainPythonModuleName = this.annotations.getPythonModule(node); const mainPackage = mainPythonModuleName === undefined ? node.name.split('.') : [mainPythonModuleName]; - const firstPipeline = getModuleMembers(node).find(isSdsPipeline); - if (firstPipeline === undefined) { - this.logging.outputError('Cannot execute: no pipeline found'); - this.logging.displayError('The current file cannot be executed, as no pipeline could be found.'); - return; - } - const mainPipelineName = this.annotations.getPythonName(firstPipeline) || firstPipeline.name; const mainModuleName = this.getMainModuleName(pipelineDocument); // Code generation const [codeMap, lastGeneratedSources] = this.generateCodeForRunner(pipelineDocument, targetPlaceholder); @@ -330,7 +324,7 @@ export class SafeDsRunner { main: { modulepath: mainPackage.join('.'), module: mainModuleName, - pipeline: mainPipelineName, + pipeline: pipelineName, }, }), ); diff --git a/packages/safe-ds-vscode/src/extension/mainClient.ts b/packages/safe-ds-vscode/src/extension/mainClient.ts index 4fd5a0b5a..0c0bf3987 100644 --- a/packages/safe-ds-vscode/src/extension/mainClient.ts +++ b/packages/safe-ds-vscode/src/extension/mainClient.ts @@ -2,7 +2,7 @@ import * as path from 'node:path'; import * as vscode from 'vscode'; import type { LanguageClientOptions, ServerOptions } from 'vscode-languageclient/node.js'; import { LanguageClient, TransportKind } from 'vscode-languageclient/node.js'; -import { ast, createSafeDsServices, messages, SafeDsServices } from '@safe-ds/lang'; +import { ast, createSafeDsServices, getModuleMembers, messages, SafeDsServices } from '@safe-ds/lang'; import { NodeFileSystem } from 'langium/node'; import { getSafeDSOutputChannel, initializeLog, logError, logOutput, printOutputMessage } from './output.js'; import crypto from 'crypto'; @@ -335,8 +335,6 @@ const runPipelineFile = async function (filePath: vscode.Uri | undefined, pipeli return; } // Run it - printOutputMessage(`Launching Pipeline (${pipelineId}): ${pipelinePath}`); - let mainDocument; if (!services.shared.workspace.LangiumDocuments.hasDocument(pipelinePath)) { mainDocument = await services.shared.workspace.LangiumDocuments.getOrCreateDocument(pipelinePath); @@ -348,7 +346,18 @@ const runPipelineFile = async function (filePath: vscode.Uri | undefined, pipeli } else { mainDocument = await services.shared.workspace.LangiumDocuments.getOrCreateDocument(pipelinePath); } - await services.runtime.Runner.executePipeline(mainDocument, pipelineId); + + const firstPipeline = getModuleMembers(mainDocument.parseResult.value).find(ast.isSdsPipeline); + if (firstPipeline === undefined) { + logError('Cannot execute: no pipeline found'); + vscode.window.showErrorMessage('The current file cannot be executed, as no pipeline could be found.'); + return; + } + const mainPipelineName = services.builtins.Annotations.getPythonName(firstPipeline) || firstPipeline.name; + + printOutputMessage(`Launching Pipeline (${pipelineId}): ${pipelinePath} - ${mainPipelineName}`); + + await services.runtime.Runner.executePipeline(pipelineId, mainDocument, mainPipelineName); }; const commandRunPipelineFile = async function (filePath: vscode.Uri | undefined) {