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
049776f4
Commit
049776f4
authored
3 years ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Allow internal properties in the extern keyword of yaml models
parent
78c738ed
No related branches found
No related tags found
2 merge requests
!39
Release 0.4.0
,
!37
F extern name
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosadvancedtools/models/data_model.py
+13
-2
13 additions, 2 deletions
src/caosadvancedtools/models/data_model.py
src/caosadvancedtools/models/parser.py
+4
-1
4 additions, 1 deletion
src/caosadvancedtools/models/parser.py
with
17 additions
and
3 deletions
src/caosadvancedtools/models/data_model.py
+
13
−
2
View file @
049776f4
...
@@ -33,6 +33,12 @@ import caosdb as db
...
@@ -33,6 +33,12 @@ import caosdb as db
from
caosdb.apiutils
import
compare_entities
,
describe_diff
from
caosdb.apiutils
import
compare_entities
,
describe_diff
CAOSDB_INTERNAL_PROPERTIES
=
[
"
name
"
,
"
unit
"
,
]
class
DataModel
(
dict
):
class
DataModel
(
dict
):
"""
Provides tools for managing a data model.
"""
Provides tools for managing a data model.
...
@@ -129,8 +135,13 @@ class DataModel(dict):
...
@@ -129,8 +135,13 @@ class DataModel(dict):
any_change
=
False
any_change
=
False
for
ent
in
existing_entities
:
for
ent
in
existing_entities
:
q
=
db
.
Query
(
"
FIND * with id={}
"
.
format
(
ent
.
id
))
if
ent
.
name
in
CAOSDB_INTERNAL_PROPERTIES
:
ref
=
q
.
execute
(
unique
=
True
)
# Workaround for the usage of internal properties like name
# in via the extern keyword:
ref
=
db
.
Property
(
name
=
ent
.
name
).
retrieve
()
else
:
q
=
db
.
Query
(
"
FIND * with id={}
"
.
format
(
ent
.
id
))
ref
=
q
.
execute
(
unique
=
True
)
diff
=
(
describe_diff
(
*
compare_entities
(
ent
,
ref
diff
=
(
describe_diff
(
*
compare_entities
(
ent
,
ref
),
name
=
ent
.
name
))
),
name
=
ent
.
name
))
...
...
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/models/parser.py
+
4
−
1
View file @
049776f4
...
@@ -22,7 +22,7 @@ import sys
...
@@ -22,7 +22,7 @@ import sys
import
caosdb
as
db
import
caosdb
as
db
import
yaml
import
yaml
from
.data_model
import
DataModel
from
.data_model
import
CAOSDB_INTERNAL_PROPERTIES
,
DataModel
# Keywords which are allowed in data model descriptions.
# Keywords which are allowed in data model descriptions.
KEYWORDS
=
[
"
parent
"
,
# deprecated, use inherit_from_* instead:
KEYWORDS
=
[
"
parent
"
,
# deprecated, use inherit_from_* instead:
...
@@ -186,6 +186,9 @@ class Parser(object):
...
@@ -186,6 +186,9 @@ class Parser(object):
ymlmodel
[
"
extern
"
]
=
[]
ymlmodel
[
"
extern
"
]
=
[]
for
name
in
ymlmodel
[
"
extern
"
]:
for
name
in
ymlmodel
[
"
extern
"
]:
if
name
in
CAOSDB_INTERNAL_PROPERTIES
:
self
.
model
[
name
]
=
db
.
Property
(
name
=
name
).
retrieve
()
continue
for
role
in
(
"
Property
"
,
"
RecordType
"
,
"
Record
"
,
"
File
"
):
for
role
in
(
"
Property
"
,
"
RecordType
"
,
"
Record
"
,
"
File
"
):
if
db
.
execute_query
(
"
COUNT {} {}
"
.
format
(
role
,
name
))
>
0
:
if
db
.
execute_query
(
"
COUNT {} {}
"
.
format
(
role
,
name
))
>
0
:
self
.
model
[
name
]
=
db
.
execute_query
(
self
.
model
[
name
]
=
db
.
execute_query
(
...
...
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