Commit 964ccd96 authored by David Mudrák's avatar David Mudrák
Browse files

MDL-64994 analytics: Improve the Python package version check

Use the new method to check that the installed Python package has high
enough yet still API-compatible version.
parent 2d8405e9
......@@ -78,7 +78,9 @@ class processor implements \core_analytics\classifier, \core_analytics\regresso
// Execute it sending the standard error to $output.
$result = exec($cmd . ' 2>&1', $output, $exitcode);
if ($result === self::REQUIRED_PIP_PACKAGE_VERSION) {
$vercheck = self::check_pip_package_version($result);
if ($vercheck === 0) {
return true;
......@@ -87,8 +89,17 @@ class processor implements \core_analytics\classifier, \core_analytics\regresso
if ($result) {
$a = (object)array('installed' => $result, 'required' => self::REQUIRED_PIP_PACKAGE_VERSION);
return get_string('packageinstalledshouldbe', 'mlbackend_python', $a);
$a = [
'installed' => $result,
if ($vercheck < 0) {
return get_string('packageinstalledshouldbe', 'mlbackend_python', $a);
} else if ($vercheck > 0) {
return get_string('packageinstalledtoohigh', 'mlbackend_python', $a);
return get_string('pythonpackagenotinstalled', 'mlbackend_python', $cmd);
......@@ -23,6 +23,7 @@
$string['packageinstalledshouldbe'] = '"moodlemlbackend" python package should be updated. The required version is "{$a->required}" and the installed version is "{$a->installed}"';
$string['packageinstalledtoohigh'] = '"moodlemlbackend" python package is not compatible with this Moodle version. The required version is "{$a->required}" or higher as long as it is API-compatible. The installed version "{$a->installed}" is too high.';
$string['pluginname'] = 'Python machine learning backend';
$string['privacy:metadata'] = 'The Python machine learning backend plugin does not store any personal data.';
$string['pythonpackagenotinstalled'] = '"moodlemlbackend" python package is not installed or there is a problem with it. Please execute "{$a}" from command line interface for more info';
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment