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
e4de3131
Commit
e4de3131
authored
3 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: introduce the cache in the crawler
parent
65a3a403
No related branches found
No related tags found
1 merge request
!53
Release 0.1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/newcrawler/crawl.py
+11
-4
11 additions, 4 deletions
src/newcrawler/crawl.py
src/newcrawler/identifiable_adapters.py
+1
-2
1 addition, 2 deletions
src/newcrawler/identifiable_adapters.py
with
12 additions
and
6 deletions
src/newcrawler/crawl.py
+
11
−
4
View file @
e4de3131
...
...
@@ -67,6 +67,7 @@ from argparse import RawTextHelpFormatter
import
caosdb
as
db
from
caosdb.common.datatype
import
is_reference
from
.stores
import
GeneralStore
,
RecordStore
from
.identified_cache
import
IdentifiedCache
from
.structure_elements
import
StructureElement
,
Directory
from
.converters
import
Converter
,
DirectoryConverter
from
.identifiable_adapters
import
IdentifiableAdapter
,
LocalStorageIdentifiableAdapter
...
...
@@ -103,6 +104,7 @@ class Crawler(object):
"""
self
.
global_converters
=
converters
self
.
identified_cache
=
IdentifiedCache
()
self
.
recordStore
=
RecordStore
()
self
.
generalStore
=
generalStore
...
...
@@ -238,15 +240,19 @@ class Crawler(object):
return
False
return
True
def
get_identified_record_from_local_cache
(
self
,
identifiable
:
db
.
Record
):
def
get_identified_record_from_local_cache
(
self
,
record
:
db
.
Record
):
"""
returns the identifiable if an identifiable with the same values already exists locally
(Each identifiable that is not found on the remote server, is
'
cached
'
locally to prevent
that the same identifiable exists twice)
"""
raise
NotImplementedError
()
identifiable
=
self
.
identifiableAdapter
.
get_identifiable
(
record
)
if
identifiable
in
self
.
identified_cache
:
return
self
.
identified_cache
[
identifiable
]
else
:
return
None
def
add_identified_record_to_local_cache
(
self
,
identifiable
:
db
.
Record
):
def
add_identified_record_to_local_cache
(
self
,
record
:
db
.
Record
):
"""
adds the given identifiable to the local cache
...
...
@@ -254,7 +260,8 @@ class Crawler(object):
(Each identifiable that is not found on the remote server, is
'
cached
'
locally to prevent
that the same identifiable exists twice)
"""
raise
NotImplementedError
()
identifiable
=
self
.
identifiableAdapter
.
get_identifiable
(
record
)
self
.
identified_cache
.
add
(
identifiable
=
identifiable
,
record
=
record
)
def
copy_attributes
(
self
,
fro
:
db
.
Entity
,
to
:
db
.
Entity
):
raise
NotImplementedError
()
...
...
This diff is collapsed.
Click to expand it.
src/newcrawler/identifiable_adapters.py
+
1
−
2
View file @
e4de3131
...
...
@@ -102,7 +102,6 @@ class IdentifiableAdapter(object):
def
resolve_references
(
self
,
record
:
db
.
Record
):
pass
# TODO rename retrieve_registered_identifiable?
def
get_identifiable
(
self
,
record
:
db
.
Record
):
"""
retrieve the registred identifiable and fill the property values to create an
...
...
@@ -126,7 +125,7 @@ class IdentifiableAdapter(object):
# case A: in the registered identifiable
# case B: in the identifiable
#TODO use id if value is Entity
#
TODO use id if value is Entity
identifiable
.
add_property
(
record
.
get_property
(
prop
.
name
))
property_name_list_A
.
append
(
prop
.
name
)
...
...
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