-
Notifications
You must be signed in to change notification settings - Fork 2
timeout related fixes and error propogation improvements
#120
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is 🚀 New features to boost your workflow:
|
079696d to
0596e06
Compare
orbeckst
left a comment
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.
👍 on the timeout=600.
I have technical comments on the tests, please see inline.
@HeydenLabASU do you want to review and give your blessing?
@ljwoods2 do you have comments?
imdclient/tests/test_imdclient.py
Outdated
| server = InThreadIMDServer(universe.trajectory) | ||
| server.set_imdsessioninfo(imdsinfo) | ||
| server.handshake_sequence("localhost", first_frame=False) | ||
| client = IMDClient( | ||
| f"localhost", | ||
| server.port, | ||
| universe.trajectory.n_atoms, | ||
| timeout=timeout_val, | ||
| ) | ||
| server.join_accept_thread() | ||
|
|
||
| # Sleep for less than timeout before sending frames | ||
| time.sleep(timeout_val - 1) | ||
| server.send_frames(0) |
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.
This code is repeated - does it make sense to turn it into a fixture or at least a method that can be used by multiple tests?
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.
Yes, I can make a function that does the "server setup and connection" part of the code
imdclient/tests/test_imdclient.py
Outdated
| server = InThreadIMDServer(universe.trajectory) | ||
| server.set_imdsessioninfo(imdsinfo) | ||
| server.handshake_sequence("localhost", first_frame=False) | ||
| client = IMDClient( | ||
| f"localhost", | ||
| server.port, | ||
| universe.trajectory.n_atoms, | ||
| timeout=timeout_val, | ||
| ) | ||
| server.join_accept_thread() | ||
|
|
||
| # Sleep for longer than timeout without sending any frames | ||
| time.sleep(timeout_val + 1) |
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.
repeated code
|
@orbeckst super backed up atm, will need ~1 week to get to this. apologies, feel free to move forward without me if you're hoping to push a release |
|
@amruthesht please resolve the conflict that's holding up the CI. Thanks. |
00b7edb to
51dd426
Compare
orbeckst
left a comment
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 refactoring of the client/server in the tests looks good to me (and all tests continue to pass).
Coverage is low because you added many more cases for exceptions and we're not testing all these different fail cases separately. There also appears to be some code (InThread client?) that is not really tested at all (?)
I don't think it's worthwhile right now to create test cases for each separate failure case (unless it's easy to do, e.g. with mocking) but we should be clear what is untested code. Could you please
- check the [coverage]((https://app.codecov.io/gh/Becksteinlab/imdclient/pull/120) for the code.
- mark untested code blocks with
#pragma: nocover - raise issues for larger code blocks that should be tested eventually
| logger.debug( | ||
| f"InThreadIMDServer: Listening on {host}:{self._bound_port}" | ||
| ) |
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.
Did black want to reformat this??
| raise EOFError | ||
| raise EOFError("Consumer has finished") | ||
|
|
||
| return self._empty_q.get() |
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.
This return is never tested according to coverage. Do you know why and does it matter?
| try: | ||
| return self._producer._get_imdframe() | ||
| except EOFError: | ||
| except EOFError as e: | ||
| logger.debug(f"IMDClient: Single-threaded connection ended") | ||
| self._disconnect() | ||
| raise EOFError | ||
| raise EOFError from e |
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.
This block is never tested. Do we not test the single-threaded client?
I think we should do test it at least with a simple test. Otherwise we're advertising code for which we don't even know if it runs correctly.
| try: | ||
| self._parse_imdframe() | ||
| except EOFError as e: | ||
| raise EOFError | ||
| logger.debug(f"IMDProducer: No more frames to read: {e}") | ||
| raise EOFError from e | ||
| except Exception as e: | ||
| raise RuntimeError("An unexpected error occurred") from e |
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.
None of these lines are covered.
Fixes #111
Changes made in this Pull Request:
timeoutdefualt value chnaged to600timeouttimeout <= 1PR Checklist