Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CaosDB Crawler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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 Crawler
Commits
7dd4419e
Commit
7dd4419e
authored
1 year ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
works
parent
92af1eb8
No related branches found
No related tags found
2 merge requests
!178
FIX: #96 Better error output for crawl.py script.
,
!167
Sync Graph
Pipeline
#50091
passed with warnings
1 year ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caoscrawler/sync_graph.py
+10
-3
10 additions, 3 deletions
src/caoscrawler/sync_graph.py
unittests/test_sync_graph.py
+21
-1
21 additions, 1 deletion
unittests/test_sync_graph.py
with
31 additions
and
4 deletions
src/caoscrawler/sync_graph.py
+
10
−
3
View file @
7dd4419e
...
@@ -88,7 +88,7 @@ class SyncGraph():
...
@@ -88,7 +88,7 @@ class SyncGraph():
)
=
self
.
_create_reference_mapping
(
self
.
nodes
)
)
=
self
.
_create_reference_mapping
(
self
.
nodes
)
self
.
_mark_entities_with_path_or_id
()
self
.
_mark_entities_with_path_or_id
()
for
node
in
self
.
nodes
:
for
node
in
list
(
self
.
nodes
)
:
try
:
try
:
identifiable
=
self
.
identifiableAdapter
.
get_identifiable
(
identifiable
=
self
.
identifiableAdapter
.
get_identifiable
(
node
,
self
.
backward_id_referenced_by
[
node
.
uuid
])
node
,
self
.
backward_id_referenced_by
[
node
.
uuid
])
...
@@ -106,6 +106,8 @@ class SyncGraph():
...
@@ -106,6 +106,8 @@ class SyncGraph():
if
node_id
is
None
:
if
node_id
is
None
:
node_id
=
self
.
_get_new_id
()
node_id
=
self
.
_get_new_id
()
node
.
id
=
node_id
node
.
id
=
node_id
for
el
in
node
.
other
:
el
.
id
=
node_id
if
node_id
in
self
.
_id_look_up
:
if
node_id
in
self
.
_id_look_up
:
self
.
_merge_into
(
node
,
self
.
_id_look_up
[
node
.
id
])
self
.
_merge_into
(
node
,
self
.
_id_look_up
[
node
.
id
])
else
:
else
:
...
@@ -358,8 +360,10 @@ class SyncGraph():
...
@@ -358,8 +360,10 @@ class SyncGraph():
if
isinstance
(
v
,
SyncNode
):
if
isinstance
(
v
,
SyncNode
):
forward_references
[
node
.
uuid
].
add
(
v
)
forward_references
[
node
.
uuid
].
add
(
v
)
backward_references
[
v
.
uuid
].
add
(
node
)
backward_references
[
v
.
uuid
].
add
(
node
)
if
len
([
el
.
name
for
el
in
node
.
registered_identifiable
.
properties
if
if
(
node
.
registered_identifiable
is
not
None
el
.
name
==
p
.
name
])
>
0
:
and
len
([
el
.
name
for
el
in
node
.
registered_identifiable
.
properties
if
el
.
name
==
p
.
name
])
>
0
):
forward_id_references
[
node
.
uuid
].
add
(
v
)
forward_id_references
[
node
.
uuid
].
add
(
v
)
backward_id_references
[
v
.
uuid
].
add
(
node
)
backward_id_references
[
v
.
uuid
].
add
(
node
)
if
(
v
.
registered_identifiable
is
not
None
and
if
(
v
.
registered_identifiable
is
not
None
and
...
@@ -418,6 +422,9 @@ class SyncGraph():
...
@@ -418,6 +422,9 @@ class SyncGraph():
assert
source
is
not
target
assert
source
is
not
target
target
.
update
(
source
)
target
.
update
(
source
)
target
.
other
.
append
(
source
)
target
.
other
.
append
(
source
)
target
.
other
.
extend
(
source
.
other
)
for
el
in
target
.
other
:
el
.
id
=
target
.
id
# update reference mappings
# update reference mappings
for
node
in
self
.
forward_references
.
pop
(
source
.
uuid
):
for
node
in
self
.
forward_references
.
pop
(
source
.
uuid
):
...
...
This diff is collapsed.
Click to expand it.
unittests/test_sync_graph.py
+
21
−
1
View file @
7dd4419e
...
@@ -455,7 +455,7 @@ def test_set_id_of_node(simple_adapter):
...
@@ -455,7 +455,7 @@ def test_set_id_of_node(simple_adapter):
@patch
(
"
caoscrawler.sync_graph.cached_get_entity_by
"
,
@patch
(
"
caoscrawler.sync_graph.cached_get_entity_by
"
,
new
=
Mock
(
side_effect
=
mock_get_entity_by
))
new
=
Mock
(
side_effect
=
mock_get_entity_by
))
def
test_merging
():
def
test_merging
(
simple_adapter
):
# identifying information can be given at various locations in the hierachical tree
# identifying information can be given at various locations in the hierachical tree
# test whether an object is correctly combined for all cases
# test whether an object is correctly combined for all cases
ident_adapter
=
CaosDBIdentifiableAdapter
()
ident_adapter
=
CaosDBIdentifiableAdapter
()
...
@@ -515,6 +515,26 @@ def test_merging():
...
@@ -515,6 +515,26 @@ def test_merging():
assert
101
==
st
.
nodes
[
0
].
id
assert
101
==
st
.
nodes
[
0
].
id
def
test_something
(
simple_adapter
):
a
=
db
.
Record
().
add_parent
(
"
RT3
"
).
add_property
(
'
a
'
,
value
=
1
)
entlist
=
[
a
,
db
.
Record
().
add_parent
(
"
RT3
"
).
add_property
(
'
a
'
,
value
=
1
),
db
.
Record
().
add_parent
(
"
RT3
"
).
add_property
(
'
a
'
,
value
=
1
),
db
.
Record
().
add_parent
(
"
RT3
"
).
add_property
(
'
a
'
,
value
=
1
),
db
.
Record
().
add_parent
(
"
RT3
"
).
add_property
(
'
a
'
,
value
=
1
),
db
.
Record
().
add_parent
(
"
RT4
"
).
add_property
(
'
RT3
'
,
value
=
a
),
db
.
Record
().
add_parent
(
"
RT3
"
).
add_property
(
'
a
'
,
value
=
1
),
db
.
Record
().
add_parent
(
"
RT3
"
).
add_property
(
'
a
'
,
value
=
1
)]
st
=
SyncGraph
(
entlist
,
simple_adapter
)
assert
len
(
st
.
nodes
)
==
2
assert
len
(
st
.
unchecked
)
==
2
assert
'
RT4
'
==
st
.
nodes
[
1
].
parents
[
0
].
name
st
.
set_id_of_node
(
st
.
nodes
[
0
],
101
)
b_prop
=
st
.
nodes
[
1
].
properties
[
0
].
value
assert
b_prop
.
id
==
101
def
test_sync_node
():
def
test_sync_node
():
# initialization
# initialization
rec
=
(
db
.
Record
(
id
=
101
,
name
=
'
101
'
)
rec
=
(
db
.
Record
(
id
=
101
,
name
=
'
101
'
)
...
...
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