Add BSK numba module support#20
Open
schaubh wants to merge 5 commits into
Open
Conversation
513e5dd to
f53d4d9
Compare
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.
Closes #17
Summary
Add supported packaging and runtime integration for pure-Python Basilisk
modules in out-of-tree BSK-SDK extensions, including modules based on the
NumbaModelAPI introduced in Basilisk v2.11.This PR:
bsk_add_python_module()to package pure-Python modules in an extensionwheel.
bsk-sdkCMake package.NumbaModelwithout requiring extension authors to patch Basilisk at runtime.
NumbaAtmosphereexample using built-in and custom messages,optional input handling, persistent memory, timestamps, and module IDs.
Affected surfaces
bsk_add_swig_module()is unchanged. Thebsk_generate_messages()callinginterface is also unchanged, but generated messaging packages now register
their custom payload classes for
NumbaModeldtype lookup.Implementation details
Packaging pure-Python modules
bsk_add_python_module()accepts a Python source file and an output packagedirectory:
The helper copies the source during CMake configuration. CMake tracks the input,
so rebuilding the wheel after a source change installs the updated module. The
helper itself is included in the installed
bsk-sdkCMake package.Supporting extension-generated messages
Basilisk v2.11 resolves a
NumbaModelmessage payload dtype by payload-classname through
Basilisk.architecture.messaging. Generated extension messagingpackages now register their payload classes there when imported.
Registration is:
raises a clear
ImportErrorinstead of silently replacing the dtype.The example package imports its messaging package before the Numba module so
custom
Message<T>,Recorder<T>, and payload dtype registration is completebefore the module wrapper is loaded. No manual patching or duplicate copy of
Basilisk's
numbaModelimplementation is required.Dependencies
Numba remains an extension-level runtime dependency. It is not added to
bsk-sdk, so extensions containing only C or C++ modules do not acquire anunnecessary dependency. The example extension declares both
bskandnumbaand documents the existing SDK/Basilisk version checks.
Example
The custom atmosphere extension now includes
NumbaAtmosphere, which:Basilisk.architecture.numbaModel.NumbaModel.AtmoPropsMsgmessages.CustomAtmStatusMsg.InMsgIsLinkedguard for the optional custom-message input.ID in persistent module memory.
examples/scenarioNumbaAtmosphereExtension.pyruns three scheduled updatesusing the module installed from the extension wheel and records both built-in
and custom outputs. The example documentation links to the Basilisk
Numba module guide
for the complete module-authoring API.
Test coverage
The installed-wheel tests verify:
bskandnumbaruntime dependencies.clearly.
preserve values and timestamps across compiled updates.
CurrentSimNanos,moduleID, and persistent module memory are propagated.compiled function while message I/O remains valid.
__dtype__fails with a useful diagnostic.build and pass.
Verification
Built and installed the SDK and downstream extension wheels using Python 3.13,
Basilisk 2.11, and Numba 0.66.0:
python -m build --wheel --no-isolation \ -o extension-dist examples/custom-atm-extension python -m pip install extension-dist/*.whlVerified that the extension wheel contains:
Ran the complete SDK test suite:
Result:
Ran all example tests, including the installed Numba module and scenario:
Result:
Ran the example scenario directly:
Observed:
Also ran
git diff --checksuccessfully.Local verification was performed on macOS. CI exercises minimum and maximum
supported Python versions on Linux, macOS, and Windows; the nightly workflow
also exercises the full SDK and example test scopes against Basilisk develop.