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

Support of Python 3.12 #2098

Open
wants to merge 33 commits into
base: staging
Choose a base branch
from
Open

Support of Python 3.12 #2098

wants to merge 33 commits into from

Conversation

miguelgfierro
Copy link
Collaborator

@miguelgfierro miguelgfierro commented May 15, 2024

Description

Related Issues

#2097

References

Checklist:

  • I have followed the contribution guidelines and code style for this project.
  • I have added tests covering my contributions.
  • I have updated the documentation accordingly.
  • I have signed the commits, e.g. git commit -s -m "your commit message".
  • This PR is being made to staging branch AND NOT TO main branch.

Signed-off-by: miguelgfierro <miguelgfierro@users.noreply.github.com>
Signed-off-by: miguelgfierro <miguelgfierro@users.noreply.github.com>
Signed-off-by: miguelgfierro <miguelgfierro@users.noreply.github.com>
@miguelgfierro
Copy link
Collaborator Author

let's try, this can be as simple as changing a few lines of code, or we might need to fix many dependencies.

Error in Cornac dependency:

2024-05-15T05:14:26: Collecting cornac<2,>=1.15.2 (from recommenders[dev,gpu]@ git+https://github.com/recommenders-team/recommenders.git@809a1d39c3e4bdab72aa56ee80d9eb79413ac29d->-r /azureml-environment-setup/condaenv.8fr4a5nk.requirements.txt (line 3))
2024-05-15T05:14:26:   Downloading cornac-1.18.0.tar.gz (5.8 MB)
2024-05-15T05:14:26:      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.8/5.8 MB 76.2 MB/s eta 0:00:00
2024-05-15T05:14:26:   Preparing metadata (setup.py): started
2024-05-15T05:14:26:   Preparing metadata (setup.py): finished with status 'error'

2024-05-15T05:14:26: failed
2024-05-15T05:14:26: Pip subprocess error:
2024-05-15T05:14:26:   Running command git clone --filter=blob:none --quiet https://github.com/recommenders-team/recommenders.git /tmp/pip-install-va67dnkb/recommenders_830bb823f0204ab9ae042e7d5057b430
2024-05-15T05:14:26:   Running command git rev-parse -q --verify 'sha^809a1d39c3e4bdab72aa56ee80d9eb79413ac29d'
2024-05-15T05:14:26:   Running command git fetch -q https://github.com/recommenders-team/recommenders.git 809a1d39c3e4bdab72aa56ee80d9eb79413ac29d
2024-05-15T05:14:26:   Running command git checkout -q 809a1d39c3e4bdab72aa56ee80d9eb79413ac29d
2024-05-15T05:14:26:   error: subprocess-exited-with-error
2024-05-15T05:14:26:   
2024-05-15T05:14:26:   √ó python setup.py egg_info did not run successfully.
2024-05-15T05:14:26:   │ exit code: 1
2024-05-15T05:14:26:   ╰─> [2 lines of output]
2024-05-15T05:14:26:       We need some dependencies to build Cornac.
2024-05-15T05:14:26:       Run: pip3 install Cython numpy scipy
2024-05-15T05:14:26:       [end of output]
2024-05-15T05:14:26:   
2024-05-15T05:14:26:   note: This error originates from a subprocess, and is likely not a problem with pip.
2024-05-15T05:14:26: error: metadata-generation-failed

2024-05-15T05:14:26: √ó Encountered error while generating package metadata.
2024-05-15T05:14:26: ╰─> See above for output.

2024-05-15T05:14:26: note: This is an issue with the package mentioned above, not pip.
2024-05-15T05:14:26: hint: See above for details.
2024-05-15T05:14:26: CondaEnvException: Pip failed

@miguelgfierro
Copy link
Collaborator Author

Other error, it seems it's coming from dependencies:

"error": ***
        "message": "Activity Failed:\n***\n    \"error\": ***\n        \"code\": \"UserError\",\n        \"message\": \"Image build failed. For more details, check log file azureml-logs/20_image_build_log.txt.\",\n        \"messageFormat\": \"Image build failed. For more details, check log file ***ArtifactPath***.\",\n        \"messageParameters\": ***\n            \"ArtifactPath\": \"azureml-logs/20_image_build_log.txt\"\n        ***,\n        \"details\": [],\n        \"innerError\": ***\n            \"code\": \"BadArgument\",\n            \"innerError\": ***\n                \"code\": \"ImageBuildFailure\"\n            ***\n        ***\n    ***,\n    \"correlation\": ***\n        \"operation\": \"5f6a3d4a1da7af81649b6ef9e4ebee05\",\n        \"request\": \"b3c45b90ff1ad97d\"\n    ***,\n    \"environment\": \"eastus\",\n    \"location\": \"eastus\",\n    \"time\": \"2024-05-15T06:37:34.302265Z\",\n    \"componentName\": \"RunHistory\"\n***"
    ***
***
2024-05-15T06:37:11:   Running command git fetch -q https://github.com/recommenders-team/recommenders.git 496b22fca0faf861ff98739c8deec46b031e8d44
2024-05-15T06:37:11:   Running command git checkout -q 496b22fca0faf861ff98739c8deec46b031e8d44
2024-05-15T06:37:11:   error: subprocess-exited-with-error
2024-05-15T06:37:11:   
2024-05-15T06:37:11:   × Getting requirements to build wheel did not run successfully.
2024-05-15T06:37:11:   │ exit code: 1
2024-05-15T06:37:11:   ╰─> [33 lines of output]
2024-05-15T06:37:11:       Traceback (most recent call last):
2024-05-15T06:37:11:         File "/azureml-envs/azureml_06f0f6a5b197cd9c88[281](https://github.com/recommenders-team/recommenders/actions/runs/9090676506/job/24984293755#step:3:288)4406eaed054/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
2024-05-15T06:37:11:           main()
2024-05-15T06:37:11:         File "/azureml-envs/azureml_06f0f6a5b197cd9c882814406eaed054/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
2024-05-15T06:37:11:           json_out['return_val'] = hook(**hook_input['kwargs'])
2024-05-15T06:37:11:                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-15T06:37:11:         File "/azureml-envs/azureml_06f0f6a5b197cd9c882814406eaed054/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 112, in get_requires_for_build_wheel
2024-05-15T06:37:11:           backend = _build_backend()
2024-05-15T06:37:11:                     ^^^^^^^^^^^^^^^^
2024-05-15T06:37:11:         File "/azureml-envs/azureml_06f0f6a5b197cd9c882814406eaed054/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 77, in _build_backend
2024-05-15T06:37:11:           obj = import_module(mod_path)
2024-05-15T06:37:11:                 ^^^^^^^^^^^^^^^^^^^^^^^
2024-05-15T06:37:11:         File "/azureml-envs/azureml_06f0f6a5b197cd9c882814406eaed054/lib/python3.12/importlib/__init__.py", line 90, in import_module
2024-05-15T06:37:11:           return _bootstrap._gcd_import(name[level:], package, level)
2024-05-15T06:37:11:                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-15T06:37:11:         File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
2024-05-15T06:37:11:         File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
2024-05-15T06:37:11:         File "<frozen importlib._bootstrap>", line 1304, in _find_and_load_unlocked
2024-05-15T06:37:11:         File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
2024-05-15T06:37:11:         File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
2024-05-15T06:37:11:         File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
2024-05-15T06:37:11:         File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
2024-05-15T06:37:11:         File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
2024-05-15T06:37:11:         File "<frozen importlib._bootstrap_external>", line 994, in exec_module
2024-05-15T06:37:11:         File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
2024-05-15T06:37:11:         File "/tmp/pip-build-env-boxwps2r/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 16, in <module>
2024-05-15T06:37:11:           import setuptools.version
2024-05-15T06:37:11:         File "/tmp/pip-build-env-boxwps2r/overlay/lib/python3.12/site-packages/setuptools/version.py", line 1, in <module>
2024-05-15T06:37:11:           import pkg_resources
2024-05-15T06:37:11:         File "/tmp/pip-build-env-boxwps2r/overlay/lib/python3.12/site-packages/pkg_resources/__init__.py", line 2172, in <module>
2024-05-15T06:37:11:           register_finder(pkgutil.ImpImporter, find_on_path)
2024-05-15T06:37:11:                           ^^^^^^^^^^^^^^^^^^^
2024-05-15T06:37:11:       AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
2024-05-15T06:37:11:       [end of output]
2024-05-15T06:37:11:   
2024-05-15T06:37:11:   note: This error originates from a subprocess, and is likely not a problem with pip.
2024-05-15T06:37:11: error: subprocess-exited-with-error

2024-05-15T06:37:11: × Getting requirements to build wheel did not run successfully.
2024-05-15T06:37:11: │ exit code: 1
2024-05-15T06:37:11: ╰─> See above for output.

source: https://github.com/recommenders-team/recommenders/actions/runs/9090676506/job/24984293755

@daviddavo
Copy link
Collaborator

pkgutil.ImpImporter and ImpLoader have been deprecated since python 3.3, and they removed it in 3.12

As the problem is with setuptools, perhaps upgrading it or forcing a more recent version should suffice. I think cornac fails just because it is the first thing to be installed with that method.

According to that issue, changing the dependency to setuptools>=67 should work, but this might create a cascade of having to upgrade numpy, among other things.

Note: the distutils package was removed, but now is provided by setuptools. setuptools is no longer automatically installed by venv, but that's no problem because it's already specified in the pyproject

@daviddavo
Copy link
Collaborator

Now the requirements are fine, but it errors after installing build dependencies and I can't see why

2024-05-15T06:37:11:   Installing build dependencies: started
2024-05-15T06:37:11:   Installing build dependencies: finished with status 'done'
2024-05-15T06:37:11:   Getting requirements to build wheel: started
2024-05-15T06:37:11:   Getting requirements to build wheel: finished with status 'error'

2024-05-15T06:37:11: failed
2024-05-15T06:37:11: 
2024-05-15T06:37:11: CondaEnvException: Pip failed

Source: https://github.com/recommenders-team/recommenders/actions/runs/9090676506/job/24984293755

@miguelgfierro
Copy link
Collaborator Author

It seems the error is the same:

ErrorResponse 
***
    "error": ***
        "message": "Activity Failed:\n***\n    \"error\": ***\n        \"code\": \"UserError\",\n        \"message\": \"Image build failed. For more details, check log file azureml-logs/20_image_build_log.txt.\",\n        \"messageFormat\": \"Image build failed. For more details, check log file ***ArtifactPath***.\",\n        \"messageParameters\": ***\n            \"ArtifactPath\": \"azureml-logs/20_image_build_log.txt\"\n        ***,\n        \"details\": [],\n        \"innerError\": ***\n            \"code\": \"BadArgument\",\n            \"innerError\": ***\n                \"code\": \"ImageBuildFailure\"\n            ***\n        ***\n    ***,\n    \"correlation\": ***\n        \"operation\": \"0eb40f8a3a5a1b8bdc7eeb65cbe1a34b\",\n        \"request\": \"c0470de765320b12\"\n    ***,\n    \"environment\": \"eastus\",\n    \"location\": \"eastus\",\n    \"time\": \"2024-05-15T08:53:48.984678Z\",\n    \"componentName\": \"RunHistory\"\n***"
    ***
***
2024-05-15T08:53:17:   error: subprocess-exited-with-error
2024-05-15T08:53:17:   
2024-05-15T08:53:17:   × Getting requirements to build wheel did not run successfully.
2024-05-15T08:53:17:   │ exit code: 1
2024-05-15T08:53:17:   ╰─> [33 lines of output]
2024-05-15T08:53:17:       Traceback (most recent call last):
2024-05-15T08:53:17:         File "/azureml-envs/azureml_5e1c99080a501af5b78a0863f3002a98/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
2024-05-15T08:53:17:           main()
2024-05-15T08:53:17:         File "/azureml-envs/azureml_5e1c99080a501af5b78a0863f3002a98/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
2024-05-15T08:53:17:           json_out['return_val'] = hook(**hook_input['kwargs'])
2024-05-15T08:53:17:                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-15T08:53:17:         File "/azureml-envs/azureml_5e1c99080a501af5b78a0863f3002a98/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 112, in get_requires_for_build_wheel
2024-05-15T08:53:17:           backend = _build_backend()
2024-05-15T08:53:17:                     ^^^^^^^^^^^^^^^^
2024-05-15T08:53:17:         File "/azureml-envs/azureml_5e1c99080a501af5b78a0863f3002a98/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 77, in _build_backend
2024-05-15T08:53:17:           obj = import_module(mod_path)
2024-05-15T08:53:17:                 ^^^^^^^^^^^^^^^^^^^^^^^
2024-05-15T08:53:17:         File "/azureml-envs/azureml_5e1c99080a501af5b78a0863f[300](https://github.com/recommenders-team/recommenders/actions/runs/9092635078/job/24989789632#step:3:307)2a98/lib/python3.12/importlib/__init__.py", line 90, in import_module
2024-05-15T08:53:17:           return _bootstrap._gcd_import(name[level:], package, level)
2024-05-15T08:53:17:                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-15T08:53:17:         File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
2024-05-15T08:53:17:         File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
2024-05-15T08:53:17:         File "<frozen importlib._bootstrap>", line 1[304](https://github.com/recommenders-team/recommenders/actions/runs/9092635078/job/24989789632#step:3:311), in _find_and_load_unlocked
2024-05-15T08:53:17:         File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
2024-05-15T08:53:17:         File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
2024-05-15T08:53:17:         File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
2024-05-15T08:53:17:         File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
2024-05-15T08:53:17:         File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
2024-05-15T08:53:17:         File "<frozen importlib._bootstrap_external>", line 994, in exec_module
2024-05-15T08:53:17:         File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
2024-05-15T08:53:17:         File "/tmp/pip-build-env-yq5nkn2j/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 16, in <module>
2024-05-15T08:53:17:           import setuptools.version
2024-05-15T08:53:17:         File "/tmp/pip-build-env-yq5nkn2j/overlay/lib/python3.12/site-packages/setuptools/version.py", line 1, in <module>
2024-05-15T08:53:17:           import pkg_resources
2024-05-15T08:53:17:         File "/tmp/pip-build-env-yq5nkn2j/overlay/lib/python3.12/site-packages/pkg_resources/__init__.py", line 2172, in <module>
2024-05-15T08:53:17:           register_finder(pkgutil.ImpImporter, find_on_path)
2024-05-15T08:53:17:                           ^^^^^^^^^^^^^^^^^^^
2024-05-15T08:53:17:       AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
2024-05-15T08:53:17:       [end of output]
2024-05-15T08:53:17:   
2024-05-15T08:53:17:   note: This error originates from a subprocess, and is likely not a problem with pip.
2024-05-15T08:53:17: error: subprocess-exited-with-error

This seems like a long problem to debug. In my experience, it is better to debug it first in local. @daviddavo would you have time to take a look?

@daviddavo
Copy link
Collaborator

Yeah, I can try and give it some time next week

@daviddavo
Copy link
Collaborator

I can't install lightfm on Python 3.12, this affects recommenders too

@daviddavo
Copy link
Collaborator

Forked the repository and made a PR

The package can be installed from my repository:

pip install git+https://github.com/daviddavo/lightfm

If the pull requests wasn't approved, I can transfer ownership of this repository to recommenders-team, and then that github repository could be used in the requirements.

Signed-off-by: David Davó <david@ddavo.me>
@daviddavo
Copy link
Collaborator

By changing temporarily changing the requirements, it works on my machine. Let's see if it works on the test groups

@daviddavo
Copy link
Collaborator

daviddavo commented May 21, 2024

The following command works on my machine:

python -m venv venv
source venv/bin/activate
pip install git+https://github.com/recommenders-team/recommenders@python312

But perhaps my system comes with some build dependencies that are not installed in the test groups...

Tomorrow I'll try and use conda to install the package on my machine and see how it goes

@miguelgfierro
Copy link
Collaborator Author

miguelgfierro commented Jun 3, 2024

hey @daviddavo we were talking today in the weekly meeting about this issue. Do you have any news?

FYI @SimonYansenZhao @anargyri

Signed-off-by: David Davó <david@ddavo.me>
@daviddavo
Copy link
Collaborator

Ready for review just to run tests

@daviddavo daviddavo marked this pull request as ready for review July 1, 2024 16:12
@miguelgfierro
Copy link
Collaborator Author

@@ -67,7 +67,7 @@ jobs:
strategy:
max-parallel: 50 # Usage limits: https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration
matrix:
python-version: ['"python=3.8"', '"python=3.9"', '"python=3.10"', '"python=3.11"']
python-version: ['"python=3.8"', '"python=3.9"', '"python=3.10"', '"python=3.11"', '"python=3.12"']
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I run the pr gate 3 times, and I got the same error with building the docker image:

    "error": ***
        "message": "Activity Failed:\n***\n    \"error\": ***\n        \"code\": \"UserError\",\n        \"message\": \"Image build failed. For more details, check log file azureml-logs/20_image_build_log.txt.\",\n        \"messageFormat\": \"Image build failed. For more details, check log file ***ArtifactPath***.\",\n        \"messageParameters\": ***\n            \"ArtifactPath\": \"azureml-logs/20_image_build_log.txt\"\n        ***,\n        \"details\": [],\n        \"innerError\": ***\n            \"code\": \"BadArgument\",\n            \"innerError\": ***\n                \"code\": \"ImageBuildFailure\"\n            ***\n        ***\n    ***,\n    \"correlation\": ***\n        \"operation\": \"e4090e90a11694fd527583a50e6946eb\",\n        \"request\": \"ce7a3c21a63c7552\"\n    ***,\n    \"environment\": \"eastus\",\n    \"location\": \"eastus\",\n    \"time\": \"2024-07-02T05:04:39.716946Z\",\n    \"componentName\": \"RunHistory\"\n***"

Could the problem be related to #2066 @SimonYansenZhao?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we access azureml-logs/20_image_build_log.txt? There are multiple reasons the BadArgument error might be raised.

Activity Failed:
***
    "error": ***
        "code": "UserError",
        "message": "Image build failed. For more details, check log file azureml-logs/20_image_build_log.txt.",
        "messageFormat": "Image build failed. For more details, check log file ***ArtifactPath***.",
        "messageParameters": ***
            "ArtifactPath": "azureml-logs/20_image_build_log.txt"
        ***,
        "details": [],
        "innerError": ***
            "code": "BadArgument",
            "innerError": ***
                "code": "ImageBuildFailure"
            ***
        ***
    ***,
    "correlation": ***
        "operation": "e4090e90a11694fd527583a50e6946eb",
        "request": "ce7a3c21a63c7552"
    ***,
    "environment": "eastus",
    "location": "eastus",
    "time": "2024-07-02T05:04:39.716946Z",
    "componentName": "RunHistory"
***

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miguelgfierro yeah, maybe.

@daviddavo
Copy link
Collaborator

daviddavo commented Jul 3, 2024

Trying again on my system it seems that the problem is related to tensorflow

Tensorflow added support for 3.12 exactly in release 2.16...

On of the breaking changes is the removal of tf.estimator, which is used in tf_utils.py and wide_deep_utils.py

I will follow this guide:

Signed-off-by: David Davó <david@ddavo.me>
Signed-off-by: David Davó <david@ddavo.me>
Signed-off-by: David Davó <david@ddavo.me>
@daviddavo
Copy link
Collaborator

The build on Python 3.8 fails due to conflicting dependencies

SciPy 1.13 does not support Python 3.8, but pymanopt needs Scipy 1.13 or less than 1.10, while recommenders needs 1.10 or higher.

2024-07-31T11:18:58.6764741Z 2024-07-31T11:18:42:   Installing build dependencies: started
2024-07-31T11:18:58.6766083Z 2024-07-31T11:18:42:   Installing build dependencies: finished with status 'done'
2024-07-31T11:18:58.6767205Z 2024-07-31T11:18:42:   Getting requirements to build wheel: started
2024-07-31T11:18:58.6768445Z 2024-07-31T11:18:42:   Getting requirements to build wheel: finished with status 'done'
2024-07-31T11:18:58.6769648Z 2024-07-31T11:18:42:   Preparing metadata (pyproject.toml): started
2024-07-31T11:18:58.6770741Z 2024-07-31T11:18:42:   Preparing metadata (pyproject.toml): finished with status 'done'
2024-07-31T11:18:58.6772436Z 2024-07-31T11:18:42: INFO: pip is looking at multiple versions of recommenders to determine which version is compatible with other requirements. This could take a while.
2024-07-31T11:18:58.6773563Z 
2024-07-31T11:18:58.6773888Z 2024-07-31T11:18:42: The conflict is caused by:
2024-07-31T11:18:58.6775051Z 2024-07-31T11:18:42:     pymanopt 2.2.1.dev14+g1de3b6f depends on scipy!=1.10.*, !=1.11.*, !=1.12.* and >=1.0
2024-07-31T11:18:58.6776248Z 2024-07-31T11:18:42:     recommenders 1.2.0 depends on scipy<=1.13.1 and >=1.10.1

In this branch I updated pymanopt to use python 3.12, which moved some modules around, so it is not possible to use different pymanopt versions depending on the python version without convoluting the code too much.

Python 3.8 security support ends on October, in 3 months. ¿Should we just remove python 3.8 testing and support? Or should we search for a set of constraints so it can be installed on python 3.8 (using scipy 1.9)? What do you think @miguelgfierro

Related issues:

@SimonYansenZhao
Copy link
Collaborator

I prefer to remove Python 3.8

Signed-off-by: David Davó <david@ddavo.me>
Signed-off-by: David Davó <david@ddavo.me>
Signed-off-by: David Davó <david@ddavo.me>
Copy link
Collaborator

@loomlike loomlike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Please check my minor comments (mostly about docstring and a clarification).

@@ -39,7 +39,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not 3.12 here?

@@ -68,23 +69,19 @@ def _computeLoss_csrmatrix(a, b, cd, indices, indptr, residual_global):
residual_global[j] = num - cd[j]
return residual_global

def _cost(self, params, residual_global):
def _cost(self, U, S, VT, residual_global):
"""Compute the cost of GeoIMC optimization problem

Args:
params (Iterator): An iterator containing the manifold point at which
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update the docstring too

@@ -94,37 +91,33 @@ def _cost(self, params, residual_global):

return cost

def _egrad(self, params, residual_global):
def _egrad(self, U, S, VT, residual_global):
"""Computes the euclidean gradient

Args:
params (Iterator): An iterator containing the manifold point at which
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update docstring

@@ -67,7 +67,7 @@ jobs:
strategy:
max-parallel: 50 # Usage limits: https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daviddavo @SimonYansenZhao

A good way to decide whether or not to drop 3.8 is to look at the percentage of people using it. We can take a percentage and say for example, if only 5% of people use 3.8 then we drop it, otherwise, we support it. Do you know where we can find that percentage?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I got from Gemini 😃
Screenshot 2024-08-01 at 13 57 10

The usage statistics of Python for websites can be found at https://w3techs.com/technologies/history_details/pl-python/3

Screenshot 2024-08-01 at 14 03 15

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets also consideer stats for this package:

According to pypistats, its about 10% and more used than 3.11... But every day more and more deps are dropping it. You can always use an old version of this package.

image

Nevertheless, I can try and relax the version of numpy and see if the tests pass.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just found it. This is from PyPI's download statistics.
Screenshot 2024-08-01 at 14 49 27

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A narrower date range gives mostly the same results.

image

What is certainly clear, is that there is way more people using python3.8 than python 3.12

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill solve the breaking changes in tensorflow and then revert the "removing 3.8" commit

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems now it's the second most used python. I think we should support it for now.
One way is to install some dependencies for more than 3.8 and another for less than 3.8. Like pandera here:

"pandera[strategies]>=0.6.5,<0.18;python_version<='3.8'", # For generating fake datasets

Signed-off-by: David Davó <david@ddavo.me>
@daviddavo
Copy link
Collaborator

daviddavo commented Aug 1, 2024

Will fail because on tensorflow 2.16:

tf.estimator API is removed. If you need to use the estimator API, you need to use TF 2.15 or an earlier version.
-- What's new in TensorFlow 2.16

Guides:

This reverts commit 913abde.

Signed-off-by: David Davó <david@ddavo.me>
@daviddavo
Copy link
Collaborator

Btw, do you have any method on running the tests on multiple versions on local? On the past I used tox

It creates an environment for each python version you specify and installs your package there, so it also tests whether the setup.py includes everything.

My current setup is having multiple environments in venv based on each python version I want to test (I just test with 3.8 and 3.12 tbh), but is prone to errors because is not automated.

I don't mind adding tox: creating another branch, adding tox config there (and docu) and then merge it into this one. Some people also use tox on CI, but I think it is not necessary in this case as the flow is already established, it would be just a dev thing.

This reverts commit 3b0d1a1.

Signed-off-by: David Davó <david@ddavo.me>
- Had to do it for python 3.12 and 3.8 compat

Signed-off-by: David Davó <david@ddavo.me>
@miguelgfierro
Copy link
Collaborator Author

@daviddavo my setup is also to have multiple environments. The only way to do it locally is to create a similar workflow as the Azure ml and replace the compute target with a local computer.

@daviddavo
Copy link
Collaborator

I ended up using tox:

tox.ini

requires =
  tox>=4
env_list = py{38,39,310,311,312}

[testenv]
description = run unit tests
extras = dev,gpu,spark
deps =
    -r requirements-external.txt
commands =
    python -c 'import pymanopt; print(pymanopt.__version__)'
    pytest {posargs:tests/unit/recommenders}

Signed-off-by: David Davó <david@ddavo.me>
Signed-off-by: David Davó <david@ddavo.me>
Signed-off-by: David Davó <david@ddavo.me>
Signed-off-by: David Davó <david@ddavo.me>
@daviddavo
Copy link
Collaborator

daviddavo commented Aug 3, 2024

It seems that tests are running again.

Let's go back to the tensorflow problem (#2072):

Trying again on my system it seems that the problem is related to tensorflow

Tensorflow added support for 3.12 exactly in release 2.16...

One of the breaking changes is the removal of tf.estimator, which is used in tf_utils.py and wide_deep_utils.py

I will follow this guide:

I tried following the guides, but I have never used Tensorflow before, so I am having difficulties understanding what's going on, what something is supposed to do, or the convoluted structure of the project. There are lots of things in the docs that I can't find in my installed version and vice-versa.

If there's someone who knows tensorflow and wants to help, I'll do a mini-guide:

  • No need to run all tests, just run tests/unit/recommenders/utils/test_tf_utils.py and test_wide_deep_utils.py
  • To make it easier to debug, in the beginning of the file, temporarily replace the pass with raise

except ImportError:
pass # skip this import if we are in cpu environment

  • Now, instead of a NameError, you will get an error when importing tf.Estimator related things.
  • The objective is to replace those functions with equivalents from keras, using the guides provided above
  • Btw, the last version to support Python 3.8 is tensorflow 2.13. When using something, check that it was already available then.

Signed-off-by: David Davó <david@ddavo.me>
@miguelgfierro
Copy link
Collaborator Author

@daviddavo about this issue. If the problem is only with wide and deep. What do you think of commenting the tests and try 3.12 with the rest of the code?
FYI @anargyri @SimonYansenZhao for feedback

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

Successfully merging this pull request may close these issues.

4 participants