clarifai-python icon indicating copy to clipboard operation
clarifai-python copied to clipboard

Fix empty model type parser

Open Kylmakalle opened this issue 3 years ago • 1 comments

I've encountered an error while using the lib last time with both python 3.7 & 3.9

Traceback (most recent call last):
   app = ClarifaiApp(api_key=clarifai_token)
  File "python3.7/site-packages/clarifai/rest/client.py", line 124, in __init__
    self.models = Models(self.api, self.solutions)  # type: Models
  File "python3.7/site-packages/clarifai/rest/client.py", line 1068, in __init__
    self.model_id_cache = self.init_model_cache()
  File "python3.7/site-packages/clarifai/rest/client.py", line 1090, in init_model_cache
    model_type = m.output_info['type']
KeyError: 'type'

Dived deeper and found that some model does not return a type

  • Good model
{'message': 'Show output_info with: GET /models/{model_id}/output_info',
 'output_config': {'closed_environment': False,
                   'concepts_mutually_exclusive': False,
                   'max_concepts': 0,
                   'min_value': 0.0},
 **'type': 'detect-concept',**
 'type_ext': 'detect-concept'}
  • Bad model (ner_english id: 3a4dd3157b18d37f3402cdaca8091ddd)
{'message': 'Show output_info with: GET /models/{model_id}/output_info',
 'output_config': {'closed_environment': False,
                   'concepts_mutually_exclusive': False,
                   'max_concepts': 0,
                   'min_value': 0.0}}

P.S: I know this lib is not maintained already, but it would be nice to share a bug & fix with community 😄

Kylmakalle avatar Jun 12 '21 16:06 Kylmakalle

Travis failed due to missing env CLARIFAI_USER_EMAIL 🤷

Kylmakalle avatar Jun 13 '21 08:06 Kylmakalle

Closing this as it's an old PR with no activity for over a year.

stmugisha avatar Aug 17 '23 16:08 stmugisha

Hi @stmugisha, what activity do you expect here?

Kylmakalle avatar Aug 17 '23 16:08 Kylmakalle