bionic icon indicating copy to clipboard operation
bionic copied to clipboard

Transitioning to assisted versioning mode doesn't catch errors with old artifacts

Open jqmp opened this issue 6 years ago • 0 comments
trafficstars

(This is a bit of an edge case, since it requires switching versioning modes. The only time I've encountered it was while trying to prepare a demo of the different versioning modes. But it'd be nice to figure out if there's an easy fix.)

Assisted versioning mode is intended to catch user errors by detecting when the user has updated a function's code but not its version. However, it can't do this for artifacts that were computed in the manual versioning mode. Here's an example as a failing test:

def test_indirect_versioning_mode_transition(builder):
    builder.assign('x', 2)

    @builder
    def y():
        return 3

    @builder
    def f(x, y):
        return x + y

    assert builder.build().get('f') == 5

    @builder  # noqa: F811
    def y():
        return 4

    # Since we're using manual versioning, it makes sense that we get a
    # stale value here.
    assert builder.build().get('f') == 5

    builder.set('core__versioning_mode', 'assist')

    # Ideally we'd get an error here, but we don't (the test fails).
    with pytest.raises(CodeVersioningError):
        builder.build().get('f')

This is because we (1) load f from the cache, (2) don't notice that the bytecode has changed (because we're in manual mode), (3) update the cache to indicate that f's value exactly satisfied what we wanted, which (4) which prevents any future bytecode checks for particular combination of artifact+code. I'm not 100% sure, but it may be possible to skip step (3) in manual mode, which should fix this.

jqmp avatar Oct 31 '19 13:10 jqmp