From a691fe44934ba01196d1bf6f358170d4fe887db3 Mon Sep 17 00:00:00 2001 From: vermeul <swen@ethz.ch> Date: Tue, 23 Oct 2018 10:46:00 +0200 Subject: [PATCH] fixed CONTROLLEDVOCABULARY bug when property names do not match the vocabulary code --- pybis/src/python/pybis/property.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pybis/src/python/pybis/property.py b/pybis/src/python/pybis/property.py index dc6a8928fe1..1eeeebb572b 100644 --- a/pybis/src/python/pybis/property.py +++ b/pybis/src/python/pybis/property.py @@ -44,7 +44,7 @@ class PropertyHolder(): name = name.rstrip('_') property_type = self._type.prop[name]['propertyType'] if property_type['dataType'] == 'CONTROLLEDVOCABULARY': - return self._openbis.get_terms(name) + return self._get_terms(property_type['vocabulary']['code']) else: syntax = { property_type["label"] : property_type["dataType"]} if property_type["dataType"] == "TIMESTAMP": @@ -54,12 +54,12 @@ class PropertyHolder(): def __setattr__(self, name, value): if name not in self._property_names: - raise KeyError("No such property: '{}'".format(name)+". Allowed properties are: {}".format(self._property_names)) + raise KeyError("No such property: '{}'. Allowed properties are: {}".format(name, self._property_names)) property_type = self._type.prop[name]['propertyType'] data_type = property_type['dataType'] if data_type == 'CONTROLLEDVOCABULARY': - voc = self._openbis.get_terms(name) - value = value.upper() + voc = self._get_terms(property_type['vocabulary']['code']) + value = str(value).upper() if value not in voc.df['code'].values: raise ValueError("Value for attribute {} must be one of these terms: {}".format( name, ", ".join(voc.df['code'].values) -- GitLab