Adds context manager to reduce code duplication in scripts that need a sim context (#436)
# Description
This PR introduces a context manager wrapper to `SimulationContext` that
can be reused by any future simulation scripts that require a similar
set up and tear down functionality. This enables using the `with`
keyword like:
```
for i in range(10):
with build_sim_context(sim_cfg) as sim:
# Do something with sim context
# State will be cleaned up at the end of this with block
```
Fixes #130
## Type of change
- New feature (non-breaking change which adds functionality)
## Checklist
- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have run all the tests with `./orbit.sh --test` and they pass
- [ ] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
---------
Signed-off-by:
jsmith-bdai <142246516+jsmith-bdai@users.noreply.github.com>
Signed-off-by:
James Smith <142246516+jsmith-bdai@users.noreply.github.com>
Co-authored-by:
Mayank Mittal <12863862+Mayankm96@users.noreply.github.com>
Showing
Please register or sign in to comment