You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run the app.py with an input mmif file with a view containing timeframe, it returns keyError: http://mmif.clams.ai/vocabulary/TimeFrame/v5
The following line of code caused the bug:
views_with_tframe = [v for v in mmif.get_views_for_document(videodocument.id) if v.metadata.contains[AnnotationTypes.TimeFrame]]
There are two potential issues with this line of code. First, for some input mmif files, they don't have the corresponding property "document": "d1" in their views with timeframe. This would cause the code be unable to capture the views that have timeframe using the code mmif.get_views_for_document(videodocument.id)
Second, v.metadata.contains[AnnotationTypes.TimeFrame]will always cause the keyError because when there isn't such a key "http://mmif.clams.ai/vocabulary/TimeFrame/v5" in the dictionary named "contains", it will return KeyError.
Reproduction steps
Run the app with an input miff file with a view containing timeframe.
Expected behavior
No response
Log output
No response
Screenshots
Traceback (most recent call last):
File "/home/zixinjiang/east/lib64/python3.9/site-packages/clams/restify/init.py", line 146, in post
return self.json_to_response(self.cla.annotate(raw_data, **raw_params))
File "/home/zixinjiang/east/lib64/python3.9/site-packages/clams/app/init.py", line 151, in annotate
annotated = self._annotate(mmif, **refined)
File "/home/zixinjiang/app-east-textdetection/app2.py", line 46, in _annotate
mmif = self.run_on_video(mmif, videodocument, new_view, **parameters)
File "/home/zixinjiang/app-east-textdetection/app2.py", line 94, in run_on_video
views_with_tframe = [v for v in mmif.get_views_for_document(videodocument.id)
File "/home/zixinjiang/app-east-textdetection/app2.py", line 95, in
if v.metadata.contains[AnnotationTypes.TimeFrame]]
File "/home/zixinjiang/east/lib64/python3.9/site-packages/mmif/serialize/model.py", line 477, in getitem
return self._items.getitem(key)
KeyError: http://mmif.clams.ai/vocabulary/TimeFrame/v5
Additional context
This bug could be solved by changing the code in such a way:
Bug Description
When I run the app.py with an input mmif file with a view containing timeframe, it returns
keyError: http://mmif.clams.ai/vocabulary/TimeFrame/v5
The following line of code caused the bug:
There are two potential issues with this line of code. First, for some input mmif files, they don't have the corresponding property
"document": "d1"
in their views with timeframe. This would cause the code be unable to capture the views that have timeframe using the codemmif.get_views_for_document(videodocument.id)
Second,
v.metadata.contains[AnnotationTypes.TimeFrame]
will always cause the keyError because when there isn't such a key "http://mmif.clams.ai/vocabulary/TimeFrame/v5" in the dictionary named "contains", it will return KeyError.Reproduction steps
Run the app with an input miff file with a view containing timeframe.
Expected behavior
No response
Log output
No response
Screenshots
Traceback (most recent call last):
File "/home/zixinjiang/east/lib64/python3.9/site-packages/clams/restify/init.py", line 146, in post
return self.json_to_response(self.cla.annotate(raw_data, **raw_params))
File "/home/zixinjiang/east/lib64/python3.9/site-packages/clams/app/init.py", line 151, in annotate
annotated = self._annotate(mmif, **refined)
File "/home/zixinjiang/app-east-textdetection/app2.py", line 46, in _annotate
mmif = self.run_on_video(mmif, videodocument, new_view, **parameters)
File "/home/zixinjiang/app-east-textdetection/app2.py", line 94, in run_on_video
views_with_tframe = [v for v in mmif.get_views_for_document(videodocument.id)
File "/home/zixinjiang/app-east-textdetection/app2.py", line 95, in
if v.metadata.contains[AnnotationTypes.TimeFrame]]
File "/home/zixinjiang/east/lib64/python3.9/site-packages/mmif/serialize/model.py", line 477, in getitem
return self._items.getitem(key)
KeyError: http://mmif.clams.ai/vocabulary/TimeFrame/v5
Additional context
This bug could be solved by changing the code in such a way:
The text was updated successfully, but these errors were encountered: