File tree Expand file tree Collapse file tree
tests/unit/python/distributed Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -153,7 +153,8 @@ jobs:
153153 -DPHYLANX_WITH_ITERATIVE_SOLVERS=ON \
154154 -DPHYLANX_WITH_DOCUMENTATION=ON \
155155 -DPHYLANX_WITH_HIGHFIVE=OFF \
156- -DPHYLANX_WITH_CXX17=ON
156+ -DPHYLANX_WITH_CXX17=ON \
157+ -DPHYLANX_WITH_PYTHON_TESTS_EMIT_FULL_DIAGNOSTICS=On
157158 - persist_to_workspace :
158159 root : /
159160 paths :
Original file line number Diff line number Diff line change @@ -95,6 +95,11 @@ phylanx_option(
9595 "Enable or disable the compilation of benchmark tests"
9696 ON ADVANCED CATEGORY "Build" )
9797
98+ phylanx_option (
99+ PHYLANX_WITH_PYTHON_TESTS_EMIT_FULL_DIAGNOSTICS BOOL
100+ "Python tests emit the full HPX diagnostics if exceptions are thrown"
101+ OFF ADVANCED CATEGORY "Build" )
102+
98103phylanx_option (
99104 PHYLANX_WITH_TESTS_REGRESSIONS BOOL
100105 "Enable or disable the compilation of regression tests"
Original file line number Diff line number Diff line change @@ -30,14 +30,27 @@ macro(add_phylanx_python_test category name)
3030 phylanx_debug ("add_phylanx_python_test (${name} )" "WORKING_DIRECTORY: ${_working_directory} " )
3131
3232 set (_environment)
33+ if (PHYLANX_WITH_PYTHON_TESTS_EMIT_FULL_DIAGNOSTICS)
34+ set (_environment
35+ PHYLANX_PYTHON_CONFIG="--hpx:ini=phylanx.full_error_diagnostics!=1"
36+ )
37+ endif ()
3338 if (${name} _ENVIRONMENT)
3439 if (MSVC )
35- set (_environment ${CMAKE_COMMAND} -E env "${${name} _ENVIRONMENT}" )
40+ if (NOT ("${_environment} x" STREQUAL "x" ))
41+ set (_environment ${CMAKE_COMMAND} -E env "${_environment} \; ${${name} _ENVIRONMENT}" )
42+ else ()
43+ set (_environment ${CMAKE_COMMAND} -E env "${${name} _ENVIRONMENT}" )
44+ endif ()
3645 else ()
37- set (_environment ENVIRONMENT "${${name} _ENVIRONMENT}" )
46+ if (NOT ("${_environment} x" STREQUAL "x" ))
47+ set (_environment ENVIRONMENT "${_environment} :${${name} _ENVIRONMENT}" )
48+ else ()
49+ set (_environment ENVIRONMENT "${${name} _ENVIRONMENT}" )
50+ endif ()
3851 endif ()
3952 endif ()
40- phylanx_debug ("add_phylanx_python_test (${name} )" "ENVIRONMENT: ${_environment} " )
53+ phylanx_info ("add_phylanx_python_test (${name} )" "ENVIRONMENT: ${_environment} " )
4154
4255 set (script ${CMAKE_CURRENT_SOURCE_DIR} /${${name} _SCRIPT})
4356
Original file line number Diff line number Diff line change 66from phylanx .core import init_hpx_runtime
77from phylanx .exceptions import RuntimeAlreadyInitializedError
88
9+ import os , platform
10+
911
1012class PhylanxSession :
1113 cfg = [
@@ -30,6 +32,17 @@ def init(num_threads=1):
3032 if not PhylanxSession .is_initialized :
3133 hpx_thread = "hpx.os_threads!=%s" % num_threads
3234 PhylanxSession .cfg [3 ] = hpx_thread
35+
36+ # append additional config settings taken from the environment
37+ if 'PHYLANX_PYTHON_CONFIG' in os .environ :
38+ if platform .system () == "Windows" :
39+ sep = ';'
40+ else :
41+ sep = ':'
42+
43+ for e in os .environ ['PHYLANX_PYTHON_CONFIG' ].split (sep ):
44+ PhylanxSession .cfg .append (e )
45+
3346 init_hpx_runtime (PhylanxSession .cfg )
3447 PhylanxSession .is_initialized = True
3548 else :
Original file line number Diff line number Diff line change @@ -307,4 +307,28 @@ void phylanx::bindings::bind_execution_tree(pybind11::module m)
307307 });
308308 },
309309 " wait for future to become ready" );
310+
311+ // translate HPX exceptions and provide more error information, if desired
312+ static pybind11::exception<hpx::exception> exc (
313+ m, " HPXError" , PyExc_RuntimeError);
314+
315+ pybind11::register_exception_translator ([](std::exception_ptr p) {
316+ try
317+ {
318+ if (p)
319+ std::rethrow_exception (p);
320+ }
321+ catch (hpx::exception& e)
322+ {
323+ if (hpx::get_config_entry (" phylanx.full_error_diagnostics" , " 0" ) ==
324+ " 1" )
325+ {
326+ exc (hpx::diagnostic_information (e).c_str ());
327+ }
328+ else
329+ {
330+ exc (e.what ());
331+ }
332+ }
333+ });
310334}
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ def sleep(x):
1818
1919@Phylanx
2020def call_sleep ():
21- sleep (1000 ) # sleep for 1 second
21+ sleep1 (1000 ) # sleep for 1 second
2222 return
2323
2424
You can’t perform that action at this time.
0 commit comments