Commit ebec727c authored by David Monllaó's avatar David Monllaó
Browse files

MDL-66004 mlbackend_python: Purge testing output dirs properly

parent 463b63db
...@@ -54,6 +54,23 @@ require_once(__DIR__ . '/../../course/lib.php'); ...@@ -54,6 +54,23 @@ require_once(__DIR__ . '/../../course/lib.php');
*/ */
class core_analytics_prediction_testcase extends advanced_testcase { class core_analytics_prediction_testcase extends advanced_testcase {
/**
* Purge all the mlbackend outputs.
*
* This is done automatically for mlbackends using the web server dataroot but
* other mlbackends may store files elsewhere and these files need to be removed.
*
* @return null
*/
public function tearDown() {
$this->setAdminUser();
$models = \core_analytics\manager::get_all_models();
foreach ($models as $model) {
$model->delete();
}
}
/** /**
* test_static_prediction * test_static_prediction
* *
...@@ -414,7 +431,8 @@ class core_analytics_prediction_testcase extends advanced_testcase { ...@@ -414,7 +431,8 @@ class core_analytics_prediction_testcase extends advanced_testcase {
// Training should work correctly if at least 1 sample of each class is included. // Training should work correctly if at least 1 sample of each class is included.
$dir = make_request_directory(); $dir = make_request_directory();
$result = $predictionsprocessor->train_classification('whatever' . microtime(), $dataset, $dir); $modeluniqueid = 'whatever' . microtime();
$result = $predictionsprocessor->train_classification($modeluniqueid, $dataset, $dir);
switch ($success) { switch ($success) {
case 'yes': case 'yes':
...@@ -429,6 +447,10 @@ class core_analytics_prediction_testcase extends advanced_testcase { ...@@ -429,6 +447,10 @@ class core_analytics_prediction_testcase extends advanced_testcase {
// what we really want to check is that an exception was not thrown. // what we really want to check is that an exception was not thrown.
$this->assertInstanceOf(\stdClass::class, $result); $this->assertInstanceOf(\stdClass::class, $result);
} }
// Purge the directory used in this test (useful in case the mlbackend is storing files
// somewhere out of the default moodledata/models dir.
$predictionsprocessor->delete_output_dir($dir, $modeluniqueid);
} }
/** /**
......
...@@ -38,7 +38,7 @@ class processor implements \core_analytics\classifier, \core_analytics\regresso ...@@ -38,7 +38,7 @@ class processor implements \core_analytics\classifier, \core_analytics\regresso
/** /**
* The required version of the python package that performs all calculations. * The required version of the python package that performs all calculations.
*/ */
const REQUIRED_PIP_PACKAGE_VERSION = '2.2.0'; const REQUIRED_PIP_PACKAGE_VERSION = '2.2.1';
/** /**
* The python package is installed in a server. * The python package is installed in a server.
......
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