Skip to content

Conversation

@amruthesht
Copy link
Contributor

@amruthesht amruthesht commented Nov 19, 2025

Fixes #111

Changes made in this Pull Request:

  • timeout defualt value chnaged to 600
  • Imporvements to exception chaining and error propogation
  • test-cases for timeout
  • warning for timeout <= 1

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

❌ Patch coverage is 52.94118% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.50%. Comparing base (73d54b7) to head (51dd426).

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@amruthesht amruthesht self-assigned this Nov 19, 2025
@amruthesht amruthesht marked this pull request as ready for review November 19, 2025 07:44
Copy link
Member

@orbeckst orbeckst left a 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?

Comment on lines 210 to 223
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)
Copy link
Member

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?

Copy link
Contributor Author

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

Comment on lines 236 to 248
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)
Copy link
Member

Choose a reason for hiding this comment

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

repeated code

@ljwoods2
Copy link
Collaborator

@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 amruthesht requested a review from orbeckst November 21, 2025 08:31
@orbeckst
Copy link
Member

@amruthesht please resolve the conflict that's holding up the CI. Thanks.

Copy link
Member

@orbeckst orbeckst left a 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

  1. check the [coverage]((https://app.codecov.io/gh/Becksteinlab/imdclient/pull/120) for the code.
  2. mark untested code blocks with #pragma: nocover
  3. raise issues for larger code blocks that should be tested eventually

Comment on lines +50 to +52
logger.debug(
f"InThreadIMDServer: Listening on {host}:{self._bound_port}"
)
Copy link
Member

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()
Copy link
Member

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?

Comment on lines 194 to +199
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
Copy link
Member

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.

Comment on lines 439 to 445
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
Copy link
Member

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.

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.

Test IMDClient timeout kwarg, add helpful hint to use it

4 participants