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
4e9d33d1
Commit
4e9d33d1
authored
2 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: docs and string conversion only for specific types
parent
cf37824d
No related branches found
No related tags found
2 merge requests
!71
REL: RElease v0.2.0
,
!59
Fix hash function
Pipeline
#29516
failed
2 years ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caoscrawler/identified_cache.py
+19
-8
19 additions, 8 deletions
src/caoscrawler/identified_cache.py
with
19 additions
and
8 deletions
src/caoscrawler/identified_cache.py
+
19
−
8
View file @
4e9d33d1
...
@@ -23,22 +23,30 @@
...
@@ -23,22 +23,30 @@
# ** end header
# ** end header
#
#
"""
stores identified records and is able to detect duplicates
"""
import
caosdb
as
db
from
hashlib
import
sha256
"""
"""
This module is a cache for Records where we checked the existence in a remote server using
identifiables. If the Record was found, this means that we identified the corresponding Record
in the remote server and the ID of the local object can be set.
To prevent querying the server again and again for the same objects, this cache allows storing
Records that were found on a remote server and those that were not (typically in separate caches).
The look up in the cache is done using a hash of a string representation.
TODO: We need a general review:
TODO: We need a general review:
- How are entities identified with each other?
- How are entities identified with each other?
- What happens if the identification fails?
- What happens if the identification fails?
Checkout how this was done in the old crawler.
"""
"""
import
caosdb
as
db
from
hashlib
import
sha256
from
datetime
import
datetime
def
_value_representation
(
value
):
def
_value_representation
(
value
):
"""
returns the string representation of property values to be used in the hash function
"""
# TODO: (for review)
# TODO: (for review)
# This expansion of the hash function was introduced recently
# This expansion of the hash function was introduced recently
...
@@ -54,8 +62,11 @@ def _value_representation(value):
...
@@ -54,8 +62,11 @@ def _value_representation(value):
return
"
PyID=
"
+
str
(
id
(
value
))
return
"
PyID=
"
+
str
(
id
(
value
))
elif
isinstance
(
value
,
list
):
elif
isinstance
(
value
,
list
):
return
"
[
"
+
"
,
"
.
join
([
_value_representation
(
el
)
for
el
in
value
])
+
"
]
"
return
"
[
"
+
"
,
"
.
join
([
_value_representation
(
el
)
for
el
in
value
])
+
"
]
"
else
:
elif
(
isinstance
(
value
,
str
)
or
isinstance
(
value
,
int
)
or
isinstance
(
value
,
float
)
or
isinstance
(
value
,
datetime
)):
return
str
(
value
)
return
str
(
value
)
else
:
raise
ValueError
(
f
"
Unknown datatype of the value:
{
value
}
"
)
def
_create_hashable_string
(
identifiable
:
db
.
Record
):
def
_create_hashable_string
(
identifiable
:
db
.
Record
):
...
...
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