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

[Bug]: TypeError: 'NoneType' object is not subscriptable #157

Open
2 tasks done
fkurushin opened this issue Apr 16, 2024 · 3 comments
Open
2 tasks done

[Bug]: TypeError: 'NoneType' object is not subscriptable #157

fkurushin opened this issue Apr 16, 2024 · 3 comments
Assignees

Comments

@fkurushin
Copy link

fkurushin commented Apr 16, 2024

Debug Tips

  • I'm sure I've read this project's Issues of README.

What happened?

alibaba_valid_1000 = []
for zh in tqdm(valid['original'].tolist()):
    ru = ts.translate_text(
        zh, 
        from_language='zh', 
        to_language='ru', 
        translator='alibaba',
        timeout=30, 
        sleep_seconds=1, 
        update_session_after_freq=10)
    alibaba_valid_1000.append(ru)
  1%|          | 12/1002 [00:38<52:41,  3.19s/it] 
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[65], line 3
      1 alibaba_valid_1000 = []
      2 for zh in tqdm(valid['original'].tolist()):
----> 3     ru = ts.translate_text(
      4         zh, 
      5         from_language='zh', 
      6         to_language='ru', 
      7         translator='alibaba',
      8         timeout=30, 
      9         sleep_seconds=1, 
     10         update_session_after_freq=10)
     11     alibaba_valid_1000.append(ru)

File ~/Chinese-Russian-translator/.venv/lib/python3.11/site-packages/translators/server.py:5469, in TranslatorsServer.translate_text(self, query_text, translator, from_language, to_language, if_use_preacceleration, **kwargs)
   5466 if not self.pre_acceleration_label and if_use_preacceleration:
   5467     _ = self.preaccelerate()
-> 5469 return self.translators_dict[translator](query_text=query_text, from_language=from_language, to_language=to_language, **kwargs)

File ~/Chinese-Russian-translator/.venv/lib/python3.11/site-packages/translators/server.py:117, in Tse.time_stat.<locals>._wrapper(*args, **kwargs)
    115     sys.stderr.write(f'TimeSpent(function: {func.__name__[:-4]}): {cost_time}s\n')
    116     return result
--> 117 return func(*args, **kwargs)

File ~/Chinese-Russian-translator/.venv/lib/python3.11/site-packages/translators/server.py:288, in Tse.check_query.<locals>._wrapper(*args, **kwargs)
    286     new_args[1] = query_text
    287     return func(*tuple(new_args), **kwargs)
--> 288 return func(*args, **{**kwargs, **{'query_text': query_text}})

File ~/Chinese-Russian-translator/.venv/lib/python3.11/site-packages/translators/server.py:1659, in AlibabaV2.alibaba_api(self, query_text, from_language, to_language, **kwargs)
   1657 time.sleep(sleep_seconds)
   1658 self.query_count += 1
-> 1659 return data if is_detail_result else data['data']['translateText']

TypeError: 'NoneType' object is not subscriptable

APP Version

5.9.1

Python Version

3.11

Runtime Environment

Linux CentOS (Default)

Country/Region

Russia

Relevant log output

No response

Screenshots

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@UlionTse
Copy link
Owner

@fkurushin
Bro, you need to print out the text that needs to be translated, so that I can debug better. Alternatively, you can debug by setting the parameter is_detail_result=True to see what the server returns from the request.

@fkurushin
Copy link
Author

@UlionTse
Hi, thanks for the answering!

{'requestId': '000BA97B-6029-4904-A518-99616C92E01A',
  'success': False,
  'httpStatusCode': 500,
  'code': 'ExceededLimit',
  'message': 'Today text translate number exceeded limit',
  'data': None}

got this output with is_detail_result=True.

I will try again tomorrow to properly catch the amount of limit

@UlionTse
Copy link
Owner

Okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants