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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Commits
428fe969
Verified
Commit
428fe969
authored
1 year ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: Removing unused functions, documentation, fixmes.
parent
f7f89bc6
No related branches found
No related tags found
2 merge requests
!178
FIX: #96 Better error output for crawl.py script.
,
!167
Sync Graph
Pipeline
#50008
passed with warnings
1 year ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caoscrawler/semantic_target.py
+31
-27
31 additions, 27 deletions
src/caoscrawler/semantic_target.py
with
31 additions
and
27 deletions
src/caoscrawler/semantic_target.py
+
31
−
27
View file @
428fe969
...
@@ -97,8 +97,7 @@ class SemanticTarget():
...
@@ -97,8 +97,7 @@ class SemanticTarget():
are updated according to the reference map.
are updated according to the reference map.
This model should only be manipulated via three functions:
This model should only be manipulated via three functions:
- make_identifiable: adds an identifiable to a SemanticEntity what possibly allows to merge it
- make_identifiable: adds an identifiable to a SemanticEntity
with another SemanticEntity
- merge_with_equivalent: check whether there is an equivalent SemanticEntity and merge into
- merge_with_equivalent: check whether there is an equivalent SemanticEntity and merge into
that if one is found
that if one is found
- check_remote_server: uses the identifiable to check the remote server and add ID and path if
- check_remote_server: uses the identifiable to check the remote server and add ID and path if
...
@@ -143,15 +142,14 @@ class SemanticTarget():
...
@@ -143,15 +142,14 @@ class SemanticTarget():
self
.
_mark_entities_with_path_or_id
()
self
.
_mark_entities_with_path_or_id
()
def
make_identifiable
(
self
,
se
:
SemanticEntity
):
def
make_identifiable
(
self
,
se
:
SemanticEntity
):
"""
creates an identifiable for the given SemanticEntity and possibly merges it into an
"""
Create an identifiable for the given SemanticEntity and store it there.
equivalent SemanticEntity
"""
"""
if
se
.
identifiable
is
not
None
:
if
se
.
identifiable
is
not
None
:
raise
RuntimeError
(
"
Already has identifiable
"
)
raise
RuntimeError
(
"
Already has identifiable
"
)
se
.
identifiable
=
self
.
identifiableAdapter
.
get_identifiable
(
se
.
identifiable
=
self
.
identifiableAdapter
.
get_identifiable
(
se
,
self
.
backward_id_referenced_by
[
se
.
uuid
])
se
,
self
.
backward_id_referenced_by
[
se
.
uuid
])
def
merge_with_equivalent
(
self
,
se
:
SemanticEntity
):
def
merge_with_equivalent
(
self
,
se
:
SemanticEntity
)
->
bool
:
equivalent_se
=
self
.
get_checked_equivalent
(
se
)
equivalent_se
=
self
.
get_checked_equivalent
(
se
)
if
equivalent_se
is
None
:
if
equivalent_se
is
None
:
return
False
return
False
...
@@ -159,14 +157,14 @@ class SemanticTarget():
...
@@ -159,14 +157,14 @@ class SemanticTarget():
self
.
_merge_into
(
se
,
equivalent_se
)
self
.
_merge_into
(
se
,
equivalent_se
)
return
True
return
True
def
check_remote_server
(
self
,
se
:
SemanticEntity
):
def
check_remote_server
(
self
,
se
:
SemanticEntity
)
->
None
:
identified_record
=
(
identified_record
=
(
self
.
identifiableAdapter
.
retrieve_identified_record_for_identifiable
(
self
.
identifiableAdapter
.
retrieve_identified_record_for_identifiable
(
se
.
identifiable
))
se
.
identifiable
))
if
identified_record
is
not
None
:
if
identified_record
is
not
None
:
se
.
identify_with
(
identified_record
)
se
.
identify_with
(
identified_record
)
def
set_missing
(
self
,
se
:
SemanticEntity
):
def
set_missing
(
self
,
se
:
SemanticEntity
)
->
None
:
"""
add the given SemanticEntity to the list of missing entities
"""
add the given SemanticEntity to the list of missing entities
This removes the SemanticEntity from the unchecked list and implies that the entity does
This removes the SemanticEntity from the unchecked list and implies that the entity does
...
@@ -208,27 +206,27 @@ class SemanticTarget():
...
@@ -208,27 +206,27 @@ class SemanticTarget():
self
.
_identifiable_look_up
):
self
.
_identifiable_look_up
):
return
self
.
_identifiable_look_up
[
entity
.
identifiable
.
get_representation
()]
return
self
.
_identifiable_look_up
[
entity
.
identifiable
.
get_representation
()]
def
get_equivalent_existing
(
self
,
se
):
#
def get_equivalent_existing(self, se):
"""
Check whether this Record exists on the remote server
#
""" Check whether this Record exists on the remote server
Returns: The stored Record
#
Returns: The stored Record
"""
#
"""
treated
=
self
.
get_any
(
se
)
#
treated = self.get_any(se)
if
id
(
treated
)
in
self
.
_existing
:
#
if id(treated) in self._existing:
return
rec
#
return rec
else
:
#
else:
return
None
#
return None
def
get_equivalent_missing
(
self
,
se
):
#
def get_equivalent_missing(self, se):
"""
Check whether this Record is missing on the remote server
#
""" Check whether this Record is missing on the remote server
Returns: The stored Record
#
Returns: The stored Record
"""
#
"""
treated
=
self
.
get_any
(
record
,
identifiable
)
#
treated = self.get_any(record, identifiable)
if
id
(
treated
)
in
self
.
_missing
:
#
if id(treated) in self._missing:
return
rec
#
return rec
else
:
#
else:
return
None
#
return None
def
combine_fragments
(
self
):
def
combine_fragments
(
self
):
for
se
in
self
.
se
:
for
se
in
self
.
se
:
...
@@ -473,13 +471,19 @@ class SemanticTarget():
...
@@ -473,13 +471,19 @@ class SemanticTarget():
if
referenced
in
self
.
unchecked
:
if
referenced
in
self
.
unchecked
:
if
referenced
in
circle
:
if
referenced
in
circle
:
closed
=
True
closed
=
True
circle
.
append
(
pval
)
circle
.
append
(
pval
)
# FIXME
added_to_circle
=
True
added_to_circle
=
True
if
not
added_to_circle
:
if
not
added_to_circle
:
return
None
return
None
return
circle
return
circle
def
_add_any
(
self
,
entity
:
SemanticEntity
,
lookup
):
def
_add_any
(
self
,
entity
:
SemanticEntity
,
lookup
):
"""
Add ``entity`` to this SemanticTarget and store in ``lookup`` cache.
The entity is stored in the SemanticEntity
'
s ``id``, ``path`` and ``identifiable`` lookup tables, if
the respective attributes exist.
"""
if
entity
.
id
is
not
None
:
if
entity
.
id
is
not
None
:
self
.
_id_look_up
[
entity
.
id
]
=
entity
self
.
_id_look_up
[
entity
.
id
]
=
entity
if
entity
.
path
is
not
None
:
if
entity
.
path
is
not
None
:
...
@@ -489,7 +493,7 @@ class SemanticTarget():
...
@@ -489,7 +493,7 @@ class SemanticTarget():
lookup
[
id
(
entity
)]
=
entity
lookup
[
id
(
entity
)]
=
entity
def
_merge_into
(
self
,
source
:
SemanticEntity
,
target
:
SemanticEntity
):
def
_merge_into
(
self
,
source
:
SemanticEntity
,
target
:
SemanticEntity
):
"""
tries to merge record into newrecord
"""
FIXME
tries to merge record into newrecord
If it fails, record is added to the try_to_merge_later list.
If it fails, record is added to the try_to_merge_later list.
In any case, references are bent to the newrecord object.
In any case, references are bent to the newrecord object.
...
...
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