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
ef34db53
Commit
ef34db53
authored
7 months ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
FIX: add datatype, unit and description to properties that are part of Records
parent
cb4bc1ed
No related branches found
No related tags found
2 merge requests
!128
MNT: Added a warning when column metadata is not configured, and a better...
,
!115
add datatype, unit and description to properties that are part of Records
Pipeline
#56221
failed
7 months ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosadvancedtools/models/data_model.py
+1
-0
1 addition, 0 deletions
src/caosadvancedtools/models/data_model.py
src/caosadvancedtools/models/parser.py
+47
-19
47 additions, 19 deletions
src/caosadvancedtools/models/parser.py
with
48 additions
and
19 deletions
src/caosadvancedtools/models/data_model.py
+
1
−
0
View file @
ef34db53
...
@@ -149,6 +149,7 @@ class DataModel(dict):
...
@@ -149,6 +149,7 @@ class DataModel(dict):
),
name
=
ent
.
name
))
),
name
=
ent
.
name
))
if
diff
!=
""
:
if
diff
!=
""
:
breakpoint
()
if
verbose
:
if
verbose
:
print
(
diff
)
print
(
diff
)
any_change
=
True
any_change
=
True
...
...
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/models/parser.py
+
47
−
19
View file @
ef34db53
...
@@ -341,6 +341,38 @@ debug : bool, optional
...
@@ -341,6 +341,38 @@ debug : bool, optional
f
"
invalid keyword in line
{
entity
[
'
__line__
'
]
}
:
"
,
1
)
f
"
invalid keyword in line
{
entity
[
'
__line__
'
]
}
:
"
,
1
)
raise
ValueError
(
err_str
,
*
err
.
args
[
1
:])
from
err
raise
ValueError
(
err_str
,
*
err
.
args
[
1
:])
from
err
# Update properties that are part of record types:
# e.g. add their datatypes, units etc..
# Otherwise comparison of existing models and the parsed model become difficult.
for
name
,
ent
in
self
.
model
.
items
():
if
not
isinstance
(
ent
,
db
.
RecordType
):
continue
props
=
ent
.
get_properties
()
for
prop
in
props
:
if
prop
.
name
in
self
.
model
:
model_prop
=
self
.
model
[
prop
.
name
]
# The information must be missing, we don't want to overwrite it accidentally:
if
prop
.
datatype
is
not
None
and
prop
.
datatype
!=
model_prop
.
datatype
:
# breakpoint()
raise
RuntimeError
(
"
datatype must not be set, here. This is probably a bug.
"
)
if
prop
.
unit
is
not
None
and
prop
.
unit
!=
model_prop
.
unit
:
# continue
raise
RuntimeError
(
"
unit must not be set, here. This is probably a bug.
"
)
if
prop
.
description
is
not
None
and
prop
.
description
!=
model_prop
.
description
:
# continue
raise
RuntimeError
(
"
description must not be set, here. This is probably a bug.
"
)
# If this property has a more detailed definition in the model,
# copy over the information:
if
isinstance
(
model_prop
,
db
.
RecordType
):
# in this case the datatype equals the name of the record type:
prop
.
datatype
=
prop
.
name
else
:
prop
.
datatype
=
model_prop
.
datatype
prop
.
unit
=
model_prop
.
unit
prop
.
description
=
model_prop
.
description
return
DataModel
(
self
.
model
.
values
())
return
DataModel
(
self
.
model
.
values
())
@staticmethod
@staticmethod
...
@@ -470,6 +502,7 @@ debug : bool, optional
...
@@ -470,6 +502,7 @@ debug : bool, optional
"""
"""
for
n
,
e
in
props
.
items
():
for
n
,
e
in
props
.
items
():
if
n
in
KEYWORDS
:
if
n
in
KEYWORDS
:
if
n
in
KEYWORDS_IGNORED
:
if
n
in
KEYWORDS_IGNORED
:
continue
continue
...
@@ -543,6 +576,13 @@ debug : bool, optional
...
@@ -543,6 +576,13 @@ debug : bool, optional
if
name
in
self
.
treated
:
if
name
in
self
.
treated
:
raise
TwiceDefinedException
(
name
)
raise
TwiceDefinedException
(
name
)
# for reducing a little bit of code duplication:
importance_dict
=
{
"
recommended_properties
"
:
db
.
RECOMMENDED
,
"
obligatory_properties
"
:
db
.
OBLIGATORY
,
"
suggested_properties
"
:
db
.
SUGGESTED
}
for
prop_name
,
prop
in
definition
.
items
():
for
prop_name
,
prop
in
definition
.
items
():
if
prop_name
==
"
__line__
"
:
if
prop_name
==
"
__line__
"
:
continue
continue
...
@@ -558,26 +598,14 @@ debug : bool, optional
...
@@ -558,26 +598,14 @@ debug : bool, optional
# Handled above
# Handled above
continue
continue
elif
prop_name
==
"
recommended_properties
"
:
elif
prop_name
in
importance_dict
:
self
.
_add_to_recordtype
(
for
imp_name
,
imp_val
in
importance_dict
.
items
():
name
,
prop
,
importance
=
db
.
RECOMMENDED
)
if
prop_name
==
imp_name
:
self
.
_add_to_recordtype
(
for
n
,
e
in
prop
.
items
():
name
,
prop
,
importance
=
imp_val
)
self
.
_treat_entity
(
n
,
e
)
elif
prop_name
==
"
obligatory_properties
"
:
self
.
_add_to_recordtype
(
name
,
prop
,
importance
=
db
.
OBLIGATORY
)
for
n
,
e
in
prop
.
items
():
self
.
_treat_entity
(
n
,
e
)
elif
prop_name
==
"
suggested_properties
"
:
self
.
_add_to_recordtype
(
name
,
prop
,
importance
=
db
.
SUGGESTED
)
for
n
,
e
in
prop
.
items
():
for
n
,
e
in
prop
.
items
():
self
.
_treat_entity
(
n
,
e
)
self
.
_treat_entity
(
n
,
e
)
# datatype is already set
# datatype is already set
elif
prop_name
==
"
datatype
"
:
elif
prop_name
==
"
datatype
"
:
...
...
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