Skip to content

Commit 6f8af6d

Browse files
committed
Update to work with fairgraph 0.13.2, so that it will continue to function after the KG migration to openMINDS v4
1 parent 35ac68c commit 6f8af6d

13 files changed

Lines changed: 193 additions & 172 deletions

File tree

validation_service_api/requirements.txt.lock

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#fairgraph==0.12.1
2-
fairgraph @ git+https://github.com/HumanBrainProject/fairgraph@stable
1+
fairgraph==0.13.2
32
uvicorn==0.13.4
43
fastapi==0.65.1
54
itsdangerous==2.0.1

validation_service_api/validation_service/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ async def get_person(self, kg_client):
138138
identity = await self.get_identity()
139139
family_name = identity["family_name"]
140140
given_name = identity["given_name"]
141-
person = omcore.Person.list(kg_client, family_name=family_name, given_name=given_name, scope="any")
141+
person = omcore.Person.list(kg_client, family_name=family_name, given_name=given_name, release_status="any")
142142
if person:
143143
if isinstance(person, list):
144144
if len(person) > 1:

validation_service_api/validation_service/data_models.py

Lines changed: 65 additions & 46 deletions
Large diffs are not rendered by default.

validation_service_api/validation_service/db.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ def _check_service_status():
2222
)
2323

2424

25-
def _get_model_by_id_or_alias(model_id, kg_client, scope, use_cache=False):
25+
def _get_model_by_id_or_alias(model_id, kg_client, release_status, use_cache=False):
2626
try:
2727
model_id = UUID(model_id)
28-
model_project = Model.from_uuid(str(model_id), kg_client, scope=scope, use_cache=use_cache)
28+
model_project = Model.from_uuid(str(model_id), kg_client, release_status=release_status, use_cache=use_cache)
2929
except ValueError:
30-
model_project = Model.from_alias(model_id, kg_client, scope=scope)
30+
model_project = Model.from_alias(model_id, kg_client, release_status=release_status)
3131
if not model_project:
3232
raise HTTPException(
3333
status_code=status.HTTP_404_NOT_FOUND,
@@ -37,26 +37,25 @@ def _get_model_by_id_or_alias(model_id, kg_client, scope, use_cache=False):
3737
return model_project
3838

3939

40-
def _get_model_instance_by_id(instance_id, kg_client, scope):
41-
model_instance = ModelVersion.from_uuid(str(instance_id), kg_client, scope=scope)
40+
def _get_model_instance_by_id(instance_id, kg_client, release_status):
41+
model_instance = ModelVersion.from_uuid(str(instance_id), kg_client, release_status=release_status)
4242
if model_instance is None:
4343
raise HTTPException(
4444
status_code=status.HTTP_404_NOT_FOUND,
4545
detail=f"Model instance with ID '{instance_id}' not found.",
4646
)
4747

48-
model_project = Model.list(kg_client, scope=scope, has_versions=model_instance, use_cache=False)
48+
model_project = Model.list(kg_client, release_status=release_status, has_versions=model_instance)
4949
if not model_project:
5050
# we could get an empty response if the model_project has just been
5151
# updated and the KG is not consistent, so we wait and try again
5252
sleep(RETRY_INTERVAL)
53-
model_project = Model.list(kg_client, scope=scope, has_versions=model_instance, use_cache=False)
53+
model_project = Model.list(kg_client, release_status=release_status, has_versions=model_instance)
5454
if not model_project:
5555
# try the service client
5656
kg_service_client = get_kg_client_for_service_account()
57-
model_project = Model.list(kg_service_client, scope="in progress", has_versions=model_instance, use_cache=False)
57+
model_project = Model.list(kg_service_client, release_status="in progress", has_versions=model_instance)
5858
if not model_project:
59-
raise Exception("foo")
6059
# in case of a dangling model instance, where the parent model_project
6160
# has been deleted but the instance wasn't
6261
raise HTTPException(
@@ -67,13 +66,13 @@ def _get_model_instance_by_id(instance_id, kg_client, scope):
6766
return model_instance, model_project.uuid
6867

6968

70-
def _get_test_by_id_or_alias(test_id, kg_client, scope):
69+
def _get_test_by_id_or_alias(test_id, kg_client, release_status):
7170
try:
7271
test_id = UUID(test_id)
7372
get_test = ValidationTest.from_uuid
7473
except ValueError:
7574
get_test = ValidationTest.from_alias
76-
test_definition = get_test(str(test_id), kg_client, scope=scope)
75+
test_definition = get_test(str(test_id), kg_client, release_status=release_status)
7776
if not test_definition: # None or empty list
7877
raise HTTPException(
7978
status_code=status.HTTP_404_NOT_FOUND,
@@ -88,8 +87,8 @@ def _get_test_by_id_or_alias(test_id, kg_client, scope):
8887
return test_definition
8988

9089

91-
def _get_test_instance_by_id(instance_id, kg_client, scope):
92-
test_instance = ValidationTestVersion.from_uuid(str(instance_id), kg_client, scope=scope)
90+
def _get_test_instance_by_id(instance_id, kg_client, release_status):
91+
test_instance = ValidationTestVersion.from_uuid(str(instance_id), kg_client, release_status=release_status)
9392
if test_instance is None:
9493
raise HTTPException(
9594
status_code=status.HTTP_404_NOT_FOUND,

validation_service_api/validation_service/queries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def build_result_filters(
157157
def model_alias_exists(alias, client):
158158
if alias:
159159
# we deliberately use space=None to search across all spaces
160-
model_with_same_alias = omcore.Model.from_alias(alias, client, space=None, scope="any")
160+
model_with_same_alias = omcore.Model.from_alias(alias, client, space=None, release_status="any")
161161
if model_with_same_alias:
162162
# need this check because alias query doesn't do exact matching
163163
return model_with_same_alias.short_name == alias
@@ -167,7 +167,7 @@ def model_alias_exists(alias, client):
167167
def test_alias_exists(alias, client):
168168
if alias:
169169
# we deliberately use space=None to search across all spaces
170-
test_with_same_alias = omcmp.ValidationTest.from_alias(alias, client, space=None, scope="any")
170+
test_with_same_alias = omcmp.ValidationTest.from_alias(alias, client, space=None, release_status="any")
171171
if test_with_same_alias:
172172
# need this check because alias query doesn't do exact matching
173173
return test_with_same_alias.short_name == alias

validation_service_api/validation_service/resources/comments.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ async def query_comments(
5353
try:
5454
kg_comments = omcore.Comment.list(
5555
kg_user_client,
56-
scope="any",
56+
release_status="any",
5757
follow_links={"commenter": {}},
5858
size=size,
5959
from_index=from_index,
60+
api="query",
6061
**filters
6162
)
6263
except AuthenticationError as err:
@@ -97,7 +98,7 @@ async def get_comment(
9798
):
9899
"""Retrieve a specific comment identified by a UUID"""
99100
kg_user_client = get_kg_client_for_user_account(token)
100-
obj = omcore.Comment.from_uuid(str(comment_id), kg_user_client, scope="any")
101+
obj = omcore.Comment.from_uuid(str(comment_id), kg_user_client, release_status="any")
101102
if obj:
102103
return Comment.from_kg_object(obj, kg_user_client)
103104
else:
@@ -121,7 +122,7 @@ async def update_comment(
121122
"""Retrieve a specific comment identified by a UUID"""
122123
kg_user_client = get_kg_client_for_user_account(token)
123124
original_comment = omcore.Comment.from_uuid(
124-
str(comment_id), kg_user_client, scope="any"
125+
str(comment_id), kg_user_client, release_status="any"
125126

126127
)
127128

@@ -146,7 +147,7 @@ async def update_comment(
146147
if comment_patch.status == PublicationStatus.draft:
147148
target_space = "myspace"
148149
else:
149-
about = original_comment.about.resolve(kg_user_client, scope="any")
150+
about = original_comment.about.resolve(kg_user_client, release_status="any")
150151
target_space = about.space
151152

152153
if original_comment.space != target_space:

0 commit comments

Comments
 (0)