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

SyntaxError on poe test when using streamlit #234

Closed
vanolucas opened this issue Apr 22, 2024 · 2 comments
Closed

SyntaxError on poe test when using streamlit #234

vanolucas opened this issue Apr 22, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@vanolucas
Copy link

vanolucas commented Apr 22, 2024

Error

The error occurs when running poe test on a Python 3.12 project that imports streamlit.

⬢ [Docker] ❯ poe test
Poe => coverage run
=========================================================================================================================================================================== test session starts ============================================================================================================================================================================
platform linux -- Python 3.12.3, pytest-8.1.1, pluggy-1.5.0 -- /opt/my-package-env/bin/python
cachedir: .pytest_cache
rootdir: /workspaces/my-package
configfile: pyproject.toml
testpaths: src, tests
plugins: typeguard-4.2.1, mock-3.14.0, xdist-3.5.0
collected 0 items / 1 error                                                                                                                                                                                                                                                                                                                                                
run-last-failure: None

================================================================================================================================================================================== ERRORS ==================================================================================================================================================================================
__________________________________________________________________________________________________________________________________________________________________ ERROR collecting src/my_package/app.py __________________________________________________________________________________________________________________________________________________________________
/opt/my-package-env/lib/python3.12/site-packages/_pytest/python.py:520: in importtestmodule
    mod = import_path(
/opt/my-package-env/lib/python3.12/site-packages/_pytest/pathlib.py:584: in import_path
    importlib.import_module(module_name)
/usr/local/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1387: in _gcd_import
    ???
<frozen importlib._bootstrap>:1360: in _find_and_load
    ???
<frozen importlib._bootstrap>:1331: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:935: in _load_unlocked
    ???
/opt/my-package-env/lib/python3.12/site-packages/typeguard/_importhook.py:98: in exec_module
    super().exec_module(module)
<frozen importlib._bootstrap_external>:995: in exec_module
    ???
<frozen importlib._bootstrap>:488: in _call_with_frames_removed
    ???
src/my_package/app.py:3: in <module>
    import streamlit as st
/opt/my-package-env/lib/python3.12/site-packages/streamlit/__init__.py:69: in <module>
    from streamlit.delta_generator import (
/opt/my-package-env/lib/python3.12/site-packages/streamlit/delta_generator.py:49: in <module>
    from streamlit.elements.arrow import ArrowMixin
/opt/my-package-env/lib/python3.12/site-packages/streamlit/elements/arrow.py:22: in <module>
    from streamlit.elements.lib.column_config_utils import (
/opt/my-package-env/lib/python3.12/site-packages/streamlit/elements/lib/column_config_utils.py:23: in <module>
    from streamlit.elements.lib.column_types import ColumnConfig, ColumnType
E     File "/opt/my-package-env/lib/python3.12/site-packages/streamlit/elements/lib/column_types.py", line 488
E       """Configure a link column in ``st.dataframe`` or ``st.data_editor``.
E       ^^^
E   SyntaxError: invalid escape sequence '\.'
------------------------------------------------------------------------------------------------------------------------------------------------------ generated xml file: /workspaces/my-package/reports/pytest.xml -------------------------------------------------------------------------------------------------------------------------------------------------------
========================================================================================================================================================================= short test summary info ==========================================================================================================================================================================
ERROR src/my_package/app.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================================================================================================================= 1 error in 0.83s =============================================================================================================================================================================
Error: Sequence aborted after failed subtask 'test[0]'

Steps to reproduce

Tested inside WSL2 on Windows 11 version 23H2.

Delete all existing poetry-cookicutter Docker containers and images.

Clone the repo to a local folder:

git clone git@github.com:radix-ai/poetry-cookiecutter.git

Open it with VSCode:

code .

Run VSCode command: Dev Containers: Rebuild Without Cache and Reopen in Container.

The poetry-cookiecutter dev container builds and opens.

Once completely initialized, open VSCode's bash terminal: Terminal: Create New Terminal.

Scaffold a new Python 3.12 package project using cruft:

cruft create -f https://github.com/radix-ai/poetry-cookiecutter

Choose the following cookiecutter values. Here reported in the generated .cruft.json:

{
  "template": "https://github.com/radix-ai/poetry-cookiecutter",
  "commit": "8ab7ee0accff3b9cb0e470bfc925858fc04d1e97",
  "checkout": null,
  "context": {
    "cookiecutter": {
      "project_type": "package",
      "project_name": "My Package",
      "project_description": "A Python package that reticulates splines.",
      "project_url": "https://github.com/user/my-package",
      "author_name": "John Smith",
      "author_email": "john@example.com",
      "python_version": "3.12",
      "development_environment": "strict",
      "with_conventional_commits": "1",
      "with_fastapi_api": "0",
      "with_typer_cli": "0",
      "continuous_integration": "GitHub",
      "private_package_repository_name": "",
      "private_package_repository_url": "",
      "__docker_image": "python:$PYTHON_VERSION-slim",
      "__docstring_style": "NumPy",
      "__project_name_kebab_case": "my-package",
      "__project_name_snake_case": "my_package",
      "_template": "https://github.com/radix-ai/poetry-cookiecutter"
    }
  },
  "directory": null
}

Exit the dev container and close VSCode.

Copy the scaffolded project to another local folder:

cd ..
cp -r poetry-cookiecutter/my-package ./

Navigate to the scaffolded project folder and open it with VSCode:

cd my-package/
code .

Build the project's dev container: run VSCode command: Dev Containers: Rebuild Without Cache and Reopen in Container.

Once completely initialized, open VSCode's bash terminal: Terminal: Create New Terminal.

Add Streamlit as a dependency:

poetry add streamlit

Create a Python file that imports streamlit:
In src/my_package/app.py:

"""A Streamlit app."""

import streamlit as st

Init a git repo:

git init

Run code linting:

poe lint

Run tests:

poe test
@spalster
Copy link

Hi, @vanolucas, thanks for submitting this issue! It looks like it's a known issue on Streamlit side in combination with the strict configuration of pytest which is enabled with development_environment=strict.
I see that there's a fix merged already so I expect it to no longer be an issue in the next streamlit release. As a temporary workaround, I'd recommend switching to the simple development environment or remove the line filterwarnings = ["error", "ignore::DeprecationWarning"] in the pyproject.toml which causes pytest to fail on warnings.

@lsorber lsorber added the bug Something isn't working label Apr 23, 2024
@lsorber
Copy link
Member

lsorber commented Apr 24, 2024

Closed by #237.

@lsorber lsorber closed this as completed Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants