Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.9", "3.13"]
python: ["3.9", "3.14"]
include:
- python: "3.9"
python_label: "MIN Python"
- python: "3.13"
- python: "3.14"
python_label: "MAX Python"

steps:
Expand Down Expand Up @@ -69,11 +69,11 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.9", "3.13"]
python: ["3.9", "3.14"]
include:
- python: "3.9"
python_label: "MIN Python"
- python: "3.13"
- python: "3.14"
python_label: "MAX Python"

steps:
Expand Down Expand Up @@ -106,11 +106,11 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.9", "3.13"]
python: ["3.9", "3.14"]
include:
- python: "3.9"
python_label: "MIN Python"
- python: "3.13"
- python: "3.14"
python_label: "MAX Python"

steps:
Expand All @@ -132,7 +132,7 @@ jobs:
- name: Install bsk-sdk wheel and Basilisk
run: |
pip install dist/*.whl --force-reinstall
git clone --depth 1 --branch patch/v2_10_x \
git clone --depth 1 --branch develop \
https://github.com/AVSLab/basilisk.git _bsk_src
pip install numpy
pip install ./_bsk_src
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

- uses: actions/setup-python@v6
with:
python-version: "3.13"
python-version: "3.14"

- uses: ./.github/actions/build-sdk-wheel
with:
Expand Down
12 changes: 10 additions & 2 deletions cmake/bsk_generate_messages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,18 @@ function(bsk_generate_messages)
list(APPEND _generated_targets ${_payload_name})
endforeach()

# Generate __init__.py that re-exports all message payloads
# Generate __init__.py that re-exports all message payloads. Importing this
# package also registers the SWIG proxy classes for the generated Message<T>
# and Recorder<T> specializations, so plugin package __init__.py files should
# import their generated messaging package before importing module wrappers.
file(MAKE_DIRECTORY "${BSK_OUTPUT_DIR}")
set(_init_file "${BSK_OUTPUT_DIR}/__init__.py")
file(WRITE "${_init_file}" "")
file(WRITE "${_init_file}"
"\"\"\"Generated Basilisk message bindings for this plugin.\n\n"
"Importing this package registers custom Message<T> and Recorder<T> SWIG\n"
"proxy classes, including the recorder() methods on custom messages.\n"
"\"\"\"\n\n"
)
foreach(_hdr IN LISTS BSK_MSG_HEADERS)
get_filename_component(_payload_name "${_hdr}" NAME_WE)
file(APPEND "${_init_file}" "from .${_payload_name} import *\n")
Expand Down
15 changes: 15 additions & 0 deletions examples/custom-atm-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,18 @@ python -m build --wheel --no-isolation
pip install dist/*.whl pytest
pytest customExponentialAtmosphere/_UnitTest/ -v
```

## Custom message recorders

If a plugin defines custom messages with `bsk_generate_messages()`, import the
generated message package from the plugin's top-level `__init__.py` before
importing module wrappers:

```python
from . import messaging
from . import myModule
```

This mirrors Basilisk's own package initialization. It registers the custom
`Message<T>` and `Recorder<T>` SWIG proxy classes so users can call
`module.customOutMsg.recorder()` without explicitly importing the message type.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from Basilisk.architecture import messaging, bskLogging # noqa: E402
from Basilisk.utilities import SimulationBaseClass, macros # noqa: E402
from custom_atm import customExponentialAtmosphere # noqa: E402
from custom_atm.messaging import CustomAtmStatusMsg, CustomAtmStatusMsgPayload # noqa: E402


def _window_density(log) -> float:
Expand All @@ -31,6 +30,13 @@ def _window_density(log) -> float:
return float(max(vals))


def _plugin_messaging():
assert hasattr(custom_atm, "messaging"), (
"custom_atm.__init__ must import generated messaging before module wrappers"
)
return custom_atm.messaging


@pytest.fixture()
def sim_env():
"""Set up a minimal Basilisk sim with the custom atmosphere plugin."""
Expand Down Expand Up @@ -88,6 +94,15 @@ def test_plugin_links_architecture_utilities():
assert radius == pytest.approx(semi_major_axis, rel=1e-12, abs=0.0)


def test_package_import_exposes_generated_messaging():
"""Package import exposes generated message bindings and recorders."""
plugin_messaging = _plugin_messaging()
msg = plugin_messaging.CustomAtmStatusMsg()
rec = msg.recorder()

assert rec is not None


def test_density_at_400km(sim_env):
sim, atmosphere, log, dt = sim_env
sim.ConfigureStopTime(dt)
Expand All @@ -110,11 +125,12 @@ def test_density_positive(sim_env):
def test_status_message_updates_density(sim_env):
sim, atmosphere, log, dt = sim_env

status_pl = CustomAtmStatusMsgPayload()
plugin_messaging = _plugin_messaging()
status_pl = plugin_messaging.CustomAtmStatusMsgPayload()
status_pl.density = 2.0
status_pl.scaleHeight = 8_500.0
status_pl.modelValid = 1
status_msg = CustomAtmStatusMsg().write(status_pl)
status_msg = plugin_messaging.CustomAtmStatusMsg().write(status_pl)
atmosphere.connectAtmStatus(status_msg)

sim.ConfigureStopTime(dt)
Expand All @@ -130,11 +146,12 @@ def test_invalid_status_message_ignored(sim_env):
sim, atmosphere, log, dt = sim_env

# modelValid=0 — should be ignored, density stays at default baseDensity
status_pl = CustomAtmStatusMsgPayload()
plugin_messaging = _plugin_messaging()
status_pl = plugin_messaging.CustomAtmStatusMsgPayload()
status_pl.density = 999.0
status_pl.scaleHeight = 1.0
status_pl.modelValid = 0
status_msg = CustomAtmStatusMsg().write(status_pl)
status_msg = plugin_messaging.CustomAtmStatusMsg().write(status_pl)
atmosphere.connectAtmStatus(status_msg)

sim.ConfigureStopTime(dt)
Expand Down
12 changes: 9 additions & 3 deletions examples/custom-atm-plugin/custom_atm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

This directory defines the Python package that gets installed into the wheel.

It contains the `__init__.py` that registers Basilisk's `cSysModel` and imports
the compiled SWIG extension. At build time, scikit-build-core places the
generated `.so` / `.pyd` binaries and message bindings here.
It contains the `__init__.py` that registers Basilisk's `cSysModel`, imports
the generated custom message bindings, and then imports the compiled SWIG
extension. At build time, scikit-build-core places the generated `.so` / `.pyd`
binaries and message bindings here.

The generated `messaging` package must be imported before module wrappers that
expose custom message fields. That import registers the SWIG proxy classes for
the plugin's `Message<T>` and `Recorder<T>` specializations, which makes calls
such as `module.customOutMsg.recorder()` work without an extra user import.
7 changes: 6 additions & 1 deletion examples/custom-atm-plugin/custom_atm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
# this line the import fails with a confusing ModuleNotFoundError.
sys.modules.setdefault("cSysModel", _cSysModel)

# Import generated custom message bindings before SWIG module wrappers. This
# registers the plugin's Message<T> and Recorder<T> proxy classes so custom
# message fields exposed by modules have their Python methods, including
# recorder(), without requiring users to import custom_atm.messaging manually.
from . import messaging
from . import customExponentialAtmosphere

__all__ = ["customExponentialAtmosphere"]
__all__ = ["customExponentialAtmosphere", "messaging"]
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ backend-path = ["."]

[project]
name = "bsk-sdk"
version = "2.10.1"
version = "2.10.2"
description = "Vendored Basilisk SDK headers, runtime, and CMake integration for plugin authors"
readme = "README.md"
license = { text = "ISC" }
Expand Down
Loading