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
4a7d981a
Commit
4a7d981a
authored
3 years ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
STY: autpep8'd
parent
6a87eceb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!43
F fix comparison
Pipeline
#18489
passed
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
+6
-5
6 additions, 5 deletions
src/caosdb/apiutils.py
unittests/test_apiutils.py
+4
-5
4 additions, 5 deletions
unittests/test_apiutils.py
with
10 additions
and
10 deletions
src/caosdb/apiutils.py
+
6
−
5
View file @
4a7d981a
# -*- coding: utf-8 -*-
#
# ** header v3.0
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale.com>
# Copyright (C) 2020 IndiScale GmbH <info@indiscale.com>
# Copyright (C) 2020
-2022
IndiScale GmbH <info@indiscale.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
...
...
@@ -109,7 +108,7 @@ def retrieve_entities_with_ids(entities):
for
i
in
range
(
len
(
entities
)
//
step
+
1
):
collection
.
extend
(
execute_query
(
create_id_query
(
entities
[
i
*
step
:(
i
+
1
)
*
step
])))
create_id_query
(
entities
[
i
*
step
:(
i
+
1
)
*
step
])))
return
collection
...
...
@@ -561,6 +560,7 @@ def getCommitIn(folder):
COMPARED
=
[
"
name
"
,
"
role
"
,
"
datatype
"
,
"
description
"
,
"
importance
"
,
"
id
"
,
"
path
"
,
"
checksum
"
,
"
size
"
]
def
compare_entities
(
old_entity
:
Entity
,
new_entity
:
Entity
):
"""
Compare two entites.
...
...
@@ -613,7 +613,7 @@ def compare_entities(old_entity: Entity, new_entity: Entity):
if
new_entity_attr_exists
:
newdiff
[
attr
]
=
newattr
# properties
for
prop
in
old_entity
.
properties
:
...
...
@@ -653,7 +653,8 @@ def compare_entities(old_entity: Entity, new_entity: Entity):
olddiff
[
"
properties
"
].
pop
(
prop
.
name
)
else
:
raise
NotImplementedError
(
"
Comparison not implemented for multi-properties.
"
)
raise
NotImplementedError
(
"
Comparison not implemented for multi-properties.
"
)
for
prop
in
new_entity
.
properties
:
if
len
([
0
for
p
in
old_entity
.
properties
if
p
.
name
==
prop
.
name
])
==
0
:
...
...
This diff is collapsed.
Click to expand it.
unittests/test_apiutils.py
+
4
−
5
View file @
4a7d981a
# -*- encoding: utf-8 -*-
#
# ** header v3.0
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale.com>
# Copyright (C) 2020 IndiScale GmbH <info@indiscale.com>
# Copyright (C) 2020
-2022
IndiScale GmbH <info@indiscale.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
...
...
@@ -180,10 +179,11 @@ def test_compare_entities_units():
assert
diff_r1
[
"
properties
"
][
"
test
"
][
"
unit
"
]
==
"
cm
"
assert
diff_r2
[
"
properties
"
][
"
test
"
][
"
unit
"
]
==
"
m
"
def
test_compare_special_properties
():
# Test for all known special properties:
SPECIAL_PROPERTIES
=
(
"
description
"
,
"
name
"
,
"
checksum
"
,
"
size
"
,
"
path
"
,
"
id
"
)
SPECIAL_PROPERTIES
=
(
"
description
"
,
"
name
"
,
"
checksum
"
,
"
size
"
,
"
path
"
,
"
id
"
)
INTS
=
(
"
size
"
,
"
id
"
)
HIDDEN
=
(
"
checksum
"
,
"
size
"
)
...
...
@@ -230,4 +230,3 @@ def test_compare_special_properties():
assert
diff_r2
[
key
]
==
2
assert
len
(
diff_r1
[
"
properties
"
])
==
0
assert
len
(
diff_r2
[
"
properties
"
])
==
0
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