Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-advanced-user-tools
Commits
8dc79b76
Commit
8dc79b76
authored
3 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
up
parent
e0b81504
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!39
Release 0.4.0
,
!6
Resulttable
Pipeline
#9105
failed
3 years ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/caosadvancedtools/scifolder/result_table_cfood.py
+82
-0
82 additions, 0 deletions
src/caosadvancedtools/scifolder/result_table_cfood.py
unittests/test.csv
+3
-0
3 additions, 0 deletions
unittests/test.csv
unittests/test_result_table_cfood.py
+67
-0
67 additions, 0 deletions
unittests/test_result_table_cfood.py
with
152 additions
and
0 deletions
src/caosadvancedtools/scifolder/result_table_cfood.py
0 → 100644
+
82
−
0
View file @
8dc79b76
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (C) 2019 Henrik tom Wörden
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import
caosdb
as
db
import
pandas
as
pd
from
caosadvancedtools.cfood
import
(
AbstractFileCFood
,
assure_has_description
,
assure_has_parent
,
assure_has_property
,
assure_object_is_in_list
,
get_entity
)
from
caosadvancedtools.read_md_header
import
get_header
from
..cfood
import
assure_property_is
,
fileguide
from
.experiment_cfood
import
ExperimentCFood
from
.generic_pattern
import
date_pattern
,
date_suffix_pattern
,
project_pattern
from
.utils
import
parse_responsibles
,
reference_records_corresponding_to_files
from
.withreadme
import
DATAMODEL
as
dm
from
.withreadme
import
RESULTS
,
REVISIONOF
,
SCRIPTS
,
WithREADME
,
get_glob
# TODO similarities with TableCrawler
class
ResultTableCFood
(
AbstractFileCFood
):
# win_paths can be used to define fields that will contain windows style
# path instead of the default unix ones. Possible fields are:
# ["results", "revisionOf"]
win_paths
=
[]
table_re
=
r
"
result_table_(?P<recordtype>.*).csv$
"
property_name_re
=
re
.
compile
(
r
"
^(?P<pname>.+?)\s*(\[\s?(?P<unit>.*?)\s?\] *)?$
"
)
@staticmethod
def
name_beautifier
(
x
):
return
x
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
table
=
pd
.
read_csv
(
fileguide
.
access
(
self
.
crawled_path
))
@staticmethod
def
get_re
():
return
(
"
.*/ExperimentalData/
"
+
project_pattern
+
date_pattern
+
date_suffix_pattern
+
ResultTableCFood
.
table_re
)
def
create_identifiables
(
self
):
self
.
recs
=
[]
self
.
experiment
,
self
.
project
=
(
ExperimentCFood
.
create_identifiable_experiment
(
self
.
match
))
for
idx
,
row
in
self
.
table
.
iterrows
():
rec
=
db
.
Record
()
rec
.
add_parent
(
self
.
match
.
group
(
"
recordtype
"
))
for
col
in
self
.
table
.
columns
[:
2
]:
match
=
ResultTableCFood
.
match
(
col
)
if
match
.
group
(
"
unit
"
):
rec
.
add_property
(
match
.
group
(
"
pname
"
),
row
.
loc
[
col
],
unit
=
match
.
group
(
"
unit
"
))
else
:
rec
.
add_property
(
match
.
group
(
"
pname
"
),
row
.
loc
[
col
])
self
.
identifiables
.
append
(
rec
)
self
.
recs
.
append
(
rec
)
self
.
identifiables
.
extend
([
self
.
experiment
,
self
.
project
])
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
)
assure_property_is
(
self
.
experiment
,
self
.
match
.
group
(
"
recordtype
"
),
self
.
recs
,
to_be_updated
=
self
.
to_be_updated
)
This diff is collapsed.
Click to expand it.
unittests/test.csv
0 → 100644
+
3
−
0
View file @
8dc79b76
demperature [°C] ,depth [m]
234.4,3.0
344.6,5.1
This diff is collapsed.
Click to expand it.
unittests/test_result_table_cfood.py
0 → 100644
+
67
−
0
View file @
8dc79b76
#!/usr/bin/env python3
# encoding: utf-8
#
# ** header v3.0
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# ** end header
#
"""
test module for ResultTableCFood
"""
import
os
import
re
import
unittest
import
caosdb
as
db
from
caosadvancedtools.scifolder.result_table_cfood
import
ResultTableCFood
class
CFoodTest
(
unittest
.
TestCase
):
def
test_re
(
self
):
self
.
assertIsNotNone
(
re
.
match
(
ResultTableCFood
.
table_re
,
"
result_table_Hallo.csv
"
))
self
.
assertEqual
(
re
.
match
(
ResultTableCFood
.
table_re
,
"
result_table_Hallo.csv
"
).
group
(
"
recordtype
"
),
"
Hallo
"
)
self
.
assertIsNotNone
(
re
.
match
(
ResultTableCFood
.
table_re
,
"
result_table_Cool RecordType.csv
"
))
self
.
assertEqual
(
re
.
match
(
ResultTableCFood
.
table_re
,
"
result_table_Cool RecordType.csv
"
).
group
(
"
recordtype
"
),
"
Cool RecordType
"
)
self
.
assertIsNone
(
re
.
match
(
ResultTableCFood
.
table_re
,
"
result_tableCool RecordType.csv
"
))
self
.
assertIsNotNone
(
re
.
match
(
ResultTableCFood
.
property_name_re
,
"
temperature [C]
"
))
self
.
assertEqual
(
re
.
match
(
ResultTableCFood
.
property_name_re
,
"
temperature [C]
"
).
group
(
"
pname
"
),
"
temperature
"
)
self
.
assertEqual
(
re
.
match
(
ResultTableCFood
.
property_name_re
,
"
temperature [C]
"
).
group
(
"
unit
"
),
"
C
"
)
self
.
assertEqual
(
re
.
match
(
ResultTableCFood
.
property_name_re
,
"
temperature [ C ]
"
).
group
(
"
unit
"
),
"
C
"
)
self
.
assertEqual
(
re
.
match
(
ResultTableCFood
.
property_name_re
,
"
temperature
"
).
group
(
"
pname
"
),
"
temperature
"
)
def
test_ident
(
self
):
rtc
=
ResultTableCFood
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"
test.csv
"
))
rtc
.
match
=
re
.
match
(
ResultTableCFood
.
get_re
(),
"
/ExperimentalData/2010_TestProject/2019-02-03_something/result_table_RT.csv
"
)
rtc
.
create_identifiables
()
rtc
.
update_identifiables
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment