Skip to content

fix: handle uninitialised runtime for get_artifact_warehouse#113

Merged
ccuetom merged 1 commit into
masterfrom
fix/get-artifact-warehouse-pre-init
Jun 24, 2026
Merged

fix: handle uninitialised runtime for get_artifact_warehouse#113
ccuetom merged 1 commit into
masterfrom
fix/get-artifact-warehouse-pre-init

Conversation

@bgrey001

@bgrey001 bgrey001 commented Jun 24, 2026

Copy link
Copy Markdown

@ciaran-coleman raised an issue when loading acquisitions in a notebook.

mosaic.get_artifact_warehouse() raised AttributeError: module mosaic has no attribute get_artifact_warehouse when called before mosaic.run() / mrun had initialised the runtime (e.g. from a notebook calling problem.acquisitions.load('acquisitions.h5').

Cause: the call was routed through mosaic.__getattr__getattr(None, ...).

Fix: add a top-level function that returns None when no runtime exists, otherwise delegates to getattr.

Tested using the following (before fix the bug is reproduced, post fix the test passes):

@pytest.fixture
def no_runtime():
    """Force mosaic._runtime to None and restore on teardown."""
    import mosaic
    saved = mosaic._runtime
    mosaic._runtime = None
    try:
        yield mosaic
    finally:
        mosaic._runtime = saved


def test_get_artifact_warehouse_returns_none_when_runtime_is_none(no_runtime):
    """The notebook case: ``mosaic.get_artifact_warehouse()`` must not raise."""
    assert no_runtime.get_artifact_warehouse() is None

@bgrey001 bgrey001 requested a review from ccuetom June 24, 2026 12:20
@ccuetom ccuetom merged commit a0b1b82 into master Jun 24, 2026
3 checks passed
@ccuetom ccuetom deleted the fix/get-artifact-warehouse-pre-init branch June 24, 2026 12:36
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