Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-pylib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
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-pylib
Commits
bd7f3ed7
Commit
bd7f3ed7
authored
3 years ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
ENH: default role is Record in high level API and implemented generic list support
parent
5d508313
No related branches found
No related tags found
2 merge requests
!57
RELEASE 0.7.3
,
!52
F refactor high level api
Pipeline
#20082
failed
3 years ago
Stage: code_style
Stage: linting
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosdb/high_level_api.py
+17
-10
17 additions, 10 deletions
src/caosdb/high_level_api.py
with
17 additions
and
10 deletions
src/caosdb/high_level_api.py
+
17
−
10
View file @
bd7f3ed7
...
@@ -606,7 +606,10 @@ class CaosDBPythonEntity(object):
...
@@ -606,7 +606,10 @@ class CaosDBPythonEntity(object):
Deserialize a yaml representation of an entity in high level API form.
Deserialize a yaml representation of an entity in high level API form.
"""
"""
entity
=
high_level_type_for_role
(
serialization
[
"
role
"
])()
if
"
role
"
in
serialization
:
entity
=
high_level_type_for_role
(
serialization
[
"
role
"
])()
else
:
entity
=
CaosDBPythonRecord
()
for
parent
in
serialization
[
"
parents
"
]:
for
parent
in
serialization
[
"
parents
"
]:
if
"
unresolved
"
in
parent
:
if
"
unresolved
"
in
parent
:
...
@@ -795,6 +798,18 @@ def _single_convert_to_python_object(robj: CaosDBPythonEntity,
...
@@ -795,6 +798,18 @@ def _single_convert_to_python_object(robj: CaosDBPythonEntity,
return
robj
return
robj
def
_convert_property_value
(
propval
):
if
isinstance
(
propval
,
CaosDBPythonUnresolvedReference
):
propval
=
propval
.
id
elif
isinstance
(
propval
,
CaosDBPythonEntity
):
propval
=
_single_convert_to_entity
(
standard_type_for_high_level_type
(
propval
)(),
propval
)
elif
isinstance
(
propval
,
list
):
propval
=
[
_convert_property_value
(
element
)
for
element
in
propval
]
# TODO: test case for list missing
return
propval
def
_single_convert_to_entity
(
entity
:
db
.
Entity
,
def
_single_convert_to_entity
(
entity
:
db
.
Entity
,
robj
:
CaosDBPythonEntity
):
robj
:
CaosDBPythonEntity
):
...
@@ -833,15 +848,7 @@ def _single_convert_to_entity(entity: db.Entity,
...
@@ -833,15 +848,7 @@ def _single_convert_to_entity(entity: db.Entity,
propval
=
robj
.
__getattribute__
(
prop
)
propval
=
robj
.
__getattribute__
(
prop
)
metadata
=
robj
.
get_property_metadata
(
prop
)
metadata
=
robj
.
get_property_metadata
(
prop
)
if
isinstance
(
propval
,
CaosDBPythonUnresolvedReference
):
propval
=
_convert_property_value
(
propval
)
propval
=
propval
.
id
elif
isinstance
(
propval
,
CaosDBPythonEntity
):
propval
=
_single_convert_to_entity
(
standard_type_for_high_level_type
(
propval
)(),
propval
)
elif
isinstance
(
propval
,
list
):
# propval = []
if
not
isinstance
(
propval
[
0
],
int
):
raise
NotImplementedError
()
entity
.
add_property
(
entity
.
add_property
(
name
=
prop
,
name
=
prop
,
...
...
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