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
6f73fbe1
Commit
6f73fbe1
authored
5 years ago
by
Karim Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
no copying if no push
parent
6f8e7d7b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!185
Feat/git push flag
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
reportservice/automatic_run.py
+1
-1
1 addition, 1 deletion
reportservice/automatic_run.py
reportservice/manual_run.py
+3
-3
3 additions, 3 deletions
reportservice/manual_run.py
reportservice/report_service.py
+42
-39
42 additions, 39 deletions
reportservice/report_service.py
with
46 additions
and
43 deletions
reportservice/automatic_run.py
+
1
−
1
View file @
6f73fbe1
...
...
@@ -73,7 +73,7 @@ if __name__ == "__main__":
args
=
vars
(
arg_parser
.
parse_args
())
conf_file
=
args
[
"
config_file
"
]
with
open
(
conf_file
,
"
r
"
)
as
f
:
cfg
=
yaml
.
load
(
f
.
read
())
cfg
=
yaml
.
load
(
f
.
read
()
,
Loader
=
yaml
.
FullLoader
)
logfile
=
args
[
"
log_file
"
]
fmt
=
'
%(asctime)s - %(name)s - %(levelname)s - %(message)s
'
...
...
This diff is collapsed.
Click to expand it.
reportservice/manual_run.py
+
3
−
3
View file @
6f73fbe1
...
...
@@ -35,11 +35,11 @@ def manual_run(request, cfg):
arg_parser
=
argparse
.
ArgumentParser
(
description
=
'
Manual Launch
'
)
arg_parser
.
add_argument
(
'
--instrument
'
,
default
=
[
'
all
'
],
nargs
=
'
+
'
,
help
=
'
select the requested instruments.
'
'
Default=
None.
"
all
"
can be used for selecting
'
'
Default=
\"
all
\"
, which
can be used for selecting
'
'
all instruments
'
)
arg_parser
.
add_argument
(
'
--gitpush
'
,
dest
=
'
Push to git
'
,
action
=
'
store_true
'
,
help
=
'
required for pushing the generated figures
'
'
to the DC git repository
'
)
'
to the DC git repository
. Default=bool(False)
'
)
arg_parser
.
set_defaults
(
gitpush
=
False
)
arg_parser
.
add_argument
(
'
--config-file
'
,
type
=
str
,
default
=
'
./report_conf.yaml
'
,
...
...
@@ -56,7 +56,7 @@ if __name__ == "__main__":
args
=
vars
(
arg_parser
.
parse_args
())
conf_file
=
args
[
"
config_file
"
]
with
open
(
conf_file
,
"
r
"
)
as
f
:
cfg
=
yaml
.
load
(
f
.
read
())
cfg
=
yaml
.
load
(
f
.
read
()
,
Loader
=
yaml
.
FullLoader
)
logfile
=
args
[
"
log_file
"
]
fmt
=
'
%(asctime)s - %(name)s - %(levelname)s - %(message)s
'
...
...
This diff is collapsed.
Click to expand it.
reportservice/report_service.py
+
42
−
39
View file @
6f73fbe1
...
...
@@ -156,7 +156,7 @@ async def server_runner(conf_file):
be accessed through ReadTheDocs.
"""
with
open
(
conf_file
,
"
r
"
)
as
f
:
config
=
yaml
.
load
(
f
.
read
())
config
=
yaml
.
load
(
f
.
read
()
,
Loader
=
yaml
.
FullLoader
)
# perform git-dir checks and pull the project for updates.
init_config_repo
(
config
[
'
GLOBAL
'
][
'
git
'
])
...
...
@@ -263,57 +263,60 @@ async def server_runner(conf_file):
logging
.
error
(
'
Jobs have timed-out!
'
)
logging
.
error
(
'
{}/temp has not been deleted.
'
.
format
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))))
# Avoid copying files if no git-push is planned
# to avoid causing local git repository errors.
if
git_push
:
# Copy all plots
for
det_name
,
det_conf
in
instrument
.
items
():
# Copy all plots
for
det_name
,
det_conf
in
instrument
.
items
():
out_folder
=
det_conf
[
'
out-folder
'
].
format
(
instrument
=
instr_name
,
detector
=
det_name
)
out_folder
=
det_conf
[
'
out-folder
'
].
format
(
instrument
=
instr_name
,
detector
=
det_name
)
figures
=
glob
.
glob
(
"
{}/*png
"
.
format
(
out_folder
))
figures
=
glob
.
glob
(
"
{}/*png
"
.
format
(
out_folder
))
det_new_files
=
{}
det_new_files
=
{}
for
f
in
figures
:
const
=
f
.
split
(
'
/
'
)[
-
1
].
split
(
'
_
'
)[
0
]
fpath
=
'
{}/{}/{}/{}
'
.
format
(
fig_local
,
instr_name
,
det_name
,
const
)
for
f
in
figures
:
const
=
f
.
split
(
'
/
'
)[
-
1
].
split
(
'
_
'
)[
0
]
fpath
=
'
{}/{}/{}/{}
'
.
format
(
fig_local
,
instr_name
,
det_name
,
const
)
os
.
makedirs
(
fpath
,
exist_ok
=
True
)
det_new_files
[
f
]
=
fpath
os
.
makedirs
(
fpath
,
exist_ok
=
True
)
det_new_files
[
f
]
=
fpath
# Set concurrency limitation.
# 50 have been chosen by trial
# Note: This is not the max limitation.
sem
=
asyncio
.
Semaphore
(
50
)
all_new_files
.
append
(
'
{}/{}
'
.
format
(
fpath
,
f
.
split
(
'
/
'
)[
-
1
]))
# Set concurrency limitation.
# 50 have been chosen by trial
# Note: This is not the max limitation.
sem
=
asyncio
.
Semaphore
(
50
)
all_new_files
.
append
(
'
{}/{}
'
.
format
(
fpath
,
f
.
split
(
'
/
'
)[
-
1
]))
await
asyncio
.
gather
(
*
[
copy_files
(
k
,
v
,
sem
)
for
k
,
v
in
det_new_files
.
items
()])
await
asyncio
.
gather
(
*
[
copy_files
(
k
,
v
,
sem
)
for
k
,
v
in
det_new_files
.
items
()])
logging
.
info
(
'
{} figures of {} are copied into {}
'
.
format
(
len
(
figures
),
det_name
,
fig_local
))
logging
.
info
(
'
{} figures of {} are copied into {}
'
.
format
(
len
(
figures
),
det_name
,
fig_local
))
# Remove sensitive information from the config file.
del
cfg
[
'
GLOBAL
'
]
# Write the requested cfg.yaml before pushing all figures.
with
open
(
'
{}/report_conf.yaml
'
.
format
(
fig_local
),
'
w
'
)
as
outfile
:
yaml
.
dump
(
cfg
,
outfile
,
default_flow_style
=
False
)
if
git_push
:
# Remove sensitive information from the config file.
del
cfg
[
'
GLOBAL
'
]
# Write the requested cfg.yaml before pushing all figures.
with
open
(
'
{}/report_conf.yaml
'
.
format
(
fig_local
),
'
w
'
)
as
outfile
:
yaml
.
dump
(
cfg
,
outfile
,
default_flow_style
=
False
)
all_new_files
.
append
(
'
{}/report_conf.yaml
'
.
format
(
fig_local
))
all_new_files
.
append
(
'
{}/report_conf.yaml
'
.
format
(
fig_local
))
if
git_push
:
asyncio
.
ensure_future
(
push_figures
(
local_repo
,
all_new_files
))
# TODO:delete out-folder
#try:
# asyncio.ensure_future(del_folder(out_folder))
#except:
#logging.error(str(e))
logging
.
info
(
'
All done
'
)
# TODO:delete out-folder
#try:
# asyncio.ensure_future(del_folder(out_folder))
#except:
#logging.error(str(e))
logging
.
info
(
'
Generating requested plots is finished!
'
)
return
...
...
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