-
Notifications
You must be signed in to change notification settings - Fork 62
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 non user code traceback #797
Conversation
Console output for errors now only shows the traceback for the users code, just need to fix minor issue
code should now be simpler and more readable
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 think we could do with a third test, one which tests if the traceback is fine if they return None
etc.
Reviewable status: 0 of 2 files reviewed, 6 unresolved discussions (waiting on @dent50cent)
aimmo-game-worker/avatar_runner.py, line 48 at r1 (raw file):
except InvalidActionException as e: print(str(e))
I think that if you call print
then str
will be automatically called, so maybe the str
is redundant? Also maybe we should have a comment explaining why we have a separate except
?
aimmo-game-worker/avatar_runner.py, line 75 at r1 (raw file):
return action.serialise() def format_user_traceback(self, tb_list):
This can be a static method
aimmo-game-worker/avatar_runner.py, line 75 at r1 (raw file):
return action.serialise() def format_user_traceback(self, tb_list):
I think a better name would be something like get_only_user_traceback
?
aimmo-game-worker/avatar_runner.py, line 78 at r1 (raw file):
start_of_user_traceback = 0 for i in range(len(tb_list)): if tb_list[i].__contains__('<string>'):
I think you should use the in
keyword here. In general, you shouldn't invoke magic methods directly, use in
, +
, or
etc
aimmo-game-worker/tests/test_avatar_runner.py, line 132 at r1 (raw file):
runner = AvatarRunner() response = runner.process_avatar_turn(world_map={}, avatar_state={}, src_code=avatar) self.assertFalse(response['log'].__contains__('/usr/src/app/'))
__contains__
aimmo-game-worker/tests/test_avatar_runner.py, line 145 at r1 (raw file):
runner = AvatarRunner() response = runner.process_avatar_turn(world_map={}, avatar_state={}, src_code=avatar) self.assertFalse(response['log'].__contains__('/usr/src/app/'))
__contains__
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'd suggest to try to briefly describe the sort of "various"/ "more" changes as it is a bit easier to review
Reviewable status: 0 of 2 files reviewed, 6 unresolved discussions (waiting on @dent50cent)
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.
Reviewable status: 0 of 2 files reviewed, 6 unresolved discussions (waiting on @dent50cent and @NiallEgan)
aimmo-game-worker/avatar_runner.py, line 48 at r1 (raw file):
Previously, NiallEgan (Niall Egan) wrote…
I think that if you call
str
will be automatically called, so maybe thestr
is redundant? Also maybe we should have a comment explaining why we have a separateexcept
?
These have been fixed, the examples i found when writing the code were for python 2.5 or lower, did more research and found it had be fixed for python 2.6. Added comment explaining the addition except.
aimmo-game-worker/avatar_runner.py, line 75 at r1 (raw file):
Previously, NiallEgan (Niall Egan) wrote…
This can be a static method
Done.
aimmo-game-worker/avatar_runner.py, line 75 at r1 (raw file):
Previously, NiallEgan (Niall Egan) wrote…
I think a better name would be something like
get_only_user_traceback
?
Done
aimmo-game-worker/avatar_runner.py, line 78 at r1 (raw file):
Previously, NiallEgan (Niall Egan) wrote…
I think you should use the
in
keyword here. In general, you shouldn't invoke magic methods directly, usein
,+
,or
etc
Done
aimmo-game-worker/tests/test_avatar_runner.py, line 132 at r1 (raw file):
Previously, NiallEgan (Niall Egan) wrote…
__contains__
Done.
aimmo-game-worker/tests/test_avatar_runner.py, line 145 at r1 (raw file):
Previously, NiallEgan (Niall Egan) wrote…
__contains__
Done.
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.
Reviewed 2 of 2 files at r2.
Reviewable status:complete! all files reviewed, all discussions resolved
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.
Reviewable status:
complete! all files reviewed, all discussions resolved
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.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dent50cent)
aimmo-game-worker/avatar_runner.py, line 55 at r2 (raw file):
except Exception as e: traceback_list = traceback.format_exc().split('\n')
Maybe this should be in get_only_user_traceback
?
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.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @NiallEgan)
aimmo-game-worker/avatar_runner.py, line 55 at r2 (raw file):
Previously, NiallEgan (Niall Egan) wrote…
Maybe this should be in
get_only_user_traceback
?
Done
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.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @NiallEgan and @dent50cent)
aimmo-game-worker/avatar_runner.py, line 77 at r3 (raw file):
@staticmethod def get_only_user_traceback(e):
Do we have to pass e
in here?
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.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @NiallEgan and @dent50cent)
aimmo-game-worker/avatar_runner.py, line 77 at r3 (raw file):
Previously, NiallEgan (Niall Egan) wrote…
Do we have to pass
e
in here?
no, this has been fixed.
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.
Reviewed 1 of 1 files at r3, 1 of 1 files at r4.
Reviewable status:complete! all files reviewed, all discussions resolved
Formatted traceback so the user's console only shows output relevant to their code.
This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)