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
f6fa53d5
Commit
f6fa53d5
authored
5 years ago
by
Mikhail Karnevskiy
Browse files
Options
Downloads
Patches
Plain Diff
use latex table with 3 columns for input parameters
parent
8e0ac83b
No related branches found
No related tags found
1 merge request
!72
Feat: Change formatting of list of input parameters
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xfel_calibrate/calibrate.py
+57
-19
57 additions, 19 deletions
xfel_calibrate/calibrate.py
with
57 additions
and
19 deletions
xfel_calibrate/calibrate.py
+
57
−
19
View file @
f6fa53d5
...
...
@@ -442,6 +442,62 @@ def concurrent_run(temp_path, nb, nbname, args, cparm=None, cval=None,
return
jobid
def
make_par_table
(
parms
,
temp_path
,
run_uuid
):
'''
Create a table with input parameters if the notebook
:param parms: parameters of the notebook
:param temp_path: path to temporary directory for job outputs
:param run_uuid: inset of folder name containing job output
'''
def
split_len
(
seq
,
length
):
l
=
[
seq
[
i
:
i
+
length
]
for
i
in
range
(
0
,
len
(
seq
),
length
)]
return
'
'
.
join
(
l
)
# prepare strings and estimate their length
l_parms
=
[]
len_parms
=
[
0
,
0
]
max_len
=
[
30
,
30
]
for
p
in
parms
:
name
=
p
.
name
.
replace
(
'
_
'
,
'
-
'
)
if
len
(
name
)
>
max_len
[
0
]:
len_parms
[
0
]
=
max_len
[
0
]
name
=
split_len
(
name
,
max_len
[
0
])
value
=
str
(
p
.
value
)
if
len
(
value
)
>
max_len
[
1
]:
len_parms
[
1
]
=
max_len
[
1
]
value
=
split_len
(
value
,
max_len
[
1
])
if
p
.
type
is
str
:
value
=
"
``{}
''"
.
format
(
value
)
value
=
value
.
replace
(
'
_
'
,
'
\\
_
'
)
comment
=
str
(
p
.
comment
)[
1
:].
replace
(
'
_
'
,
'
\\
_
'
)
l_parms
.
append
([
name
,
value
,
comment
])
with
open
(
"
{}/slurm_tmp_{}/InputParameters.rst
"
.
format
(
temp_path
,
run_uuid
),
"
w
"
)
as
finfile
:
finfile
.
write
(
"
Input of the calibration pipeline
\n
"
)
finfile
.
write
(
"
=================================
\n\n
"
)
finfile
.
write
(
"
.. math::
\n
"
)
col_type
=
[
'
l
'
,
'
c
'
,
'
p{.3
\\
textwidth}
'
]
# fix column width is needed
if
len_parms
[
0
]
==
max_len
[
0
]:
col_type
[
0
]
=
'
p{.3
\\
textwidth}
'
if
len_parms
[
1
]
==
max_len
[
1
]:
col_type
[
1
]
=
'
p{.3
\\
textwidth}
'
finfile
.
write
(
"
\\
begin{{tabular}}{{ {} {} {} }}
\n
"
.
format
(
*
col_type
))
finfile
.
write
(
"
\\
hline
\n
"
)
for
p
in
l_parms
:
tmpl
=
"
\\
textbf{{-{{}}-{} }} & {} & {}
\\\\\n
"
finfile
.
write
(
tmpl
.
format
(
*
p
))
finfile
.
write
(
"
\\
hline
\n
"
)
finfile
.
write
(
"
\\
end{tabular}
\n
"
)
def
run
():
"""
Run a calibration task with parser arguments
"""
...
...
@@ -527,25 +583,7 @@ def run():
# Write all input parameters to rst file to be included to final report
parms
=
parameter_values
(
parms
,
**
args
)
with
open
(
"
{}/slurm_tmp_{}/InputParameters.rst
"
.
format
(
temp_path
,
run_uuid
),
"
w
"
)
as
finfile
:
finfile
.
write
(
"
Input of the calibration pipeline
\n
"
)
finfile
.
write
(
"
=================================
\n\n
"
)
finfile
.
write
(
"
.. math::
\n
"
)
finfile
.
write
(
"
\\
begin{tabular}{ll}
\n
"
)
finfile
.
write
(
"
\\
hline
\n
"
)
for
p
in
parms
:
#finfile.write("{} \n\n".format(p.comment))
#finfile.write(".. parsed-literal::\n")
if
p
.
type
is
str
:
tmpl
=
"
\\
textbf{{-{{}}-{} }} & ``{}
''
, {}
\\\\\n
"
else
:
tmpl
=
"
\\
textbf{{-{{}}-{} }} & {}, {}
\\\\\n
"
finfile
.
write
(
tmpl
.
format
(
p
.
name
.
replace
(
'
_
'
,
'
-
'
),
str
(
p
.
value
).
replace
(
'
_
'
,
'
\\
_
'
),
str
(
p
.
comment
)[
1
:].
replace
(
'
_
'
,
'
\\
_
'
)))
finfile
.
write
(
"
\\
hline
\n
"
)
finfile
.
write
(
"
\\
end{tabular}
\n
"
)
make_par_table
(
parms
,
temp_path
,
run_uuid
)
# wait on all jobs to run and then finalize the run by creating a report from the notebooks
out_path
=
"
{}/{}/{}/{}
"
.
format
(
report_path
,
detector
.
upper
(),
...
...
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