Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ProfiT-HPC
aggregator
Commits
b02089e9
Commit
b02089e9
authored
Dec 27, 2018
by
Azat Khuziyakhmetov
Browse files
modified data.py to comply with recent changes
parent
70b1e1ce
Changes
5
Hide whitespace changes
Inline
Side-by-side
data.py
View file @
b02089e9
#! /usr/bin/env python3
import
argparse
import
json
import
db.getproc
import
db.getnode
import
db.getjob
import
db.metrics
import
argparse
import
db.aggregator
as
aggregator
import
postexec.exportjobinfo
as
xjob
import
conf.config
as
conf
from
format
import
format
def
format_output
(
job_id
,
proc
,
job
,
nodes
,
alloc_cu
):
nodenames
=
list
(
nodes
.
keys
())
nodes_concat
=
[]
for
n
in
nodenames
:
cc
=
{
db
.
metrics
.
APInames
.
NODE_NAME
:
n
,
**
proc
[
n
],
**
nodes
[
n
]}
# add allocated cu info
m
=
db
.
metrics
.
metrics_node
[
"alloc_cu"
][
"apiname"
]
if
n
in
alloc_cu
:
cc
[
m
]
=
alloc_cu
[
n
]
nodes_concat
.
append
(
cc
)
o
=
{
"job_id"
:
None
,
"general"
:
{},
"nodes"
:
[]
}
def
print_job_info
(
job_id
,
type
):
aggr
=
aggregator
.
get_aggregator
(
job_id
,
type
)
formatted
=
format
.
format
(
aggr
,
type
)
o
[
"job_id"
]
=
job_id
o
[
"general"
]
=
job
o
[
"nodes"
]
=
nodes_concat
print
(
json
.
dumps
(
formatted
))
return
o
def
print_job_info
(
job_id
):
proc
=
db
.
getproc
.
get_proc_data
(
job_id
)
job
,
alloc_cu
=
db
.
getjob
.
get_job_data
(
job_id
)
nodenames
=
list
(
proc
.
keys
())
nodes
=
db
.
getnode
.
get_node_data
(
nodenames
)
if
conf
.
DEBUG
:
print
(
"jobinfo from INFLUXDB and REMOTE: {:s}"
.
format
(
json
.
dumps
(
nodes
)))
print
(
"jobinfo from BATCH: {:s}"
.
format
(
json
.
dumps
(
job
)))
output
=
format_output
(
job_id
,
proc
,
job
,
nodes
,
alloc_cu
)
print
(
json
.
dumps
(
output
))
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
"""
Gets the job information required for generating
an
ASCII report
Gets the job information required for generating ASCII
or PDF
report
s
and outputs it in JSON format.
Optionaly it stores the job info in DB.
"""
)
"""
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser
.
add_argument
(
"-s"
,
"--save"
,
help
=
"save batch info of the job in DB"
,
action
=
"store_true"
)
parser
.
add_argument
(
"-t"
,
"--type"
,
help
=
"type of the output"
,
choices
=
[
'ascii'
,
'pdf'
],
default
=
"ascii"
)
parser
.
add_argument
(
"JOBID"
,
help
=
"job ID used in the batch system"
)
...
...
@@ -76,7 +41,7 @@ def main():
print
(
"Job {} was exported"
.
format
(
job_id
))
return
0
print_job_info
(
job_id
)
print_job_info
(
job_id
,
args
.
type
)
return
0
...
...
db/
data
.py
→
db/
aggrstruct
.py
View file @
b02089e9
File moved
db/influx/influxdb_wrapper.py
View file @
b02089e9
from
.influxdb_fetchjob
import
get_job_data
from
.influxdb_fetchproc
import
get_proc_data
from
.influxdb_fetchnode
import
get_node_data
from
..
data
import
*
from
..
aggrstruct
import
*
def
fetch_all
(
job_id
,
type
):
data
=
{}
...
...
format/format.py
View file @
b02089e9
# this script contains the main function format to format the data ready to
# output
from
db
import
data
from
db
.aggrstruct
import
*
from
.formats_json
import
OutputSchemes
def
get_value
(
agg
,
path
,
**
ids
):
...
...
@@ -73,14 +73,28 @@ def format_ascii(agg):
return
result
def
format_pdf
(
agg
):
scheme
=
OutputSchemes
.
ascii
result
=
{}
result
=
format_scheme
(
agg
,
scheme
)
result
=
format_acsii_nonstd
(
agg
,
result
)
return
result
def
format
(
agg
,
type
=
"ascii"
):
if
type
(
agg
)
is
not
Aggregator
:
if
not
isinstance
(
agg
,
Aggregator
)
:
raise
RuntimeError
(
"No aggregator in the format method"
)
assert
type
in
[
"ascii"
,
"pdf"
]
if
type
==
"ascii"
:
format_ascii
(
agg
)
formatted
=
format_ascii
(
agg
)
elif
type
==
"pdf"
:
format_pdf
(
agg
)
formatted
=
format_pdf
(
agg
)
return
formatted
def
format_acsii_nonstd
(
agg
,
result
):
# TODO: format alloc_cu
...
...
postexec/exportjobinfo.py
View file @
b02089e9
...
...
@@ -6,8 +6,8 @@ from datetime import datetime
from
io
import
StringIO
import
requests
from
requests.auth
import
HTTPBasicAuth
from
db
import
common
from
db.metrics
import
MType
from
db
.influx
import
common
from
db.
influx.
metrics
import
MType
import
conf.config
as
conf
import
conf.influxdb
as
confdb
...
...
Write
Preview
Markdown
is supported
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