add error catching
This commit is contained in:
parent
a2b3733a1e
commit
3e01470aa0
@ -40,17 +40,15 @@ def get_data(variable, feature_columns, query):
|
||||
prepared data, packaged into NumPy arrays
|
||||
"""
|
||||
|
||||
columns = ','.join(['array_agg("{col}") As "{col}"'.format(col=col) for col in feature_columns])
|
||||
columns = ','.join(['array_agg("{col}") As "{col}"'.format(col=col) for col in feature_columns])
|
||||
|
||||
data = plpy.execute('''
|
||||
SELECT array_agg("{variable}") As target,
|
||||
{columns}
|
||||
FROM ({query}) As a
|
||||
'''.format(
|
||||
variable = variable,
|
||||
columns = columns,
|
||||
query = query
|
||||
))
|
||||
try:
|
||||
data = plpy.execute('''SELECT array_agg("{variable}") As target, {columns} FROM ({query}) As a'''.format(
|
||||
variable=variable,
|
||||
columns=columns,
|
||||
query=query))
|
||||
except Exception, e:
|
||||
plpy.error('failed to fetch data to construct model')
|
||||
|
||||
target = np.array(data[0]['target'])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user