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

Add tests for MongoDB and fix bugs #237

Merged
merged 13 commits into from
Feb 21, 2024

Conversation

thalassemia
Copy link
Contributor

@thalassemia thalassemia commented Feb 2, 2024

Adding MongoDB to the test environment proved very straightforward thanks to service containers. I repurposed an existing script to test large emits, query capabilities, and manual insertion of documents. Along the way, I fixed three issues:

  • time key was not being added to broken-down emits when time was 0
  • Deleting configuration in delete_experiment_from_database failed when using multiple CPU processes
  • Documents manually inserted using data_to_database were not retrievable by data_from_database unless a specific structure was adhered to

According to pytest, coverage of emitter.py went from 44% to 90% with this PR. Most of the remaining untested code is in the MongoDB Atlas functions.


By creating this pull request, I agree to the Contributor License
Agreement, which is available in CLA.md at the top level of this
repository.

@thalassemia thalassemia requested a review from a team as a code owner February 2, 2024 20:15
@@ -71,7 +71,7 @@ def test_hierarchy_update() -> None:
'Protein': {'X': 50 * units.mg / units.mL}}}}

# make a txtl composite, embedded under an 'agents' store
txtl_composer = AgentDivision({})
txtl_composer = AgentDivision({'growth': {'default_growth_noise': 0}})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test randomly failed on me once, so I'm hoping this change makes it more reproducible.

Copy link
Member

@eagmon eagmon left a comment

Choose a reason for hiding this comment

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

looks great @thalassemia!

Just a question about the pytest workflow -- how does this mongo image work? Does github host this?

vivarium/experiments/large_experiment.py Show resolved Hide resolved
@thalassemia
Copy link
Contributor Author

The image is hosted on Docker Hub: https://hub.docker.com/_/mongo. In this PR, I pinned the 6.0.13 version of the image for no particular reason. We could set the tag to latest to automatically pull the newest image.

@eagmon eagmon merged commit f92aa65 into vivarium-collective:master Feb 21, 2024
12 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.

2 participants