Skip to content

Commit

Permalink
support float array as input parameter type
Browse files Browse the repository at this point in the history
  • Loading branch information
salmma committed Jun 4, 2024
1 parent fa38352 commit 6cf4f3c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ******************************************************************************
import json


class ParameterDictionary(dict):
"""
Definition of supported parameter types
"""
__parameter_types = {"String": str, "Integer": int, "Float": float, "Unknown": str, "Array": list}
__parameter_types = {"String": str, "Integer": int, "Float": float, "Unknown": str, "Array": list,
"FloatArray": list}

"""
Converts a given parameter type definition pair to a parameter of the defined type.
Expand All @@ -38,9 +40,13 @@ def __convert_to_typed_parameter(cls, parameter):
return None

try:
t = ParameterDictionary.__parameter_types[parameter['type']]
value = parameter['rawValue']
return t(value)
if parameter["type"] == "FloatArray":
value = json.loads(parameter['rawValue'])
return value
else:
t = ParameterDictionary.__parameter_types[parameter['type']]
value = parameter['rawValue']
return t(value)
except:
return None

Expand Down

0 comments on commit 6cf4f3c

Please sign in to comment.