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
7c9f0e43
Commit
7c9f0e43
authored
3 years ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Clean up how slurm_calibrate.sh is called
parent
4c39100c
No related branches found
No related tags found
1 merge request
!489
Assorted cleanup of xfel-calibrate
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/slurm_calibrate.sh
+9
-10
9 additions, 10 deletions
bin/slurm_calibrate.sh
src/xfel_calibrate/calibrate.py
+17
-11
17 additions, 11 deletions
src/xfel_calibrate/calibrate.py
src/xfel_calibrate/finalize.py
+2
-1
2 additions, 1 deletion
src/xfel_calibrate/finalize.py
with
28 additions
and
22 deletions
bin/slurm_calibrate.sh
+
9
−
10
View file @
7c9f0e43
...
@@ -7,24 +7,23 @@ ipcluster_profile=$3
...
@@ -7,24 +7,23 @@ ipcluster_profile=$3
notebook
=
$4
notebook
=
$4
detector
=
$5
detector
=
$5
caltype
=
$6
caltype
=
$6
final
=
$7
finalize
=
$7
finalize
=
$8
cluster_cores
=
$8
cluster_cores
=
$9
cal_python_path
=
$9
notebook_python_path
=
${
10
}
echo
"Running with the following parameters:"
echo
"Running with the following parameters:"
echo
"Notebook path:
$nb_path
"
echo
"Notebook path:
$nb_path
"
echo
"Python path:
$python_path
"
echo
"Python path:
$python_path
"
echo
"Calibration Python:
$cal_python_path
"
echo
"IP-Cluster profile:
$ipcluster_profile
"
echo
"IP-Cluster profile:
$ipcluster_profile
"
echo
"notebook:
$notebook
"
echo
"notebook:
$notebook
"
echo
"detector:
$detector
"
echo
"detector:
$detector
"
echo
"caltype:
$caltype
"
echo
"caltype:
$caltype
"
echo
"final:
$final
"
echo
"finalize:
$finalize
"
echo
"finalize:
$finalize
"
echo
"cluster_cores:
$cluster_cores
"
echo
"cluster_cores:
$cluster_cores
"
echo
"job ID:
$SLURM_JOB_ID
"
echo
"job ID:
$SLURM_JOB_ID
"
export
CAL_NOTEBOOK_NAME
=
$notebook
export
CAL_NOTEBOOK_NAME
=
"
$notebook
"
# set-up enviroment
# set-up enviroment
source
/etc/profile.d/modules.sh
source
/etc/profile.d/modules.sh
...
@@ -44,8 +43,8 @@ fi
...
@@ -44,8 +43,8 @@ fi
echo
"Running notebook"
echo
"Running notebook"
${
notebook_
python_path
}
-m
princess
${
nb_path
}
--save
--on-error-resume-next
${
python_path
}
-m
princess
${
nb_path
}
--save
--on-error-resume-next
${
notebook
_python_path
}
-m
nbconvert
--to
rst
--TemplateExporter
.exclude_input
=
True
${
nb_path
}
${
cal
_python_path
}
-m
nbconvert
--to
rst
--TemplateExporter
.exclude_input
=
True
${
nb_path
}
# stop the cluster if requested
# stop the cluster if requested
if
[
"
${
ipcluster_profile
}
"
!=
"NO_CLUSTER"
]
if
[
"
${
ipcluster_profile
}
"
!=
"NO_CLUSTER"
]
...
@@ -56,7 +55,7 @@ then
...
@@ -56,7 +55,7 @@ then
rm
-rf
$profile_path
rm
-rf
$profile_path
fi
fi
if
[
"
${
final
}
"
==
"FINAL
"
]
if
[
-n
"
${
final
ize
}
"
]
then
then
${
python_path
}
${
finalize
}
$SLURM_JOB_ID
${
cal_
python_path
}
${
finalize
}
$SLURM_JOB_ID
fi
fi
This diff is collapsed.
Click to expand it.
src/xfel_calibrate/calibrate.py
+
17
−
11
View file @
7c9f0e43
...
@@ -580,20 +580,21 @@ def set_figure_format(nb, enable_vector_format):
...
@@ -580,20 +580,21 @@ def set_figure_format(nb, enable_vector_format):
cell
.
source
+=
"
\n
%config InlineBackend.figure_formats = [
'
svg
'
]
\n
"
cell
.
source
+=
"
\n
%config InlineBackend.figure_formats = [
'
svg
'
]
\n
"
def
create_finalize_script
(
fmt_args
,
temp_path
,
job_list
):
def
create_finalize_script
(
fmt_args
,
temp_path
,
job_list
)
->
str
:
"""
"""
Create a finalize script to produce output report
Create a finalize script to produce output report
:param fmt_args: Dictionary of fmt arguments
:param fmt_args: Dictionary of fmt arguments
:param temp_path: Path to temporary folder to run slurm job
:param temp_path: Path to temporary folder to run slurm job
:param job_list: List of slurm jobs
:param job_list: List of slurm jobs
:return: The path of the created script
"""
"""
tmpl
=
Template
(
"""
\
tmpl
=
Template
(
"""
\
#!/usr/bin/env python3
#!/usr/bin/env python3
import
sy
s
import
o
s
from xfel_calibrate.finalize import finalize
from xfel_calibrate.finalize import finalize
finalize(joblist={{joblist}},
finalize(joblist={{joblist}},
finaljob=
sys.argv[1]
,
finaljob=
os.environ.get(
'
SLURM_JOB_ID
'
,
''
)
,
run_path=
'
{{run_path}}
'
,
run_path=
'
{{run_path}}
'
,
out_path=
'
{{out_path}}
'
,
out_path=
'
{{out_path}}
'
,
project=
'
{{project}}
'
,
project=
'
{{project}}
'
,
...
@@ -616,6 +617,7 @@ def create_finalize_script(fmt_args, temp_path, job_list):
...
@@ -616,6 +617,7 @@ def create_finalize_script(fmt_args, temp_path, job_list):
# executed and writable for user, readable for user, group and others
# executed and writable for user, readable for user, group and others
all_stats
=
stat
.
S_IXUSR
|
stat
.
S_IWUSR
|
stat
.
S_IRUSR
|
stat
.
S_IRGRP
|
stat
.
S_IROTH
all_stats
=
stat
.
S_IXUSR
|
stat
.
S_IWUSR
|
stat
.
S_IRUSR
|
stat
.
S_IRGRP
|
stat
.
S_IROTH
os
.
chmod
(
f_name
,
all_stats
)
os
.
chmod
(
f_name
,
all_stats
)
return
f_name
def
save_executed_command
(
run_tmp_path
,
version
):
def
save_executed_command
(
run_tmp_path
,
version
):
...
@@ -742,7 +744,9 @@ def concurrent_run(
...
@@ -742,7 +744,9 @@ def concurrent_run(
# add finalization to the last job
# add finalization to the last job
if
final_job
:
if
final_job
:
create_finalize_script
(
fmt_args
,
temp_path
,
job_list
)
finalize_script
=
create_finalize_script
(
fmt_args
,
temp_path
,
job_list
)
else
:
finalize_script
=
''
# then run an sbatch job
# then run an sbatch job
srun_base
=
[]
srun_base
=
[]
...
@@ -752,19 +756,21 @@ def concurrent_run(
...
@@ -752,19 +756,21 @@ def concurrent_run(
if
user_venv
:
if
user_venv
:
print
(
f
"
Running job in user venv at
{
user_venv
}
\n
"
)
print
(
f
"
Running job in user venv at
{
user_venv
}
\n
"
)
python
=
str
(
user_venv
/
'
bin
'
/
'
python
'
)
else
:
python
=
python_path
# From settings.py, default is sys.executable
srun_base
+=
[
srun_base
+=
[
os
.
path
.
join
(
PKG_DIR
,
"
bin
"
,
"
slurm_calibrate.sh
"
),
# path to helper sh
os
.
path
.
join
(
PKG_DIR
,
"
bin
"
,
"
slurm_calibrate.sh
"
),
# path to helper sh
os
.
path
.
abspath
(
nbpath
),
# path to notebook
os
.
path
.
abspath
(
nbpath
),
# path to notebook
python
_path
,
# path to python
python
,
# path to python
to run notebook (& ipcluster)
cluster_profile
,
cluster_profile
,
'"
{}
"'
.
format
(
base_name
.
upper
()),
base_name
.
upper
(),
'"
{}
"'
.
format
(
args
[
"
detector
"
].
upper
()),
args
[
"
detector
"
].
upper
(),
'"
{}
"'
.
format
(
args
[
"
type
"
].
upper
()),
args
[
"
type
"
].
upper
(),
"
FINAL
"
if
final_job
else
"
NONFINAL
"
,
finalize_script
,
"
{}/finalize.py
"
.
format
(
os
.
path
.
abspath
(
temp_path
)),
str
(
cluster_cores
),
str
(
cluster_cores
),
user_venv
+
"
/bin/python
"
if
user_venv
else
python_path
# used for nb execution
sys
.
executable
,
# Python for calib machinery (nbconvert, finalize)
]
]
output
=
check_output
(
srun_base
).
decode
(
'
utf8
'
)
output
=
check_output
(
srun_base
).
decode
(
'
utf8
'
)
...
...
This diff is collapsed.
Click to expand it.
src/xfel_calibrate/finalize.py
+
2
−
1
View file @
7c9f0e43
...
@@ -403,7 +403,8 @@ def finalize(joblist, finaljob, run_path, out_path, project, calibration,
...
@@ -403,7 +403,8 @@ def finalize(joblist, finaljob, run_path, out_path, project, calibration,
prepare_plots
(
run_path
)
prepare_plots
(
run_path
)
# Archiving files in slurm_tmp
# Archiving files in slurm_tmp
joblist
.
append
(
str
(
finaljob
))
if
finaljob
:
joblist
.
append
(
str
(
finaljob
))
metadata
=
cal_tools
.
tools
.
CalibrationMetadata
(
out_path
)
metadata
=
cal_tools
.
tools
.
CalibrationMetadata
(
out_path
)
job_time_fmt
=
'
JobID,Start,End,Elapsed,Suspended,State
'
.
split
(
'
,
'
)
job_time_fmt
=
'
JobID,Start,End,Elapsed,Suspended,State
'
.
split
(
'
,
'
)
job_time_summary
=
get_job_info
(
joblist
,
job_time_fmt
)
job_time_summary
=
get_job_info
(
joblist
,
job_time_fmt
)
...
...
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