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

invalid escape sequences in h2o-py docstrings #16466

Closed
jmahlik opened this issue Dec 23, 2024 · 1 comment · Fixed by #16505
Closed

invalid escape sequences in h2o-py docstrings #16466

jmahlik opened this issue Dec 23, 2024 · 1 comment · Fixed by #16505
Assignees
Labels
Milestone

Comments

@jmahlik
Copy link
Contributor

jmahlik commented Dec 23, 2024

H2O version, Operating System and Environment
main branch, windows, python 3.12+

Actual behavior
There are some invalid escape sequences in the docstrings of h2o-py.

These will eventually raise errors when the package is imported. https://docs.python.org/3/whatsnew/3.12.html#other-language-changes. I ran in to this when generating documentation via sphinx when h2o is installed. It causes sphinx to crash since sphix is using the content of the docstrings.

python -Werror ./venv/Lib/site-packages/h2o/model/model_base.py
...\venv\Lib\site-packages\h2o\model\model_base.py:913: SyntaxWarning: invalid escape sequence '\s'
  """
python -Werror ./venv/Lib/site-packages/h2o/estimators/xgboost.py
...\venv\Lib\site-packages\h2o\estimators\xgboost.py", line 2559
    """
    ^^^
SyntaxError: invalid escape sequence '\*'

Expected behavior
Replace the invalid sequences with valid escapes or use raw strings

Steps to reproduce
Steps to reproduce the behavior (with working code on a sample dataset, if possible):
Just running the file is enough to trigger this i.e. python -Werror ./venv/Lib/site-packages/h2o/estimators/xgboost.py

Upload logs
If you can, please upload the H2O logs. More information on how to do that is available here, or you can use the h2o.downloadAllLogs() in R or the h2o.download_all_logs() function in Python.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@jmahlik jmahlik added the bug label Dec 23, 2024
@jmahlik
Copy link
Contributor Author

jmahlik commented Jan 20, 2025

Turns out these are actually a runtime problem. Importing h2o in a conftest.py under pytest and tox crashes with import errors.

This happens on python 3.11 - 3.13.

tox -e py311
.pkg: _optional_hooks> python C:\Users\\venv\Lib\site-packages\pyproject_api\_backend.py True setuptools.build_meta
.pkg: get_requires_for_build_wheel> python C:\Users\\venv\Lib\site-packages\pyproject_api\_backend.py True setuptools.build_meta
.pkg: build_wheel> python C:\Users\\venv\Lib\site-packages\pyproject_api\_backend.py True setuptools.build_meta
py311: install_package> venv\Scripts\uv.exe pip install --reinstall --no-deps <package-name>@C:\Users\\.tox\.tmp\package\69\<package-name>-1.6.0-py3-none-any.whl
py311: commands[0]> pytest --cov --junitxml=report.py311.xml --basetemp=C:\Users\\.tox\py311\tmp -vv
ImportError while loading conftest 'C:\Users\\tests\conftest.py'.
tests\conftest.py:12: in <module>
    import h2o
.tox\py311\Lib\site-packages\h2o\__init__.py:26: in <module>
    from h2o.h2o import (connect, init, api, connection, resume,
.tox\py311\Lib\site-packages\h2o\h2o.py:14: in <module>
    from .backend import H2OConnection
.tox\py311\Lib\site-packages\h2o\backend\__init__.py:44: in <module>
    from .connection import H2OConnection
.tox\py311\Lib\site-packages\h2o\backend\connection.py:34: in <module>
    from h2o.model.metrics import make_metrics
.tox\py311\Lib\site-packages\h2o\model\__init__.py:8: in <module>
    from .model_base import ModelBase
E     File "C:\Users\\.tox\py311\Lib\site-packages\h2o\model\model_base.py", line 913
E       """
E       ^^^
E   SyntaxError: invalid escape sequence '\s'
py311: exit 4 (2.14 seconds) C:\Users\> pytest --cov --junitxml=report.py311.xml --basetemp=C:\Users\\.tox\py311\tmp -vv pid=17720
  py311: FAIL code 4 (4.28=setup[2.14]+cmd[2.14] seconds)
  evaluation failed :( (4.64 seconds)

jmahlik added a commit to StateFarmIns/h2o-3 that referenced this issue Jan 21, 2025
Allow h2o to be imported without triggering syntax errors.

Closes h2oai#16466
valenad1 pushed a commit that referenced this issue Jan 28, 2025
Allow h2o to be imported without triggering syntax errors.

Closes #16466
valenad1 pushed a commit that referenced this issue Jan 28, 2025
Allow h2o to be imported without triggering syntax errors.

Closes #16466
@valenad1 valenad1 added this to the 3.46.0.7 milestone Jan 28, 2025
@valenad1 valenad1 linked a pull request Jan 28, 2025 that will close this issue
valenad1 added a commit that referenced this issue Jan 29, 2025
* GH-16466: Fixed invalid escape sequences in docstrings

Allow h2o to be imported without triggering syntax errors.

Closes #16466

* Adjust escape in the gen_xgboost.py

---------

Co-authored-by: Justin Mahlik <[email protected]>
@valenad1 valenad1 self-assigned this Jan 29, 2025
valenad1 added a commit that referenced this issue Feb 6, 2025
* GH-16466 escape sequences (#16505)

* GH-16466: Fixed invalid escape sequences in docstrings

Allow h2o to be imported without triggering syntax errors.

Closes #16466

* Adjust escape in the gen_xgboost.py

---------

Co-authored-by: Justin Mahlik <[email protected]>

* GH-16471 - replace hortonworks with private nexus repo (#16506)

---------

Co-authored-by: Justin Mahlik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants