Skip to content

Commit 4a74803

Browse files
committed
distinguashing context
1 parent c8f7a0a commit 4a74803

2 files changed

Lines changed: 25 additions & 21 deletions

File tree

pipeline/src/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ def to_jsonld(
7373

7474
data = {"@type": self.type_}
7575
if with_context:
76-
data["@context"] = {"@vocab": "https://openminds.ebrains.eu/vocab/"}
76+
if self.type_.startswith("https://openminds.ebrains.eu/"):
77+
data["@context"] = {"@vocab": "https://openminds.ebrains.eu/vocab/"}
78+
else:
79+
data["@context"] = {"@vocab": "https://openminds.om-i.org/vocab/"}
7780
if hasattr(self, "id") and self.id:
7881
data["@id"] = self.id
7982
for property in self.__class__.properties:

pipeline/tests/test_regressions.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_issue_0002():
1212

1313
node = build_fake_node(omcore.Person)
1414
data = node.to_jsonld()
15-
assert data["@type"] == "https://openminds.ebrains.eu/core/Person"
15+
assert data["@type"] == "https://openminds.om-i.org/types/Person"
1616

1717

1818
def test_issue_0003():
@@ -38,21 +38,22 @@ def test_issue_0003():
3838
)
3939
# on export, a single item should be wrapped in a list, where the property expects an array
4040
expected = {
41-
"@context": {"@vocab": "https://openminds.ebrains.eu/vocab/"},
42-
"@type": "https://openminds.ebrains.eu/core/FileArchive",
41+
"@context": {"@vocab": "https://openminds.om-i.org/vocab/"},
42+
"@type": "https://openminds.om-i.org/types/FileArchive",
4343
"IRI": "http://example.com/archive.zip",
4444
"format": {
45-
"@type": "https://openminds.ebrains.eu/core/ContentType",
45+
"@type": "https://openminds.om-i.org/types/ContentType",
4646
"name": "application/zip",
47-
},
47+
},
4848
"sourceData": [
4949
{
50-
"@type": "https://openminds.ebrains.eu/core/File",
50+
"@type": "https://openminds.om-i.org/types/File",
5151
"IRI": "http://example.com/some_file.txt",
5252
"name": "some_file.txt",
5353
}
5454
],
5555
}
56+
5657
assert (
5758
node1.to_jsonld(include_empty_properties=False) == node2.to_jsonld(include_empty_properties=False) == expected
5859
)
@@ -89,20 +90,20 @@ def test_issue0007():
8990

9091
actual = person.to_jsonld(include_empty_properties=False, embed_linked_nodes=False, with_context=True)
9192
expected = {
92-
"@context": {"@vocab": "https://openminds.ebrains.eu/vocab/"},
93+
"@context": {"@vocab": "https://openminds.om-i.org/vocab/"},
9394
"@id": "_:001",
94-
"@type": "https://openminds.ebrains.eu/core/Person",
95+
"@type": "https://openminds.om-i.org/types/Person",
9596
"familyName": "Professor",
9697
"givenName": "A",
9798
"affiliation": [
9899
{
99-
"@type": "https://openminds.ebrains.eu/core/Affiliation",
100+
"@type": "https://openminds.om-i.org/types/Affiliation",
100101
"memberOf": {
101102
"@id": "_:002"
102103
},
103104
},
104105
{
105-
"@type": "https://openminds.ebrains.eu/core/Affiliation",
106+
"@type": "https://openminds.om-i.org/types/Affiliation",
106107
"memberOf": {
107108
"@id": "_:003"
108109
},
@@ -117,22 +118,22 @@ def test_issue0007():
117118

118119
with open(output_paths[0]) as fp:
119120
saved_data = json.load(fp)
120-
os.remove("issue0007.jsonld")
121+
#os.remove("issue0007.jsonld")
121122
expected_saved_data = {
122-
"@context": {"@vocab": "https://openminds.ebrains.eu/vocab/"},
123+
"@context": {"@vocab": "https://openminds.om-i.org/vocab/"},
123124
"@graph": [
124125
{
125126
"@id": "_:001",
126-
"@type": "https://openminds.ebrains.eu/core/Person",
127+
"@type": "https://openminds.om-i.org/types/Person",
127128
"affiliation": [
128129
{
129-
"@type": "https://openminds.ebrains.eu/core/Affiliation",
130+
"@type": "https://openminds.om-i.org/types/Affiliation",
130131
"memberOf": {
131132
"@id": "_:002"
132133
},
133134
},
134135
{
135-
"@type": "https://openminds.ebrains.eu/core/Affiliation",
136+
"@type": "https://openminds.om-i.org/types/Affiliation",
136137
"memberOf": {
137138
"@id": "_:003"
138139
},
@@ -143,12 +144,12 @@ def test_issue0007():
143144
},
144145
{
145146
"@id": "_:002",
146-
"@type": "https://openminds.ebrains.eu/core/Organization",
147+
"@type": "https://openminds.om-i.org/types/Organization",
147148
"fullName": "University of This Place",
148149
},
149150
{
150151
"@id": "_:003",
151-
"@type": "https://openminds.ebrains.eu/core/Organization",
152+
"@type": "https://openminds.om-i.org/types/Organization",
152153
"fullName": "University of That Place",
153154
},
154155
],
@@ -170,12 +171,12 @@ def test_issue0008():
170171
)
171172
actual = person.to_jsonld(include_empty_properties=False, embed_linked_nodes=False, with_context=True)
172173
expected = {
173-
"@context": {"@vocab": "https://openminds.ebrains.eu/vocab/"},
174+
"@context": {"@vocab": "https://openminds.om-i.org/vocab/"},
174175
"@id": "_:002",
175-
"@type": "https://openminds.ebrains.eu/core/Person",
176+
"@type": "https://openminds.om-i.org/types/Person",
176177
"affiliation": [
177178
{
178-
"@type": "https://openminds.ebrains.eu/core/Affiliation",
179+
"@type": "https://openminds.om-i.org/types/Affiliation",
179180
"endDate": "2023-09-30",
180181
"memberOf": {
181182
"@id": "_:001"

0 commit comments

Comments
 (0)