Skip to content

Commit ebf3355

Browse files
committed
fix test
1 parent de1899e commit ebf3355

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

cubids/tests/test_cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,9 @@ def test_validate_sequential_with_n_cpus(tmp_path):
262262
# This should complete without error
263263
_main(["validate", str(bids_dir), str(output_prefix), "--sequential", "--n-cpus", "1"])
264264

265-
# Verify the command completed successfully by checking if the output directory exists
266-
assert (bids_dir / "code" / "CuBIDS").exists()
265+
# Verify the command completed successfully by checking if the output files exist
266+
assert (output_prefix.parent / f"{output_prefix.name}_validation.tsv").exists()
267+
assert (output_prefix.parent / f"{output_prefix.name}_validation.json").exists()
267268

268269

269270
def test_group_command_with_test_dataset(tmp_path):

cubids/workflows.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -275,37 +275,34 @@ def validate(
275275
# concatenate the parsed data and exit
276276
if len(parsed) < 1:
277277
logger.info("No issues/warnings parsed, your dataset is BIDS valid.")
278-
return
279-
278+
# Create empty parsed DataFrame to ensure output files are written
279+
parsed = pd.DataFrame()
280280
else:
281281
parsed = pd.concat(parsed, axis=0, ignore_index=True)
282282
subset = parsed.columns.difference(["subject"])
283283
parsed = parsed.drop_duplicates(subset=subset)
284-
285284
logger.info("BIDS issues/warnings found in the dataset")
286285

287-
if output_prefix:
288-
# normally, write dataframe to file in CLI
289-
if abs_path_output:
290-
val_tsv = str(output_prefix) + "_validation.tsv"
291-
else:
292-
val_tsv = (
293-
str(bids_dir) + "/code/CuBIDS/" + str(output_prefix) + "_validation.tsv"
294-
)
286+
if output_prefix:
287+
# normally, write dataframe to file in CLI
288+
if abs_path_output:
289+
val_tsv = str(output_prefix) + "_validation.tsv"
290+
else:
291+
val_tsv = str(bids_dir) + "/code/CuBIDS/" + str(output_prefix) + "_validation.tsv"
295292

296-
parsed.to_csv(val_tsv, sep="\t", index=False)
293+
parsed.to_csv(val_tsv, sep="\t", index=False)
297294

298-
# build validation data dictionary json sidecar
299-
val_dict = get_val_dictionary()
300-
val_json = val_tsv.replace("tsv", "json")
301-
with open(val_json, "w") as outfile:
302-
json.dump(val_dict, outfile, indent=4)
295+
# build validation data dictionary json sidecar
296+
val_dict = get_val_dictionary()
297+
val_json = val_tsv.replace("tsv", "json")
298+
with open(val_json, "w") as outfile:
299+
json.dump(val_dict, outfile, indent=4)
303300

304-
logger.info("Writing issues out to file %s", val_tsv)
305-
return
306-
else:
307-
# user may be in python session, return dataframe
308-
return parsed
301+
logger.info("Writing issues out to file %s", val_tsv)
302+
return
303+
else:
304+
# user may be in python session, return dataframe
305+
return parsed
309306

310307

311308
def bids_version(bids_dir, write=False, schema=None):

0 commit comments

Comments
 (0)