From 7ac00ba52a4f0693ecf806146b407d2a7dd41d4a Mon Sep 17 00:00:00 2001 From: JoaquinVanschoren Date: Thu, 31 Oct 2019 01:21:06 +0100 Subject: [PATCH 1/2] ES robustness bandaid --- openml_OS/libraries/ElasticSearch.php | 47 ++++++++++++++------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/openml_OS/libraries/ElasticSearch.php b/openml_OS/libraries/ElasticSearch.php index 9ffaca8c5..ac8f08c3e 100644 --- a/openml_OS/libraries/ElasticSearch.php +++ b/openml_OS/libraries/ElasticSearch.php @@ -1064,10 +1064,12 @@ private function fetch_classes($id = false) { private function fetch_runfiles($min, $max) { $index = array(); - foreach ($this->db->query('SELECT source, field, name, format, file_id from runfile where source >= ' . $min . ' and source < ' . $max) as $r) { - $index[$r->source][$r->field]['url'] = BASE_URL . 'data/download/' . $r->file_id . '/' . $r->name; - $index[$r->source][$r->field]['format'] = $r->format; - } + $runfiles = $this->db->query('SELECT source, field, name, format, file_id from runfile where source >= ' . $min . ' and source < ' . $max); + if ($runfiles) + foreach ($runfiles as $r) { + $index[$r->source][$r->field]['url'] = BASE_URL . 'data/download/' . $r->file_id . '/' . $r->name; + $index[$r->source][$r->field]['format'] = $r->format; + } return $index; } @@ -1439,16 +1441,16 @@ private function build_task_type($d) { ); $inputs = $this->db->query('SELECT name, type, description, io, requirement FROM task_type_inout where ttid=' . $d->ttid); - - foreach ($inputs as $i) { - $new_data['input'][] = array( - 'name' => $i->name, - 'type' => $i->type, - 'description' => $i->description, - 'io' => $i->io, - 'requirement' => $i->requirement - ); - } + if ($inputs) + foreach ($inputs as $i) { + $new_data['input'][] = array( + 'name' => $i->name, + 'type' => $i->type, + 'description' => $i->description, + 'io' => $i->io, + 'requirement' => $i->requirement + ); + } return $new_data; } @@ -1767,15 +1769,16 @@ public function index_single_dataset($id) { if ($id and ! $datasets) return 'Error: data set ' . $id . ' is unknown'; - foreach ($datasets as $d) { - $params['body'][] = array( - 'index' => array( - '_id' => $d->did - ) - ); + if ($datasets) + foreach ($datasets as $d) { + $params['body'][] = array( + 'index' => array( + '_id' => $d->did + ) + ); - $params['body'][] = $this->build_data($d); - } + $params['body'][] = $this->build_data($d); + } $responses = $this->client->bulk($params); From 7203d29880a779d1d4b25ef6072e748df269703e Mon Sep 17 00:00:00 2001 From: JoaquinVanschoren Date: Thu, 31 Oct 2019 01:40:10 +0100 Subject: [PATCH 2/2] study type update for frontend --- openml_OS/libraries/ElasticSearch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openml_OS/libraries/ElasticSearch.php b/openml_OS/libraries/ElasticSearch.php index ac8f08c3e..1e1b47f9b 100644 --- a/openml_OS/libraries/ElasticSearch.php +++ b/openml_OS/libraries/ElasticSearch.php @@ -761,7 +761,7 @@ private function build_study($d) { 'uploader_id' => $d->creator, 'uploader' => array_key_exists($d->creator, $this->user_names) ? $this->user_names[$d->creator] : 'Unknown', 'visibility' => $d->visibility, - 'type' => $d->main_entity_type, + 'study_type' => $d->main_entity_type, 'legacy' => $d->legacy, 'suggest' => array( 'input' => array($d->name, $d->description . ' '),