Commit 98dcc5c4 authored by Gitlab CI's avatar Gitlab CI Committed by Davide Fazzini
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
......@@ -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])
......
......@@ -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)
......
......@@ -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)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment