Skip to content

Commit

Permalink
send format to the client
Browse files Browse the repository at this point in the history
  • Loading branch information
mam10eks committed Jan 29, 2025
1 parent 5236cab commit 7504ba6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions application/src/tira_app/endpoints/v1/_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DatasetSerializer(ModelSerializer):
ir_datasets_id = SerializerMethodField()
description = SerializerMethodField()
file_listing = SerializerMethodField()
format = SerializerMethodField()

class Meta:
model = modeldb.Dataset
Expand All @@ -37,6 +38,7 @@ class Meta:
"chatnoir_id",
"mirrors",
"file_listing",
"format",
]

def get_mirrors(self, obj):
Expand All @@ -56,6 +58,14 @@ def get_file_listing(self, obj):
except json.JSONDecodeError:
return None

def get_format(self, obj):
if not obj or not obj.format:
return None
try:
return json.loads(obj.format)
except json.JSONDecodeError:
return None

def get_ir_datasets_id(self, obj):
if obj.ir_datasets_id and obj.ir_datasets_id_2:
return [obj.ir_datasets_id, obj.ir_datasets_id_2]
Expand Down

0 comments on commit 7504ba6

Please sign in to comment.