IBM / clai

Command Line Artificial Intelligence or CLAI is an open-sourced project from IBM Research aimed to bring the power of AI to the command line interface.
https://clai-home.mybluemix.net/
MIT License
476 stars 73 forks source link

UnboundLocalError: local variable 'data' referenced before assignment in nlc2cmd/wa_skills/tarbot.py #13

Closed twinstar26 closed 4 years ago

twinstar26 commented 4 years ago

Describe the bug UnboundLocalError: local variable 'data' referenced before assignment in nlc2cmd/wa_skills/tarbot.py

To Reproduce Steps to reproduce the behavior:

  1. start clai
  2. intent should be related to compression or extraction

output # cat nohup.out Exception in thread Thread-8: Traceback (most recent call last): File "/usr/local/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/usr/local/lib/python3.6/threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "/opt/local/share/clai/bin/clai/server/plugins/nlc2cmd/service.py", line 24, in __compute result.append( eval('wa_skills.' + args[0])(args[1]) ) File "/opt/local/share/clai/bin/clai/server/plugins/nlc2cmd/wa_skills/tarbot.py", line 157, in wa_skill_processor_tarbot return data, confidence UnboundLocalError: local variable 'data' referenced before assignment

shell and OS (please complete the following information):

Additional context https://github.com/IBM/clai/blob/77612341d7c45d3a00afaca594f438ee7ec86b2c/clai/server/plugins/nlc2cmd/wa_skills/tarbot.py#L155

how to solve When this else statement is triggered, data is not defined before hitting this line and we are returning data in the next statement. So we need to define default value of data.

kpfadnis commented 4 years ago

@twinstar26 Tarbot skill is meant to provide user with command given its natural language usage. If there isn't any matching intent, I would recommend passing None as a data object similar to how confidence is set to 0.0 in the beginning.

https://github.com/IBM/clai/blob/a98701ce1a64b030c482ba4a0b6f352c9e5af1e5/clai/server/plugins/nlc2cmd/wa_skills/tarbot.py#L19

twinstar26 commented 4 years ago

Sorry! I misunderstood the flow. Thanks for pointing out!! I originally thought that after recognizing intent only then control flow would be passed to specific skill for further parameter recognition.
But the orchestration layer broadcasts response to every skill and collects confidence at the end. So yeah makes sense.