Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor 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
calibration
pycalibration
Commits
bb49781f
Commit
bb49781f
authored
5 years ago
by
Karim Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
add config from manual_run and review fixes
parent
c28bb534
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!93
feat/reportservice
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
reportservice/automatic_run.py
+3
-6
3 additions, 6 deletions
reportservice/automatic_run.py
reportservice/manual_run.py
+11
-9
11 additions, 9 deletions
reportservice/manual_run.py
with
14 additions
and
15 deletions
reportservice/automatic_run.py
+
3
−
6
View file @
bb49781f
...
...
@@ -9,15 +9,12 @@ import yaml
import
zmq
import
zmq.asyncio
async
def
auto_run
():
async
def
auto_run
(
cfg
):
"""
Run the report service automatically depending on the scheduled times
in the run_time list, read from the config yaml file (report_conf.yaml)
"""
with
open
(
"
report_conf.yaml
"
,
'
r
'
)
as
ymlfile
:
cfg
=
yaml
.
load
(
ymlfile
)
# time index that points at a timestamp, when the next
# report service run takes place.
tidx
=
0
...
...
@@ -67,7 +64,7 @@ if __name__ == "__main__":
args
=
vars
(
arg_parser
.
parse_args
())
conf_file
=
args
[
"
config_file
"
]
with
open
(
conf_file
,
"
r
"
)
as
f
:
c
onfi
g
=
yaml
.
load
(
f
.
read
())
c
f
g
=
yaml
.
load
(
f
.
read
())
logfile
=
args
[
"
log_file
"
]
fmt
=
'
%(asctime)s - %(name)s - %(levelname)s - %(message)s
'
...
...
@@ -78,5 +75,5 @@ if __name__ == "__main__":
datefmt
=
'
%Y-%m-%d %H:%M:%S
'
)
loop
=
asyncio
.
get_event_loop
()
loop
.
run_until_complete
(
auto_run
())
loop
.
run_until_complete
(
auto_run
(
cfg
))
loop
.
close
()
This diff is collapsed.
Click to expand it.
reportservice/manual_run.py
+
11
−
9
View file @
bb49781f
...
...
@@ -6,16 +6,15 @@ import urllib.parse
import
yaml
import
zmq
import
zmq.asyncio
def
manual_run
(
req
_instr
):
def
manual_run
(
req
uest
,
cfg
):
"""
Run the report service manually from any machine
and provide the requested configuration for
reports generation.
:param req
_in
st
r
: a list for generating reports for the
:param req
ue
st: a list for generating reports for the
requested Instruments. This list can
contain the Instruments names e.g [
'
SPB
'
]
or [
'
all
'
] for generating reports for all
...
...
@@ -25,19 +24,18 @@ def manual_run(req_instr):
for test purposes.
"""
with
open
(
"
report_conf.yaml
"
,
'
r
'
)
as
ymlfile
:
cfg
=
yaml
.
load
(
ymlfile
)
port
=
cfg
[
'
GLOBAL
'
][
'
server-port
'
]
con
=
zmq
.
Context
()
socket
=
con
.
socket
(
zmq
.
REQ
)
con
=
socket
.
connect
(
port
)
socket
.
send_pyobj
(
req
_in
st
r
)
socket
.
send_pyobj
(
req
ue
st
)
msg
=
socket
.
recv_pyobj
()
logging
.
info
(
'
{} Manual Run
'
.
format
(
msg
))
arg_parser
=
argparse
.
ArgumentParser
(
description
=
'
Manual Launch
'
)
arg_parser
.
add_argument
(
'
--instrument
'
,
default
=
[
'
all
'
],
nargs
=
'
+
'
)
arg_parser
.
add_argument
(
'
--testing
'
,
dest
=
'
testing
'
,
action
=
'
store_true
'
)
arg_parser
.
set_defaults
(
testing
=
False
)
arg_parser
.
add_argument
(
'
--config-file
'
,
type
=
str
,
default
=
'
./report_conf.yaml
'
)
arg_parser
.
add_argument
(
'
--log-file
'
,
type
=
str
,
default
=
'
./report.log
'
)
arg_parser
.
add_argument
(
'
--logging
'
,
type
=
str
,
default
=
"
INFO
"
,
...
...
@@ -47,7 +45,7 @@ if __name__ == "__main__":
args
=
vars
(
arg_parser
.
parse_args
())
conf_file
=
args
[
"
config_file
"
]
with
open
(
conf_file
,
"
r
"
)
as
f
:
c
onfi
g
=
yaml
.
load
(
f
.
read
())
c
f
g
=
yaml
.
load
(
f
.
read
())
logfile
=
args
[
"
log_file
"
]
fmt
=
'
%(asctime)s - %(name)s - %(levelname)s - %(message)s
'
...
...
@@ -56,5 +54,9 @@ if __name__ == "__main__":
level
=
getattr
(
logging
,
args
[
'
logging
'
]),
format
=
'
%(levelname)-6s: %(asctime)s %(message)s
'
,
datefmt
=
'
%Y-%m-%d %H:%M:%S
'
)
if
args
[
"
testing
"
]:
request
=
cfg
else
:
request
=
args
[
"
instrument
"
]
manual_run
(
args
[
"
instrument
"
]
)
manual_run
(
request
,
cfg
)
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