def METHOD_NAME(device, grating, offset):
    if grating not in device.axes["grating"].choices:
        raise ValueError("Grating must be one of %s" % (device.axes["grating"].choices.keys(),))
    device.SetGratingOffset(grating, offset)
    logging.info("Grating offset is at %d", device.GetGratingOffset(grating))