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
cb9aba79
Commit
cb9aba79
authored
9 months ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
DEPR: deprecate old_entity/new_entity of compare_entities
parent
4e061b4f
No related branches found
No related tags found
2 merge requests
!159
Release 0.16.o
,
!155
Review filter lists and compare_entities
Pipeline
#57185
passed with warnings
9 months ago
Stage: code_style
Stage: linting
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+2
-0
2 additions, 0 deletions
CHANGELOG.md
src/linkahead/apiutils.py
+26
-9
26 additions, 9 deletions
src/linkahead/apiutils.py
with
28 additions
and
9 deletions
CHANGELOG.md
+
2
−
0
View file @
cb9aba79
...
...
@@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
*
`ParentList.remove`
is now case insensitive when a name is used.
### Deprecated ###
*
the use of the arguments
`old_entity`
and
`new_entity`
in
`compare_entities`
is now deprecated. Please use
`entity0`
and
`entity1`
respectively instead.
### Removed ###
...
...
This diff is collapsed.
Click to expand it.
src/linkahead/apiutils.py
+
26
−
9
View file @
cb9aba79
...
...
@@ -28,10 +28,11 @@
"""
from
__future__
import
annotations
import
logging
import
warnings
from
collections.abc
import
Iterable
from
typing
import
Any
,
Union
,
Optional
from
typing
import
Any
,
Optional
,
Union
from
.common.datatype
import
is_reference
from
.common.models
import
(
SPECIAL_ATTRIBUTES
,
Container
,
Entity
,
File
,
...
...
@@ -179,9 +180,12 @@ def getCommitIn(folder):
return
get_commit_in
(
folder
)
def
compare_entities
(
old_entity
:
Entity
,
new_entity
:
Entity
,
def
compare_entities
(
entity0
:
Optional
[
Entity
]
=
None
,
entity1
:
Optional
[
Entity
]
=
None
,
compare_referenced_records
:
bool
=
False
,
entity_name_id_equivalency
:
bool
=
False
entity_name_id_equivalency
:
bool
=
False
,
old_entity
:
Optional
[
Entity
]
=
None
,
new_entity
:
Optional
[
Entity
]
=
None
,
)
->
tuple
[
dict
[
str
,
Any
],
dict
[
str
,
Any
]]:
"""
Compare two entities.
...
...
@@ -219,9 +223,9 @@ def compare_entities(old_entity: Entity, new_entity: Entity,
Params
------
old_
entity : Entity
entity
0
: Entity
First entity to be compared.
new_
entity : Entity
entity
1
: Entity
Second entity to be compared.
compare_referenced_records: bool, default: False
If set to True, values with referenced records
...
...
@@ -252,9 +256,22 @@ def compare_entities(old_entity: Entity, new_entity: Entity,
# - Make the empty_diff functionality faster by adding a parameter to
# this function so that it returns after the first found difference?
# - Add parameter to restrict diff to some characteristics
entity0
,
entity1
=
old_entity
,
new_entity
diff
=
({
"
properties
"
:
{},
"
parents
"
:
[]},
if
entity0
is
None
and
old_entity
is
None
:
raise
ValueError
(
"
Please provide the first entity as first argument (`entity0`)
"
)
if
entity1
is
None
and
new_entity
is
None
:
raise
ValueError
(
"
Please provide the second entity as second argument (`entity1`)
"
)
if
old_entity
is
not
None
:
warnings
.
warn
(
"
Please use
'
entity0
'
instead of
'
old_entity
'
.
"
,
DeprecationWarning
)
if
entity0
is
not
None
:
raise
ValueError
(
"
You cannot use both, entity0 and old_entity
"
)
entity0
=
old_entity
if
new_entity
is
not
None
:
warnings
.
warn
(
"
Please use
'
entity1
'
instead of
'
new_entity
'
.
"
,
DeprecationWarning
)
if
entity1
is
not
None
:
raise
ValueError
(
"
You cannot use both, entity1 and new_entity
"
)
entity1
=
new_entity
diff
:
tuple
=
({
"
properties
"
:
{},
"
parents
"
:
[]},
{
"
properties
"
:
{},
"
parents
"
:
[]})
if
entity0
is
entity1
:
...
...
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