Skip to content

Commit

Permalink
Default path which should maybe be better.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheChymera committed Apr 9, 2022
1 parent 0359c53 commit 5a577ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dandi/bids_validator_xs.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def validate_all(

def write_report(
validation_result,
report_path="bids-validator-report_{}.log",
report_path="/var/tmp/bids-validator-report_{}.log",
datetime_format="%Y%m%d-%H%M%S",
):
"""Write a human-readable report based on the validation result.
Expand All @@ -459,6 +459,11 @@ def write_report(

report_path = report_path.format(datetime.datetime.now().strftime(datetime_format))
report_path = os.path.abspath(os.path.expanduser(report_path))
try:
os.makedirs(os.path.dirname(report_path))
except OSError:
pass

total_file_count = len(validation_result["path_listing"])
validated_files_count = total_file_count - len(validation_result["path_tracking"])
with open(report_path, "w") as f:
Expand Down
3 changes: 3 additions & 0 deletions dandi/tests/test_bids_validator_xs.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,10 @@ def test_bids_datasets(bids_examples, tmp_path):
for f in files:
selected_path = os.path.join(root, f)
selected_paths.append(selected_path)
# Does terminal debug output work?
result = validate_bids(selected_paths, schema_version=schema_path, debug=True)
# Does default log path specification work?
result = validate_bids(selected_paths, schema_version=schema_path, report_path=True)
# Does custom log path specification work?
result = validate_bids(
selected_paths,
Expand Down

0 comments on commit 5a577ee

Please sign in to comment.