Skip to content

Commit

Permalink
feat: check the runner version to be compatible (#888)
Browse files Browse the repository at this point in the history
### Summary of Changes

- check the runner version to be compatible before starting the runner

Closes #880

---------

Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
  • Loading branch information
WinPlay02 and megalinter-bot authored Feb 17, 2024
1 parent f42c9aa commit 83378a3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
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

0 comments on commit 83378a3

Please sign in to comment.