diff --git a/integrationtests/crawl.py b/integrationtests/crawl.py index 65600016ed5dff97d3794b61cf540b9d0505698d..61f51c297bc1fafa686a334031f772e095ab3896 100755 --- a/integrationtests/crawl.py +++ b/integrationtests/crawl.py @@ -34,7 +34,7 @@ from caosadvancedtools.crawler import FileCrawler from caosadvancedtools.guard import INSERT, UPDATE from caosadvancedtools.scifolder import (AnalysisCFood, ExperimentCFood, PublicationCFood, SimulationCFood, - SoftwareCFood) + SoftwareCFood, ResultTableCFood) try: from sss_helper import get_argument_parser, print_success @@ -89,7 +89,7 @@ if __name__ == "__main__": interactive=False, hideKnown=False, cfood_types=[ExperimentCFood, AnalysisCFood, SoftwareCFood, PublicationCFood, SimulationCFood, - ]) + ResultTableCFood]) if args.authorize_run: for run_id in args.authorize_run: diff --git a/integrationtests/model.yml b/integrationtests/model.yml index 0a4ad381bfc119dd65d2c192f8de823deda525ae..357adfc7b6618f427297105f722b2d333c34c792 100644 --- a/integrationtests/model.yml +++ b/integrationtests/model.yml @@ -18,6 +18,14 @@ SoftwareVersion: binaries: sourceCode: Software: +DepthTest: + obligatory_properties: + temperature: + datatype: DOUBLE + description: 'temp' + depth: + datatype: DOUBLE + description: 'temp' Person: obligatory_properties: firstName: diff --git a/integrationtests/test_crawler_with_cfoods.py b/integrationtests/test_crawler_with_cfoods.py index c39c3fc67d7ca30e3d013ac205ef398de216ad9c..18aa4847845ca2353d82a0439102211f1072e77e 100755 --- a/integrationtests/test_crawler_with_cfoods.py +++ b/integrationtests/test_crawler_with_cfoods.py @@ -57,6 +57,17 @@ class CrawlerTest(unittest.TestCase): datfile.description) assert os.path.basename(datfile.path) == "datafile.dat" + # There should be two DepthTest Properties + depthtests = exp.get_property("DepthTest") + assert len(depthtests) == 1 + assert len(depthtests.value) == 2 + depthtest = db.Record(id=depthtests.value[0]) + depthtest.retrieve() + assert "DepthTest" in [p.name for p in project.get_parents()] + assert 234.4 == depthtest.get_property("temperature").value[0] + assert "簞C" == depthtest.get_property("temperature").unit + assert 3.0 == depthtest.get_property("depth").value[0] + # Should have a responsible person self.assertIsNotNone(exp.get_property("responsible")) person = db.Record(id=exp.get_property("responsible").value[0]) diff --git a/src/caosadvancedtools/scifolder/__init__.py b/src/caosadvancedtools/scifolder/__init__.py index d7d67937b42ca23173fc93d4e704411f33d80bc4..cf753cfc0b72bf95e34edea1301b96ed18f040d0 100644 --- a/src/caosadvancedtools/scifolder/__init__.py +++ b/src/caosadvancedtools/scifolder/__init__.py @@ -3,3 +3,4 @@ from .experiment_cfood import ExperimentCFood from .publication_cfood import PublicationCFood from .simulation_cfood import SimulationCFood from .software_cfood import SoftwareCFood +from .result_table_cfood import ResultTableCFood diff --git a/src/caosadvancedtools/scifolder/result_table_cfood.py b/src/caosadvancedtools/scifolder/result_table_cfood.py index edd65b309f0ae927949e3e7b6a3d0b3aa91d5f65..b6e5573d6bad26b32d10d24b54a04358cb5dd0e5 100644 --- a/src/caosadvancedtools/scifolder/result_table_cfood.py +++ b/src/caosadvancedtools/scifolder/result_table_cfood.py @@ -17,6 +17,7 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. import caosdb as db +import re import pandas as pd from caosadvancedtools.cfood import (AbstractFileCFood, assure_has_description, assure_has_parent, assure_has_property, @@ -63,7 +64,7 @@ class ResultTableCFood(AbstractFileCFood): rec.add_parent(self.match.group("recordtype")) for col in self.table.columns[:2]: - match = ResultTableCFood.match(col) + match = re.match(ResultTableCFood.property_name_re, col) if match.group("unit"): rec.add_property(match.group("pname"), row.loc[col], unit=match.group("unit")) @@ -77,6 +78,7 @@ class ResultTableCFood(AbstractFileCFood): def update_identifiables(self): for ii, (idx, row) in enumerate(self.table.iterrows()): for col in row.index: - assure_property_is(self.recs[ii], col, row.loc[col], to_be_updated=self.to_be_updated) + match = re.match(ResultTableCFood.property_name_re, col) + assure_property_is(self.recs[ii], match.group("pname"), row.loc[col], to_be_updated=self.to_be_updated) assure_property_is(self.experiment, self.match.group("recordtype"), self.recs, to_be_updated=self.to_be_updated) diff --git a/unittests/test.csv b/unittests/test.csv index f8ec95d33f7185960abfaa63284effc531bd8573..b005ccf120eb808d017b97e3b92777511cd0a126 100644 --- a/unittests/test.csv +++ b/unittests/test.csv @@ -1,3 +1,3 @@ -demperature [蚓] ,depth [m] +temperature [蚓] ,depth 234.4,3.0 344.6,5.1