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
2a372d08
Commit
2a372d08
authored
Sep 10, 2019
by
Azat Khuziyakhmetov
Browse files
ascii -> text
parent
f7815360
Changes
7
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
2a372d08
...
...
@@ -23,9 +23,9 @@ Sample configs must not be used in the code.
The main executable of the aggregator module is
`data.py`
. You can type
`./data.py -h`
for more help.
```
usage: data.py [-h] [-s] [-t {
ascii
,pdf}] JOBID
usage: data.py [-h] [-s] [-t {
text
,pdf}] JOBID
Gets the job information required for generating
ASCII
or PDF reports and
Gets the job information required for generating
text
or PDF reports and
outputs it in JSON format. Optionaly it stores the job info in DB.
positional arguments:
...
...
@@ -34,9 +34,9 @@ positional arguments:
optional arguments:
-h, --help show this help message and exit
-s, --save save batch info of the job in DB (default: False)
-t {
ascii
,pdf}, --type {
ascii
,pdf}
-t {
text
,pdf}, --type {
text
,pdf}
type of the output (default:
ascii
)
type of the output (default:
text
)
```
## Get test output
...
...
data.py
View file @
2a372d08
...
...
@@ -16,7 +16,7 @@ def print_job_info(job_id, type):
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
"""
Gets the job information required for generating
ASCII
or PDF reports
Gets the job information required for generating
text
or PDF reports
and outputs it in JSON format.
Optionaly it stores the job info in DB.
"""
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
...
...
@@ -25,7 +25,7 @@ def main():
action
=
"store_true"
)
parser
.
add_argument
(
"-t"
,
"--type"
,
help
=
"type of the output"
,
choices
=
[
'
ascii
'
,
'pdf'
],
default
=
"
ascii
"
)
choices
=
[
'
text
'
,
'pdf'
],
default
=
"
text
"
)
parser
.
add_argument
(
"JOBID"
,
help
=
"job ID used in the batch system"
)
...
...
db/aggregator.py
View file @
2a372d08
from
.influx
import
influxdb_wrapper
def
get_aggregator
(
job_id
,
type
=
"
ascii
"
):
def
get_aggregator
(
job_id
,
type
=
"
text
"
):
aggr
=
influxdb_wrapper
.
get_aggregator
(
job_id
,
type
)
return
aggr
db/influx/influxdb_wrapper.py
View file @
2a372d08
...
...
@@ -20,7 +20,7 @@ def fetch_all(job_id, type):
return
data
def
get_aggregator
(
job_id
,
type
=
"
ascii
"
):
def
get_aggregator
(
job_id
,
type
=
"
text
"
):
data
=
fetch_all
(
job_id
,
type
)
aggr
=
Aggregator
()
...
...
format/format.py
View file @
2a372d08
...
...
@@ -70,8 +70,8 @@ def format_scheme(agg, sstruc, path="", **ids):
return
result
def
format_
ascii
(
agg
):
scheme
=
OutputSchemes
.
ascii
def
format_
text
(
agg
):
scheme
=
OutputSchemes
.
text
result
=
{}
result
=
format_scheme
(
agg
,
scheme
)
...
...
@@ -90,14 +90,14 @@ def format_pdf(agg):
return
result
def
format
(
agg
,
type
=
"
ascii
"
):
def
format
(
agg
,
type
=
"
text
"
):
if
not
isinstance
(
agg
,
Aggregator
):
raise
RuntimeError
(
"No aggregator in the format method"
)
assert
type
in
[
"
ascii
"
,
"pdf"
]
assert
type
in
[
"
text
"
,
"pdf"
]
if
type
==
"
ascii
"
:
formatted
=
format_
ascii
(
agg
)
if
type
==
"
text
"
:
formatted
=
format_
text
(
agg
)
elif
type
==
"pdf"
:
formatted
=
format_pdf
(
agg
)
...
...
format/formats_json.py
View file @
2a372d08
class
OutputSchemes
:
ascii
=
{
text
=
{
"type"
:
"dict"
,
"path"
:
""
,
"scheme"
:
{
...
...
test_format.py
View file @
2a372d08
...
...
@@ -33,4 +33,4 @@ for i, _ in enumerate(agg.nodes):
setattr
(
agg
.
nodes
[
i
],
f
,
"node_"
+
str
(
i
)
+
"_"
+
str
(
f
)
+
"_value"
)
# format and output JSON
pprint
(
format
.
format_
ascii
(
agg
))
pprint
(
format
.
format_
text
(
agg
))
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