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
c8bd3e9c
Commit
c8bd3e9c
authored
5 years ago
by
Mikhail Karnevskiy
Browse files
Options
Downloads
Patches
Plain Diff
Add summary job option
parent
9e6669d3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!74
Feat: Add summary job option
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cal_tools/cal_tools/tools.py
+7
-2
7 additions, 2 deletions
cal_tools/cal_tools/tools.py
xfel_calibrate/calibrate.py
+40
-2
40 additions, 2 deletions
xfel_calibrate/calibrate.py
with
47 additions
and
4 deletions
cal_tools/cal_tools/tools.py
+
7
−
2
View file @
c8bd3e9c
...
...
@@ -31,9 +31,14 @@ def combine_report(run_path, calibration):
group
,
name_param
,
conc_param
=
"
_
"
.
join
(
comps
[:
-
2
]),
comps
[
-
2
],
comps
[
-
1
]
else
:
group
,
name_param
,
conc_param
=
comps
[
0
],
"
None
"
,
"
None
"
with
open
(
"
{}/{}.rst
"
.
format
(
sphinx_path
,
group
),
"
a
"
)
as
gfile
:
if
conc_param
!=
"
None
"
:
if
conc_param
==
"
summary
"
:
title
=
"
{}. {}
"
.
format
(
calibration
,
"
Summary.
"
)
gfile
.
write
(
title
+
"
\n
"
)
gfile
.
write
(
"
=
"
*
len
(
title
)
+
"
\n
"
)
gfile
.
write
(
"
\n
"
)
elif
conc_param
!=
"
None
"
:
title
=
"
{}. {} = {}
"
.
format
(
calibration
,
name_param
,
conc_param
)
gfile
.
write
(
title
+
"
\n
"
)
gfile
.
write
(
"
=
"
*
len
(
title
)
+
"
\n
"
)
...
...
This diff is collapsed.
Click to expand it.
xfel_calibrate/calibrate.py
+
40
−
2
View file @
c8bd3e9c
...
...
@@ -358,9 +358,19 @@ def flatten_list(l):
return
"
_
"
.
join
([
str
(
flatten_list
(
v
))
for
v
in
l
])
if
isinstance
(
l
,
list
)
else
l
def
clean_nonfinal_cells
(
nb
):
first_cell
=
False
for
cell
in
nb
.
cells
:
if
not
first_cell
and
cell
.
cell_type
==
'
code
'
:
first_cell
=
True
continue
if
'
!!!FINAL!!!
'
not
in
cell
.
source
:
cell
.
source
=
''
def
concurrent_run
(
temp_path
,
nb
,
nbname
,
args
,
cparm
=
None
,
cval
=
None
,
final_job
=
False
,
job_list
=
[],
fmtcmd
=
""
,
cluster_cores
=
8
,
sequential
=
False
,
priority
=
2
):
sequential
=
False
,
priority
=
2
,
dependent
=
False
):
"""
Launch a concurrent job on the cluster via SLURM
"""
...
...
@@ -376,6 +386,10 @@ def concurrent_run(temp_path, nb, nbname, args, cparm=None, cval=None,
parms
=
extract_parameters
(
nb
)
params
=
parameter_values
(
parms
,
**
args
)
new_nb
=
replace_definitions
(
nb
,
params
,
execute
=
False
)
if
dependent
:
suffix
=
"
summary
"
clean_nonfinal_cells
(
new_nb
)
base_name
=
nbname
.
replace
(
"
.ipynb
"
,
""
)
new_name
=
"
{}__{}__{}.ipynb
"
.
format
(
os
.
path
.
basename
(
base_name
),
cparm
,
suffix
)
...
...
@@ -416,6 +430,12 @@ def concurrent_run(temp_path, nb, nbname, args, cparm=None, cval=None,
else
:
srun_base
=
[]
if
dependent
:
srun_dep
=
"
--dependency=afterok
"
for
jobid
in
job_list
:
srun_dep
+=
"
:{}
"
.
format
(
jobid
)
srun_base
+=
[
srun_dep
]
srun_base
+=
[
os
.
path
.
abspath
(
"
{}/bin/slurm_calibrate.sh
"
.
format
(
os
.
path
.
dirname
(
__file__
))),
# path to helper sh
os
.
path
.
abspath
(
nbpath
),
# path to notebook
python_path
,
# path to python
...
...
@@ -634,15 +654,33 @@ def run():
cvtype
=
p
.
type
break
run_overall
=
False
for
p
in
parms
:
if
p
.
name
==
'
run_overall
'
:
run_overall
=
p
.
value
break
for
cnum
,
cval
in
enumerate
(
cvals
):
jobid
=
concurrent_run
(
run_tmp_path
,
nb
,
notebook
,
args
,
cvar
,
[
cval
,
]
if
not
isinstance
(
cval
,
list
)
and
cvtype
is
list
else
cval
,
cnum
==
len
(
list
(
cvals
))
-
1
,
joblist
,
fmtcmd
,
1
and
not
run_overall
,
joblist
,
fmtcmd
,
cluster_cores
=
cluster_cores
,
sequential
=
sequential
,
priority
=
priority
)
joblist
.
append
(
jobid
)
# Run summary job here if needed
if
run_overall
:
jobid
=
concurrent_run
(
run_tmp_path
,
nb
,
os
.
path
.
basename
(
notebook
),
args
,
final_job
=
True
,
job_list
=
joblist
,
fmtcmd
=
fmtcmd
,
cluster_cores
=
cluster_cores
,
sequential
=
sequential
,
priority
=
priority
,
dependent
=
True
)
joblist
.
append
(
jobid
)
if
not
all
([
j
is
None
for
j
in
joblist
]):
print
(
"
Submitted the following SLURM jobs: {}
"
.
format
(
"
,
"
.
join
(
joblist
)))
...
...
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