Hi, as I wrote above, when using the sample.save() call, and if in sample.props is a vocabulary attribute set as None, I am required to select one of the vocabulary terms.
Pybis version is 1.35.1
Here is my function:
def save_object(session, object_type, properties, parent_info=None, space=config.SPACE, project=config.PROJECT, experiment=config.EXPERIMENT):
"""Salva un oggetto in openBIS"""
try:
if object_type in config.COORDINATES.keys():
#OVERRIDE inputs
space=config.COORDINATES[object_type][0]
project=config.COORDINATES[object_type][1]
experiment=config.COORDINATES[object_type][2]
new_sample = session.new_sample(
type=object_type,
space=f"/{space}",
project=f"/{space}/{project}",
experiment=f"/{space}/{project}/{experiment}",
props=properties)
else:
new_sample = session.new_sample(
type=object_type,
space=f"/{space}",
project=f"/{space}/{project}" if project else None,
experiment=f"/{space}/{project}/{experiment}" if experiment else None,
props=properties)
if parent_info:
parent_samples = session.get_samples(where={'$name': parent_info['code']['$name']})
st.text("Parent samples")
st.text(parent_samples)
# we should iterate here or consider entire list
if parent_samples:
new_sample.parents = [parent_samples[0]]
new_sample.save()
return new_sample
except Exception as e:
st.error(f"Errore nel salvataggio: {e}")
return None
I copy-paste the exception message:
Errore nel salvataggio: Value for attribute «sediment.msl_sediment» must be one of these terms: MSL_SEDIMENT1, MSL_SEDIMENT2, MSL_SEDIMENT3, MSL_SEDIMENT4, MSL_SEDIMENT5, MSL_SEDIMENT6, MSL_SEDIMENT7, MSL_SEDIMENT8, MSL_SEDIMENT9, MSL_SEDIMENT10, MSL_SEDIMENT11, MSL_SEDIMENT12, MSL_SEDIMENT13, MSL_SEDIMENT14, MSL_SEDIMENT15, MSL_SEDIMENT16, MSL_SEDIMENT17, MSL_SEDIMENT18, MSL_SEDIMENT19, MSL_SEDIMENT20, MSL_SEDIMENT21, MSL_SEDIMENT22
Thank you for any help you can provide!
Best
Stefano
EDIT: I formatted the message a bit better
PS: in the ELN empty vocabulary attributes are allowed