counterdata-network / story-processor

Story discovery engine for the Counterdata Network. Grabs relevant stories from various APIs, runs them against bespoke classifier models, post results to a central server.
Apache License 2.0
0 stars 2 forks source link

fix(sentry): Tackle Sentry bugs #70

Closed math4humanities closed 3 months ago

math4humanities commented 4 months ago

fix(classify): add a check for when stories is empty. In response to ValueError Found array with 0 sample(s) (shape=(0, 645)) while a minimum of 1 is required

math4humanities commented 4 months ago

From the comment on the method I'd expect this clause to return [None, None, []] (note the last item as an empty List). Am I right or does returning model_scores=None make more sense based on where it is called?

No, I think you're right, it doesn't make any more sense returning None. Following the classification task though, there might be a need to also add a check in _add_confidence_to_stories or maybe we can handle the no stories case directly in the classification task, classify_and_post_worker?

rahulbot commented 4 months ago

Adding in some defensive code to protect against empty story lists sounds smart. Perhaps add some checks in those places you mentioned for extra safety.