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

Adapt tests to reuse Orchestrator #567

Merged
merged 30 commits into from
May 14, 2024
Merged

Conversation

ashao
Copy link
Member

@ashao ashao commented Apr 23, 2024

Tests which needed to launch an Orchestrator were spinning up and shutting down their own instances. This led to a number of cases where a single test failing would cascade into failures of other tests. Additionally, this also meant that a significant amount of time in the tests was spent waiting for Orchestrators to launch.

This PR adds a session-scoped fixture that returns an Orchestrator. Most tests which use an Orchestrator have been updated to use this fixture; the remaining for various reasons still need to spin up their own (for example the multiple database tests need to have a named Orchestrator).

This PR is not 100% complete with the following to be done

  • Add another fixture that flushes the database after every test
  • Undergo style checks
  • Fix failing tests

@ashao ashao requested review from ankona and MattToast April 23, 2024 20:43
conftest.py Outdated Show resolved Hide resolved
@MattToast MattToast removed their request for review April 25, 2024 17:54
conftest.py Outdated Show resolved Hide resolved
conftest.py Outdated Show resolved Hide resolved
Copy link
Member

@MattToast MattToast left a comment

Choose a reason for hiding this comment

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

Two small questions about intent that I wanted to write down so that I could cover them later while I pick up this PR

smartsim/database/orchestrator.py Outdated Show resolved Hide resolved
smartsim/database/orchestrator.py Outdated Show resolved Hide resolved
tests/test_experiment.py Outdated Show resolved Hide resolved
smartsim/experiment.py Outdated Show resolved Hide resolved
conftest.py Outdated Show resolved Hide resolved
@MattToast MattToast changed the title [Draft] Adapt tests to reuse Orchestrator Adapt tests to reuse Orchestrator Apr 30, 2024
@MattToast MattToast requested review from ankona, amandarichardsonn and AlyssaCote and removed request for ankona May 1, 2024 19:48
Copy link
Contributor

@AlyssaCote AlyssaCote left a comment

Choose a reason for hiding this comment

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

This is awesome! And I really like how it was implemented. I have a couple questions and there's a test file that needs some love, but that's it!

conftest.py Outdated Show resolved Hide resolved
Comment on lines 40 to 42
def test_single_db_fixture(single_db):
experiment = Experiment("test_single_fixture")
experiment.reconnect_orchestrator(single_db.checkpoint_file)
Copy link
Contributor

Choose a reason for hiding this comment

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

Incomplete test? And if we're testing one of the fixtures, we might want to test all of them!

Copy link
Member

Choose a reason for hiding this comment

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

Uhhh... good question! I've never written testing code for testing code before. I'll defer to @ashao on this one for intention.

Copy link
Member Author

Choose a reason for hiding this comment

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

How meta do we want to go? But yes the intention of this was to make sure that fixture works as expected. I'm imagining us bashing our head against something related to the fixture and just being able to do:

pytest test_fixtures.py::test_single_db_fixture

and save us some time down the line. Happy to be argued down, but in general I think it's not crazy to have a some sanity checking of testing code since it helps to debug tests

Copy link
Contributor

Choose a reason for hiding this comment

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

I definitely don't hate the idea of being able to sanity check that the fixtures are working as expected.

conftest.py Show resolved Hide resolved
Copy link
Contributor

@ankona ankona left a comment

Choose a reason for hiding this comment

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

This PR is like a dream come true. I can't wait for my speedy test results.

Copy link

codecov bot commented May 3, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 78.71%. Comparing base (0f4c765) to head (09aa6f3).
Report is 1 commits behind head on develop.

❗ Current head 09aa6f3 differs from pull request most recent head 3694737. Consider uploading reports for the commit 3694737 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #567      +/-   ##
===========================================
- Coverage    84.34%   78.71%   -5.63%     
===========================================
  Files           67       67              
  Lines         4637     4642       +5     
===========================================
- Hits          3911     3654     -257     
- Misses         726      988     +262     
Files Coverage Δ
smartsim/_core/config/config.py 91.56% <ø> (-7.23%) ⬇️
smartsim/database/orchestrator.py 87.30% <100.00%> (+0.29%) ⬆️
smartsim/entity/dbnode.py 91.22% <100.00%> (-0.88%) ⬇️
smartsim/entity/entityList.py 100.00% <ø> (ø)
smartsim/error/__init__.py 100.00% <ø> (ø)
smartsim/error/errors.py 100.00% <100.00%> (ø)
smartsim/_core/control/controller.py 74.93% <72.72%> (-2.76%) ⬇️
smartsim/ml/data.py 30.86% <20.00%> (-0.39%) ⬇️

... and 17 files with indirect coverage changes

Copy link
Contributor

@amandarichardsonn amandarichardsonn left a comment

Choose a reason for hiding this comment

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

LGTM, will take a second pass in the morning! Just some super small comments

smartsim/database/orchestrator.py Outdated Show resolved Hide resolved
smartsim/database/orchestrator.py Show resolved Hide resolved
smartsim/error/errors.py Show resolved Hide resolved
conftest.py Show resolved Hide resolved
@@ -102,7 +102,7 @@ Detailed Notes
Torch will unconditionally try to link in this library, however
fails because the linking flags are incorrect.
([SmartSim-PR538](https://github.com/CrayLabs/SmartSim/pull/538))
- Change type_extension and pydantic versions in readthedocs
- Change typing\_extensions and pydantic versions in readthedocs
Copy link
Contributor

Choose a reason for hiding this comment

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

I notice two updates to the Detailed Notes section but one update to the Description!

Copy link
Member

Choose a reason for hiding this comment

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

Yeah the change to "Description" and one of the "Detailed Notes" edits were just minor typo/grammar things.

The actual "Detailed Note" I added I figured fell under the category of "Minor enhancements to test suite" which is already listed in the "Description" section, so I just added something the details. LMK if you think this warrants its on entry in the "Description" and I can add something there!!

smartsim/_core/control/controller.py Show resolved Hide resolved
@ashao
Copy link
Member Author

ashao commented May 9, 2024

Note that Al noted a defect which causes cascading failures if the database was stopped on purpose or because of a database error. A fix is coming in

@ashao ashao marked this pull request as draft May 9, 2024 16:22
@ashao ashao force-pushed the orchestrator_fixture branch 5 times, most recently from a165c25 to 09aa6f3 Compare May 11, 2024 13:45
@ashao ashao marked this pull request as ready for review May 12, 2024 13:34
@ashao ashao requested a review from ankona May 12, 2024 13:34
Copy link
Contributor

@AlyssaCote AlyssaCote left a comment

Choose a reason for hiding this comment

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

LGTM!!

@ashao ashao merged commit 781d4b6 into CrayLabs:develop May 14, 2024
34 checks passed
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.

5 participants