Skip to content

Commit

Permalink
MDL-66004 mlbackend_python: Purge testing output dirs properly
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllaó committed Oct 3, 2019
1 parent aab2b21 commit 63c15f6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion analytics/tests/prediction_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@
*/
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
*
Expand Down Expand Up @@ -414,7 +431,8 @@ public function test_ml_classifiers_return($success, $nsamples, $classes, $predi

// Training should work correctly if at least 1 sample of each class is included.
$dir = make_request_directory();
$result = $predictionsprocessor->train_classification('whatever' . microtime(), $dataset, $dir);
$modeluniqueid = 'whatever' . microtime();
$result = $predictionsprocessor->train_classification($modeluniqueid, $dataset, $dir);

switch ($success) {
case 'yes':
Expand All @@ -429,6 +447,10 @@ public function test_ml_classifiers_return($success, $nsamples, $classes, $predi
// what we really want to check is that an exception was not thrown.
$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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/mlbackend/python/classes/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class processor implements \core_analytics\classifier, \core_analytics\regresso
/**
* 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.
Expand Down

0 comments on commit 63c15f6

Please sign in to comment.