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
bc112cf6
Commit
bc112cf6
authored
7 months ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
FIX: Don't ignore top-level description or unit if datatype is given
parent
ed483239
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
#57882
passed
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/parser.py
+14
-19
14 additions, 19 deletions
src/caosadvancedtools/models/parser.py
unittests/test_yaml_model_parser.py
+23
-2
23 additions, 2 deletions
unittests/test_yaml_model_parser.py
with
37 additions
and
21 deletions
src/caosadvancedtools/models/parser.py
+
14
−
19
View file @
bc112cf6
...
@@ -351,25 +351,20 @@ debug : bool, optional
...
@@ -351,25 +351,20 @@ debug : bool, optional
if
prop
.
name
in
self
.
model
:
if
prop
.
name
in
self
.
model
:
model_prop
=
self
.
model
[
prop
.
name
]
model_prop
=
self
.
model
[
prop
.
name
]
# The information must be missing, we don't want to overwrite it accidentally:
# 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
:
if
prop
.
datatype
is
None
:
continue
if
isinstance
(
model_prop
,
db
.
RecordType
):
# TODO: Data type overwrite is allowed here (because
prop
.
datatype
=
model_prop
.
name
# of lists), but this might change in the future.
else
:
# raise RuntimeError("datatype must not be set, here. This is probably a bug.")
prop
.
datatype
=
model_prop
.
datatype
if
prop
.
unit
is
not
None
and
prop
.
unit
!=
model_prop
.
unit
:
# TODO: Data type overwrite is allowed here (because
continue
# of lists), but this might change in the future.
if
prop
.
description
is
not
None
and
prop
.
description
!=
model_prop
.
description
:
# elif prop.datatype != model_prop.datatype:
continue
# raise RuntimeError("datatype must not be set, here. This is probably a bug.")
if
prop
.
unit
is
None
:
# If this property has a more detailed definition in the model,
# No unit for plain reference properties
# copy over the information:
if
not
isinstance
(
model_prop
,
db
.
RecordType
):
prop
.
unit
=
model_prop
.
unit
if
isinstance
(
model_prop
,
db
.
RecordType
):
if
prop
.
description
is
None
:
# 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
prop
.
description
=
model_prop
.
description
return
DataModel
(
self
.
model
.
values
())
return
DataModel
(
self
.
model
.
values
())
...
...
This diff is collapsed.
Click to expand it.
unittests/test_yaml_model_parser.py
+
23
−
2
View file @
bc112cf6
...
@@ -657,9 +657,11 @@ RT1:
...
@@ -657,9 +657,11 @@ RT1:
obligatory_properties:
obligatory_properties:
foo:
foo:
RT2:
RT2:
datatype: LIST<RT2>
test_reference:
test_reference:
RT2:
RT2:
description: Describe RT2
test_reference:
test_reference:
datatype: RT2
datatype: RT2
...
@@ -681,10 +683,10 @@ test_reference:
...
@@ -681,10 +683,10 @@ test_reference:
<RecordType id=
"
2273
"
name=
"
RT1
"
>
<RecordType id=
"
2273
"
name=
"
RT1
"
>
<Version id=
"
0c1b9df6677ee40d1e1429b2123e078ee6c863e0
"
head=
"
true
"
/>
<Version id=
"
0c1b9df6677ee40d1e1429b2123e078ee6c863e0
"
head=
"
true
"
/>
<Property id=
"
2272
"
name=
"
foo
"
description=
"
bla bla
"
datatype=
"
INTEGER
"
unit=
"
m
"
importance=
"
OBLIGATORY
"
flag=
"
inheritance:FIX
"
/>
<Property id=
"
2272
"
name=
"
foo
"
description=
"
bla bla
"
datatype=
"
INTEGER
"
unit=
"
m
"
importance=
"
OBLIGATORY
"
flag=
"
inheritance:FIX
"
/>
<Property id=
"
2274
"
name=
"
RT2
"
d
atatype=
"
RT2
"
importance=
"
OBLIGATORY
"
flag=
"
inheritance:FIX
"
/>
<Property id=
"
2274
"
name=
"
RT2
"
d
escription=
"
Describe RT2
"
datatype=
"
LIST<RT2>
"
importance=
"
OBLIGATORY
"
flag=
"
inheritance:FIX
"
/>
<Property id=
"
2275
"
name=
"
test_reference
"
datatype=
"
RT2
"
importance=
"
OBLIGATORY
"
flag=
"
inheritance:FIX
"
/>
<Property id=
"
2275
"
name=
"
test_reference
"
datatype=
"
RT2
"
importance=
"
OBLIGATORY
"
flag=
"
inheritance:FIX
"
/>
</RecordType>
</RecordType>
<RecordType id=
"
2274
"
name=
"
RT2
"
>
<RecordType id=
"
2274
"
name=
"
RT2
"
description=
"
Describe RT2
"
>
<Version id=
"
185940642680a7eba7f71914dd8dd7758dd13faa
"
head=
"
true
"
/>
<Version id=
"
185940642680a7eba7f71914dd8dd7758dd13faa
"
head=
"
true
"
/>
</RecordType>
</RecordType>
<Property id=
"
2275
"
name=
"
test_reference
"
datatype=
"
RT2
"
>
<Property id=
"
2275
"
name=
"
test_reference
"
datatype=
"
RT2
"
>
...
@@ -699,13 +701,32 @@ test_reference:
...
@@ -699,13 +701,32 @@ test_reference:
c3
=
compare_entities
(
model
[
"
RT2
"
],
entities
[
2
])
c3
=
compare_entities
(
model
[
"
RT2
"
],
entities
[
2
])
c4
=
compare_entities
(
model
[
"
test_reference
"
],
entities
[
3
])
c4
=
compare_entities
(
model
[
"
test_reference
"
],
entities
[
3
])
# Make sure the mock response matches the datamodel definiton
# exactly, i.e., they only differ in ids which are None for all
# entities from the datamodel and not None for the mocked
# response.
for
cs
in
(
c1
,
c2
,
c3
,
c4
):
for
cs
in
(
c1
,
c2
,
c3
,
c4
):
assert
"
id
"
in
cs
[
0
]
assert
"
id
"
in
cs
[
0
]
assert
cs
[
0
][
"
id
"
]
is
None
assert
cs
[
0
][
"
id
"
]
is
None
assert
cs
[
0
][
"
parents
"
]
==
[]
for
name
,
val
in
cs
[
0
][
"
properties
"
].
items
():
# Also properties differ in ids: The one from the
# datamodel have None
assert
len
(
val
)
==
1
assert
"
id
"
in
val
assert
val
[
"
id
"
]
is
None
assert
"
id
"
in
cs
[
1
]
assert
"
id
"
in
cs
[
1
]
assert
cs
[
1
][
"
id
"
]
is
not
None
assert
cs
[
1
][
"
id
"
]
is
not
None
assert
cs
[
1
][
"
parents
"
]
==
[]
for
name
,
val
in
cs
[
1
][
"
properties
"
].
items
():
# Also properties differ in ids: The one from the
# mock response have not None
assert
len
(
val
)
==
1
assert
"
id
"
in
val
assert
val
[
"
id
"
]
is
not
None
# The server response would be the same as the xml above:
# The server response would be the same as the xml above:
def
get_existing_entities
(
ent_cont
):
def
get_existing_entities
(
ent_cont
):
return
entities
return
entities
...
...
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