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
c16a32d3
Commit
c16a32d3
authored
2 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: add logging on inserts and updates
parent
f326deec
No related branches found
No related tags found
2 merge requests
!105
REL: v0.4.0
,
!102
MAINT: add logging on inserts and updates
Pipeline
#33845
failed
2 years ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
src/caoscrawler/crawl.py
+28
-4
28 additions, 4 deletions
src/caoscrawler/crawl.py
with
29 additions
and
4 deletions
CHANGELOG.md
+
1
−
0
View file @
c16a32d3
...
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
...
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ###
### Added ###
-
DateElementConverter: allows to interpret text as a date object
-
DateElementConverter: allows to interpret text as a date object
-
the restricted_path argument allows to crawl only a subtree
-
the restricted_path argument allows to crawl only a subtree
-
logging that provides a summary of what is inserted and updated
### Changed ###
### Changed ###
...
...
This diff is collapsed.
Click to expand it.
src/caoscrawler/crawl.py
+
28
−
4
View file @
c16a32d3
...
@@ -1017,20 +1017,25 @@ class Crawler(object):
...
@@ -1017,20 +1017,25 @@ class Crawler(object):
referencing_entities
)
referencing_entities
)
for
record
in
to_be_updated
]
for
record
in
to_be_updated
]
# Merge with existing data to prevent unwanted overwrites
# Merge with existing data to prevent unwanted overwrites
to_be_updated
=
self
.
_merge_properties_from_remote
(
to_be_updated
,
to_be_updated
=
self
.
_merge_properties_from_remote
(
to_be_updated
,
identified_records
)
identified_records
)
# remove unnecessary updates from list by comparing the target records
# remove unnecessary updates from list by comparing the target records
# to the existing ones
# to the existing ones
to_be_updated
=
self
.
remove_unnecessary_updates
(
to_be_updated
=
self
.
remove_unnecessary_updates
(
to_be_updated
,
identified_records
)
to_be_updated
,
identified_records
)
logger
.
info
(
f
"
Going to insert
{
len
(
to_be_inserted
)
}
Entities:
\n
"
+
self
.
create_entity_summary
(
to_be_inserted
))
logger
.
info
(
f
"
Going to update
{
len
(
to_be_inserted
)
}
Entities:
\n
"
+
self
.
create_entity_summary
(
to_be_updated
))
if
commit_changes
:
if
commit_changes
:
self
.
execute_parent_updates_in_list
(
to_be_updated
,
securityMode
=
self
.
securityMode
,
self
.
execute_parent_updates_in_list
(
to_be_updated
,
securityMode
=
self
.
securityMode
,
run_id
=
self
.
run_id
,
unique_names
=
unique_names
)
run_id
=
self
.
run_id
,
unique_names
=
unique_names
)
logger
.
info
(
f
"
Added parent RecordTypes where necessary.
"
)
self
.
execute_inserts_in_list
(
self
.
execute_inserts_in_list
(
to_be_inserted
,
self
.
securityMode
,
self
.
run_id
,
unique_names
=
unique_names
)
to_be_inserted
,
self
.
securityMode
,
self
.
run_id
,
unique_names
=
unique_names
)
logger
.
info
(
f
"
Executed inserts.
"
)
self
.
execute_updates_in_list
(
self
.
execute_updates_in_list
(
to_be_updated
,
self
.
securityMode
,
self
.
run_id
,
unique_names
=
unique_names
)
to_be_updated
,
self
.
securityMode
,
self
.
run_id
,
unique_names
=
unique_names
)
logger
.
info
(
f
"
Executed updates.
"
)
update_cache
=
UpdateCache
()
update_cache
=
UpdateCache
()
pending_inserts
=
update_cache
.
get_inserts
(
self
.
run_id
)
pending_inserts
=
update_cache
.
get_inserts
(
self
.
run_id
)
...
@@ -1045,6 +1050,25 @@ class Crawler(object):
...
@@ -1045,6 +1050,25 @@ class Crawler(object):
return
(
to_be_inserted
,
to_be_updated
)
return
(
to_be_inserted
,
to_be_updated
)
@staticmethod
def
create_entity_summary
(
entities
:
list
[
db
.
Entity
]):
"""
Creates a summary string reprensentation of a list of entities.
"""
parents
=
{}
for
el
in
entities
:
for
pp
in
el
.
parents
:
if
pp
.
name
not
in
parents
:
parents
[
pp
.
name
]
=
[]
else
:
parents
[
pp
.
name
].
append
(
el
.
id
)
output
=
""
for
key
,
value
in
parents
.
items
():
output
+=
f
"
{
key
}
:
\n
"
for
el
in
value
:
output
+=
create_entity_link
(
el
)
+
"
,
"
output
=
output
[:
-
2
]
+
"
\n
"
return
output
@staticmethod
@staticmethod
def
inform_about_pending_changes
(
pending_changes
,
run_id
,
path
,
inserts
=
False
):
def
inform_about_pending_changes
(
pending_changes
,
run_id
,
path
,
inserts
=
False
):
# Sending an Email with a link to a form to authorize updates is
# Sending an Email with a link to a form to authorize updates is
...
...
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