nelse003 / exhaustive_search

Testing exhaustive search algorithms for crystallographic occupancy refinement and surrounding problems
0 stars 0 forks source link

Pytest doesn't seem to work with multiprocessing section of exhaustive search #75

Closed nelse003 closed 6 years ago

nelse003 commented 6 years ago

Creating a simple instance of libtbx implemented multiprocessing to test in pytest:

import libtbx.easy_mp

def f(x):
    return x**2

def try_easy_mp():
    result = libtbx.easy_mp.pool_map(func=f,args=range(101))
    print(result)

    return result

And the corresponding test:

from easy_mp_example import try_easy_mp

def test_try_easy_mp():
    result = try_easy_mp()
    assert result[-1] == 10000

This test passes (locally on ccp4-python -m pytest). This implies that multiprocessing may not be the issue. Try an example with a call with a fixed function?

nelse003 commented 6 years ago

Using a fixed function seems to work:

def f_1(x, magic_string):
    print(magic_string)
    return x**2

def try_f_caller():
    f_call = f_caller(magic_string="CATS")
    result = libtbx.easy_mp.pool_map(fixed_func=f_call, args=range(101))
    print(result)
    return result

class f_caller (object) :
    def __init__ (self, magic_string) :
        self._obj = magic_string
    def __call__ (self, x) :
        return f_1(x,magic_string = self._obj)

and the corresponding test

def test_try_f_caller():
    result = try_f_caller()
    assert result[-1] == 10000

Passes.

Lets look at the exact failure of test_validation?

nelse003 commented 6 years ago

pytest -s allows printing for update of whats going on. Use screen for crashes of ssh connection

nelse003 commented 6 years ago

Pytest no longer used