-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tournaments can run on Windows #721
Conversation
This has not been used for a while now.
Todo: adjust docs.
This reverts commit af41e22.
Because life is short.
Agreed - we could even wrap the parallel processing in a condition that checks the os |
Good call, will put something like that together now :) 👍 |
I think this is in good shape for a review now:
Have added some tests and also a short documentation tutorial about parallel processing. I suggest that once this is OK'd and in:
|
What about the wrapping of the parallel processing in a condition so that it only happens if not windows? |
Yup: I missed that (thought I had done it), appveyor just pointed it out. Just pushing that now :) |
@@ -1,4 +1,7 @@ | |||
from __future__ import absolute_import | |||
import sys | |||
|
|||
on_windows = sys.platform.startswith("win") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you've gone with sys.platform rather than os.name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an educated reason: would os.name
be better? I have to check for nt
or something like that right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've always used os.name == 'nt'
based on answers at http://stackoverflow.com/questions/4553129/when-to-use-os-name-sys-platform-or-platform-system#11674977
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool: I'll change that 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I wondered if you knew something that I don't !!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope: I just got scared away by the nt
:) Have changed this with 72238a3
Big 👍 from me for this one. That was a painful day.... |
I don't know what you're talking about. Windows is easy! ;-) In all seriousness I tried to be fairly careful to clean up the files but it would have been really nice if NamedTemporaryFile actually did something useful in Windows (or if TemporaryDirectory had existed before Python 3.2). Multiprocessing on windows is a separate nightmare. |
You had done a great job, and it's highly appreciated. You figured out all the bugs 👍
We'll get there eventually (hopefully)! Either way hopefully this will all be in place so that you could contribute actual Game Theory next :) |
I actually checked and NamedDirectory wouldn't have helped (at least in cleaning up the files on windows). As far as I can tell the implementation of NamedTemporaryFile on windows with the locking behaviour is the only way to guarantee the file will be deleted. Without locking something else could open the file and then Windows wouldn't allow it to be removed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although this is good work, I'm not a fan of this kind of thing -- I doubt many windows users would use the library without a GUI and it makes the code more complex to maintain -- but I won't stand in the way.
Has anyone tested the library with bash on windows? That might be a better way to have some support on windows, and who knows, maybe multiprocessing works?
@@ -1,10 +1,11 @@ | |||
environment: | |||
matrix: | |||
- PYTHON: "C:\\Python27" | |||
- PYTHON: "C:\\Python34" | |||
#- PYTHON: "C:\\Python27" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we delete these if they won't be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have pushed that.
@@ -34,9 +33,9 @@ def test_full_tournament(self): | |||
tournament = axelrod.Tournament(name='test', players=strategies, | |||
game=self.game, turns=2, | |||
repetitions=2) | |||
tmp_file = tempfile.NamedTemporaryFile() | |||
filename = "test_outputs/test_tournament.csv" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we going to run into issues if the directory doesn't exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The directory should exist, I've put a README.md
file in there so cloning the library should put it there right?
@@ -93,11 +102,15 @@ def play(self, build_results=True, filename=None, | |||
self.progress_bar = tqdm.tqdm(total=len(self.match_generator), | |||
desc="Playing matches") | |||
|
|||
self.setup_output_file(filename) | |||
if on_windows and (filename is None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if the tournament takes up a lot of memory on windows, it won't work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup: it it takes up a lot of memory then it will crash. It will work fine if a filename is provided though.
I know of 3 that have (with anaconda, Jupyter etc I actually would hope we would not close the door on windows users). I expect I'll have students doing so too. Important to get it working natively on windows even if it does make it harder for us.
That's not really running on Windows though. I expect that if it runs on bash it might not pick up the |
Several of the students who came to the sprint were on windows - and I suspect that's often the case for young undergrads coming to university with their shiny new laptops! |
Bash on windows is Ubuntu related - but still beta and a little more work to install than Anaconda. I'm not sure if all the Linux features would work on it or not but I'm installing it now so I can find out. |
Thanks @Ducksual: that's helpful. Either way I think that in the interest of EDIT |
@Ducksual it would be interesting to know what the following does on bash for windows...:
|
|
Neat :) |
It's kind of neat but a little intimidating if you haven't used linux/bash before. After changing your machine to developer mode and going through the install you still don't have any gui support for linux. |
Oh absolutely. Bash for windows isn't really a solution. I was just curious :) |
Although it might be for some people as it looks like you would be able to run parallel tournaments with it. It's good to know. |
Thanks @Ducksual @drvinceknight @meatballs ! Great work everyone. |
Started with #719 but has a bit more:
I believe this will pass all CI tests... Heading to bed: will work on some more tomorrow :)