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
edc39b3e
Commit
edc39b3e
authored
4 months ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: rename arguments of empty diff
parent
62cdd301
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!159
Release 0.16.o
,
!154
Added the possibility to use custom labels instead of 'old' and 'new'
Pipeline
#57462
passed with warnings
4 months 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/linkahead/apiutils.py
+31
-13
31 additions, 13 deletions
src/linkahead/apiutils.py
with
31 additions
and
13 deletions
src/linkahead/apiutils.py
+
31
−
13
View file @
edc39b3e
...
...
@@ -447,28 +447,46 @@ def compare_entities(entity0: Optional[Entity] = None,
return
diff
def
empty_diff
(
old_entity
:
Entity
,
new_entity
:
Entity
,
def
empty_diff
(
entity0
:
Entity
,
entity1
:
Entity
,
compare_referenced_records
:
bool
=
False
,
entity_name_id_equivalency
:
bool
=
False
)
->
bool
:
entity_name_id_equivalency
:
bool
=
False
,
old_entity
:
Optional
[
Entity
]
=
None
,
new_entity
:
Optional
[
Entity
]
=
None
,
)
->
bool
:
"""
Check whether the `compare_entities` found any differences between
old_
entity and
new_
entity.
entity
0
and entity
1
.
Parameters
----------
old_
entity,
new_
entity : Entity
entity
0
, entity
1
: Entity
Entities to be compared
compare_referenced_records : bool, optional
Whether to compare referenced records in case of both, `
old_
entity` and
`
new_
entity`, have the same reference properties and both have a Record
Whether to compare referenced records in case of both, `entity
0
` and
`entity
1
`, have the same reference properties and both have a Record
object as value.
entity_name_id_equivalency : bool, optional
If set to True, the comparison between an entity and an int or str also
checks whether the int/str matches the name or id of the entity, so
Entity(id=100) == 100 ==
"
100
"
.
"""
olddiff
,
newdiff
=
compare_entities
(
old_entity
,
new_entity
,
compare_referenced_records
,
entity_name_id_equivalency
)
for
diff
in
[
olddiff
,
newdiff
]:
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
e0diff
,
e1diff
=
compare_entities
(
entity0
,
entity1
,
compare_referenced_records
,
entity_name_id_equivalency
)
for
diff
in
[
e0diff
,
e1diff
]:
for
key
in
[
"
parents
"
,
"
properties
"
]:
if
len
(
diff
[
key
])
>
0
:
# There is a difference somewhere in the diff
...
...
@@ -641,11 +659,11 @@ def describe_diff(entity0_diff: dict[str, Any], entity1_diff: dict[str, Any],
entity0_diff: dict[str, Any]
First element of the tuple output of :func:`compare_entities`.
This is referred to as the
"
old
"
version.
This is referred to as the
"
first
"
version.
entity1_diff: dict[str, Any]
Second element of the tuple output of :func:`compare_entities`.
This is referred to as the
"
new
"
version.
This is referred to as the
"
second
"
version.
name: Optional[str]
...
...
@@ -655,10 +673,10 @@ def describe_diff(entity0_diff: dict[str, Any], entity1_diff: dict[str, Any],
Default None. Not used anymore.
label_e0: str
Can be used to set a custom label for the diff that is associated with the
old
entity.
Can be used to set a custom label for the diff that is associated with the
first
entity.
label_e1: str
Can be used to set a custom label for the diff that is associated with the
new
entity.
Can be used to set a custom label for the diff that is associated with the
second
entity.
Returns:
--------
...
...
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