Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure in accessing views with TimeFrame #10

Open
1192119703jzx opened this issue Aug 26, 2024 · 4 comments · May be fixed by #12
Open

Failure in accessing views with TimeFrame #10

1192119703jzx opened this issue Aug 26, 2024 · 4 comments · May be fixed by #12
Assignees
Labels
🐛B Something isn't working

Comments

@1192119703jzx
Copy link

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:

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:

views_with_tframe = mmif.get_views_contain(AnnotationTypes.TimeFrame)
@1192119703jzx 1192119703jzx added the 🐛B Something isn't working label Aug 26, 2024
@clams-bot clams-bot added this to apps Aug 26, 2024
@github-project-automation github-project-automation bot moved this to Todo in apps Aug 26, 2024
1192119703jzx added a commit that referenced this issue Aug 26, 2024
@1192119703jzx 1192119703jzx linked a pull request Aug 26, 2024 that will close this issue
@github-staff github-staff deleted a comment Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛B Something isn't working
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

4 participants
@1192119703jzx and others