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
1bc2c28e
Commit
1bc2c28e
authored
3 years ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
ENH: more information from Properties is added to metadata now
parent
4fea5909
No related branches found
No related tags found
2 merge requests
!57
RELEASE 0.7.3
,
!52
F refactor high level api
Pipeline
#19509
canceled
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
+15
-27
15 additions, 27 deletions
src/caosdb/high_level_api.py
with
15 additions
and
27 deletions
src/caosdb/high_level_api.py
+
15
−
27
View file @
1bc2c28e
...
...
@@ -41,7 +41,7 @@ from .apiutils import get_type_of_entity_with
from
typing
import
Any
,
Optional
,
List
,
Union
,
Dict
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
,
fields
from
datetime
import
datetime
@dataclass
...
...
@@ -74,7 +74,6 @@ class CaosDBPythonUnresolvedReference:
def
__init__
(
self
,
id
=
None
):
self
.
id
=
id
class
CaosDBPythonEntity
(
object
):
_last_id
=
0
...
...
@@ -129,7 +128,7 @@ class CaosDBPythonEntity(object):
@name.setter
def
name
(
self
,
val
:
str
):
self
.
_name
=
name
self
.
_name
=
val
@property
def
description
(
self
):
...
...
@@ -140,7 +139,7 @@ class CaosDBPythonEntity(object):
@description.setter
def
description
(
self
,
val
:
str
):
self
.
_description
=
description
self
.
_description
=
val
@property
def
version
(
self
):
...
...
@@ -168,11 +167,15 @@ class CaosDBPythonEntity(object):
The entity to be set.
"""
name
=
ent
.
name
val
=
ent
.
value
pr
=
ent
.
datatype
val
,
reference
=
self
.
_type_converted_value
(
val
,
pr
)
self
.
set_property
(
name
,
val
,
reference
,
datatype
=
pr
)
val
=
self
.
_type_converted_value
(
ent
.
value
,
ent
.
datatype
)
metadata
=
self
.
get_property_metadata
(
ent
.
name
)
for
prop_name
in
fields
(
metadata
):
k
=
prop_name
.
name
metadata
.
__setattr__
(
k
,
ent
.
__getattribute__
(
k
))
self
.
set_property
(
ent
.
name
,
val
,
datatype
=
ent
.
datatype
)
def
get_property_metadata
(
self
,
prop_name
:
str
)
->
CaosDBPropertyMetaData
:
"""
...
...
@@ -223,21 +226,8 @@ class CaosDBPythonEntity(object):
overwrite: bool
Use this if you definitely only want one property with
that name (set to True).
datatype: Optional[str]
"""
# Store the datatype (if given) in a hidden field
# The datatypes will be stored in name, value pairs.
# TODO: check whether handling of lists and multi properties is correct.
metadata
=
self
.
get_property_metadata
(
name
)
metadata
.
datatype
=
datatype
if
isinstance
(
name
,
db
.
Entity
):
# TODO: check, whether this is reasonable?
name
=
name
.
name
raise
NotImplementedError
()
if
name
in
self
.
_forbidden
:
raise
RuntimeError
(
"
Entity cannot be converted to a corresponding
"
"
Python representation. Name of property
"
+
...
...
@@ -362,8 +352,7 @@ class CaosDBPythonEntity(object):
return
[
att
]
def
add_parent
(
self
,
parent
:
Union
[
CaosDBPythonUnresolvedParent
,
CaosDBPythonRecordType
]):
CaosDBPythonUnresolvedParent
,
"
CaosDBPythonRecordType
"
]):
"""
Add a parent to this entity. Either using an unresolved parent or
using a real record type.
...
...
@@ -371,11 +360,10 @@ class CaosDBPythonEntity(object):
if
self
.
has_parent
(
parent
):
raise
RuntimeError
(
"
Duplicate parent.
"
)
self
.
_parents
.
a
d
d
(
parent
)
self
.
_parents
.
a
ppen
d
(
parent
)
def
has_parent
(
self
,
parent
:
Union
[
CaosDBPythonUnresolvedParent
,
CaosDBPythonRecordType
]):
CaosDBPythonUnresolvedParent
,
"
CaosDBPythonRecordType
"
]):
"""
Check whether this parent already exists for this entity.
"""
...
...
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