Skip to content

Get rid of explicit SPICE unloading - #326

Merged
Mark2000 merged 1 commit into
developfrom
feature/less-spice-loading
May 18, 2026
Merged

Mark2000 merged 1 commit into
developfrom
feature/less-spice-loading

Conversation

@Mark2000

@Mark2000 Mark2000 commented Dec 15, 2025 •

Copy link
Copy Markdown
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How should this pull request be reviewed?

  • By commit
  • All changes at once

How Has This Been Tested?

Tested in BSK PR.

Checklist

  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation and release notes
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Base automatically changed from feature/model-modularity to develop January 2, 2026 21:40
@Mark2000
Mark2000 force-pushed the feature/less-spice-loading branch 2 times, most recently from 7967c99 to ccfedb3 Compare January 2, 2026 22:39
@Mark2000
Mark2000 force-pushed the feature/less-spice-loading branch from ccfedb3 to 6763016 Compare February 18, 2026 22:40
@Mark2000 Mark2000 changed the title Get rid of explicit SPICE unloading Get rid of explicit SPICE unloading www.test.com Feb 18, 2026
@Mark2000 Mark2000 changed the title Get rid of explicit SPICE unloading www.test.com Get rid of explicit SPICE unloading Feb 18, 2026
@Mark2000
Mark2000 force-pushed the feature/less-spice-loading branch from 6763016 to f4c87f0 Compare February 18, 2026 22:59
@Mark2000
Mark2000 marked this pull request as ready for review May 7, 2026 17:57
Copilot AI review requested due to automatic review settings May 7, 2026 17:57
@Mark2000
Mark2000 force-pushed the feature/less-spice-loading branch from f4c87f0 to f2f382c Compare May 7, 2026 18:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 called gravFactory.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 older bsk versions 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

  • TrajectorySimulator no 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.

@Mark2000
Mark2000 merged commit f9bad91 into develop May 18, 2026
7 checks passed
@Mark2000
Mark2000 deleted the feature/less-spice-loading branch May 18, 2026 23:48
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