Skip to content

Commit

Permalink
Merge pull request #262 from FAIRmat-NFDI/261-add-a-skip-verification…
Browse files Browse the repository at this point in the history
…-flag-skip-verify-to-dataconverter

Adds --skip-verify to dataconverter
  • Loading branch information
sherjeelshabih authored Feb 23, 2024
2 parents 58a8850 + 9495147 commit 1a6f0f5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pynxtools/dataconverter/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def transfer_data_into_template(
reader,
nxdl_name,
nxdl_root: Optional[ET.Element] = None,
skip_verify: bool = False,
**kwargs,
):
"""Transfer parse and merged data from input experimental file, config file and eln.
Expand All @@ -167,6 +168,8 @@ def transfer_data_into_template(
Root name of nxdl file, e.g. NXmpes from NXmpes.nxdl.xml
nxdl_root : ET.element
Root element of nxdl file, otherwise provide nxdl_name
skip_verify: bool, default False
Skips verification routine if set to True
Returns
-------
Expand Down Expand Up @@ -200,7 +203,8 @@ def transfer_data_into_template(
data = data_reader().read( # type: ignore[operator]
template=Template(template), file_paths=input_file, **kwargs
)
helpers.validate_data_dict(template, data, nxdl_root)
if not skip_verify:
helpers.validate_data_dict(template, data, nxdl_root)
return data


Expand All @@ -213,6 +217,7 @@ def convert(
generate_template: bool = False,
fair: bool = False,
undocumented: bool = False,
skip_verify: bool = False,
**kwargs,
):
"""The conversion routine that takes the input parameters and calls the necessary functions.
Expand All @@ -234,6 +239,8 @@ def convert(
in the template.
undocumented : bool, default False
If True, an undocumented warning is given.
skip_verify: bool, default False
Skips verification routine if set to True
Returns
-------
Expand All @@ -252,6 +259,7 @@ def convert(
reader=reader,
nxdl_name=nxdl,
nxdl_root=nxdl_root,
skip_verify=skip_verify,
**kwargs,
)

Expand Down Expand Up @@ -336,6 +344,12 @@ def parse_params_file(params_file):
default=False,
help="Shows a log output for all undocumented fields",
)
@click.option(
"--skip-verify",
is_flag=True,
default=False,
help="Skips the verification routine during conversion.",
)
@click.option(
"--mapping",
help="Takes a <name>.mapping.json file and converts data from given input files.",
Expand All @@ -351,6 +365,7 @@ def convert_cli(
fair: bool,
params_file: str,
undocumented: bool,
skip_verify: bool,
mapping: str,
):
"""The CLI entrypoint for the convert function"""
Expand Down Expand Up @@ -397,4 +412,5 @@ def convert_cli(
generate_template,
fair,
undocumented,
skip_verify,
)

0 comments on commit 1a6f0f5

Please sign in to comment.