Repository navigation
Get rid of explicit SPICE unloading - #326
Merged
Merged
Conversation
Mark2000
force-pushed
the
feature/less-spice-loading
branch
2 times, most recently
from
January 2, 2026 22:39
7967c99 to
ccfedb3
Compare
Mark2000
force-pushed
the
feature/less-spice-loading
branch
from
February 18, 2026 22:40
ccfedb3 to
6763016
Compare
Mark2000
force-pushed
the
feature/less-spice-loading
branch
from
February 18, 2026 22:59
6763016 to
f4c87f0
Compare
Mark2000
marked this pull request as ready for review
May 7, 2026 17:57
Mark2000
force-pushed
the
feature/less-spice-loading
branch
from
May 7, 2026 18:00
f4c87f0 to
f2f382c
Compare
There was a problem hiding this comment.
Pull request overview
Removes explicit SPICE-kernel unloading logic in WorldModel and TrajectorySimulator, aligning bsk_rl with updated Basilisk/SPICE behavior to reduce overhead and avoid relying on Python finalizers.
Changes:
- Removed
__del__implementations that calledgravFactory.unloadSpiceKernels()in simulation/world and orbital utilities. - Updated/renamed related unit tests and removed destructor-side-effect assertions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
tests/unittest/sim/test_world.py |
Updates unit tests to stop asserting explicit SPICE unload on object deletion; normalizes test names. |
src/bsk_rl/utils/orbital.py |
Removes SPICE-unload finalizer from TrajectorySimulator. |
src/bsk_rl/sim/world.py |
Removes SPICE-unload finalizer from WorldModel, relying on Basilisk’s updated behavior. |
Comments suppressed due to low confidence (2)
src/bsk_rl/sim/world.py:205
- This change removes explicit SPICE kernel unloading from the world lifecycle. Since this behavior is now dependent on Basilisk providing automatic kernel cleanup, consider enforcing a minimum
bsk/Basilisk version that includes the new SPICE behavior (or adding an explicit runtime/version check) so users running olderbskversions don’t accumulate loaded kernels across resets in a long-lived process.
# setup Spice interface for some solar system bodies
timeInitString = utc_init
self.gravFactory.createSpiceInterface(
path_ephem_data, timeInitString, epochInMsg=True
)
self.gravFactory.spiceObject.zeroBase = "earth"
self.simulator.AddModelToTask(
self.world_task_name, self.gravFactory.spiceObject, ModelPriority=priority
)
def setup_ephem_object(self, priority: int = 988, **kwargs) -> None:
"""Set up the ephemeris object to use with the SPICE library.
Args:
priority: Model priority.
**kwargs: Passed to other setup functions.
"""
self.ephemConverter = ephemerisConverter.EphemerisConverter()
src/bsk_rl/utils/orbital.py:553
TrajectorySimulatorno longer unloads SPICE kernels on object deletion. If this relies on newer Basilisk behavior, it would be safer to either (a) require that Basilisk version explicitly, or (b) provide an explicit cleanup/close method callers can invoke, since__del__timing is non-deterministic and older Basilisk versions may keep kernels loaded across many simulator instantiations.
@property
def r_BP_P(self) -> interp1d:
"""Interpolator for r_BP_P."""
if self.sim_time < self.dt * 3:
self.extend_to(self.dt * 3)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Merge one BSK is updated on pypi with spice PR: AVSLab/basilisk#1180
Uses new BSK spice behavior to limit overheads.
Type of change
How should this pull request be reviewed?
How Has This Been Tested?
Tested in BSK PR.
Checklist