Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
postprocessing
Media Metadata Indexer
Commits
98fa99f6
Unverified
Commit
98fa99f6
authored
Nov 09, 2020
by
Sebastian Schüpbach
Browse files
fix record_values processing
Signed-off-by:
Sebastian Schüpbach
<
sebastian.schuepbach@unibas.ch
>
parent
a6cdad23
Pipeline
#16772
failed with stages
in 1 minute and 33 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
mediametadatatodb_app/resources/MediametadataToDB.py
View file @
98fa99f6
...
...
@@ -342,15 +342,15 @@ class MediametadataToDB:
_write_values_in_db
(
mariadb_cursor
,
record_values_for_db
)
mariadb_connection
.
commit
()
for
record_value
in
record_values_for_db
:
logging
.
info
(
f
'Record
{
record_value
[
"
@id
"
]
}
successfully indexed'
)
reporter
.
send_message
(
record_value
[
'
@id
'
],
"SUCCESS"
,
"Indexing successful"
)
logging
.
info
(
f
'Record
{
record_value
[
"
sig
"
]
}
successfully indexed'
)
reporter
.
send_message
(
record_value
[
'
sig
'
],
"SUCCESS"
,
"Indexing successful"
)
record_values_for_db
=
[]
consumer
.
commit
()
except
Exception
as
ex
:
status
=
'It was not possible to consume the Kafka messages.'
+
'
\n
'
+
str
(
ex
)
logging
.
error
(
status
)
for
record_value
in
record_values_for_db
:
reporter
.
send_message
(
record_value
[
'
@id
'
],
"FAILURE"
,
f
"Indexing failed:
{
ex
}
"
)
reporter
.
send_message
(
record_value
[
'
sig
'
],
"FAILURE"
,
f
"Indexing failed:
{
ex
}
"
)
def
__init__
(
self
):
# TODO : maybe take that to a configuration (development vs pod running in
...
...
mediametadatatodb_app/resources/reporter.py
View file @
98fa99f6
...
...
@@ -70,7 +70,7 @@ class Reporter:
now
=
datetime
.
datetime
.
now
()
# //@formatter:off
timestamp
=
now
.
strftime
(
'%Y-%m-%dT%H:%M:%S.'
)
+
\
str
(
round
(
int
(
now
.
strftime
(
'%f'
))
/
1000
))
str
(
round
(
int
(
now
.
strftime
(
'%f'
))
/
1000
))
# //@formatter:on
report
=
{
'id'
:
identifier
,
...
...
@@ -79,7 +79,9 @@ class Reporter:
'step'
:
'mediametadatatodb'
,
'timestamp'
:
timestamp
}
value_bytes
=
bytes
(
json
.
dumps
(
report
),
encoding
=
'utf-8'
)
json_report
=
json
.
dumps
(
report
)
value_bytes
=
bytes
(
json_report
,
encoding
=
'utf-8'
)
logging
.
debug
(
f
'Sending report to
{
os
.
environ
[
"REPORTING_TOPIC"
]
}
:
{
json_report
}
'
)
self
.
_producer
.
send
(
os
.
environ
[
'REPORTING_TOPIC'
],
key
=
key_bytes
,
value
=
value_bytes
)
self
.
_producer
.
flush
()
except
Exception
as
ex
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment