Skip to content

Bypassing validation #341

@bmcfee

Description

@bmcfee

Warning, possibly bad ideas to follow.

mir_eval is generally pretty defensive about its inputs, and (i think?) all of the evaluators include at least some minimal validation of inputs for proper formatting, semantics, data types, etc. This is a good thing in general, but it can be quite wasteful when validation checks are expensive and performed many times on the same inputs. In a current project of mine, I'm finding that more than half of the computation time is going into validation, and most of this is wasted as the comparisons are of different model outputs against the same reference data.

This makes me think that we could provide a mechanism to bypass validation of input in situations where the user is certain that the data is well-formed. (Note: for now, I've simply commented out the validation lines in question, but that's obviously a bad solution in general.) We could control this by a context manager and a global state variable (yuck, I know), which would be pretty slick from a user perspective:

scores = mir_eval.chord.evaluate(...)  # Does validation checks as usual

with mir_eval.unsafe():
   scores = mir_eval.chord.evaluate(...)  # Skips validation checks

Ugly as a global state variable is, I think I prefer it to threading flag parameters through all evaluators here. This is primarily because we already bury quite a few things in kwargs, and it would be easy to lose track. Forcing a context manager for this would at least make it explicit and visually distinct from the user's perspective when this is happening.

Or it might just be a bad idea. 🤷 Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions