Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SCHEMA] - Adding validator to CLI #1641

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions tools/schemacode/bidsschematools/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import click

from .schema import export_schema, load_schema
from .validator import validate_bids


@click.group()
Expand Down Expand Up @@ -32,5 +33,50 @@ def export(ctx, schema, output):
fobj.write(text)


@cli.command()
@click.argument("in_paths", nargs=-1, required=True)
@click.option("--schema")
@click.option("--dummy_paths", is_flag=True)
@click.option("--bids_reference_root")
@click.option("--schema_path")
@click.option("--bids_version")
@click.option("--report_path", is_flag=True)
@click.option("--suppress_errors", is_flag=True)
@click.option("accept_non_bids_dir", is_flag=True)
@click.pass_context
def validate(
ctx,
schema,
in_paths,
dummy_paths,
bids_reference_root,
schema_path,
bids_version,
report_path,
suppress_errors,
accept_non_bids_dir,
):
suleesan marked this conversation as resolved.
Show resolved Hide resolved
"""Validate BIDS Schema"""
logger = logging.getLogger("bidsschematools")
if schema:
schema_path = schema
validation_result = validate_bids(
in_paths,
dummy_paths,
bids_reference_root,
schema_path,
bids_version,
report_path,
suppress_errors,
accept_non_bids_dir,
)
suleesan marked this conversation as resolved.
Show resolved Hide resolved
logger.debug("Printing out path_tracking in validation_result dictionary")
if validation_result["path_tracking"]:
print(validation_result["path_tracking"])

# print validation_result["path_tracking"] if not empty
# return 0 = success, non-zero = fail use Click exception handling
suleesan marked this conversation as resolved.
Show resolved Hide resolved


if __name__ == "__main__":
cli()