@@ -314,6 +314,7 @@ class ModelInstance(BaseModel):
314314 version : str
315315 description : str = None
316316 parameters : HttpUrl = None
317+ path : str = None
317318 code_format : ContentType = None
318319 source : AnyUrl = None # should be required
319320 license : License = None # use Enum
@@ -346,6 +347,7 @@ def from_kg_query(cls, item, client):
346347 item ["alternatives" ].append (f"https://search.kg.ebrains.eu/instances/{ item ['id' ]} " )
347348 if item ["source" ] and "modeldb" in item ["source" ].lower ():
348349 item ["alternatives" ].append (item ["source" ])
350+ item ["path" ] = item .pop ("entry_point" , None )
349351
350352 # provide download zip link if source is a container folder
351353 if item ["source" ] and "object.cscs.ch" in item ["source" ] and "?prefix" in item ["source" ] and item ["source" ][- 1 ] == "/" :
@@ -418,6 +420,7 @@ def from_kg_object(cls, instance, client, model_id, scope):
418420 "version" : instance .version_identifier or "unknown" ,
419421 "description" : instance .version_innovation ,
420422 "parameters" : None , # todo: get from instance.input_data
423+ "path" : instance .entry_point ,
421424 "timestamp" : instance .release_date ,
422425 "model_id" : model_id ,
423426 "alternatives" : alternatives ,
@@ -464,6 +467,7 @@ def to_kg_object(self, model_project):
464467 repository = repository ,
465468 licenses = get_term ("License" , self .license ),
466469 release_date = self .timestamp if self .timestamp else date .today (),
470+ entry_point = self .path
467471 )
468472 if self .uri :
469473 minst .id = str (self .uri )
@@ -476,6 +480,7 @@ class ModelInstancePatch(BaseModel):
476480 version : str = None
477481 description : str = None
478482 parameters : HttpUrl = None
483+ path : str = None
479484 code_format : ContentType = None
480485 source : HttpUrl = None
481486 license : License = None
@@ -1796,11 +1801,12 @@ class PublicationStatus(str, Enum):
17961801
17971802
17981803class NewComment (BaseModel ):
1799- about : UUID
1804+ about : str
18001805 content : str
18011806
18021807 def to_kg_object (self , kg_client , commenter ):
1803- about = KGObject .from_id (str (self .about ), kg_client )
1808+ about_uuid = self .about .split ("/" )[- 1 ]
1809+ about = KGObject .from_id (about_uuid , kg_client )
18041810 # by definition this is a new object, so we create its UUID
18051811 # now to avoid taking time for the "exists()" query
18061812 id = kg_client .uri_from_uuid (str (uuid4 ()))
@@ -1813,9 +1819,14 @@ def to_kg_object(self, kg_client, commenter):
18131819 )
18141820
18151821
1822+ type_map = {
1823+ "Model" : "models" ,
1824+ "ValidationTest" : "tests"
1825+ }
1826+
18161827class Comment (BaseModel ):
18171828 """Users may comment on models, validation tests or validation results."""
1818- about : UUID
1829+ about : str
18191830 content : str
18201831 commenter : Person
18211832 timestamp : datetime
@@ -1824,8 +1835,13 @@ class Comment(BaseModel):
18241835
18251836 @classmethod
18261837 def from_kg_object (cls , comment , kg_client ):
1838+ if isinstance (comment .about , KGProxy ):
1839+ obj_type = type_map [comment .about .classes [0 ].__name__ ]
1840+ else :
1841+ assert isinstance (comment .about , KGObject )
1842+ obj_type = type_map [comment .about .__class__ .__name__ ]
18271843 obj = cls (
1828- about = UUID ( comment .about .uuid ) ,
1844+ about = f"/ { obj_type } / { comment .about .uuid } " ,
18291845 content = comment .comment ,
18301846 commenter = Person .from_kg_object (comment .commenter , kg_client ),
18311847 timestamp = comment .timestamp ,
@@ -1840,7 +1856,7 @@ def from_kg_object(cls, comment, kg_client):
18401856 return obj
18411857
18421858 def to_kg_object (self , kg_client ):
1843- about = KGObject .from_id (str ( self .about ) , kg_client )
1859+ about = KGObject .from_id (self .about . split ( "/" )[ - 1 ] , kg_client )
18441860 return omcore .Comment (
18451861 about = about ,
18461862 comment = self .content ,
0 commit comments