# Creating inventory spaces using PyBIS?

**URL:** <https://community.openbis.ch/t/creating-inventory-spaces-using-pybis/275>\
**Category:** ELN, LIMS, Data management functionalities\
**Created:** [16 November 2023 14:26 UTC](https://community.openbis.ch/t/creating-inventory-spaces-using-pybis/275 "2023-11-16T14:26:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kerzel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.openbis.ch/kerzel/32/30_2.png) [@kerzel](https://community.openbis.ch/u/kerzel)\
**Post date:** [16 November 2023 14:26 UTC](https://community.openbis.ch/t/creating-inventory-spaces-using-pybis/275/1 "2023-11-16T14:26:08Z")

</div>

Dear all,

I’m trying to define and fill our schema from python.  
I noticed that I can create spaces with:

```auto
space_equipment_new = oBis.new_space(code=code_space_equipment, description='Equipment and devices')
space_equipment_new.save()

```

However, this ends up in `Others`, how do I make it appear in `Inventory spaces`?

Many thanks  
Ulrich

---

<div class="post-metadata">

**Author:** ![cbarillari](https://dub1.discourse-cdn.com/flex013/user_avatar/community.openbis.ch/cbarillari/32/10_2.png) [@cbarillari](https://community.openbis.ch/u/cbarillari)\
**Post date:** [20 November 2023 07:41 UTC](https://community.openbis.ch/t/creating-inventory-spaces-using-pybis/275/2 "2023-11-20T07:41:09Z")

</div>

Dear Ulrich,

this is described here: [Space Management — Python documentation](https://openbis.readthedocs.io/en/latest/user-documentation/general-admin-users/admins-documentation/space-management.html#move-spaces-between-lab-notebook-and-inventory)

---

<div class="post-metadata">

**Author:** ![kerzel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.openbis.ch/kerzel/32/30_2.png) [@kerzel](https://community.openbis.ch/u/kerzel)\
**Post date:** [20 November 2023 12:20 UTC](https://community.openbis.ch/t/creating-inventory-spaces-using-pybis/275/3 "2023-11-20T12:20:21Z")

</div>

Dear @cbarillari,

many thanks - yes, hm, I can create the new inventory space in the ELN without problem, but is it possible to do so from pyBIS?  
The webpage refers to the ELN/Core UI?

All the best  
Ulrich

---

<div class="post-metadata">

**Author:** ![cbarillari](https://dub1.discourse-cdn.com/flex013/user_avatar/community.openbis.ch/cbarillari/32/10_2.png) [@cbarillari](https://community.openbis.ch/u/cbarillari)\
**Post date:** [20 November 2023 12:33 UTC](https://community.openbis.ch/t/creating-inventory-spaces-using-pybis/275/4 "2023-11-20T12:33:52Z")

</div>

Unfortunately not, because Inventory and Lab Notebook only exist in the ELN UI, not in openBIS.

You can create a space with pyBIS and by default it will be shown in the ELN under Lab Notebook. You then need to move it to the Inventory in the ELN Settings.

---

<div class="post-metadata">

**Author:** ![jraedler](https://dub1.discourse-cdn.com/flex013/user_avatar/community.openbis.ch/jraedler/32/13_2.png) [@jraedler](https://community.openbis.ch/u/jraedler)\
**Post date:** [22 November 2023 12:33 UTC](https://community.openbis.ch/t/creating-inventory-spaces-using-pybis/275/5 "2023-11-22T12:33:04Z")

</div>

Dear Ulrich,

you can do this with pybis, but it’s a bit tricky. After you created a space you need to:

1. load the global or group specific ELN settings as a sample/object (with `get_sample`)
2. convert its property `$eln_settings` from JSON to python objects (with `json.loads`)
3. add the space to the list `inventorySpaces`
4. dump the settings back to JSON format (`json.dumps`) and apply to the property `$eln_settings`
5. save the settings sample

This works for us.
