Skip to content

Commit

Permalink
Merge branch 'mdl-68199-fix-master' of https://github.com/jaypha/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Dec 2, 2021
2 parents 312bfce + e7f51a3 commit 0888efd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions analytics/classes/model_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function export(string $zipfilename, bool $includeweights = true) : strin
// Model config in JSON.
$modeldata = $this->export_model_data();

$exporttmpdir = make_request_directory('analyticsexport');
$exporttmpdir = make_request_directory();
$jsonfilepath = $exporttmpdir . DIRECTORY_SEPARATOR . 'model-config.json';
if (!file_put_contents($jsonfilepath, json_encode($modeldata))) {
print_error('errornoexportconfig', 'analytics');
Expand Down Expand Up @@ -256,7 +256,7 @@ public static function get_class_component(string $fullclassname) : ?string {
*/
public function extract_import_contents(string $zipfilepath) : array {

$importtempdir = make_request_directory('analyticsimport' . microtime(false));
$importtempdir = make_request_directory();

$zip = new \zip_packer();
$filelist = $zip->extract_to_pathname($zipfilepath, $importtempdir);
Expand Down
7 changes: 3 additions & 4 deletions lib/mlbackend/python/classes/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ public function classify($uniqueid, \stored_file $dataset, $outputdir) {
throw new \moodle_exception('errorpredictwrongformat', 'analytics', '', json_last_error_msg());
}


if ($resultobj->status != 0) {
$resultobj = $this->format_error_info($resultobj);
}
Expand Down Expand Up @@ -337,7 +336,7 @@ public function evaluate_classification($uniqueid, $maxdeviation, $niterations,
// We need an extra request to get the resources generated during the evaluation process.

// Directory to temporarly store the evaluation log zip returned by the server.
$evaluationtmpdir = make_request_directory('mlbackend_python_evaluationlog');
$evaluationtmpdir = make_request_directory();
$evaluationzippath = $evaluationtmpdir . DIRECTORY_SEPARATOR . 'evaluationlog.zip';

$requestparams = ['uniqueid' => $uniqueid, 'dirhash' => $this->hash_dir($outputdir),
Expand Down Expand Up @@ -377,7 +376,7 @@ public function evaluate_classification($uniqueid, $maxdeviation, $niterations,
*/
public function export(string $uniqueid, string $modeldir) : string {

$exporttmpdir = make_request_directory('mlbackend_python_export');
$exporttmpdir = make_request_directory();

if (!$this->useserver) {
// Use the local file system.
Expand Down Expand Up @@ -717,7 +716,7 @@ private function hash_dir(string $dir) {
*/
private function zip_dir(string $dir) {

$ziptmpdir = make_request_directory('mlbackend_python');
$ziptmpdir = make_request_directory();
$ziptmpfile = $ziptmpdir . DIRECTORY_SEPARATOR . 'mlbackend.zip';

$files = get_directory_list($dir);
Expand Down
2 changes: 1 addition & 1 deletion lib/setuplib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,7 @@ function get_request_storage_directory($exceptiononerror = true, bool $forcecrea
* @param bool $forcecreate Force creation of a new parent directory
* @return string The full path to directory if successful, false if not; may throw exception
*/
function make_request_directory($exceptiononerror = true, bool $forcecreate = false) {
function make_request_directory(bool $exceptiononerror = true, bool $forcecreate = false) {
$basedir = get_request_storage_directory($exceptiononerror, $forcecreate);
return make_unique_writable_directory($basedir, $exceptiononerror);
}
Expand Down

0 comments on commit 0888efd

Please sign in to comment.