clamsproject / clams-python

CLAMS SDK for python
http://sdk.clams.ai/
Apache License 2.0
4 stars 1 forks source link

Inconsistencies in map parameter #219

Closed marcverhagen closed 4 months ago

marcverhagen commented 4 months ago

Because

For the SWT app, the default value of the map parameter in metadata.py is an empty list. If the user sets those parameters during app invocation (for example ?map=S:slate&map=B:bar) then the value of map in the user parameters is a list while in the refined parameters it is a dictionary:

['S:slate', 'B:bar']             # user parameters
{'S': 'slate', 'B': 'bar'}       # refined parameters

If the user adds no map parameters then there is no map value in the user parameters, but there is a n empty list in the refined parameters (so the refined parameters can be a list or a dictionary).

If I set the default of map as follows:

metadata.add_parameter(
    name='map', type='map', default=['S:slate', 'B:bar'], description="")

Then the map value in refined parameters is that same list, which means that it needs to be manually turned into a dictionary before it is used downstream.

https://github.com/clamsproject/app-swt-detection/blob/e6662c46aa19e4540eccf42c83ecbf07cf9397be/app.py#L101-L112

I don't think there is any hurry in dealing with this, but maybe we can think a little bit about this for the future.

Done when

No response

Additional context

No response