Skip to content

Commit

Permalink
more fixes in compliance with updated context
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaumet committed Sep 4, 2023
1 parent 84e319c commit 5619add
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions bids_prov/fsl/fsl_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,9 @@ def fsl_to_bids_prov(filename: str, context_url=CONTEXT_URL, output_file=None,

lines = readlines(filename)
records = build_records(lines, agent_id)
graph["records"].update(records)
graph["Records"].update(records)

compute_sha_256_entity(graph["records"]["prov:Entity"])
compute_sha_256_entity(graph["Records"]["prov:Entity"])

return writing_jsonld(graph, indent, output_file)

Expand Down
2 changes: 1 addition & 1 deletion bids_prov/spm/spm_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def get_records(task_groups: dict, agent_id: str, verbose=False) -> dict:
Returns
-------
dict[str, list]
records : dict with key "@context", ... "records":{"prov:Agent": ..."prov:Activity":..."prov:Entity":....}
records : dict with key "@context", ... "Records":{"prov:Agent": ..."prov:Activity":..."prov:Entity":....}
"""

Expand Down
2 changes: 1 addition & 1 deletion bids_prov/tests/samples_test/batch_example_spm_ref.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"@context": "https://raw.githubusercontent.com/bids-standard/BEP028_BIDSprov/master/context.json",
"BIDSProvVersion": "dev",
"@id": "http://example.org/ds00000X",
"records": {
"Records": {
"prov:Agent": [
{
"@id": "urn:c15521b1-b3dc-450a-9daa-37e51b591d75",
Expand Down
2 changes: 1 addition & 1 deletion bids_prov/tests/samples_test/partial_conjunction.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"@context": "https://raw.githubusercontent.com/bids-standard/BEP028_BIDSprov/master/context.json",
"BIDSProvVersion": "dev",
"@id": "http://example.org/ds00000X",
"records": {
"Records": {
"prov:Agent": [
{
"@id": "urn:c15521b1-b3dc-450a-9daa-37e51b591d75",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"@context": "https://raw.githubusercontent.com/bids-standard/BEP028_BIDSprov/master/context.json",
"BIDSProvVersion": "dev",
"@id": "http://example.org/ds00000X",
"records": {
"Records": {
"prov:Agent": [
{
"@id": "urn:c15521b1-b3dc-450a-9daa-37e51b591d75",
Expand Down
6 changes: 3 additions & 3 deletions bids_prov/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ def test_get_default_graph():
# Test the default arguments
graph, agent_id = get_default_graph(label)
assert graph["@context"] == CONTEXT_URL
assert graph["records"]["prov:Agent"][0]["Label"] == label
assert graph["Records"]["prov:Agent"][0]["Label"] == label
assert agent_id is not None

# Test custom arguments
graph, agent_id = get_default_graph(label, context_url, spm_ver)
assert graph["@context"] == context_url
assert graph["records"]["prov:Agent"][0]["Label"] == label
assert graph["records"]["prov:Agent"][0]["version"] == spm_ver
assert graph["Records"]["prov:Agent"][0]["Label"] == label
assert graph["Records"]["prov:Agent"][0]["version"] == spm_ver
assert agent_id is not None


Expand Down
4 changes: 2 additions & 2 deletions bids_prov/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def get_id():


def get_default_graph(label: str, context_url: str = CONTEXT_URL, soft_ver: str = "dev", ) \
-> Tuple[Mapping[str, Union[str, Mapping]], str]: # TODO Dict instead of Mapping , see parser graph["records"].update
-> Tuple[Mapping[str, Union[str, Mapping]], str]: # TODO Dict instead of Mapping , see parser graph["Records"].update
agent_id = get_id()
return {
"@context": context_url,
"BIDSProvVersion": "dev", # TODO ?
"records": {
"Records": {
"prov:Agent": [
{
"@id": "urn:" + agent_id,
Expand Down
6 changes: 3 additions & 3 deletions bids_prov/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def viz_jsonld11(jsonld11: dict, img_file: str) -> None:
context_10 = {
k: v
for k, v in context_11["@context"].items()
if k not in {"@version", "records"}
if k not in {"@version", "Records"}
}

# Load graph from json-ld file as non 1.1 JSON-LD
Expand All @@ -56,7 +56,7 @@ def viz_jsonld11(jsonld11: dict, img_file: str) -> None:
viz_turtle(content=g.serialize(format="turtle"), img_file=img_file)


def join_jsonld(lds: list, graph_key="records", omit_details=True) -> dict:
def join_jsonld(lds: list, graph_key="Records", omit_details=True) -> dict:
"""
lds: list of dict
jsonld graphs to be joined
Expand Down Expand Up @@ -101,7 +101,7 @@ def main(filename: str, output_file=None, omit_details=True) -> None:
jsonld11s.append(ld)

# join multiple definitions
jsonld11 = join_jsonld(jsonld11s, graph_key="records",
jsonld11 = join_jsonld(jsonld11s, graph_key="Records",
omit_details=omit_details)

if output_file is None:
Expand Down

0 comments on commit 5619add

Please sign in to comment.