Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

add ThreadedEvaluator; fix docstring of ParallelEvaluator#95

Closed
bennr01 wants to merge 10 commits intoCodeReclaimers:masterCodeReclaimers/neat-python:masterfrom
bennr01:masterbennr01/neat-python:masterCopy head branch name to clipboard
Closed

add ThreadedEvaluator; fix docstring of ParallelEvaluator#95
bennr01 wants to merge 10 commits intoCodeReclaimers:masterCodeReclaimers/neat-python:masterfrom
bennr01:masterbennr01/neat-python:masterCopy head branch name to clipboard

Conversation

@bennr01
Copy link
Contributor

@bennr01 bennr01 commented Jul 9, 2017

I have added the neat.threaded.ThreadedEvaluator and fixed a mistake in the docstring of neat.parallel.ParallelEvaluator.__init__.
the ThreadedEvaluator-class is like the ParallelEvaluator-class, but uses threads instead of processes.
This is useful when using python implementations without an GIL like jython.
I also created an example of the ThreadedEvaluator based on examples/xor/evolve-feedforward-parallel.py.

The docstring of neat.parallel.ParallelEvaluator.__init__ stated that eval_function should take one argument (the genome object)[...]. However, eval_function is called with two arguments (the genome object and the config). This is now corrected.

Edit: This PR now also modifies .travis.yml to enforce the usage pypy3.5-5.8.0 instead of pypy3. Travis uses an old pypy3, which causes some bugs in multithreaded script.

bennr01 added 3 commits July 8, 2017 19:28
I have added a 'neat.threaded.ThreadedEvaluator' for evaluating genomes
in threads. This is useful when using a python implementation without
GIL.
The ThreadedEvaluator is based on the ParallelEvaluator.
neat.threaded.ThreadEvolver will now start its worker automatically
the documentation of 'neat.parallel.ParallelEvolver' said that
'eval_function' should take one argument (the genome), but it is
called with two arguments(the genome and the config).
@coveralls
Copy link

coveralls commented Jul 9, 2017

Coverage Status

Coverage decreased (-2.03%) to 90.538% when pulling fd24ff9 on bennr01:master into 765c5b5 on CodeReclaimers:master.

@drallensmith
Copy link
Contributor

drallensmith commented Jul 9, 2017

To get the test coverage back up, take a look at the tests subdirectory and do a search for "parallel", then add corresponding functions. (I'd also noticed the documentation glitch; it's noted in my docs_update branch - see #92 )

-Allen

bennr01 added 2 commits July 10, 2017 00:35
I have added a test for neat.threaded.ThreadedEvaluator based on the
test for neat.parallel.ParallelEvaluator.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.7%) to 91.899% when pulling 8950183 on bennr01:master into 765c5b5 on CodeReclaimers:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.7%) to 91.899% when pulling 8950183 on bennr01:master into 765c5b5 on CodeReclaimers:master.

@bennr01
Copy link
Contributor Author

bennr01 commented Jul 9, 2017

@drallensmith thanks, i have added a test (and actually found a bug, i always forget that there is no xrange in python3).
Edit: The Travic-CI build seems to fail on pypy3, but the tests works for me when i run them outside travis. Is this a random failure?
Edit 2: I found the problem. Travis uses an outdated pypy3. Manuall setting the pypy version using pypy3.5-5.8.0 fixes the build.

@coveralls
Copy link

coveralls commented Jul 9, 2017

Coverage Status

Coverage decreased (-0.02%) to 92.547% when pulling 9bb7616 on bennr01:master into 765c5b5 on CodeReclaimers:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 92.547% when pulling 9bb7616 on bennr01:master into 765c5b5 on CodeReclaimers:master.

bennr01 and others added 4 commits July 10, 2017 16:52
i removed the test for checki if
'neat.threaded.ThreadedEvaluator.__del__'  stops the threads. This is
because __del__ is not always called and thus may result in false test
results.
I have changed travis.yml to use `pypy3.5-5.8.0` instead of `pypy3`.
Travis uses an outdated version of `pypy3`.
`pypy3.5-5.8.0` contains some fixes for multithreaded scripts, which *may* fix the bug in the travic-ci build for `neat.threaded.ThreadedEvaluator`.
travis-ci: explicitly set pypy3 version to `pypy3.5-5.8.0`
@drallensmith
Copy link
Contributor

Putting in travis_wait also works, BTW - see my current pull request. (Sorry, didn't realize that you were having that problem...) Quite welcome re testing - I just had that happen over on LARG/HFO with me; since it's mostly C++, they were using "did it build" as their test, along with running a few examples, so I didn't find a bug until after I actually added some testing scripts.

travis-ci uses an outdated `pypy3`, which contains a bug when using multiple threads. This causes some test to fail on `pypy3`.
Replacing `pypy3` with `pypy3.5-5.8.0` in `.travis.yml` fixes the tests.

I also added another test for general functionality of `neat.threaded.ThreadedEvaluator`.
@drallensmith
Copy link
Contributor

drallensmith commented Jul 10, 2017

Oh - it actually does only take 1 argument, it's just that the argument in question is a tuple of genome, config. (The Pool function won't do more than one argument.) I have to say I wish python tuples weren't just defined by commas - they're easy to miss.

@coveralls
Copy link

coveralls commented Jul 10, 2017

Coverage Status

Coverage increased (+0.2%) to 92.746% when pulling a8afafa on bennr01:master into 765c5b5 on CodeReclaimers:master.

@bennr01
Copy link
Contributor Author

bennr01 commented Jul 10, 2017

@drallensmith thanks for the continued help.
re testing: Maybe i should start adding tests to my projects too. They really do seem to help quite a bit. Although my experiences with automated tests is that it takes more time to fix the tests that fixing the code they are testing.

@drallensmith
Copy link
Contributor

Quite welcome. Of course, fixing the tested code requires knowing about the bugs first...

@bennr01
Copy link
Contributor Author

bennr01 commented Jul 15, 2017

I am closing this PR and will combine it with my next PR.

@CodeReclaimers
Copy link
Owner

Hey just wanted to say thanks for all the hard work on this--if I don't get some free time soon I'll just commit your PRs so they don't languish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.