From 5b3c722c2606ffbaa573c766c9075edda8a5f4fe Mon Sep 17 00:00:00 2001 From: alaskowski <alaskowski@ethz.ch> Date: Thu, 15 Jun 2023 10:47:38 +0200 Subject: [PATCH] SSDM-13623: Fixing property assignment flow to newly created sample type; Updating docs. PyBIS-1.35.6rc2 --- .../src/python/CHANGELOG.md | 2 + .../src/python/README.md | 4 +- .../src/python/pybis/__init__.py | 2 +- .../src/python/pybis/pybis.py | 18 ++++++-- .../src/python/setup.cfg | 2 +- api-openbis-python3-pybis/src/python/setup.py | 2 +- .../src/python/tests/test_sample.py | 42 +++++++++++++++++++ 7 files changed, 63 insertions(+), 9 deletions(-) diff --git a/api-openbis-python3-pybis/src/python/CHANGELOG.md b/api-openbis-python3-pybis/src/python/CHANGELOG.md index 1d609f04893..9ea53b8d317 100644 --- a/api-openbis-python3-pybis/src/python/CHANGELOG.md +++ b/api-openbis-python3-pybis/src/python/CHANGELOG.md @@ -1,6 +1,8 @@ ## Changes with pybis-1.35.6 - Added metaData attribute handling for sample, sampleType, experiment, experimentType, dataset, datasetType +- Fixed property assignment to a newly created sample type +- Updated docs ## Changes with pybis-1.35.5 diff --git a/api-openbis-python3-pybis/src/python/README.md b/api-openbis-python3-pybis/src/python/README.md index 739421c0092..20ba1f6a2f7 100644 --- a/api-openbis-python3-pybis/src/python/README.md +++ b/api-openbis-python3-pybis/src/python/README.md @@ -563,7 +563,7 @@ o.get_projects( o.get_projects(space='MY_SPACE') space.get_projects() -project.get_experiments() +project.get_experiments() # see details and limitations in Section 'search for experiments' project.get_attachments() # deprecated, as attachments are not compatible with ELN-LIMS. # Attachments are an old concept and should not be used anymore. @@ -745,7 +745,7 @@ sample.save() sample = o.get_sample('/MY_SPACE/MY_SAMPLE_CODE') sample = o.get_sample('20170518112808649-52') -samples= o.get_samples(type='UNKNOWN') # search for samples, see below +samples= o.get_samples(type='UNKNOWN') # see details and limitations in Section 'search for samples / objects' # get individual attributes sample.space diff --git a/api-openbis-python3-pybis/src/python/pybis/__init__.py b/api-openbis-python3-pybis/src/python/pybis/__init__.py index b065fb1d23c..ed69f7363be 100644 --- a/api-openbis-python3-pybis/src/python/pybis/__init__.py +++ b/api-openbis-python3-pybis/src/python/pybis/__init__.py @@ -15,7 +15,7 @@ name = "pybis" __author__ = "ID SIS • ETH Zürich" __email__ = "openbis-support@id.ethz.ch" -__version__ = "1.35.6rc1" +__version__ = "1.35.6rc2" from . import pybis from .pybis import DataSet diff --git a/api-openbis-python3-pybis/src/python/pybis/pybis.py b/api-openbis-python3-pybis/src/python/pybis/pybis.py index 3cb5587b4de..c37bcd9f607 100644 --- a/api-openbis-python3-pybis/src/python/pybis/pybis.py +++ b/api-openbis-python3-pybis/src/python/pybis/pybis.py @@ -2382,7 +2382,10 @@ class Openbis: where=None, **properties, ): - """Returns a DataFrame of all samples for a given space/project/experiment (or any combination) + """Returns a DataFrame of all samples for a given space/project/experiment (or any combination). + The default result contains only basic attributes, i.e identifier, permId, type, registrator, + registrationDate, modifier, modificationDate. Additional attributes may be downloaded by specifying + 'attrs' list. Filters ------- @@ -2560,7 +2563,10 @@ class Openbis: where=None, **properties, ): - """Returns a DataFrame of all samples for a given space/project (or any combination) + """Returns a DataFrame of all samples for a given space/project (or any combination). + The default result contains only basic attributes, i.e identifier, permId, type, registrator, + registrationDate, modifier, modificationDate. Additional attributes may be downloaded by specifying + 'attrs' list. Filters: -------- @@ -2783,7 +2789,10 @@ class Openbis: where=None, **properties, ): - """Returns a DataFrame of all dataSets for a given project/experiment/sample (or any combination) + """Returns a DataFrame of all dataSets for a given project/experiment/sample (or any combination). + The default result contains only basic attributes, i.e permId, type, experiment, sample, registrationDate, + modificationDate, location, status, presentInArchive, size. + Additional attributes may be downloaded by specifying 'attrs' list. Filters ------- @@ -4140,7 +4149,7 @@ class Openbis: get_object_types = get_sample_types # Alias - def get_sample_type(self, type, only_data=False, with_vocabulary=False): + def get_sample_type(self, type, only_data=False, with_vocabulary=False, use_cache=True): return self.get_entity_type( entity="sampleType", identifier=type, @@ -4148,6 +4157,7 @@ class Openbis: with_vocabulary=with_vocabulary, method=self.get_sample_type, only_data=only_data, + use_cache=use_cache ) get_object_type = get_sample_type # Alias diff --git a/api-openbis-python3-pybis/src/python/setup.cfg b/api-openbis-python3-pybis/src/python/setup.cfg index ca77a8a16e7..59c9b3405cd 100644 --- a/api-openbis-python3-pybis/src/python/setup.cfg +++ b/api-openbis-python3-pybis/src/python/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = PyBIS -version = 1.35.6rc1 +version = 1.35.6rc2 author = ID SIS • ETH Zürich author_email = openbis-support@id.ethz.ch license = Apache Software License Version 2.0 diff --git a/api-openbis-python3-pybis/src/python/setup.py b/api-openbis-python3-pybis/src/python/setup.py index fb31b656c0a..0a56f53fe16 100644 --- a/api-openbis-python3-pybis/src/python/setup.py +++ b/api-openbis-python3-pybis/src/python/setup.py @@ -26,7 +26,7 @@ with open("README.md", "r", encoding="utf-8") as fh: setup( name="PyBIS", - version="1.35.6rc1", + version="1.35.6rc2", author="ID SIS • ETH Zürich", author_email="openbis-support@id.ethz.ch", description="openBIS connection and interaction, optimized for using with Jupyter", diff --git a/api-openbis-python3-pybis/src/python/tests/test_sample.py b/api-openbis-python3-pybis/src/python/tests/test_sample.py index eb7e326e489..50420c887c3 100644 --- a/api-openbis-python3-pybis/src/python/tests/test_sample.py +++ b/api-openbis-python3-pybis/src/python/tests/test_sample.py @@ -278,3 +278,45 @@ def test_sample_array_properties(space): sample.save() assert sample.props['sample_array_integer'] == [3, 2, 1] + + +def test_create_sample_type_assign_property(space): + name_suffix = str(time.time()) + sc = "TEST_" + name_suffix + pc = "ESFA_" + name_suffix + ptc1 = "START_DATE_" + name_suffix + ptc2 = "EXP_DESCRIPTION_" + name_suffix + stc = "EXPERIMENTAL_STEP_MILAR_" + name_suffix + + # Create the new space and project + sp = space.openbis.new_space(code=sc, description="Test space") + sp.save() + pr = space.openbis.new_project(code=pc, space=sc, description="ESFA experiments") + pr.save() + + # Create the experiment + exp = space.openbis.new_collection(code=pc, project="/" + sc + "/" + pc, type="COLLECTION") + exp.save() + + # Create the sample type + date_prop = space.openbis.new_property_type(code=ptc1, dataType="TIMESTAMP", + label="Start date", + description="Date of the measurement") + date_prop.save() + date_prop = space.openbis.new_property_type(code=ptc2, dataType="MULTILINE_VARCHAR", + label="Experimental description", + description="Experimental description") + date_prop.save() + st = space.openbis.new_sample_type(code=stc, generatedCodePrefix="EXSTEPMILAR") + st.save() + + if st is None: + print(space.openbis.get_sample_types()) + st = space.openbis.get_sample_type(stc) + st.save() + + st.assign_property(ptc1) + st.assign_property(ptc2) + st.assign_property("$NAME") + st.save() + -- GitLab