@tensorleap_integration_test

code_loader.inner_leap_binder.leapbinder_decorators.tensorleap_integration_test

The tensorleap_integration_test decorates Tensorleap's integration test, and is used to instruct the platform on what code interfaces should be used when analyzing your model and to locally test the validity of a Tensorleap integration script.

@tensorleap_integration_test()
def integration_test(idx: int, subset: PreprocessResponse) -> None:
    pass

Examples

Basic Usage

from code_loader.plot_functions.visualize import visualize
from code_loader.inner_leap_binder.leapbinder_decorators import tensorleap_integration_test

# Import your integration functions (defined in your integration script)
from leap_integration import (
    preprocess_func, input_encoder, gt_encoder,
    image_visualizer, my_metric, my_loss, load_model
)

@tensorleap_integration_test()
def integration_test(idx, subset):
    image = input_encoder(idx, subset)
    gt = gt_encoder(idx, subset)

    model = load_model()
    y_pred = model([image])

    img_vis = image_visualizer(image)
    visualize(img_vis)

    metric_res = my_metric(gt, y_pred)
    loss_res = my_loss(gt, y_pred)
    print(metric_res, loss_res)


if __name__ == '__main__':
    train, val, *_ = preprocess_func()
    for i in range(3):
        integration_test(i, train)
        integration_test(i, val)

Last updated

Was this helpful?