Closed fmder closed 11 months ago
@bje- I think I got everything working from #76. Could you test if Ray can work with this? I added automated tests, but it is not 100% coverage unfortunately.
76 Merged into current master.
I don't see a merge commit on master?
I don't see a merge commit on master?
Ah, it's still on a branch.
No improvement that I can see:
(PoolActor pid=3240907) AttributeError: Can't get attribute 'Individual' on <module 'deap.creator' from '/home/bje/source/nemo/myenv/lib/python3.10/site-packages/deap/creator.py'>
Was #76 fixing the issue before?
The changes don't merge so I wasn't easily able to test it.
You'd need the changes to be on master?
Still from the fmder-metacreator branch:
ray.exceptions.RaySystemError: System error: Can't get attribute 'Individual' on <module 'deap.creator' from '/home/bje/source/nemo/myenv/lib/python3.10/site-packages/deap/creator.py'>
Ok, i'll check later today if I can find something I missed while merging
Thanks for the feedback
Ok, I've been testing two small scripts recreating a messaging environment, one pickles to file, the other unpickles.
import pickle
from deap import creator
creator.create("TempInd", list)
i = creator.TempInd([1, 2, 3])
with open("ind.pkl", "wb") as f:
pickle.dump(i, f)
import pickle
from deap import creator
with open("ind.pkl", "rb") as f:
i = pickle.load(f)
With current version 1.3.3, I get the same error:
AttributeError: Can't get attribute 'TempInd' on <module 'deap.creator' from '[...]/lib/python3.9/site-packages/deap/creator.py'>
while, with the current version, there is no error. The MetaCreator seems to work as intended.
"current version" being master?
Follow-up: I made the change below to onemax_mp.py
and it works. I think the problem must be in my code.
diff --git a/examples/ga/onemax_mp.py b/examples/ga/onemax_mp.py
index 32d34e0..3377b5f 100755
--- a/examples/ga/onemax_mp.py
+++ b/examples/ga/onemax_mp.py
@@ -18,6 +18,7 @@ import array
import multiprocessing
import random
import sys
+import ray.util.multiprocessing
if sys.version_info < (2, 7):
print("mpga_onemax example requires Python >= 2.7.")
@@ -54,7 +55,7 @@ def main(seed):
toolbox.register("select", tools.selTournament, tournsize=3)
# Process Pool of 4 workers
- pool = multiprocessing.Pool(processes=4)
+ pool = ray.util.multiprocessing.Pool(processes=4)
toolbox.register("map", pool.map)
pop = toolbox.population(n=300)
76 Merged into current master.
fixes #76