PyBIS: new_object_type does not have "description"

Dear all,

it seems that in version pybis==1.36.3 the parameter “description” is not there?

    obj_electronmicroscope_new = oBis.new_object_type(
        code                = code_obj_electronmicroscope,
        generatedCodePrefix = 'ELECTRON_MICROSCOPE',
        #description         = 'Electron Microscope',
        autoGeneratedCode   = True
    )

Many thanks
Ulrich

Dear Ulrich,

‘Description’ is not part of the ‘new_object_type’ method parameter (and never has been). It is an attribute you can set, i.e:

obj_electronmicroscope_new = oBis.new_object_type(
        code                = code_obj_electronmicroscope,
        generatedCodePrefix = 'ELECTRON_MICROSCOPE',
        autoGeneratedCode   = True
    )
obj_electronmicroscope_new.description = 'Electron Microscope'

Where did you find this snippet? I can not find it in PyBIS docs

Best,
Adam

Dear @alaskowski

great, thank you.
I’m in the process of coding up our metadata schema, as well as populating it with instruments, consumables and (some) protocols in python.
(Similar to what you prepared in Java for the tutorials, but python based as I’m not sure how much people know about Java…
If you’re interested, I’m happy to share it with you once I’ve made some more progress?

All the best
Ulrich

Dear @kerzel

Sure, I don’t mind checking it out but I strongly recommend to share it with the whole community via our community github repo: openbis · GitHub

It may benefit other people in the future or someone may point out some improvements as well :wink:

Best,
Adam

Dear @alaskowski

of course - the code will go into a repo that is then shared with the community.
However, I though it maybe helpful if we do a little peer-review first and see if we can spot any things that should be improved, etc? I’d upload the code to the same repo though, it’s more a matter when to announce to the community they can have a look if they find it helpful.

All the best
bon weekend
Uli

Hello @kerzel , you could also consider the following options to populate the schema:

  • the Excel master data service
  • The new import API (coming in the next version)
  • Our JSON based schema export/import

The advantage over a simple pybis script is that these solutions all offer transactional behaviour

Dear @bafe,

many thanks - true.
It’s not just the metadata though, but also the instruments and devices, consumables, protocols, etc.
though, of course, some stuff will be filled by hand, we aim for talking to all groups, get their working environment and code it - I’m not sure we can track down everyone and everything over time otherwise…

All the best
Ulrich

Hello Ulrich,
Importing metadata on top of just a schema should be possible with any of the methods above.

I don’t want to sell you anything, but having done the custom scripting way before I’d like to stress the fact that the standard way is well though out and offers significant advantages compared to scripts when it comes to robustness and user friendliness.

Let me explain a bit.The excel import (as well as the Java V3 API, therefore our JSON import) support OpenBIS transactions:

All the creation/import operations specified in a configuration file happen in the same transaction (a “unit of work”). If anything fails during the import, the state of the OpenBIS database is rolled back to the state before the import, leaving a clean database behind.

If you don’t use transactions, an error happening midway during an import will result in an incomplete database with a potentially large number of objects but not the data you wanted to import. This might require manual clean-up.

I hope this helps clarify why I stress the importance of these features

Dear Simone,

many thanks for the detailed explanation. I’ll take another look at the options you suggested and investigate a bit more in detail.
Realistically, using Java will be difficult as most people will have some knowledge of Python but typically not to the level where they could code a more complex scenario

All the best
Uli

1 Like