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
e42f344c
Commit
e42f344c
authored
2 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
DOC: refine docstrings
parent
36cddad8
No related branches found
No related tags found
3 merge requests
!91
Release 0.3
,
!69
Refactor Identifiable and caches
,
!67
MAINT: introduce an identifiable class
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caoscrawler/identifiable.py
+6
-1
6 additions, 1 deletion
src/caoscrawler/identifiable.py
src/caoscrawler/identified_cache.py
+18
-13
18 additions, 13 deletions
src/caoscrawler/identified_cache.py
with
24 additions
and
14 deletions
src/caoscrawler/identifiable.py
+
6
−
1
View file @
e42f344c
...
@@ -65,7 +65,12 @@ class Identifiable():
...
@@ -65,7 +65,12 @@ class Identifiable():
@staticmethod
@staticmethod
def
_value_representation
(
value
)
->
str
:
def
_value_representation
(
value
)
->
str
:
"""
returns the string representation of property values to be used in the hash function
"""
"""
returns the string representation of property values to be used in the hash function
The string is the path of a File Entity, the CaosDB ID or Python ID of other Entities
(Python Id only if there is no CaosDB ID) and the string representation of bool, float, int
and str.
"""
if
value
is
None
:
if
value
is
None
:
return
"
None
"
return
"
None
"
...
...
This diff is collapsed.
Click to expand it.
src/caoscrawler/identified_cache.py
+
18
−
13
View file @
e42f344c
...
@@ -25,18 +25,7 @@
...
@@ -25,18 +25,7 @@
"""
"""
This module is a cache for Records where we checked the existence in a remote server using
see class docstring
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:
- How are entities identified with each other?
- What happens if the identification fails?
Checkout how this was done in the old crawler.
"""
"""
from
.identifiable
import
Identifiable
from
.identifiable
import
Identifiable
...
@@ -44,7 +33,23 @@ import caosdb as db
...
@@ -44,7 +33,23 @@ import caosdb as db
class
IdentifiedCache
(
object
):
class
IdentifiedCache
(
object
):
def
__init__
(
self
):
"""
This class is like a dictionary where the keys are Identifiables. When you check whether an
Identifiable exists as key this class returns True not only if that exact Python object is
used as a key, but if an Identifiable is used as key that is **equal** to the one being
considered (see __eq__ function of Identifiable). Similarly, if you do `cache[identifiable]`
you get the Record where the key is an Identifiable that is equal to the one in the rectangular
brackets.
This class is used 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).
"""
def
__init__
(
self
):
self
.
_cache
=
{}
self
.
_cache
=
{}
self
.
_identifiables
=
[]
self
.
_identifiables
=
[]
...
...
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