Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LHCb
DaVinci
Commits
98dcc5c4
Commit
98dcc5c4
authored
Jan 22, 2022
by
Gitlab CI
Committed by
Davide Fazzini
Jan 22, 2022
Browse files
Fixed formatting
patch generated by
https://gitlab.cern.ch/lhcb/DaVinci/-/jobs/18975338
parent
6b585e93
Pipeline
#3476805
passed with stages
in 24 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
DaVinciSys/scripts/davinci
View file @
98dcc5c4
...
...
@@ -134,7 +134,10 @@ def run_job(configurables, export=None, with_defaults=False, dry_run=None):
ignore_unknown_options
=
False
,
allow_extra_args
=
False
))
@
click
.
argument
(
"option_type"
)
@
click
.
option
(
"-f"
,
"--filename"
,
default
=
"options_template.yaml"
,
help
=
"Name for the template file."
)
"-f"
,
"--filename"
,
default
=
"options_template.yaml"
,
help
=
"Name for the template file."
)
@
click
.
option
(
"-i"
,
"--interactive"
,
...
...
@@ -165,8 +168,11 @@ def create_options_template(option_type, filename, interactive):
context_settings
=
dict
(
ignore_unknown_options
=
False
,
allow_extra_args
=
False
))
@
click
.
option
(
"-f"
,
"--filenames"
,
default
=
(
"inputdb_template.yaml"
,
"jobopt_template.yaml"
),
nargs
=
2
,
help
=
"Name for the template files: inputfiledb and joboptfile."
)
"-f"
,
"--filenames"
,
default
=
(
"inputdb_template.yaml"
,
"jobopt_template.yaml"
),
nargs
=
2
,
help
=
"Name for the template files: inputfiledb and joboptfile."
)
def
create_options_templates
(
filenames
):
"""
Create a template for the two options files to be passed to DaVinci when running a job:
\n
...
...
@@ -179,7 +185,7 @@ def create_options_templates(filenames):
Click automatically converts "_" in "-", so this function can be invoked calling
create-options-template as shown in the help.
"""
create_inputdb_template
(
filenames
[
0
])
create_jobopt_template
(
filenames
[
1
])
...
...
DaVinciSys/tests/test_davinci_script.py
View file @
98dcc5c4
...
...
@@ -96,9 +96,10 @@ def test_create_options_templates():
assert
result
.
returncode
==
0
import
yaml
with
open
(
os
.
path
.
expandvars
(
"test_inputdb_template.yaml"
))
as
inputdb_file
:
with
open
(
os
.
path
.
expandvars
(
"test_inputdb_template.yaml"
))
as
inputdb_file
:
assert
yaml
.
safe_load
(
inputdb_file
)
with
open
(
os
.
path
.
expandvars
(
"test_inputdb_template.yaml"
))
as
jobopt_file
:
assert
yaml
.
safe_load
(
jobopt_file
)
...
...
Phys/DaVinci/python/DaVinci/utilities_script.py
View file @
98dcc5c4
...
...
@@ -119,7 +119,8 @@ def get_dummy_config():
return
config
def
create_jobopt_template
(
file_name
=
"jobopt_template.yaml"
,
interactive
=
False
):
def
create_jobopt_template
(
file_name
=
"jobopt_template.yaml"
,
interactive
=
False
):
"""
Function for creating simple template for the joboptfile dict.
...
...
@@ -147,11 +148,11 @@ def create_jobopt_template(file_name = "jobopt_template.yaml", interactive = Fal
# Get the DaVinci dict containing the default values.
from
DaVinci.options_default
import
__optsDict__
as
opts_dict
dict_template
=
{}
dict_template
=
{}
# These are the data options that are set via the inputfiledb, so we remove them from the joboptfile.
list_data_qualifiers
=
[
"data_type"
,
"input_type"
,
"simulation"
,
"conddb_tag"
,
"dddb_tag"
,
"input_files"
"data_type"
,
"input_type"
,
"simulation"
,
"conddb_tag"
,
"dddb_tag"
,
"input_files"
]
for
name
,
config
in
opts_dict
.
items
():
...
...
@@ -163,15 +164,18 @@ def create_jobopt_template(file_name = "jobopt_template.yaml", interactive = Fal
# Adding to the dict only if the value is not the default one.
if
not
value
==
config
[
"value"
]:
dict_template
.
update
({
name
:
value
})
if
len
(
dict_template
):
with
open
(
file_name
,
'w'
)
as
jobopt_file
:
yaml
.
safe_dump
(
dict_template
,
jobopt_file
,
default_flow_style
=
False
)
yaml
.
safe_dump
(
dict_template
,
jobopt_file
,
default_flow_style
=
False
)
else
:
click
.
echo
(
"All option values match the default ones, no job option file is needed!"
)
click
.
echo
(
"All option values match the default ones, no job option file is needed!"
)
def
create_inputdb_template
(
file_name
=
"inputdb_template.yaml"
):
def
create_inputdb_template
(
file_name
=
"inputdb_template.yaml"
):
"""
Function for creating simple template for the TestFileDB-like file.
...
...
@@ -198,6 +202,6 @@ def create_inputdb_template(file_name = "inputdb_template.yaml"):
" Author: '<me :-)>'
\n
"
\
" Date: '<date_of_creation>'
\n
"
\
" Comment: '<E.g. how the files were created or for what purpose>'"
with
open
(
file_name
,
'w'
)
as
inputdb_file
:
inputdb_file
.
write
(
template_str
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment