Create Masterdata using pyBIS

Dear all,
following the very nice workshop I thought we move towards creating the metadata from a script and, given the programming skills in the lab, python / pyBIS in particular.
I’ve upgraded to pybis 1.36.2, obis 0.4.4, the opbenbis server is at: 20.10.7.1

when I try to create the properties as in the tutorial:

pt1 = o.new_property_type(
    code        = 'NO_OF_EXP_RUNS', 
    label       = 'number of experiment runs', 
    description = 'number of experiment runs',
    dataType    = 'INTEGER',
)
pt1.save()

I get the following error message:

{"method": "createPropertyTypes", "params": ["ulrichkerzel-230925083439475xB457ABEBCB6F7E8AFA8CE5ACA698D222", [{"@type": "as.dto.property.create.PropertyTypeCreation", "code": "NO_OF_EXP_RUNS", "label": "number of experiment runs", "description": "number of experiment runs", "managedInternally": false, "dataType": "INTEGER", "vocabularyId": null, "materialTypeId": null, "schema": null, "transformation": null, "metaData": null, "multiValue": false}]], "id": "2", "jsonrpc": "2.0"}

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/kerzel/Repositories/openbis/openbis/test_schema.ipynb Cell 12 line 7
      1 pt1 = oBis.new_property_type(
      2     code        = 'NO_OF_EXP_RUNS', 
      3     label       = 'number of experiment runs', 
      4     description = 'number of experiment runs',
      5     dataType    = 'INTEGER',
      6 )
----> 7 pt1.save()

File ~/.cache/pypoetry/virtualenvs/openbis-qARisZC2-py3.10/lib/python3.10/site-packages/pybis/openbis_object.py:214, in OpenBisObject.save(self)
    211 if props:
    212     request["params"][1][0]["properties"] = props
--> 214 resp = self.openbis._post_request(self.openbis.as_v3, request)
    216 if VERBOSE:
    217     print(f"{self.entity} successfully created.")

File ~/.cache/pypoetry/virtualenvs/openbis-qARisZC2-py3.10/lib/python3.10/site-packages/pybis/pybis.py:1249, in Openbis._post_request(self, resource, request)
   1245 def _post_request(self, resource, request):
   1246     """internal method, used to handle all post requests and serializing / deserializing
   1247     data
   1248     """
-> 1249     return self._post_request_full_url(urljoin(self.url, resource), request)
...
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "multiValue" (class ch.ethz.sis.openbis.generic.asapi.v3.dto.property.create.PropertyTypeCreation), not marked as ignorable (12 known properties: "vocabularyId", "label", "managedInternally", "@id", "description", "code", "sampleTypeId", "schema", "dataType", "transformation", "materialTypeId", "metaData"])
 at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: ch.ethz.sis.openbis.generic.asapi.v3.dto.property.create.PropertyTypeCreation["multiValue"])
Attempt of deserialization without type failed with: 
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "@type" (class ch.ethz.sis.openbis.generic.asapi.v3.dto.property.create.PropertyTypeCreation), not marked as ignorable (12 known properties: "vocabularyId", "label", "managedInternally", "@id", "description", "code", "sampleTypeId", "schema", "dataType", "transformation", "materialTypeId", "metaData"])
 at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: ch.ethz.sis.openbis.generic.asapi.v3.dto.property.create.PropertyTypeCreation["@type"]) (through reference chain: java.util.ArrayList[0])

It seems to be related to the new field “multiValue” you mentioned during the workshop?
Though I’m not quite sure where it got in…

BTW, is there a way to delete a property type?

Similarly, when I try to crate a new object/sample type, I get:

obj_ebsdsim_software = oBis.new_object_type(
    code                = 'EBSDSIM_SOFTWARE',
    generatedCodePrefix = 'EBSDSIM_SOFTWARE',
    #description         = 'Software used in EBSD Simulation',
    autoGeneratedCode   = True
)
obj_ebsdsim_software.save()

(here, description is not known?)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/kerzel/Repositories/openbis/openbis/test_schema.ipynb Cell 13 line 7
      1 obj_ebsdsim_software = oBis.new_object_type(
      2     code                = 'EBSDSIM_SOFTWARE',
      3     generatedCodePrefix = 'EBSDSIM_SOFTWARE',
      4     #description         = 'Software used in EBSD Simulation',
      5     autoGeneratedCode   = True
      6 )
----> 7 obj_ebsdsim_software.save()

File ~/.cache/pypoetry/virtualenvs/openbis-qARisZC2-py3.10/lib/python3.10/site-packages/pybis/openbis_object.py:214, in OpenBisObject.save(self)
    211 if props:
    212     request["params"][1][0]["properties"] = props
--> 214 resp = self.openbis._post_request(self.openbis.as_v3, request)
    216 if VERBOSE:
    217     print(f"{self.entity} successfully created.")

File ~/.cache/pypoetry/virtualenvs/openbis-qARisZC2-py3.10/lib/python3.10/site-packages/pybis/pybis.py:1249, in Openbis._post_request(self, resource, request)
   1245 def _post_request(self, resource, request):
   1246     """internal method, used to handle all post requests and serializing / deserializing
   1247     data
   1248     """
-> 1249     return self._post_request_full_url(urljoin(self.url, resource), request)
...
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "metaData" (class ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.create.SampleTypeCreation), not marked as ignorable (12 known properties: "propertyAssignments", "showContainer", "showParentMetadata", "validationPluginId", "listable", "@id", "description", "code", "generatedCodePrefix", "autoGeneratedCode", "subcodeUnique", "showParents"])
 at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.create.SampleTypeCreation["metaData"])
Attempt of deserialization without type failed with: 
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "@

I also tried from the tutorial:

expt = oBis.new_experiment_type(code="MY_EXCITING_EXPERIMENT", description="my exciting new experiment")
expt.save()

but got the same error

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/kerzel/Repositories/openbis/openbis/test_schema.ipynb Cell 14 line 2
      1 expt = oBis.new_experiment_type(code="MY_EXCITING_EXPERIMENT", description="my exciting new experiment")
----> 2 expt.save()

File ~/.cache/pypoetry/virtualenvs/openbis-qARisZC2-py3.10/lib/python3.10/site-packages/pybis/openbis_object.py:214, in OpenBisObject.save(self)
    211 if props:
    212     request["params"][1][0]["properties"] = props
--> 214 resp = self.openbis._post_request(self.openbis.as_v3, request)
    216 if VERBOSE:
    217     print(f"{self.entity} successfully created.")

File ~/.cache/pypoetry/virtualenvs/openbis-qARisZC2-py3.10/lib/python3.10/site-packages/pybis/pybis.py:1249, in Openbis._post_request(self, resource, request)
   1245 def _post_request(self, resource, request):
   1246     """internal method, used to handle all post requests and serializing / deserializing
   1247     data
   1248     """
-> 1249     return self._post_request_full_url(urljoin(self.url, resource), request)

File ~/.cache/pypoetry/virtualenvs/openbis-qARisZC2-py3.10/lib/python3.10/site-packages/pybis/pybis.py:1296, in Openbis._post_request_full_url(self, full_url, request)
   1294 if "error" in resp:
   1295     print(json.dumps(request))
-> 1296     raise ValueError(resp["error"]["message"])
   1297 elif "result" in resp:
...
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "metaData" (class ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.create.ExperimentTypeCreation), not marked as ignorable (5 known properties: "propertyAssignments", "@id", "description", "code", "validationPluginId"])
 at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.create.ExperimentTypeCreation["metaData"])
Attempt of deserialization without type failed with: 
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "@type" (class ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.create.ExperimentTypeCreation), not marked as ignorable (5 known properties: "propertyAssignments", "@id", "description", "code", "validationPluginId"])
 at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.create.ExperimentTypeCreation["@type"]) (through reference chain: java.util.ArrayList[0])

Any help would be greatly appreciated.

Many thanks
Ulrich

Dear Ulrich,

For some reason new features like multiValue properties and entity metaData were not properly made backwards-compatible. I’m currently testing a fixed version of PyBIS and it should be released pretty soon. I will update this thread once it is done.

BTW, is there a way to delete a property type?

Yes, it is possible - you only need to use ‘delete()’ method:

pt = o.new_property_type(
        code=property_type_code,
        label='custom INTEGER property',
        description='custom property created in unit test',
        dataType='INTEGER',
    )
pt.save()

pt.delete('Reason for delete')

Best,
Adam