Changeset: 4f973ef7ce16 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4f973ef7ce16
Modified Files:
monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh
monetdb5/extras/pyapi/pyapi.c
Branch: pyapi
Log Message:
Better error handling.
diffs (95 lines):
diff --git a/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh
b/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh
--- a/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh
+++ b/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh
@@ -1,7 +1,7 @@
# The base directory of testing, a new folder is created in this base
directory [$PYAPI_TEST_DIR], and everything is done in that new folder
-export PYAPI_BASE_DIR=/local/raasveld
+export PYAPI_BASE_DIR=/home/mytherin/
# The terminal to start mserver with, examples are gnome-terminal, xterm,
konsole
export TERMINAL=x-terminal-emulator
# Port used by the MSERVER
@@ -11,7 +11,7 @@ export MSERVERTEST='netstat -ant | grep
# Testing parameters
# Input test (zero copy vs copy)
# The input sizes to test (in MB)
-export INPUT_TESTING_SIZES="0.1 1 10 100 1000"
+export INPUT_TESTING_SIZES="0.1 1 10 100 1000 10000"
# Amount of tests to run for each size
export INPUT_TESTING_NTESTS=10
diff --git a/monetdb5/extras/pyapi/pyapi.c b/monetdb5/extras/pyapi/pyapi.c
--- a/monetdb5/extras/pyapi/pyapi.c
+++ b/monetdb5/extras/pyapi/pyapi.c
@@ -412,9 +412,9 @@ str PyAPIeval(MalBlkPtr mb, MalStkPtr st
disable_testing = true;
}
- if (!disable_testing && benchmark_output != NULL) {
+ if (benchmark_output != NULL) {
reset_hook();
- if (!mapped) init_hook();
+ if (!disable_testing && !mapped) init_hook();
timer(&start_time);
}
#endif
@@ -770,7 +770,9 @@ str PyAPIeval(MalBlkPtr mb, MalStkPtr st
}
}
if (result_array == NULL) {
- msg = createException(MAL, "pyapi.eval", "Failed to create Numpy
Array from BAT.");
+ if (msg == MAL_SUCCEED) {
+ msg = createException(MAL, "pyapi.eval", "Failed to create
Numpy Array from BAT.");
+ }
goto wrapup;
}
PyTuple_SetItem(pArgs, ai++, result_array);
@@ -1509,9 +1511,9 @@ returnvalues:
#ifdef _PYAPI_TESTING_
GDKfree(exprStr);
- if (!disable_testing && benchmark_output != NULL) {
+ if (benchmark_output != NULL) {
FILE *f = NULL;
- if (!mapped) {
+ if (!mapped && !disable_testing) {
revert_hook();
peak_memory_usage = GET_MEMORY_PEAK();
}
@@ -1523,8 +1525,10 @@ returnvalues:
f = fopen(benchmark_output, "a");
if (f != NULL) {
fprintf(f, "%llu\t%f\n", peak_memory_usage,
GET_ELAPSED_TIME(start_time, end_time));
+ fclose(f);
+ } else {
+ perror("Error");
}
- fclose(f);
MT_lock_unset(&pyapiLock, "pyapi.evaluate");
}
#endif
@@ -1746,8 +1750,11 @@ wrapup:
PyObject *PyMaskedArray_FromBAT(PyInput *inp, size_t t_start, size_t t_end,
char **return_message)
{
BAT *b = inp->bat;
+ char *msg;
PyObject *vararray = PyArrayObject_FromBAT(inp, t_start, t_end,
return_message);
- char *msg;
+ if (vararray == NULL) {
+ return NULL;
+ }
// To deal with null values, we use the numpy masked array structure
// The masked array structure is an object with two arrays of equal size,
a data array and a mask array
// The mask array is a boolean array that has the value 'True' when the
element is NULL, and 'False' otherwise
@@ -2041,6 +2048,10 @@ PyObject *PyArrayObject_FromBAT(PyInput
msg = createException(MAL, "pyapi.eval", "unknown argument type ");
goto wrapup;
}
+ if (vararray == NULL) {
+ msg = PyError_CreateException("Failed to convert BAT to Numpy array.",
NULL);
+ goto wrapup;
+ }
return vararray;
wrapup:
*return_message = msg;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list