calpoly-csai / api

Official API for the NIMBUS Voice Assistant accessible via HTTP REST protocol.
https://nimbus.api.calpolycsai.com/
GNU General Public License v3.0
9 stars 4 forks source link

Quick TypeError fix in NLP šŸ‘ #187

Closed ethanahlquist closed 4 years ago

ethanahlquist commented 4 years ago

What's New?

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

There was a bug in ./api/nimbus_npl/variable_extractor.py At line 80 a TypeError was raised:

Saving to database: ErrorLog(question=when are Nico office hours?, stacktrace=Traceback (most recent call last):
  File "/home/ethan/Documents/CSAI/new/api/flask_api.py", line 169, in handle_question
    response = {"answer": nimbus.answer_question(question)}
  File "/home/ethan/Documents/CSAI/new/api/nimbus.py", line 33, in answer_question
    ans_dict = self.predict_question(question)
  File "/home/ethan/Documents/CSAI/new/api/nimbus.py", line 65, in predict_question
    nlp_props = self.variable_extractor.extract_variables(question)
  File "/home/ethan/Documents/CSAI/new/api/nimbus_nlp/variable_extractor.py", line 80, in extract_variables
    if (request.payload != []):
TypeError: Can only compare repeated composite fields against other repeated composite fields.
, timestamp=2020-08-01 23:13:02.076835, id=None, is_view=None, metadata=None)...

Solution

Change:

  if (request.payload != []):

To:

  if request.payload:

Type of change (pick-one)

How Has This Been Tested?

The change allowed for correct responses from the server.

Checklist (check-all-before-merge)

formatting help: - [x] means "checked' and - [ ] means "unchecked"

sonarcloud[bot] commented 4 years ago

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication