Displaying out of order options from a list

Hello all,

I have seem to run into an issue with the ordering of option choices using:

from qiime2.plugin import Choices

The issue is that it does not keep the order from the plugin_setup.py when having a substantial amount of choices from a list of strings.

Input:

    parameters={'region': Str %Choices(['ITS2','ITS1','ALL']),
                    'taxa': Str %Choices(['A','B','C','D','E','F','G','H','I','L','M','N','O','P','Q', 'R', 'S', 'T','U','X','Y']),
                    'threads': Int},

Output:

However, when a few choices are being called, it works fine it seems.

Is there anyway to keep the order 100% the same?

This might be an issue of me being silly and not paying close attention.

This issue is not that big of a deal, but it would be more visual appealing to me if there is a way to keep the ordering the exact same as the plugin_setup.py

Thanks,

Kyle Weber.

Hey @kweber!

It's definitely not you, it's us! What's happening is the argument to Choices is converted to a set which doesn't have an order (and iteration over it is more or less random). In Python 3.6 dictionaries are now all implicitly ordered dictionaries, so set might inherit that behavior, however its really something we should deal with.

We've even have an issue for this which we've just never gotten around to tackling. If anyone wants to take that on, I'd be more than happy to assist :slight_smile:

3 Likes

Hey @ebolyen

As soon as you posted, I also discovered the github issue tracker of it.

I should have looked around a bit more before I posted, sorry about that.

Anyways, I will let the pros handle the issue :smile:.

Its not that big of a concern for me, I was just wondering if I was missing something or doing something wrong.

Thanks for the clarification on the issue.

Best,

Kyle Weber

2 Likes