Avaiga / taipy

Turns Data and AI algorithms into production-ready web applications in no time.
https://www.taipy.io
Apache License 2.0
10.94k stars 775 forks source link

BUG-Switching Taipy version triggers error on import #1180

Closed AlexandreSajus closed 4 months ago

AlexandreSajus commented 4 months ago

Description Installing taipy in a virtual environment and then installing taipy==3.0.0 will trigger this error on import:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\asaju\Desktop\test_version\venv\Lib\site-packages\taipy\__init__.py", line 16, in <module>
    from taipy.config._init import *  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\asaju\Desktop\test_version\venv\Lib\site-packages\taipy\config\__init__.py", line 31, in <module>
    __version__ = _get_version()
                  ^^^^^^^^^^^^^^
  File "C:\Users\asaju\Desktop\test_version\venv\Lib\site-packages\taipy\config\version.py", line 6, in _get_version
    with open(f"{os.path.dirname(os.path.abspath(__file__))}{os.sep}version.json") as version_file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\asaju\\Desktop\\test_version\\venv\\Lib\\site-packages\\taipy\\config\\version.json'

We found this error with Jean-Robin this morning, and a user contacted support about it this evening.

This is Critical as the error triggers on import, and the error message does not provide ways to fix this.

Workarounds

How to reproduce In a terminal:

Expected behavior Changing versions of Taipy should not trigger errors

Runtime environment

jrobinAV commented 4 months ago

If it is the same as the one I encountered, it seems related to pip, not the taipy package.

An easy workaround that worked for me was to just uninstall the first version of taipy and re-install the version I want.

florian-vuillemot commented 4 months ago

After testing, I agree with @jrobinAV . The version.json is deleted when switching to 3.0.0, even if it is present in version 3.0.0. Can you from 3.0.0 and 3.1.0?

joaoandre-avaiga commented 4 months ago

When we switched from a multi-repository package structure to a mono repository package structure for Taipy 3.1, there was a small issue that caused the sub-packages (taipy-config, taipy-core, etc.) not to be fully compatible between the two versions, which causes that when pip tries to use a previous installed sub packed that is already cached in the python environment ends up with missing non-python files(JSON, pyi, etc.) that are required for Taipy to work properly.

This issue can be solved by forcing pip to reinstall all dependencies with: pip install --no-cache-dir -I taipy==3.0.0. We are now adding an entry to the documentation and will not patch Taipy 3.0 to resolve this issue. Note that this only happens in this specific case of downgrading from 3.1 to 3.0 and older versions, and future versions of Taipy will have this side effect.