MachineLearningLifeScience / poli

A library of discrete objectives
MIT License
13 stars 1 forks source link

`FoldX` breaks in parallel #184

Closed miguelgondu closed 4 months ago

miguelgondu commented 4 months ago

Currently, if we try to run the example of running FoldXStabilityAndSasa in parallel, we get the following error:

poli 🧪: Creating the objective foldx_stability_and_sasa from the repository.
poli 🧪: Starting the function foldx_stability_and_sasa as an isolated process.
Running in parallel
Traceback (most recent call last):
  File "/Users/sjt972/Projects/poli/src/poli/external_isolated_function_script.py", line 164, in run
    attribute = getattr(f, msg[0])
AttributeError: 'FoldXStabilitityAndSASAIsolatedLogic' object has no attribute '__getstate__'

Traceback (most recent call last):
  File "/Users/sjt972/Projects/poli/src/poli/external_isolated_function_script.py", line 164, in run
    attribute = getattr(f, msg[0])
AttributeError: 'FoldXStabilitityAndSASAIsolatedLogic' object has no attribute '__getstate__'

Traceback (most recent call last):
  File "/Users/sjt972/Projects/poli/src/poli/external_isolated_function_script.py", line 164, in run
    attribute = getattr(f, msg[0])
AttributeError: 'FoldXStabilitityAndSASAIsolatedLogic' object has no attribute '__getstate__'

Traceback (most recent call last):
  File "/Users/sjt972/Projects/poli/src/poli/external_isolated_function_script.py", line 164, in run
    attribute = getattr(f, msg[0])
AttributeError: 'FoldXStabilitityAndSASAIsolatedLogic' object has no attribute '__getstate__'

Traceback (most recent call last):
  File "/Users/sjt972/Projects/poli/src/poli/external_isolated_function_script.py", line 164, in run
    attribute = getattr(f, msg[0])
AttributeError: 'FoldXStabilitityAndSASAIsolatedLogic' object has no attribute '__getstate__'

Traceback (most recent call last):
  File "/Users/sjt972/Projects/poli/src/poli/external_isolated_function_script.py", line 164, in run
    attribute = getattr(f, msg[0])
AttributeError: 'FoldXStabilitityAndSASAIsolatedLogic' object has no attribute '__getstate__'

Traceback (most recent call last):
  File "/Users/sjt972/Projects/poli/src/poli/external_isolated_function_script.py", line 164, in run
    attribute = getattr(f, msg[0])
AttributeError: 'FoldXStabilitityAndSASAIsolatedLogic' object has no attribute '__getstate__'

Traceback (most recent call last):
  File "/Users/sjt972/Projects/poli/src/poli/external_isolated_function_script.py", line 164, in run
    attribute = getattr(f, msg[0])
AttributeError: 'FoldXStabilitityAndSASAIsolatedLogic' object has no attribute '__getstate__'

Traceback (most recent call last):
  File "/Users/sjt972/Projects/poli/src/poli/external_isolated_function_script.py", line 164, in run
    attribute = getattr(f, msg[0])
AttributeError: 'FoldXStabilitityAndSASAIsolatedLogic' object has no attribute '__getstate__'

Traceback (most recent call last):
  File "/Users/sjt972/Projects/poli/src/poli/external_isolated_function_script.py", line 164, in run
    attribute = getattr(f, msg[0])
AttributeError: 'FoldXStabilitityAndSASAIsolatedLogic' object has no attribute '__getstate__'

Traceback (most recent call last):
  File "/Users/sjt972/Projects/poli/examples/protein_stability_and_sasa/evaluating_stability_and_sasa_in_parallel/parallel_query.py", line 20, in <module>
    print(f(x0))
  File "/Users/sjt972/Projects/poli/src/poli/core/abstract_black_box.py", line 255, in __call__
    f_batch_ = pool.starmap(
  File "/Users/sjt972/anaconda3/envs/poli-dev/lib/python3.9/multiprocessing/pool.py", line 372, in starmap
    return self._map_async(func, iterable, starmapstar, chunksize).get()
  File "/Users/sjt972/anaconda3/envs/poli-dev/lib/python3.9/multiprocessing/pool.py", line 771, in get
    raise self._value
  File "/Users/sjt972/anaconda3/envs/poli-dev/lib/python3.9/multiprocessing/pool.py", line 537, in _handle_tasks
    put(task)
  File "/Users/sjt972/anaconda3/envs/poli-dev/lib/python3.9/multiprocessing/connection.py", line 206, in send
    self._send_bytes(_ForkingPickler.dumps(obj))
  File "/Users/sjt972/anaconda3/envs/poli-dev/lib/python3.9/multiprocessing/reduction.py", line 51, in dumps
    cls(buf, protocol).dump(obj)
TypeError: cannot pickle '_thread.lock' object

When trying to run in parallel, the isolated logic is trying to be pickled by calling __getstate__. Since it doesn't have that attribute, it fails.

miguelgondu commented 4 months ago

If we run the script in poli__protein, it works well. There's something about the isolated process that's unpickle-able.