Skip to content
Snippets Groups Projects
Commit 5c6ba7bd authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

MAINT: getting closer to Spec

- reordered Experiment and Analysis CFood
- change Project folder name to 2010_xxx
- adjusted test to specs
- added function to set description
- Source -> SourceCode
- added source
parent 2673cffa
No related branches found
No related tags found
No related merge requests found
Showing with 49 additions and 30 deletions
...@@ -58,7 +58,7 @@ if __name__ == "__main__": ...@@ -58,7 +58,7 @@ if __name__ == "__main__":
c = Crawler(use_cache=True, access=access, c = Crawler(use_cache=True, access=access,
verbosity=DEBUG, verbosity=DEBUG,
food=[ProjectCFood, food=[ProjectCFood,
AnalysisCFood, ExperimentCFood, ExperimentCFood,AnalysisCFood,
PublicationCFood, SimulationCFood, PublicationCFood, SimulationCFood,
]) ])
c.crawl(files, interactive=False, security_level=UPDATE) c.crawl(files, interactive=False, security_level=UPDATE)
...@@ -4,7 +4,7 @@ responsible: ...@@ -4,7 +4,7 @@ responsible:
description: A description of another example analysis. description: A description of another example analysis.
source: source:
- filename: "/ExperimentalData/TestProject/2019-02-03/*.dat" - filename: "/ExperimentalData/2010_TestProject/2019-02-03/*.dat"
description: an example reference to a results file description: an example reference to a results file
scripts: scripts:
......
...@@ -8,7 +8,7 @@ results: ...@@ -8,7 +8,7 @@ results:
description: an example reference to a results file description: an example reference to a results file
source: source:
- filename: /ExperimentalData/TestProject/2019-02-03_something/ - filename: /ExperimentalData/2010_TestProject/2019-02-03_something/
description: an example reference to an experiment description: an example reference to an experiment
revisionOf: revisionOf:
......
...@@ -4,6 +4,6 @@ responsible: ...@@ -4,6 +4,6 @@ responsible:
description: A description of another example experiment. description: A description of another example experiment.
results: results:
- filename: "/ExperimentalData/TestProject/2019-02-03/*.dat" - filename: "/ExperimentalData/2010_TestProject/2019-02-03/*.dat"
description: an example reference to a results file description: an example reference to a results file
... ...
...@@ -4,7 +4,7 @@ responsible: ...@@ -4,7 +4,7 @@ responsible:
description: A description of another example experiment. description: A description of another example experiment.
source: source:
- /home/professional/CaosDB/caosdb-deploy/profiles/empty/custom/extroot/DataAnalysis/TestProject/2019-02-03/results.pdf - /home/professional/CaosDB/caosdb-deploy/profiles/empty/custom/extroot/DataAnalysis/2010_TestProject/2019-02-03/results.pdf
results: results:
- "*.pdf" - "*.pdf"
......
...@@ -16,7 +16,7 @@ revisonOf: ...@@ -16,7 +16,7 @@ revisonOf:
- ../2019-02-03 - ../2019-02-03
source: source:
- /extroot/ExperimentalData/TestProject/2019-02-03 - /extroot/ExperimentalData/2010_TestProject/2019-02-03
tags: tags:
- collagen - collagen
......
...@@ -23,11 +23,11 @@ responsible: ...@@ -23,11 +23,11 @@ responsible:
datatype: REFERENCE datatype: REFERENCE
results: results:
datatype: REFERENCE datatype: REFERENCE
data: source:
datatype: REFERENCE datatype: REFERENCE
scripts: scripts:
datatype: REFERENCE datatype: REFERENCE
Source: SourceCode:
Simulation: Simulation:
obligatory_properties: obligatory_properties:
date: date:
......
...@@ -24,7 +24,7 @@ class CrawlerTest(unittest.TestCase): ...@@ -24,7 +24,7 @@ class CrawlerTest(unittest.TestCase):
# There should be a Project with name TestProject which is referenced # There should be a Project with name TestProject which is referenced
project_id = exp.get_property("Project").value project_id = exp.get_property("Project").value
project = get_entity_with_id(project_id) project = get_entity_with_id(project_id)
assert project.name == "TestProject" assert project.name == "2010_TestProject"
assert "Project" in [p.name for p in project.get_parents()] assert "Project" in [p.name for p in project.get_parents()]
# There should be a datafile as result attached with path datafile.dat # There should be a datafile as result attached with path datafile.dat
...@@ -86,27 +86,21 @@ class CrawlerTest(unittest.TestCase): ...@@ -86,27 +86,21 @@ class CrawlerTest(unittest.TestCase):
datfile = get_entity_with_id(datfile_id) datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "plot.py" assert os.path.basename(datfile.path) == "plot.py"
# There should be a file as script attached with path plot.py
datfile_id = ana.get_property("source").value[0]
datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "datafile.dat"
self.assertEqual(datfile.description,
"an example reference to a results file")
# Should have a responsible person # Should have a responsible person
self.assertIsNotNone(ana.get_property("Responsible")) self.assertIsNotNone(ana.get_property("Responsible"))
person = db.Record(id=ana.get_property("Responsible").value) person = db.Record(id=ana.get_property("Responsible").value[0])
person.retrieve() person.retrieve()
self.assertEqual("Only", person.get_property("FirstName").value) print(person)
self.assertEqual("Only", person.get_property("firstname").value)
# Should have a description # Should have a description
self.assertIsNotNone(ana.description) self.assertIsNotNone(ana.description)
# Should reference an experiment # Should reference an experiment
self.assertIsNotNone(ana.get_property("Experiment")) self.assertIsNotNone(ana.get_property("Experiment"))
person = db.Record(id=ana.get_property("Responsible").value) exp = db.Record(id=ana.get_property("Experiment").value[0])
person.retrieve() exp.retrieve()
self.assertEqual("2019-02-03", person.get_property("date").value) self.assertEqual("2019-02-03", exp.get_property("date").value)
####################### #######################
# # second analysis # # # # second analysis # #
...@@ -125,9 +119,9 @@ class CrawlerTest(unittest.TestCase): ...@@ -125,9 +119,9 @@ class CrawlerTest(unittest.TestCase):
# Should reference an experiment # Should reference an experiment
self.assertIsNotNone(ana.get_property("Experiment")) self.assertIsNotNone(ana.get_property("Experiment"))
person = db.Record(id=ana.get_property("Responsible").value) exp = db.Record(id=ana.get_property("Experiment").value[0])
person.retrieve() exp.retrieve()
self.assertEqual("2019-02-03", person.get_property("date").value) self.assertEqual("2019-02-03", exp.get_property("date").value)
def test_simulation(self): def test_simulation(self):
###################### ######################
...@@ -168,7 +162,7 @@ class CrawlerTest(unittest.TestCase): ...@@ -168,7 +162,7 @@ class CrawlerTest(unittest.TestCase):
"FIND Simulation with date=2019-02-03 and identifier='something'", "FIND Simulation with date=2019-02-03 and identifier='something'",
unique=True) unique=True)
# There should be a file as script attached with path plot.py # There should be a file as script attached
exp = get_entity_with_id(sim.get_property("source").value) exp = get_entity_with_id(sim.get_property("source").value)
self.assertEqual(exp.parents[0].name, "Experiment") self.assertEqual(exp.parents[0].name, "Experiment")
...@@ -215,8 +209,8 @@ class CrawlerTest(unittest.TestCase): ...@@ -215,8 +209,8 @@ class CrawlerTest(unittest.TestCase):
datfile = get_entity_with_id(datfile_id) datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "poster.pdf" assert os.path.basename(datfile.path) == "poster.pdf"
# There should be a file as data attached with path plot.py # There should be a file as data attached
datfile_id = pub.get_property("sources").value[0] datfile_id = pub.get_property("source").value[0]
datfile = get_entity_with_id(datfile_id) datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "results.pdf" assert os.path.basename(datfile.path) == "results.pdf"
...@@ -228,8 +222,8 @@ class CrawlerTest(unittest.TestCase): ...@@ -228,8 +222,8 @@ class CrawlerTest(unittest.TestCase):
########################## ##########################
pub = db.execute_query("FIND *paper_on_exciting_stuff ", unique=True) pub = db.execute_query("FIND *paper_on_exciting_stuff ", unique=True)
# There should be a file as data attached with path plot.py # There should be a file as data attached
datfile_id = pub.get_property("sources").value[0] datfile_id = pub.get_property("source").value[0]
datfile = get_entity_with_id(datfile_id) datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "results.pdf" assert os.path.basename(datfile.path) == "results.pdf"
......
...@@ -287,6 +287,31 @@ def assure_object_is_in_list(obj, containing_object, property_name, ...@@ -287,6 +287,31 @@ def assure_object_is_in_list(obj, containing_object, property_name,
to_be_updated.append(containing_object) to_be_updated.append(containing_object)
def assure_has_description(entity, description, to_be_updated=None,
verbosity=INFO, force=False):
"""
Checks whether `entity` has the description that is passed.
If this is the case this function ends. Otherwise the entity is assigned
a new description. The list to_be_updated is supplied, the entity is added to
the list in order to indicate, that the entity `entity` should be updated.
Otherwise it is directly updated
"""
if entity.description == description:
return
entity.description = description
if to_be_updated is None:
if force:
entity.update(unique=False)
else:
guard.safe_update(entity, unique=False)
else:
to_be_updated.append(entity)
def assure_has_parent(entity, parent, to_be_updated=None, verbosity=INFO, def assure_has_parent(entity, parent, to_be_updated=None, verbosity=INFO,
force=False): force=False):
""" """
......
...@@ -80,7 +80,7 @@ def find_file_included_by(glob): ...@@ -80,7 +80,7 @@ def find_file_included_by(glob):
Returns a container. Returns a container.
""" """
query_string = "FIND file which is stored at '{}'".format(glob) query_string = "FIND file which is stored at {}".format(glob)
try: try:
return db.execute_query(query_string) return db.execute_query(query_string)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment