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

Fixing LitQATaskDatasetcompute_trajectory_metrics crash with bad status extraction #500

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

jamesbraza
Copy link
Collaborator

If the re.split(pattern=GenerateAnswer.ANSWER_SPLIT_REGEX_PATTERN, ...) doesn't give at least 4 values, the ensuing total paper count, relevant paper count, and evidence count summation will crash with an IndexError:

  File "/path/to/.venv/lib/python3.12/site-packages/paperqa/agents/task.py", line 193, in compute_trajectory_metrics
    sum(int(sa[i]) for sa in split_answers) / len(split_answers)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/.venv/lib/python3.12/site-packages/paperqa/agents/task.py", line 193, in <genexpr>
    sum(int(sa[i]) for sa in split_answers) / len(split_answers)
            ~~^^^
IndexError: list index out of range

This PR fixes that IndexError

@jamesbraza jamesbraza added the bug Something isn't working label Sep 27, 2024
@jamesbraza jamesbraza self-assigned this Sep 27, 2024
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Sep 27, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 27, 2024
@jamesbraza jamesbraza merged commit 0d75e2c into main Sep 27, 2024
5 checks passed
@jamesbraza jamesbraza deleted the fixing-crash-metrics branch September 27, 2024 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants