Skip to content
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

Remove pygame code (fixes #186) #219

Merged
merged 3 commits into from
Oct 21, 2017
Merged

Remove pygame code (fixes #186) #219

merged 3 commits into from
Oct 21, 2017

Conversation

Ditti4
Copy link
Contributor

@Ditti4 Ditti4 commented Oct 20, 2017

The commits in this pull request will (hopefully) remove all the pygame-related code, including all the rendering code and hopefully leaving no unused code behind, like it was requested in #186.

If you happen to find anything that you don't agree with or that you'd like me to change, just let me know. :)

@nirs nirs requested review from nirs and rollandf October 20, 2017 21:36
@nirs
Copy link
Member

nirs commented Oct 20, 2017

@Ditti4, thanks for your contribution!

Copy link
Member

@nirs nirs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ditti4 Thanks!

@@ -11,16 +10,5 @@ def __init__(self):

# Component interface

def init(self):
self.texture = pygame.image.load(config.finish_line_png)

def update(self, info):
self.timeleft = info["timeleft"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used only for rendering, I think we can remove the entire module.

@@ -18,31 +17,6 @@ def __init__(self):
self.players = {}
self.timeleft = config.game_duration

def init(self):
self.texture = pygame.image.load(config.dashboard_png)

def update(self, players, timeleft):
self.timeleft = timeleft
self.players = players
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dashboard is used only for rendering, we can remove the entire module.

car.init()
self.finish_line.init()
self.draw(self.surface)

def update(self, info):
self.track.update(info)
self.players = {p["name"]: p for p in info['players']}
self.dashboard.update(self.players, info["timeleft"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed

car.init()
self.finish_line.init()
self.draw(self.surface)

def update(self, info):
self.track.update(info)
self.players = {p["name"]: p for p in info['players']}
self.dashboard.update(self.players, info["timeleft"])
for player in self.players.itervalues():
self.cars[player['car']].update(player)
self.finish_line.update(info)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed

@Ditti4
Copy link
Contributor Author

Ditti4 commented Oct 20, 2017

Removing those two modules seems to have worked pretty well. I must've overlooked that those weren't used anymore. Sorry about that and thanks for pointing it out!

number_of_cars = 4
car_jitter = 10
play_sound = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "Dashboard", "Finish line", and "Window" are also not needed now.

The the "Files" section, we can remove the paths to the various resources (e.g. obstables_dir). I think the server is using only the install_dir to serve the resources.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The the "Files" section, we can remove the paths to the various resources (e.g. obstables_dir). I think the server is using only the install_dir to serve the resources.

Yup, just tried that. Only keeping the install_dir (well, and web_root and res_root) seems to work. I wasn't sure about removing that first so I kept it in. Thanks!

Copy link
Member

@nirs nirs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Member

@nirs nirs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@@ -1,5 +1,4 @@
autobahn
pygame
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We introduced duplication when adding the pipenv configuration. Note to self: open an issue for generating the requirements file from pipenv.

Copy link
Member

@nirs nirs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@nirs
Copy link
Member

nirs commented Oct 20, 2017

@Ditti4, Removing the rest of the unused configuration, it looks ready.

@nirs
Copy link
Member

nirs commented Oct 20, 2017

@Ditti4 but testing show that moving error to server package is incorrect - it is used by common/message. We need to move it back to common.

$ ./rose-server 
Traceback (most recent call last):
  File "./rose-server", line 3, in <module>
    from rose.server import main
  File "/home/nsoffer/src/rose/rose/server/main.py", line 9, in <module>
    from . import game, net
  File "/home/nsoffer/src/rose/rose/server/game.py", line 5, in <module>
    from rose.common import config, message, obstacles
  File "/home/nsoffer/src/rose/rose/common/message.py", line 2, in <module>
    from rose.common import error
ImportError: cannot import name error
$ ./rose-client examples/none.py 
Traceback (most recent call last):
  File "./rose-client", line 3, in <module>
    from rose.client import main
  File "/home/nsoffer/src/rose/rose/client/main.py", line 6, in <module>
    from rose.common import config, message
  File "/home/nsoffer/src/rose/rose/common/message.py", line 2, in <module>
    from rose.common import error
ImportError: cannot import name error

Unfortunately testing coverage is very low, so you must run both server and clients to check that everything still work.

  1. start the server
  2. in another shell, start a client with exampes/none.py
  3. in another shell, start a client with examples/random_driver.py
  4. open a browser at http://localhost:8880/
  5. Start a game

Thanks!

@Ditti4
Copy link
Contributor Author

Ditti4 commented Oct 20, 2017

Surprisingly enough, I followed those exact steps before every push. Looking at my local code base though, I can still see error.pyc in the common directory, so python must've used that one, ignoring the fact that the original .py file does not exist anymore.

@Ditti4
Copy link
Contributor Author

Ditti4 commented Oct 20, 2017

Hmm, the examples still use the actions module. Should we move that back as well, considering it's not only used by the server this way either?

@nirs
Copy link
Member

nirs commented Oct 20, 2017

@Ditti4 Right, the actions module is used by the driver code, we need to keep this module in the common package as well.

For another PR: It would be nice to write a test for client code loading a driver module, detecting such issues.

@nirs
Copy link
Member

nirs commented Oct 20, 2017

@Ditti4 useful way to avoid stale pyc files issue is to clean your tree before testing:

git clean -dxf

Note that it will delete anything which which git does not know about, including temporary files you may have created ;-)

@Ditti4
Copy link
Contributor Author

Ditti4 commented Oct 20, 2017

Do you mind if I go ahead and just remove the previous commit (which moved the two modules) using a rebase so the history gets cleaned up a little or would you prefer a revert?

@nirs
Copy link
Member

nirs commented Oct 20, 2017

@Ditti4 I like clean history. Best remove the commit using "git rebase -i" and push again using --force. I would like to rebase and merge the commits, without squashing them.

@Ditti4
Copy link
Contributor Author

Ditti4 commented Oct 21, 2017

@nirs Should I also mark the two commits removing more modules and more config options as fixups of their original commits or do you want me to keep those separate?

Locally I currently have them marked as fixup so we end up with total amount of three commits.

@nirs
Copy link
Member

nirs commented Oct 21, 2017

@Ditti4 yes, fixing the original commit instead of adding patches is preferred.

@Ditti4
Copy link
Contributor Author

Ditti4 commented Oct 21, 2017

Then there you go, all fixed up and hopefully final. Thanks for your guidance! :)

@nirs nirs merged commit fdd8726 into RedHat-Israel:master Oct 21, 2017
@nirs nirs mentioned this pull request Oct 21, 2017
@nirs
Copy link
Member

nirs commented Oct 21, 2017

@Ditti4 thanks for this fine work!

Would you like to try a more interesting and much harder task? see #177

nirs added a commit to nirs/ROSE that referenced this pull request Oct 21, 2017
Some imports and instance variables are not needed now in the client
package, after pygame was removed in RedHat-Israel#219.
nirs added a commit that referenced this pull request Oct 21, 2017
Some imports and instance variables are not needed now in the client
package, after pygame was removed in #219.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants