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
8c9680bd
Commit
8c9680bd
authored
1 year ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
review
parent
3eb3cb96
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!178
FIX: #96 Better error output for crawl.py script.
,
!167
Sync Graph
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caoscrawler/sync_graph.py
+11
-18
11 additions, 18 deletions
src/caoscrawler/sync_graph.py
with
11 additions
and
18 deletions
src/caoscrawler/sync_graph.py
+
11
−
18
View file @
8c9680bd
...
@@ -122,16 +122,17 @@ class SyncGraph():
...
@@ -122,16 +122,17 @@ class SyncGraph():
self
.
identifiableAdapter
=
identifiableAdapter
self
.
identifiableAdapter
=
identifiableAdapter
# A dictionary allowing for quick lookup of sync nodes using their (possibly negative) IDs.
# A dictionary allowing for quick lookup of sync nodes using their (possibly negative) IDs.
# This dictionary is initially set using _mark_entities_with_path_or_id and later updated
# This dictionary is initially set using _mark_entities_with_path_or_id and later updated
# using set_id_of_node.
# using set_id_of_node
or during merges of nodes
.
self
.
_id_look_up
:
dict
[
Union
[
int
,
TempID
,
str
],
SyncNode
]
=
{}
self
.
_id_look_up
:
dict
[
Union
[
int
,
TempID
,
str
],
SyncNode
]
=
{}
# Similar as above for looking up nodes using paths
:
# Similar as above for looking up nodes using paths
self
.
_path_look_up
:
dict
[
str
,
SyncNode
]
=
{}
self
.
_path_look_up
:
dict
[
str
,
SyncNode
]
=
{}
# Similar as above for looking up nodes using identifiables. This dictionary uses
# Similar as above for looking up nodes using identifiables. This dictionary uses
the text
#
the
get_representation method of Identifiable as keys.
#
representation generated by
get_representation method of Identifiable as keys.
self
.
_identifiable_look_up
:
dict
[
str
,
SyncNode
]
=
{}
self
.
_identifiable_look_up
:
dict
[
str
,
SyncNode
]
=
{}
# look up for the nodes that were marked as being missing (on the remote server)
self
.
_missing
:
dict
[
int
,
SyncNode
]
=
{}
self
.
_missing
:
dict
[
int
,
SyncNode
]
=
{}
# same for existing
self
.
_existing
:
dict
[
int
,
SyncNode
]
=
{}
self
.
_existing
:
dict
[
int
,
SyncNode
]
=
{}
self
.
_nonidentifiable
:
dict
[
int
,
SyncNode
]
=
{}
# entities that are missing get negative IDs to allow identifiable creation
# entities that are missing get negative IDs to allow identifiable creation
self
.
_remote_missing_counter
=
-
1
self
.
_remote_missing_counter
=
-
1
...
@@ -327,7 +328,11 @@ class SyncGraph():
...
@@ -327,7 +328,11 @@ class SyncGraph():
"""
"""
for
ent
in
entities
:
for
ent
in
entities
:
if
ent
.
role
==
"
Record
"
and
len
(
ent
.
parents
)
==
0
:
if
ent
.
role
==
"
Record
"
and
len
(
ent
.
parents
)
==
0
:
raise
RuntimeError
(
f
"
Records must have a parent.
\n
{
ent
}
"
)
raise
ValueError
(
f
"
Records must have a parent.
\n
{
ent
}
"
)
if
isinstance
(
ent
.
id
,
int
)
and
ent
.
id
<
0
:
raise
ValueError
(
f
"
Records must not have negative integers as IDs.
\n
{
ent
}
"
)
if
isinstance
(
ent
.
id
,
str
)
and
re
.
match
(
r
"
^-\d+$
"
,
ent
.
id
):
raise
ValueError
(
f
"
Records must not have negative integers as IDs.
\n
{
ent
}
"
)
def
_get_nodes_whose_identity_relies_on
(
self
,
node
:
SyncNode
):
def
_get_nodes_whose_identity_relies_on
(
self
,
node
:
SyncNode
):
"""
returns a set of nodes that reference the given node as identifying property or are
"""
returns a set of nodes that reference the given node as identifying property or are
...
@@ -452,17 +457,6 @@ class SyncGraph():
...
@@ -452,17 +457,6 @@ class SyncGraph():
self
.
_path_look_up
[
node
.
path
]
=
node
self
.
_path_look_up
[
node
.
path
]
=
node
self
.
set_id_of_node
(
node
,
remote_id
)
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
checked
Last review by Alexander Schlemmer on 2024-05-24.
"""
for
node
in
list
(
self
.
nodes
[::
-
1
]):
if
"
nonidentifiable
"
in
[
p
.
name
for
p
in
node
.
registered_identifiable
.
properties
]:
self
.
unchecked
.
remove
(
node
)
self
.
_nonidentifiable
[
id
(
node
)]
=
node
def
_merge_into
(
self
,
source
:
SyncNode
,
target
:
SyncNode
):
def
_merge_into
(
self
,
source
:
SyncNode
,
target
:
SyncNode
):
"""
tries to merge source into target and performs the necessary updates:
"""
tries to merge source into target and performs the necessary updates:
- update the membervariables of target using source (``target.update(source)``).
- update the membervariables of target using source (``target.update(source)``).
...
@@ -613,7 +607,6 @@ class SyncGraph():
...
@@ -613,7 +607,6 @@ class SyncGraph():
# (None is the default second argument of set_id_of_node.)
# (None is the default second argument of set_id_of_node.)
for
other_node
in
self
.
_get_nodes_whose_identity_relies_on
(
node
):
for
other_node
in
self
.
_get_nodes_whose_identity_relies_on
(
node
):
if
other_node
in
self
.
unchecked
:
if
other_node
in
self
.
unchecked
:
print
(
f
"
set
\n
{
other_node
}
\n
to missing due to missing
\n
{
node
}
"
)
self
.
set_id_of_node
(
other_node
)
self
.
set_id_of_node
(
other_node
)
def
_mark_existing
(
self
,
node
:
SyncNode
):
def
_mark_existing
(
self
,
node
:
SyncNode
):
...
...
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