Skip to content

Op validation #1

Description

@ctrueden

It would be nice if an op could provide a companion function for validation, which can be used to validate inputs before leaning on Appose to build out an environment or start any new process. Maybe something like:

@op(env="stardist", axes="xy")
def stardist2d(image: ndarray[axes("xy")]) -> ndarray[axes("xy")]:
    ...

@op_validator(op=stardist2d)
def stardist2d_validator(image: ndarray[axes("xy")]) -> str | None:
    if len(image.shape) != 2: return f"Expected 2D image but got {len(image.shape)}D"
    if image.shape[0] < 64 or image.shape[1] < 64: return f"Image is too small: expected at least 64x64 but got {image.shape[0]}x{image.shape[1]}"

As long as validation can be done without importing environment-specific things, skop runners can use them in the primary process to "fail fast" if inputs would be invalid.

(At the time of this writing, the axis specification syntax is still in flux, so by the time you are reading this, the above is probably wrong, but hopefully you get the idea about validator companion functions anyway.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions