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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-pylib
Commits
68e1c25c
Commit
68e1c25c
authored
Jul 12, 2021
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
deprication warning
parent
ca8f7d9b
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!19
ENH: add resolve_value to Property
This commit is part of merge request
!19
. Comments created here will be created in the context of that merge request.
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosdb/apiutils.py
+29
-21
29 additions, 21 deletions
src/caosdb/apiutils.py
with
29 additions
and
21 deletions
src/caosdb/apiutils.py
+
29
−
21
Edit
View file @
68e1c25c
...
@@ -31,6 +31,7 @@ Some simplified functions for generation of records etc.
...
@@ -31,6 +31,7 @@ Some simplified functions for generation of records etc.
import
sys
import
sys
import
tempfile
import
tempfile
from
collections.abc
import
Iterable
from
collections.abc
import
Iterable
import
warnings
from
subprocess
import
call
from
subprocess
import
call
from
caosdb.common.datatype
import
(
BOOLEAN
,
DATETIME
,
DOUBLE
,
FILE
,
INTEGER
,
from
caosdb.common.datatype
import
(
BOOLEAN
,
DATETIME
,
DOUBLE
,
FILE
,
INTEGER
,
...
@@ -85,6 +86,34 @@ def new_record(record_type, name=None, description=None,
...
@@ -85,6 +86,34 @@ def new_record(record_type, name=None, description=None,
return
r
return
r
def
id_query
(
ids
):
warnings
.
warn
(
"
Please use
'
create_id_query
'
, which only creates
"
"
the string.
"
,
DeprecationWarning
)
return
execute_query
(
create_id_query
(
ids
))
def
create_id_query
(
ids
):
return
"
FIND ENTITY WITH
"
+
"
OR
"
.
join
(
[
"
ID={}
"
.
format
(
id
)
for
id
in
ids
])
def
retrieve_entity_with_id
(
eid
):
return
execute_query
(
"
FIND ENTITY WITH ID={}
"
.
format
(
eid
),
unique
=
True
)
def
retrieve_entities_with_ids
(
entities
):
collection
=
Container
()
step
=
20
for
i
in
range
(
len
(
entities
)
//
step
+
1
):
collection
.
extend
(
execute_query
(
create_id_query
(
entities
[
i
*
step
:(
i
+
1
)
*
step
])))
return
collection
def
get_type_of_entity_with
(
id_
):
def
get_type_of_entity_with
(
id_
):
objs
=
retrieve_entities_with_ids
([
id_
])
objs
=
retrieve_entities_with_ids
([
id_
])
...
@@ -693,27 +722,6 @@ def _apply_to_ids_of_entity(entity, func):
...
@@ -693,27 +722,6 @@ def _apply_to_ids_of_entity(entity, func):
prop
.
value
=
func
(
prop
.
value
)
prop
.
value
=
func
(
prop
.
value
)
def
create_id_query
(
ids
):
return
"
FIND ENTITY WITH
"
+
"
OR
"
.
join
(
[
"
ID={}
"
.
format
(
id
)
for
id
in
ids
])
def
retrieve_entity_with_id
(
eid
):
return
execute_query
(
"
FIND ENTITY WITH ID={}
"
.
format
(
eid
),
unique
=
True
)
def
retrieve_entities_with_ids
(
entities
):
collection
=
Container
()
step
=
20
for
i
in
range
(
len
(
entities
)
//
step
+
1
):
collection
.
extend
(
execute_query
(
create_id_query
(
entities
[
i
*
step
:(
i
+
1
)
*
step
])))
return
collection
def
resolve_reference
(
prop
):
def
resolve_reference
(
prop
):
"""
resolves the value of a reference property
"""
resolves the value of a reference property
...
...
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