-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add push to openbis to update masterdata in openBIS #13
Comments
This is part of #11 |
Ok, I saw the documentation: https://openbis.readthedocs.io/en/latest/software-developer-documentation/apis/python-v3-api.html#create-sample-types-object-types |
A small snippet for something that works creating entities and assigning properties: from datetime import datetime
o = ologin()
code = "TEST_OBJECT_FROM_PYTHON"
objects_obis = [
entity.get("code") for entity in o.get_object_types().df.to_dict(orient="records")
]
if code in objects_obis:
obj = o.get_object_type(code)
obj.description = f"New description changed at <<{datetime.now()}>> Testing object creation from pybis"
else:
obj = o.new_object_type(
code=code,
description=f"<<{datetime.now()}>> Testing object creation from pybis",
generatedCodePrefix="TEST2025JAN",
autoGeneratedCode=True,
validationPlugin="",
)
obj.save()
## Assign properties to the object
properties_obis = [
entity.get("code") for entity in o.get_property_types().df.to_dict(orient="records")
]
code_prop_1 = "$NAME"
if code_prop_1 in properties_obis:
obj.assign_property(
prop="$NAME",
section="General information",
mandatory=True,
showInEditView=True,
)
else:
prop = o.new_property_type(
code=code_prop_1,
description="Name",
dataType="VARCHAR",
label="Name",
)
prop.save()
obj.assign_property(
prop="$NAME",
section="General information",
mandatory=True,
showInEditView=True,
)
code_prop_2 = "CHEMICAL"
if code_prop_2 in properties_obis:
obj.assign_property(
prop="CHEMICAL",
section="General information",
mandatory=True,
showInEditView=True,
)
else:
prop = o.new_property_type(
code=code_prop_2,
description="Chemical",
dataType="SAMPLE",
label="Chemical",
)
prop.save()
obj.assign_property(
prop="CHEMICAL",
section="General information",
mandatory=True,
showInEditView=True,
) |
We need to create a script to check and update the datamodel in the openBIS instance.
We could use the pyBIS methods
new_...
to create new object types/property types/vocabulary types if these do not exist in the instance. For this, the masterdata_checker is necessary.@carlosmada22
TODO:
push_to_openbis
which accepts:--excel-file
(same behavior as inimport-from-excel
):--python-path
checker
_log_msgs
:checker
has been successful (no critical, error, warning), creates or updates entity in openBISlogger.info("The checking of the entity type {cls_name} did not pass. Please, check your entity definitions.
The text was updated successfully, but these errors were encountered: