Output Type Based on Input Type

Is there any way to make a plugin dynamically define output artifact types based on input artifact types? This could be useful in cases where the same action could apply to multiple artifact types.

For example, filtering samples/features from a FeatureTable by name is a common operation that would apply to Frequency, RelativeFrequency and PresenceAbsence tables. For this case it would be nice to write one action that accepts as input a FeatureTable of any subtype and returns a table with the same type as the input.

1 Like

Hey @Hunter_Cameron!

Unfortunately there is no such mechanism (aside from some ghosts in qiime2.core.type.Signature), but we do have an issue for this. We call this idea a TypeMap.

So far we have been able to avoid the need for this kind of functionality, but there are some cases (like you mention) where it would be very useful.

One of the more important constraints of this is the output type should be solvable in a static way. So at the moment, our best idea for that would be some kind of mapping between inputs and outputs. You could then encode that as JSON or anything else, and then any interface would be able to refine the output. And even if you chained actions together into an ad-hoc pipeline, you’d always know what the final types would be without running a single line of plugin code.

That’s a little complicated which is why we’ve avoided it for as long as we have (and may avoid it longer still).

1 Like