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
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
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!178
FIX: #96 Better error output for crawl.py script.
,
!167
Sync Graph
Changes
2
Hide 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():
if
se
.
id
is
not
None
:
raise
RuntimeError
(
'
cannot update id
'
)
if
node_id
is
None
:
if
se
.
path
is
None
and
se
.
identifiable
is
None
:
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
)
self
.
_treat_missing
(
se
)
else
:
assert
node_id
>
0
se
.
id
=
node_id
self
.
_add_any
(
se
,
self
.
_existing
)
self
.
unchecked
.
remove
(
se
)
self
.
_treat_existing
(
se
)
def
set_identifiable_of_node
(
self
,
se
:
SyncNode
,
identifiable
:
Identifiable
):
se
.
identifiable
=
identifiable
...
...
@@ -407,26 +395,28 @@ class SyncGraph():
def
_mark_entities_with_path_or_id
(
self
):
"""
A path or an ID is sufficiently identifying. Thus, those entities can be marked as
checked
"""
for
node
in
list
(
self
.
nodes
[::
-
1
]):
if
node
.
id
is
None
and
node
.
path
is
None
:
continue
for
node
in
list
(
self
.
nodes
):
if
node
.
id
is
not
None
:
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
:
try
:
existing
=
cached_get_entity_by
(
path
=
node
.
path
)
except
EmptyUniqueQueryError
:
existing
=
None
if
existing
is
not
None
:
node
.
identify_with
(
existing
)
# at this point, node has an ID if it is existing
treated_before
=
self
.
get_equivalent
(
node
)
if
treated_before
is
None
:
if
node
.
id
is
None
or
node
.
id
<
0
:
self
.
set_missing
(
node
)
if
self
.
get_equivalent
(
node
)
is
not
None
:
self
.
_merge_into
(
node
,
self
.
get_equivalent
(
node
))
else
:
self
.
set_existing
(
node
)
else
:
self
.
_merge_into
(
node
,
treated_before
)
try
:
existing
=
cached_get_entity_by
(
path
=
node
.
path
)
except
EmptyUniqueQueryError
:
existing
=
None
remote_id
=
None
if
existing
is
not
None
:
remote_id
=
existing
.
id
self
.
_path_look_up
[
node
.
path
]
=
node
self
.
set_id_of_node
(
node
,
remote_id
)
def
_remove_non_identifiables
(
self
):
"""
A path or an ID is sufficiently identifying. Thus, those entities can be marked as
...
...
@@ -515,3 +505,20 @@ the respective attributes exist.
else
:
if
id
(
p
.
value
)
in
se_lookup
:
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():
st
=
SyncGraph
(
entlist
,
ident_adapter
)
assert
len
(
st
.
unchecked
)
==
2
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
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
.
nodes
)
==
1
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