Skip to content

Commit 7ac00ba

Browse files
ES robustness bandaid
1 parent a8555e9 commit 7ac00ba

1 file changed

Lines changed: 25 additions & 22 deletions

File tree

openml_OS/libraries/ElasticSearch.php

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,10 +1064,12 @@ private function fetch_classes($id = false) {
10641064

10651065
private function fetch_runfiles($min, $max) {
10661066
$index = array();
1067-
foreach ($this->db->query('SELECT source, field, name, format, file_id from runfile where source >= ' . $min . ' and source < ' . $max) as $r) {
1068-
$index[$r->source][$r->field]['url'] = BASE_URL . 'data/download/' . $r->file_id . '/' . $r->name;
1069-
$index[$r->source][$r->field]['format'] = $r->format;
1070-
}
1067+
$runfiles = $this->db->query('SELECT source, field, name, format, file_id from runfile where source >= ' . $min . ' and source < ' . $max);
1068+
if ($runfiles)
1069+
foreach ($runfiles as $r) {
1070+
$index[$r->source][$r->field]['url'] = BASE_URL . 'data/download/' . $r->file_id . '/' . $r->name;
1071+
$index[$r->source][$r->field]['format'] = $r->format;
1072+
}
10711073
return $index;
10721074
}
10731075

@@ -1439,16 +1441,16 @@ private function build_task_type($d) {
14391441
);
14401442

14411443
$inputs = $this->db->query('SELECT name, type, description, io, requirement FROM task_type_inout where ttid=' . $d->ttid);
1442-
1443-
foreach ($inputs as $i) {
1444-
$new_data['input'][] = array(
1445-
'name' => $i->name,
1446-
'type' => $i->type,
1447-
'description' => $i->description,
1448-
'io' => $i->io,
1449-
'requirement' => $i->requirement
1450-
);
1451-
}
1444+
if ($inputs)
1445+
foreach ($inputs as $i) {
1446+
$new_data['input'][] = array(
1447+
'name' => $i->name,
1448+
'type' => $i->type,
1449+
'description' => $i->description,
1450+
'io' => $i->io,
1451+
'requirement' => $i->requirement
1452+
);
1453+
}
14521454
return $new_data;
14531455
}
14541456

@@ -1767,15 +1769,16 @@ public function index_single_dataset($id) {
17671769
if ($id and ! $datasets)
17681770
return 'Error: data set ' . $id . ' is unknown';
17691771

1770-
foreach ($datasets as $d) {
1771-
$params['body'][] = array(
1772-
'index' => array(
1773-
'_id' => $d->did
1774-
)
1775-
);
1772+
if ($datasets)
1773+
foreach ($datasets as $d) {
1774+
$params['body'][] = array(
1775+
'index' => array(
1776+
'_id' => $d->did
1777+
)
1778+
);
17761779

1777-
$params['body'][] = $this->build_data($d);
1778-
}
1780+
$params['body'][] = $this->build_data($d);
1781+
}
17791782

17801783
$responses = $this->client->bulk($params);
17811784

0 commit comments

Comments
 (0)