Skip to content

Commit

Permalink
Merge pull request #278 from datalad/issue-277-status-scrambles-json-…
Browse files Browse the repository at this point in the history
…output

Fix JSON output of `meta-extract`, which is scrambled by status-messages from `subdatasets()`-calls
  • Loading branch information
christian-monch authored Aug 25, 2022
2 parents 755aa40 + 0875dd7 commit d8acd6a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datalad_metalad/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ def legacy_extract_dataset(ea: ExtractionArguments) -> Iterable[dict]:

if issubclass(ea.extractor_class, MetadataExtractor):

status = ea.source_dataset.subdatasets()
status = ea.source_dataset.subdatasets(result_renderer="disabled")
extractor = ea.extractor_class()
ensure_legacy_content_availability(ea, extractor, "dataset", status)

Expand Down
28 changes: 28 additions & 0 deletions datalad_metalad/tests/test_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Test metadata extraction"""
import json
import subprocess
import unittest.mock
from pathlib import Path
Expand Down Expand Up @@ -668,3 +669,30 @@ def test_symlink_handling(tmp_dir_path_str=None):
**common_kwargs,
)
)


@with_tempfile(mkdir=True)
def test_submodule_status_suppression(tmp_dir_path_str=None):
tmp_dir = Path(tmp_dir_path_str)

super_ds = create(tmp_dir / "super")
super_ds.save(**common_kwargs)
create(
dataset=str(tmp_dir / "super"),
path=str(tmp_dir / "super" / "sub"),
)
super_ds.save(recursive=True, **common_kwargs)

output = subprocess.run(
[
"datalad",
"meta-extract",
"-d",
str(tmp_dir / "super"),
"metalad_core"
],
stdout=subprocess.PIPE
).stdout.decode().strip()

# Ensure that only JSON is written out
json_object = json.loads(output)

0 comments on commit d8acd6a

Please sign in to comment.