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
8f6d3528
Commit
8f6d3528
authored
3 years ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
DOC: updated merge_entities docstr to note that the function is currently experimental
parent
a68883c4
No related branches found
No related tags found
2 merge requests
!57
RELEASE 0.7.3
,
!45
F copy entity
Pipeline
#21662
passed with warnings
3 years ago
Stage: code_style
Stage: linting
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosdb/apiutils.py
+7
-0
7 additions, 0 deletions
src/caosdb/apiutils.py
unittests/test_apiutils.py
+7
-4
7 additions, 4 deletions
unittests/test_apiutils.py
with
14 additions
and
4 deletions
src/caosdb/apiutils.py
+
7
−
0
View file @
8f6d3528
...
...
@@ -39,6 +39,8 @@ from caosdb.common.models import (Container, Entity, File, Property, Query,
Record
,
RecordType
,
execute_query
,
get_config
,
SPECIAL_ATTRIBUTES
)
import
logging
def
new_record
(
record_type
,
name
=
None
,
description
=
None
,
tempid
=
None
,
insert
=
False
,
**
kwargs
):
...
...
@@ -689,8 +691,13 @@ def merge_entities(entity_a: Entity, entity_b: Entity):
The merge operation is done in place.
Returns entity_a.
WARNING: This function is currently experimental and insufficiently tested. Use with care.
"""
logging
.
warning
(
"
This function is currently experimental and insufficiently tested. Use with care.
"
)
# Compare both entities:
diff_r1
,
diff_r2
=
compare_entities
(
entity_a
,
entity_b
)
...
...
This diff is collapsed.
Click to expand it.
unittests/test_apiutils.py
+
7
−
4
View file @
8f6d3528
...
...
@@ -33,6 +33,8 @@ import caosdb.apiutils
from
caosdb.apiutils
import
(
apply_to_ids
,
compare_entities
,
create_id_query
,
resolve_reference
,
merge_entities
)
from
caosdb.common.models
import
SPECIAL_ATTRIBUTES
from
.test_property
import
testrecord
import
pytest
...
...
@@ -247,12 +249,13 @@ def test_copy_entities():
assert
c
.
name
==
"
A
"
assert
c
.
role
==
r
.
role
assert
c
.
parents
[
0
].
name
==
"
B
"
#
Currently
parent
s
and propert
ies are always individual to a copy
:
assert
c
.
parents
[
0
]
!=
r
.
parents
[
0
]
# parent and propert
y objects are not shared among copy and original
:
assert
c
.
parents
[
0
]
is
not
r
.
parents
[
0
]
for
i
in
[
0
,
1
]:
assert
c
.
properties
[
i
]
!=
r
.
properties
[
i
]
assert
c
.
properties
[
i
].
value
==
r
.
properties
[
i
].
value
assert
c
.
properties
[
i
]
is
not
r
.
properties
[
i
]
for
special
in
SPECIAL_ATTRIBUTES
:
assert
getattr
(
c
.
properties
[
i
],
special
)
==
getattr
(
r
.
properties
[
i
],
special
)
assert
c
.
get_importance
(
c
.
properties
[
i
])
==
r
.
get_importance
(
r
.
properties
[
i
])
...
...
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