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

"pybabel extract" gives "NameError: name 'SQLLAB_TIMEOUT' is not defined" #16613

Closed
audour opened this issue Sep 7, 2021 · 3 comments · Fixed by #16629
Closed

"pybabel extract" gives "NameError: name 'SQLLAB_TIMEOUT' is not defined" #16613

audour opened this issue Sep 7, 2021 · 3 comments · Fixed by #16629
Labels
#bug Bug report

Comments

@audour
Copy link
Contributor

audour commented Sep 7, 2021

Running pybabel extract -F superset/translations/babel.cfg -o superset/translations/messages.pot -k _ -k __ -k t -k tn -k tct . as suggested within CONTRIBUTING.md#translating is not working for me.

Expected results

The template file superset/translations/messages.pot is updated with current application strings.

Actual results

  • I get an error NameError: name 'SQLLAB_TIMEOUT' is not defined.
  • messages.pot is emptied

How to reproduce the bug

Follow CONTRIBUTING.md#extracting-new-strings-for-translation

Environment

  • superset version: 1.3.0
  • python version: 3.8.10
  • pybabel version: 2.9.1

Checklist

  • [ x ] I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • [ x ] I have reproduced the issue with at least the latest released version of superset.
  • [ x ] I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

Full logs:

$ pybabel extract -F superset/translations/babel.cfg -o superset/translations/messages.pot -k _ -k __ -k t -k tn -k tct .
extracting messages from superset/__init__.py
extracting messages from superset/app.py
extracting messages from superset/cli.py
extracting messages from superset/config.py
extracting messages from superset/constants.py
extracting messages from superset/dataframe.py
extracting messages from superset/errors.py
extracting messages from superset/exceptions.py
extracting messages from superset/extensions.py
extracting messages from superset/forms.py
extracting messages from superset/jinja_context.py
extracting messages from superset/legacy.py
extracting messages from superset/result_set.py
extracting messages from superset/schemas.py
extracting messages from superset/sql_lab.py
Traceback (most recent call last):
  File "/home/admin/superset_translation/venv/bin/pybabel", line 8, in <module>
    sys.exit(main())
  File "/home/admin/superset_translation/venv/lib/python3.8/site-packages/babel/messages/frontend.py", line 929, in main
    return CommandLineInterface().run(sys.argv)
  File "/home/admin/superset_translation/venv/lib/python3.8/site-packages/babel/messages/frontend.py", line 853, in run
    return cmdinst.run()
  File "/home/admin/superset_translation/venv/lib/python3.8/site-packages/babel/messages/frontend.py", line 481, in run
    for filename, lineno, message, comments, context in extracted:
  File "/home/admin/superset_translation/venv/lib/python3.8/site-packages/babel/messages/extract.py", line 149, in extract_from_dir
    for message_tuple in check_and_call_extract_file(
  File "/home/admin/superset_translation/venv/lib/python3.8/site-packages/babel/messages/extract.py", line 207, in check_and_call_extract_file
    for message_tuple in extract_from_file(
  File "/home/admin/superset_translation/venv/lib/python3.8/site-packages/babel/messages/extract.py", line 243, in extract_from_file
    return list(extract(method, fileobj, keywords, comment_tags,
  File "/home/admin/superset_translation/venv/lib/python3.8/site-packages/babel/messages/extract.py", line 325, in extract
    for lineno, funcname, messages, comments in results:
  File "/home/admin/superset_translation/venv/lib/python3.8/site-packages/babel/messages/extract.py", line 487, in extract_python
    value = eval(code, {'__builtins__': {}}, {})
  File "<string>", line 2, in <module>
NameError: name 'SQLLAB_TIMEOUT' is not defined

Linked issue: #16550

@audour audour added the #bug Bug report label Sep 7, 2021
@audour
Copy link
Contributor Author

audour commented Sep 8, 2021

Thanks a lot @hushaoqing : I've applied locally your change (#16629) and it works!

Note:

  • I had a remaining issue because pybabel extract -F superset/translations/babel.cfg -o superset/translations/messages.pot -k _ -k __ -k t -k tn -k tct . crashed again logging ValueError: Unknown extraction method 'jinja2'. It turns out that running pip install jinja2 resolved the issue: maybe it should be documented at https://github.com/apache/superset/blob/master/CONTRIBUTING.md#translating
  • I can create a dedicated issue if it seems relevant to you

@hushaoqing
Copy link
Contributor

@audour
jinja2 has been included in the requirements.

jinja2==2.11.3

Have you tried to run pip install -r requirements/testing.txt?
(documented at https://github.com/apache/superset/blob/master/CONTRIBUTING.md#flask-server)

@audour
Copy link
Contributor Author

audour commented Sep 9, 2021

No, I haven't followed CONTRIBUTING.md#setup-local-environment-for-development because it seemed useless for me as I just wanted to improve French translation. But ok I understand that it was documented.

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

Successfully merging a pull request may close this issue.

2 participants