Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
metadata-and-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
web-et-numerique-internet
data.grandlyon.com
web-portal
components
indexers
metadata-and-data
Commits
1f12dc5a
Commit
1f12dc5a
authored
6 years ago
by
ddamiron
Browse files
Options
Downloads
Patches
Plain Diff
add get json for all progress_ratio and timestamp end-point
parent
e7b78edd
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
api.py
+6
-4
6 additions, 4 deletions
api.py
lib/mongo_session.py
+3
-1
3 additions, 1 deletion
lib/mongo_session.py
workers/reindexer.py
+2
-2
2 additions, 2 deletions
workers/reindexer.py
workers/sample-generator.py
+27
-4
27 additions, 4 deletions
workers/sample-generator.py
with
38 additions
and
11 deletions
api.py
+
6
−
4
View file @
1f12dc5a
...
@@ -149,7 +149,8 @@ def build_plot(session_id, step):
...
@@ -149,7 +149,8 @@ def build_plot(session_id, step):
def
build_all_plot
(
session_id
):
def
build_all_plot
(
session_id
):
img
=
io
.
BytesIO
()
img
=
io
.
BytesIO
()
plt
.
clf
()
plt
.
clf
()
for
step
in
[
'
main
'
,
'
metadata-processor
'
,
'
doc-enricher
'
,
'
doc-processor
'
,
'
doc-indexer
'
,
'
reindexer
'
,
'
sampler
'
]:
for
step
in
[
'
main
'
,
'
metadata-processor
'
,
'
doc-enricher
'
,
'
doc-processor
'
,
'
doc-indexer
'
,
'
pre-reindexer-checker
'
,
'
reindexer
'
,
'
sampler
'
]:
try
:
try
:
x
,
y
=
MongoSession
(
cfg
=
cfg
).
get_array_from_step
(
this_session_id
=
session_id
,
step_name
=
step
)
x
,
y
=
MongoSession
(
cfg
=
cfg
).
get_array_from_step
(
this_session_id
=
session_id
,
step_name
=
step
)
plt
.
plot
(
x
,
y
,
label
=
step
)
plt
.
plot
(
x
,
y
,
label
=
step
)
...
@@ -158,8 +159,8 @@ def build_all_plot(session_id):
...
@@ -158,8 +159,8 @@ def build_all_plot(session_id):
plt
.
legend
()
plt
.
legend
()
plt
.
xlabel
(
'
time
'
)
plt
.
xlabel
(
'
time
'
)
plt
.
ylabel
(
'
progress ratio
'
)
plt
.
ylabel
(
'
progress ratio
'
)
plt
.
title
(
'
indexer
session
scripts progress
report.
'
)
plt
.
title
(
'
indexer
-
session
-
scripts
:
progress
-
report.
'
)
plt
.
grid
(
Tru
e
)
plt
.
grid
(
Fals
e
)
plt
.
savefig
(
img
,
format
=
'
png
'
)
plt
.
savefig
(
img
,
format
=
'
png
'
)
img
.
seek
(
0
)
img
.
seek
(
0
)
...
@@ -172,7 +173,8 @@ def build_all_plot(session_id):
...
@@ -172,7 +173,8 @@ def build_all_plot(session_id):
def
build_full_session_json
(
session_id
):
def
build_full_session_json
(
session_id
):
data
=
dict
()
data
=
dict
()
for
step
in
[
'
main
'
,
'
metadata-processor
'
,
'
doc-enricher
'
,
'
doc-processor
'
,
'
doc-indexer
'
,
'
reindexer
'
,
'
sampler
'
]:
for
step
in
[
'
main
'
,
'
metadata-processor
'
,
'
doc-enricher
'
,
'
doc-processor
'
,
'
doc-indexer
'
,
'
pre-reindexer-checker
'
,
'
reindexer
'
,
'
sampler
'
]:
try
:
try
:
data
[
step
]
=
dict
()
data
[
step
]
=
dict
()
data
[
step
][
'
timestamp
'
],
data
[
step
][
'
progress_ratio
'
]
=
\
data
[
step
][
'
timestamp
'
],
data
[
step
][
'
progress_ratio
'
]
=
\
...
...
This diff is collapsed.
Click to expand it.
lib/mongo_session.py
+
3
−
1
View file @
1f12dc5a
...
@@ -100,7 +100,9 @@ class MongoSession:
...
@@ -100,7 +100,9 @@ class MongoSession:
data_time
=
[]
data_time
=
[]
data_value
=
[]
data_value
=
[]
request_result
=
self
.
mongo_data_collection
.
find
({
"
session_id
"
:
this_session_id
,
"
step
"
:
step_name
},
request_result
=
self
.
mongo_data_collection
.
find
({
"
session_id
"
:
this_session_id
,
"
step
"
:
step_name
,
'
loglevel
'
:
'
INFO
'
},
{
'
timestamp
'
:
1
,
'
progress_ratio
'
:
1
})
{
'
timestamp
'
:
1
,
'
progress_ratio
'
:
1
})
for
res
in
request_result
:
for
res
in
request_result
:
...
...
This diff is collapsed.
Click to expand it.
workers/reindexer.py
+
2
−
2
View file @
1f12dc5a
...
@@ -173,7 +173,7 @@ def on_msg_callback(channel, method, properties, body):
...
@@ -173,7 +173,7 @@ def on_msg_callback(channel, method, properties, body):
log_message
=
LogMessage
(
session_id
=
cfg
[
'
session
'
][
'
id
'
],
log_message
=
LogMessage
(
session_id
=
cfg
[
'
session
'
][
'
id
'
],
# session_id=cfg['session']['id'],
# session_id=cfg['session']['id'],
uuid
=
cfg
[
'
session
'
][
'
current_uuid
'
],
uuid
=
cfg
[
'
session
'
][
'
current_uuid
'
],
step
=
'
reindexer
'
,
step
=
'
pre-
reindexer
-checker
'
,
status
=
'
Documents are still being pushed to the source index
'
,
status
=
'
Documents are still being pushed to the source index
'
,
uuid_prefix
=
'
full
'
,
uuid_prefix
=
'
full
'
,
info
=
uuid
,
info
=
uuid
,
...
@@ -302,7 +302,7 @@ def on_msg_callback(channel, method, properties, body):
...
@@ -302,7 +302,7 @@ def on_msg_callback(channel, method, properties, body):
uuid_prefix
=
'
full
'
,
uuid_prefix
=
'
full
'
,
info
=
uuid
,
info
=
uuid
,
loglevel
=
'
ERROR
'
,
loglevel
=
'
ERROR
'
,
progress_ratio
=
0.5
progress_ratio
=
None
)
)
json_body
=
json
.
dumps
(
log_message
.
__dict__
)
json_body
=
json
.
dumps
(
log_message
.
__dict__
)
...
...
This diff is collapsed.
Click to expand it.
workers/sample-generator.py
+
27
−
4
View file @
1f12dc5a
...
@@ -182,12 +182,12 @@ def callback(channel, method, properties, body):
...
@@ -182,12 +182,12 @@ def callback(channel, method, properties, body):
logging
.
info
(
"
Deleting already existing samples for dataset with slug = %s
"
%
docs_to_index
[
0
][
'
slug
'
])
logging
.
info
(
"
Deleting already existing samples for dataset with slug = %s
"
%
docs_to_index
[
0
][
'
slug
'
])
# ---------------------- send log ----------------------------
# ---------------------- send log ----------------------------
message
=
"
Deleting already existing samples for dataset
with slug = {:s}
"
.
format
(
docs_to_index
[
0
][
'
slug
'
])
message
=
"
Deleting already existing samples for dataset
"
log_message
=
LogMessage
(
session_id
=
cfg
[
'
session
'
][
'
id
'
],
log_message
=
LogMessage
(
session_id
=
cfg
[
'
session
'
][
'
id
'
],
uuid
=
cfg
[
'
session
'
][
'
current_uuid
'
],
uuid
=
cfg
[
'
session
'
][
'
current_uuid
'
],
step
=
'
sampler
'
,
step
=
'
sampler
'
,
status
=
message
,
status
=
message
,
uuid_prefix
=
''
,
uuid_prefix
=
'
meta
'
,
info
=
uuid
,
info
=
uuid
,
loglevel
=
'
INFO
'
,
loglevel
=
'
INFO
'
,
progress_ratio
=
0
progress_ratio
=
0
...
@@ -224,7 +224,7 @@ def callback(channel, method, properties, body):
...
@@ -224,7 +224,7 @@ def callback(channel, method, properties, body):
uuid_prefix
=
'
full
'
,
uuid_prefix
=
'
full
'
,
info
=
uuid
,
info
=
uuid
,
loglevel
=
'
ERROR
'
,
loglevel
=
'
ERROR
'
,
progress_ratio
=
None
progress_ratio
=
0
)
)
json_body
=
json
.
dumps
(
log_message
.
__dict__
)
json_body
=
json
.
dumps
(
log_message
.
__dict__
)
...
@@ -265,7 +265,7 @@ def callback(channel, method, properties, body):
...
@@ -265,7 +265,7 @@ def callback(channel, method, properties, body):
uuid_prefix
=
''
,
uuid_prefix
=
''
,
info
=
uuid
,
info
=
uuid
,
loglevel
=
'
INFO
'
,
loglevel
=
'
INFO
'
,
progress_ratio
=
1
progress_ratio
=
0.9
)
)
json_body
=
json
.
dumps
(
log_message
.
__dict__
)
json_body
=
json
.
dumps
(
log_message
.
__dict__
)
...
@@ -289,6 +289,29 @@ def callback(channel, method, properties, body):
...
@@ -289,6 +289,29 @@ def callback(channel, method, properties, body):
destin_es
.
indices
.
refresh
(
index
=
cfg
[
'
reindexer
'
][
'
destination_index
'
])
destin_es
.
indices
.
refresh
(
index
=
cfg
[
'
reindexer
'
][
'
destination_index
'
])
logging
.
info
(
"
Removing lock for dataset with uuid = %s.
"
%
uuid
.
replace
(
'
.full
'
,
''
))
logging
.
info
(
"
Removing lock for dataset with uuid = %s.
"
%
uuid
.
replace
(
'
.full
'
,
''
))
unlock
(
cfg
[
'
session
'
][
'
working_directory
'
],
uuid
.
replace
(
'
.full
'
,
''
)
)
unlock
(
cfg
[
'
session
'
][
'
working_directory
'
],
uuid
.
replace
(
'
.full
'
,
''
)
)
# ---------------------- send log ----------------------------
log_message
=
LogMessage
(
session_id
=
cfg
[
'
session
'
][
'
id
'
],
# session_id=cfg['session']['id'],
uuid
=
cfg
[
'
session
'
][
'
current_uuid
'
],
step
=
'
sampler
'
,
status
=
'
Removing lock for dataset
'
,
uuid_prefix
=
'
full
'
,
info
=
uuid
,
loglevel
=
'
INFO
'
,
progress_ratio
=
1
)
json_body
=
json
.
dumps
(
log_message
.
__dict__
)
print
(
"
[x] json body :
"
,
json_body
)
channel
.
basic_publish
(
exchange
=
cfg
[
'
rabbitmq
'
][
'
exchange_logs_name
'
],
routing_key
=
cfg
[
'
rabbitmq
'
][
'
routing_key_logs
'
],
body
=
json_body
,
properties
=
pika
.
BasicProperties
(
delivery_mode
=
2
)
)
# ------------------------------------------------------------
else
:
else
:
channel
.
basic_nack
(
delivery_tag
=
method
.
delivery_tag
,
requeue
=
1
)
channel
.
basic_nack
(
delivery_tag
=
method
.
delivery_tag
,
requeue
=
1
)
logging
.
error
(
json
.
dumps
(
rep
,
indent
=
4
))
logging
.
error
(
json
.
dumps
(
rep
,
indent
=
4
))
...
...
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