mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-59995 core_admin: added setting to define Python bin path
This commit is contained in:
parent
32f9550e85
commit
391663ce28
@ -12,6 +12,8 @@ $temp->add(new admin_setting_configexecutable('pathtodu', new lang_string('patht
|
||||
$temp->add(new admin_setting_configexecutable('aspellpath', new lang_string('aspellpath', 'admin'), new lang_string('edhelpaspellpath'), ''));
|
||||
$temp->add(new admin_setting_configexecutable('pathtodot', new lang_string('pathtodot', 'admin'), new lang_string('pathtodot_help', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configexecutable('pathtogs', new lang_string('pathtogs', 'admin'), new lang_string('pathtogs_help', 'admin'), '/usr/bin/gs'));
|
||||
$temp->add(new admin_setting_configexecutable('pathtopython', new lang_string('pathtopython', 'admin'),
|
||||
new lang_string('pathtopythondesc', 'admin'), ''));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
|
||||
|
@ -835,6 +835,8 @@ $string['pathtopgdumpinvalid'] = 'Invalid path to pg_dump - either wrong path or
|
||||
$string['pathtopsql'] = 'Path to psql';
|
||||
$string['pathtopsqldesc'] = 'This is only necessary to enter if you have more than one psql on your system (for example if you have more than one version of postgresql installed)';
|
||||
$string['pathtopsqlinvalid'] = 'Invalid path to psql - either wrong path or not executable';
|
||||
$string['pathtopython'] = 'Path to Python';
|
||||
$string['pathtopythondesc'] = 'Path to your executable Python binary.';
|
||||
$string['pcreunicodewarning'] = 'It is strongly recommended to use PCRE PHP extension that is compatible with Unicode characters.';
|
||||
$string['perfdebug'] = 'Performance info';
|
||||
$string['performance'] = 'Performance';
|
||||
|
@ -40,15 +40,38 @@ class processor implements \core_analytics\classifier, \core_analytics\regresso
|
||||
*/
|
||||
const REQUIRED_PIP_PACKAGE_VERSION = '0.0.2';
|
||||
|
||||
/**
|
||||
* The path to the Python bin.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $pathtopython;
|
||||
|
||||
/**
|
||||
* The constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
global $CFG;
|
||||
|
||||
// Set the python location if there is a value.
|
||||
if (!empty($CFG->pathtopython)) {
|
||||
$this->pathtopython = $CFG->pathtopython;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the plugin ready to be used?.
|
||||
*
|
||||
* @return bool
|
||||
* @return bool|string Returns true on success, a string detailing the error otherwise
|
||||
*/
|
||||
public function is_ready() {
|
||||
if (empty($this->pathtopython)) {
|
||||
$settingurl = new \moodle_url('/admin/settings.php', array('section' => 'systempaths'));
|
||||
return get_string('pythonpathnotdefined', 'mlbackend_python', $settingurl->out());
|
||||
}
|
||||
|
||||
// Check the installed pip package version.
|
||||
$cmd = 'python -m moodlemlbackend.version';
|
||||
$cmd = "{$this->pathtopython} -m moodlemlbackend.version";
|
||||
|
||||
$output = null;
|
||||
$exitcode = null;
|
||||
@ -84,7 +107,7 @@ class processor implements \core_analytics\classifier, \core_analytics\regresso
|
||||
// Obtain the physical route to the file.
|
||||
$datasetpath = $this->get_file_path($dataset);
|
||||
|
||||
$cmd = 'python -m moodlemlbackend.training ' .
|
||||
$cmd = "{$this->pathtopython} -m moodlemlbackend.training " .
|
||||
escapeshellarg($uniqueid) . ' ' .
|
||||
escapeshellarg($outputdir) . ' ' .
|
||||
escapeshellarg($datasetpath);
|
||||
@ -125,7 +148,7 @@ class processor implements \core_analytics\classifier, \core_analytics\regresso
|
||||
// Obtain the physical route to the file.
|
||||
$datasetpath = $this->get_file_path($dataset);
|
||||
|
||||
$cmd = 'python -m moodlemlbackend.prediction ' .
|
||||
$cmd = "{$this->pathtopython} -m moodlemlbackend.prediction " .
|
||||
escapeshellarg($uniqueid) . ' ' .
|
||||
escapeshellarg($outputdir) . ' ' .
|
||||
escapeshellarg($datasetpath);
|
||||
@ -168,7 +191,7 @@ class processor implements \core_analytics\classifier, \core_analytics\regresso
|
||||
// Obtain the physical route to the file.
|
||||
$datasetpath = $this->get_file_path($dataset);
|
||||
|
||||
$cmd = 'python -m moodlemlbackend.evaluation ' .
|
||||
$cmd = "{$this->pathtopython} -m moodlemlbackend.evaluation " .
|
||||
escapeshellarg($uniqueid) . ' ' .
|
||||
escapeshellarg($outputdir) . ' ' .
|
||||
escapeshellarg($datasetpath) . ' ' .
|
||||
|
@ -25,3 +25,4 @@
|
||||
$string['packageinstalledshouldbe'] = '"moodlemlbackend" python package should be updated. The required version is "{$a->required}" and the installed version is "{$a->installed}"';
|
||||
$string['pluginname'] = 'Python machine learning backend';
|
||||
$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';
|
||||
$string['pythonpathnotdefined'] = 'The path to your executable Python binary has not been defined. Please visit "{$a}" to set it.';
|
||||
|
Loading…
x
Reference in New Issue
Block a user