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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Commits
db8db7fc
Commit
db8db7fc
authored
1 year ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
77577f96
No related branches found
No related tags found
2 merge requests
!178
FIX: #96 Better error output for crawl.py script.
,
!167
Sync Graph
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caoscrawler/sync_graph.py
+39
-32
39 additions, 32 deletions
src/caoscrawler/sync_graph.py
unittests/test_sync_graph.py
+2
-2
2 additions, 2 deletions
unittests/test_sync_graph.py
with
41 additions
and
34 deletions
src/caoscrawler/sync_graph.py
+
39
−
32
View file @
db8db7fc
...
@@ -158,22 +158,10 @@ class SyncGraph():
...
@@ -158,22 +158,10 @@ class SyncGraph():
if
se
.
id
is
not
None
:
if
se
.
id
is
not
None
:
raise
RuntimeError
(
'
cannot update id
'
)
raise
RuntimeError
(
'
cannot update id
'
)
if
node_id
is
None
:
if
node_id
is
None
:
if
se
.
path
is
None
and
se
.
identifiable
is
None
:
self
.
_treat_missing
(
se
)
raise
RuntimeError
(
"
no identifying information
"
)
se
.
id
=
self
.
_remote_missing_counter
self
.
_remote_missing_counter
-=
1
self
.
_add_any
(
se
,
self
.
_missing
)
self
.
unchecked
.
remove
(
se
)
for
other_missing
in
(
self
.
backward_id_references
[
se
.
uuid
]
+
self
.
forward_id_referenced_by
[
se
.
uuid
]):
self
.
set_id_of_node
(
other_missing
)
else
:
else
:
assert
node_id
>
0
se
.
id
=
node_id
se
.
id
=
node_id
self
.
_add_any
(
se
,
self
.
_existing
)
self
.
_treat_existing
(
se
)
self
.
unchecked
.
remove
(
se
)
def
set_identifiable_of_node
(
self
,
se
:
SyncNode
,
identifiable
:
Identifiable
):
def
set_identifiable_of_node
(
self
,
se
:
SyncNode
,
identifiable
:
Identifiable
):
se
.
identifiable
=
identifiable
se
.
identifiable
=
identifiable
...
@@ -407,26 +395,28 @@ class SyncGraph():
...
@@ -407,26 +395,28 @@ class SyncGraph():
def
_mark_entities_with_path_or_id
(
self
):
def
_mark_entities_with_path_or_id
(
self
):
"""
A path or an ID is sufficiently identifying. Thus, those entities can be marked as
"""
A path or an ID is sufficiently identifying. Thus, those entities can be marked as
checked
"""
checked
"""
for
node
in
list
(
self
.
nodes
[::
-
1
]):
for
node
in
list
(
self
.
nodes
):
if
node
.
id
is
None
and
node
.
path
is
None
:
if
node
.
id
is
not
None
:
continue
if
self
.
get_equivalent
(
node
)
is
not
None
:
self
.
_merge_into
(
node
,
self
.
get_equivalent
(
node
))
else
:
self
.
_id_look_up
[
node
.
id
]
=
node
self
.
_treat_existing
(
node
)
for
node
in
list
(
self
.
nodes
):
if
node
.
path
is
not
None
:
if
node
.
path
is
not
None
:
if
self
.
get_equivalent
(
node
)
is
not
None
:
self
.
_merge_into
(
node
,
self
.
get_equivalent
(
node
))
else
:
try
:
try
:
existing
=
cached_get_entity_by
(
path
=
node
.
path
)
existing
=
cached_get_entity_by
(
path
=
node
.
path
)
except
EmptyUniqueQueryError
:
except
EmptyUniqueQueryError
:
existing
=
None
existing
=
None
remote_id
=
None
if
existing
is
not
None
:
if
existing
is
not
None
:
node
.
identify_with
(
existing
)
remote_id
=
existing
.
id
self
.
_path_look_up
[
node
.
path
]
=
node
# at this point, node has an ID if it is existing
self
.
set_id_of_node
(
node
,
remote_id
)
treated_before
=
self
.
get_equivalent
(
node
)
if
treated_before
is
None
:
if
node
.
id
is
None
or
node
.
id
<
0
:
self
.
set_missing
(
node
)
else
:
self
.
set_existing
(
node
)
else
:
self
.
_merge_into
(
node
,
treated_before
)
def
_remove_non_identifiables
(
self
):
def
_remove_non_identifiables
(
self
):
"""
A path or an ID is sufficiently identifying. Thus, those entities can be marked as
"""
A path or an ID is sufficiently identifying. Thus, those entities can be marked as
...
@@ -515,3 +505,20 @@ the respective attributes exist.
...
@@ -515,3 +505,20 @@ the respective attributes exist.
else
:
else
:
if
id
(
p
.
value
)
in
se_lookup
:
if
id
(
p
.
value
)
in
se_lookup
:
p
.
value
=
se_lookup
[
id
(
p
.
value
)]
p
.
value
=
se_lookup
[
id
(
p
.
value
)]
def
_treat_missing
(
self
,
node
):
if
node
.
path
is
None
and
node
.
identifiable
is
None
:
raise
RuntimeError
(
"
no identifying information
"
)
node
.
id
=
self
.
_remote_missing_counter
self
.
_remote_missing_counter
-=
1
self
.
_add_any
(
node
,
self
.
_missing
)
self
.
unchecked
.
remove
(
node
)
for
other_missing
in
(
self
.
backward_id_references
[
node
.
uuid
].
union
(
self
.
forward_id_referenced_by
[
node
.
uuid
])):
self
.
set_id_of_node
(
other_missing
)
def
_treat_existing
(
self
,
node
):
assert
node
.
id
>
0
self
.
_add_any
(
node
,
self
.
_existing
)
self
.
unchecked
.
remove
(
node
)
This diff is collapsed.
Click to expand it.
unittests/test_sync_graph.py
+
2
−
2
View file @
db8db7fc
...
@@ -315,10 +315,10 @@ def test_merging():
...
@@ -315,10 +315,10 @@ def test_merging():
st
=
SyncGraph
(
entlist
,
ident_adapter
)
st
=
SyncGraph
(
entlist
,
ident_adapter
)
assert
len
(
st
.
unchecked
)
==
2
assert
len
(
st
.
unchecked
)
==
2
st
.
set_identifiable_of_node
(
st
.
nodes
[
0
],
st
.
set_identifiable_of_node
(
st
.
nodes
[
0
],
Identifiable
(
recordtype
=
"
A
"
,
name
=
'
101
'
,
properties
=
{
'
a
'
:
1
}))
Identifiable
(
record
_
type
=
"
A
"
,
name
=
'
101
'
,
properties
=
{
'
a
'
:
1
}))
assert
len
(
st
.
unchecked
)
==
2
assert
len
(
st
.
unchecked
)
==
2
st
.
set_identifiable_of_node
(
st
.
nodes
[
1
],
st
.
set_identifiable_of_node
(
st
.
nodes
[
1
],
Identifiable
(
recordtype
=
"
A
"
,
name
=
'
101
'
,
properties
=
{
'
a
'
:
1
}))
Identifiable
(
record
_
type
=
"
A
"
,
name
=
'
101
'
,
properties
=
{
'
a
'
:
1
}))
assert
len
(
st
.
unchecked
)
==
1
assert
len
(
st
.
unchecked
)
==
1
assert
len
(
st
.
nodes
)
==
1
assert
len
(
st
.
nodes
)
==
1
assert
st
.
nodes
[
1
].
id
is
None
assert
st
.
nodes
[
1
].
id
is
None
...
...
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