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
2aa2f759
Commit
2aa2f759
authored
3 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
FIX: old tests run again
parent
df463163
No related branches found
No related tags found
2 merge requests
!53
Release 0.1
,
!3
F retrieve
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/newcrawler/crawl.py
+15
-2
15 additions, 2 deletions
src/newcrawler/crawl.py
unittests/test_tool.py
+11
-0
11 additions, 0 deletions
unittests/test_tool.py
with
26 additions
and
2 deletions
src/newcrawler/crawl.py
+
15
−
2
View file @
2aa2f759
...
@@ -319,7 +319,8 @@ class Crawler(object):
...
@@ -319,7 +319,8 @@ class Crawler(object):
# side effect
# side effect
record
.
id
=
identified_record
.
id
record
.
id
=
identified_record
.
id
to_be_updated
.
append
(
record
)
to_be_updated
.
append
(
record
)
self
.
add_identified_record_to_local_cache
(
record
)
# TODO think this through
# self.add_identified_record_to_local_cache(record)
del
flat
[
i
]
del
flat
[
i
]
resolved_references
=
True
resolved_references
=
True
...
@@ -334,13 +335,22 @@ class Crawler(object):
...
@@ -334,13 +335,22 @@ class Crawler(object):
return
to_be_inserted
,
to_be_updated
return
to_be_inserted
,
to_be_updated
def
replace_entities_by_ids
(
self
,
rec
:
db
.
Record
):
for
el
in
rec
.
properties
:
if
isinstance
(
el
.
value
,
db
.
Entity
):
el
.
value
=
el
.
value
.
id
elif
isinstance
(
el
.
value
,
list
):
for
index
,
val
in
enumerate
(
el
.
value
):
if
isinstance
(
val
,
db
.
Entity
):
el
.
value
[
index
]
=
val
.
id
def
remove_unnecessary_updates
(
self
,
updateList
:
list
[
db
.
Record
]):
def
remove_unnecessary_updates
(
self
,
updateList
:
list
[
db
.
Record
]):
"""
"""
checks whether all relevant attributes (especially Property values) are equal
checks whether all relevant attributes (especially Property values) are equal
"""
"""
for
i
in
reversed
(
range
(
len
(
updateList
))):
for
i
in
reversed
(
range
(
len
(
updateList
))):
record
=
updateList
[
i
]
record
=
updateList
[
i
]
identifiable
=
self
.
identifiableAdapter
.
g
et_identifiable
(
record
)
identifiable
=
self
.
identifiableAdapter
.
r
et
rieve
_identifiable
(
record
)
comp
=
compare_entities
(
record
,
identifiable
)
comp
=
compare_entities
(
record
,
identifiable
)
identical
=
True
identical
=
True
...
@@ -392,6 +402,9 @@ class Crawler(object):
...
@@ -392,6 +402,9 @@ class Crawler(object):
to_be_inserted
,
to_be_updated
=
self
.
split_into_inserts_and_updates
(
updateList
)
to_be_inserted
,
to_be_updated
=
self
.
split_into_inserts_and_updates
(
updateList
)
# remove unnecessary updates from list
# remove unnecessary updates from list
for
el
in
to_be_updated
:
self
.
replace_entities_by_ids
(
el
)
self
.
remove_unnecessary_updates
(
to_be_updated
)
self
.
remove_unnecessary_updates
(
to_be_updated
)
# TODO
# TODO
...
...
This diff is collapsed.
Click to expand it.
unittests/test_tool.py
+
11
−
0
View file @
2aa2f759
...
@@ -514,3 +514,14 @@ def test_can_be_checked_externally(crawler):
...
@@ -514,3 +514,14 @@ def test_can_be_checked_externally(crawler):
assert
not
crawler
.
can_be_checked_externally
(
db
.
Record
()
assert
not
crawler
.
can_be_checked_externally
(
db
.
Record
()
.
add_property
(
'
a
'
,
123
)
.
add_property
(
'
a
'
,
123
)
.
add_property
(
'
b
'
,
db
.
Record
()))
.
add_property
(
'
b
'
,
db
.
Record
()))
def
test_replace_entities_by_ids
(
crawler
):
a
=
(
db
.
Record
().
add_parent
(
"
B
"
).
add_property
(
"
A
"
,
12345
)
.
add_property
(
"
B
"
,
db
.
Record
(
id
=
12345
))
.
add_property
(
"
C
"
,
[
db
.
Record
(
id
=
12345
),
233324
]))
crawler
.
replace_entities_by_ids
(
a
)
assert
a
.
get_property
(
"
A
"
).
value
==
12345
assert
a
.
get_property
(
"
B
"
).
value
==
12345
assert
a
.
get_property
(
"
C
"
).
value
==
[
12345
,
233324
]
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