Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: check the runner version to be compatible #888

Merged
merged 2 commits into from
Feb 17, 2024
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
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Safely develop Data Science programs with a statically checked domain specific l
2. To _execute_ Safe-DS programs, the [Safe-DS Runner](https://github.com/Safe-DS/Runner) has to be installed and
configured additionally:
1. Install [Python](https://www.python.org/) (3.11 or 3.12).
2. Run `pip install safe-ds-runner` in a command line to download the latest Runner version
2. Run `pip install "safe-ds-runner>=0.6.0,<0.7.0"` in a command line to download the latest matching Runner version
from [PyPI](https://pypi.org/project/safe-ds-runner/).
3. If the Visual Studio Code extension cannot start the runner, adjust the setting `safe-ds.runner.command`.
Enter the absolute path to the Runner executable, as seen in the image below.
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/safe-ds-lang/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"chevrotain": "^11.0.3",
"glob": "^10.3.10",
"langium": "^2.1.3",
"semver": "^7.6.0",
"source-map": "^0.7.4",
"tree-kill": "^1.2.2",
"vscode-languageserver": "^9.0.1",
Expand Down
16 changes: 15 additions & 1 deletion packages/safe-ds-lang/src/language/runner/safe-ds-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ 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 semver from 'semver';

// Most of the functionality cannot be tested automatically as a functioning runner setup would always be required

const SUPPORTED_VERSION_RANGE = '>=0.6.0 <0.7.0';

export class SafeDsRunner {
private readonly annotations: SafeDsAnnotations;
private readonly generator: SafeDsPythonGenerator;
Expand Down Expand Up @@ -85,7 +89,17 @@ export class SafeDsRunner {
try {
const pythonServerTest = child_process.spawn(runnerCommand, [...runnerCommandParts, '-V']);
const versionString = await this.getPythonServerVersion(pythonServerTest);
this.logging.outputInfo(`Using safe-ds-runner version: ${versionString}`);
if (!semver.satisfies(versionString, SUPPORTED_VERSION_RANGE)) {
this.logging.outputError(
`Installed runner version ${versionString} does not meet requirements: ${SUPPORTED_VERSION_RANGE}`,
);
this.logging.displayError(
`The installed runner version ${versionString} is not compatible with this version of the extension. The installed version should match these requirements: ${SUPPORTED_VERSION_RANGE}. Please update to a matching version.`,
);
return;
} else {
this.logging.outputInfo(`Using safe-ds-runner version: ${versionString}`);
}
} catch (error) {
this.logging.outputError(`Could not start runner: ${error}`);
this.logging.displayError('The runner process could not be started.');
Expand Down