Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
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-advanced-user-tools
Commits
19043df5
Commit
19043df5
authored
4 years ago
by
Henrik tom Wörden
Committed by
Florian Spreckelsen
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Various Enhancements
parent
5c60c46b
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!22
Release 0.3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.docker/Dockerfile
+1
-1
1 addition, 1 deletion
.docker/Dockerfile
src/caosadvancedtools/crawler.py
+24
-7
24 additions, 7 deletions
src/caosadvancedtools/crawler.py
src/caosadvancedtools/datainconsistency.py
+29
-0
29 additions, 0 deletions
src/caosadvancedtools/datainconsistency.py
with
54 additions
and
8 deletions
.docker/Dockerfile
+
1
−
1
View file @
19043df5
...
...
@@ -7,7 +7,7 @@ RUN apt-get update && \
python3-requests
\
python3-pandas
\
python3-html2text
\
tox
\
tox
\
git
\
openjdk-11-jdk-headless
\
python-autopep8
\
...
...
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/crawler.py
+
24
−
7
View file @
19043df5
...
...
@@ -51,6 +51,7 @@ from caosdb.exceptions import TransactionError
from
.cache
import
Cache
,
UpdateCache
,
get_pretty_xml
from
.cfood
import
RowCFood
,
get_ids_for_entities_with_names
from
.datainconsistency
import
DataInconsistencyError
from
.datamodel_problems
import
DataModelProblems
from
.guard
import
RETRIEVE
,
ProhibitedException
from
.guard
import
global_guard
as
guard
...
...
@@ -88,7 +89,8 @@ class UnknownCache(object):
class
Crawler
(
object
):
def
__init__
(
self
,
cfood_types
,
use_cache
=
False
,
abort_on_exception
=
True
,
interactive
=
True
,
hideKnown
=
False
):
abort_on_exception
=
True
,
interactive
=
True
,
hideKnown
=
False
,
debug_file
=
None
,
cache_file
=
None
):
"""
Parameters
----------
...
...
@@ -102,6 +104,10 @@ class Crawler(object):
interactive : boolean, optional
If true, questions will be posed during execution of the
crawl function.
debug_file : a file where debug output is saved. The path will be
printed when a critical error occured.
cache_file : a file where the cached identifiables are stored. See
cache.py
"""
...
...
@@ -110,11 +116,12 @@ class Crawler(object):
self
.
report
=
db
.
Container
()
self
.
use_cache
=
use_cache
self
.
hideKnown
=
hideKnown
self
.
debug_file
=
debug_file
self
.
abort_on_exception
=
abort_on_exception
self
.
update_cache
=
UpdateCache
()
if
self
.
use_cache
:
self
.
cache
=
Cache
()
self
.
cache
=
Cache
(
db_file
=
cache_file
)
def
iteritems
(
self
):
"""
generates items to be crawled with an index
"""
...
...
@@ -192,10 +199,12 @@ class Crawler(object):
logger
.
debug
(
"
{} matched
\n
{}.
"
.
format
(
Cfood
.
__name__
,
item
))
except
DataInconsistencyError
:
pass
except
Exception
as
e
:
logger
.
debug
(
"
Failed during execution of {}!
"
.
format
(
Cfood
.
__name__
))
#
traceback.
prin
t_exc()
logger
.
debug
(
traceback
.
forma
t_exc
()
)
logger
.
debug
(
e
)
if
self
.
abort_on_exception
:
...
...
@@ -287,10 +296,12 @@ class Crawler(object):
cfood
.
update_identifiables
()
self
.
push_identifiables_to_CaosDB
(
cfood
)
except
DataInconsistencyError
:
pass
except
Exception
as
e
:
logger
.
info
(
"
Failed during execution of {}!
"
.
format
(
cfood
.
__class__
.
__name__
))
#
traceback.
prin
t_exc()
logger
.
debug
(
traceback
.
forma
t_exc
()
)
logger
.
debug
(
e
)
if
self
.
abort_on_exception
:
...
...
@@ -329,8 +340,13 @@ ____________________\n""".format(i+1, len(pending_changes)) + str(el[3]))
logger
.
error
(
err_msg
)
logger
.
error
(
'
Crawler finished with Datamodel Errors
'
)
elif
errors_occured
:
logger
.
error
(
"
There were fatal errors during execution, please
"
"
contact the system administrator!
"
)
msg
=
"
There were fatal errors during execution, please
"
"
contact the system administrator!
"
if
self
.
debug_file
:
msg
+=
"
\n
Please provide the following path:
\n
{}
"
.
format
(
self
.
debug_file
)
logger
.
error
(
msg
)
logger
.
error
(
"
Crawler terminated with failures!
"
)
logger
.
debug
(
tbs
)
else
:
...
...
@@ -511,7 +527,8 @@ carefully and if the changes are ok, click on the following link:
for
ent
in
identifiables
:
if
ent
.
id
is
None
or
ent
.
id
<
0
:
logger
.
debug
(
"
Looking for: {}
"
.
format
(
ent
))
logger
.
debug
(
"
Looking for: {}
"
.
format
(
ent
.
id
if
ent
.
id
is
not
None
else
ent
.
name
))
existing
=
Crawler
.
find_existing
(
ent
)
if
existing
is
not
None
:
...
...
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/datainconsistency.py
0 → 100644
+
29
−
0
View file @
19043df5
#!/usr/bin/env python
# encoding: utf-8
#
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2020 Indiscale GmbH <info@indiscale.com>
# Copyright (C) 2020 Henrik tom Wörden <h.tomwoerden@indiscale.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
Implements an error to be used when there is a problem with the data to be
read. I.e. something that users of CaosDB need to fix.
"""
class
DataInconsistencyError
(
ValueError
):
pass
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