Creating Inventory Spaces with PyBIS

I would like to create new spaces for the inventory. According to the admin documentation newly created spaces are shown in the lab notebook by default. They are moveable by editing the Settings. I need a solution that does not require the GUI. Unfortunately, neither PyBIS nor the Excel Import seem to be able to do that. Am I missing something?

Hi, the Inventory and Lab notebook exist in the ELN UI, but they are not entities in openBIS.
The info of whether a Space belongs to the Inventory or Lab notebook is stored in an openBIS object with json format. You could potentially modify this, but this object is quite complex and contains a lot of information, so we really would not recommend this.
Doing this via UI is the best option.

Hi, you can use pyBIS to change the ELN-Settings, but you need to be extra careful :wink:

import json

eln_settings_sample = o.get_sample("/ELN_SETTINGS/GENERAL_ELN_SETTINGS")
eln_settings = json.loads(eln_settings_sample.props('$eln_settings'))
# change whatever you need to change
# e.g. eln_settings['inventorySpaces'] = ['YOUR_INVENTORY', 'ANOTHER_INVENTORY`]
# make sure to store the property as a JSON string
eln_settings_sample.props['$eln_settings'] = json.dumps(eln_settings)
eln_settings_sample.save()
1 Like