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

Upgrade package versioning to use Poetry #1681

Closed
wants to merge 21 commits into from
Closed

Upgrade package versioning to use Poetry #1681

wants to merge 21 commits into from

Conversation

HadiSDev
Copy link

@HadiSDev HadiSDev commented Sep 16, 2023

Upgraded to use poetry

Description

  • Dockerfiles uses poetry
  • pyproject.toml changes to included relevant poetry settings
  • removed old setup files
  • Scripts updates

Motivation and Context

  • I have raised an issue to propose this change (required for new features and bug fixes)

it is an old issue, but I put the effort to make it work anyway: #545

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)

Checklist

  • I've read the CONTRIBUTION guide (required)
  • I have updated the changelog accordingly (required).
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.
  • I have opened an associated PR on the SB3-Contrib repository (if necessary)
  • I have opened an associated PR on the RL-Zoo3 repository (if necessary)
  • I have reformatted the code using make format (required)
  • I have checked the codestyle using make check-codestyle and make lint (required)
  • I have ensured make pytest and make type both pass. (required)
  • I have checked that the documentation builds using make doc (required)

Note: You can run most of the checks using make commit-checks.

Note: we are using a maximum length of 127 characters per line

@HadiSDev
Copy link
Author

Only thing missing is to add the credentials to poetry for publishing the package:
https://python-poetry.org/docs/repositories/#publishable-repositories

@HadiSDev HadiSDev closed this Sep 17, 2023
@HadiSDev HadiSDev reopened this Sep 18, 2023
@rhaps0dy
Copy link
Contributor

Working with CUDA Pytorch using Poetry is quite hard in my experience. Poetry insists on reinstalling it to the CPU version.

I also think you're not supposed to commit the poetry.lock for libraries.

Nowadays pip also lets you specify dependencies directly in pyproject.toml. Take a look at the tuned-lens pyproject.toml for example.

@HadiSDev
Copy link
Author

HadiSDev commented Sep 19, 2023

@rhaps0dy Thanks for taking a look at my PR <3 So just to respond to the points you made:

  • It is part of the poetry convention to push the lock file to the repo as it is much faster to install the packages with that and it secures the versions platform independent. See SO forum

  • The pytorch CUDA issue is more or less fixed. Poetry will install the CUDA version by default unless you are on a macos system.

  • If a user wants to use another torch version like 2.0 or only cpu version, then can specify that in their own project lock or requirement file with no issues. I can share some examples later after work hours

EDIT:
I just noticed that you posted a link to the poetry website docs. It seems from what I can read that there are pros and cons with both solutions so I will investigate this further to see what makes most sense. Will share later

@HadiSDev
Copy link
Author

Okay I think it is better to actually remove the .lock file. Will make it easier for developers as we all have different machines. As for specifying the torch version, say for example I wanted to use torch 2.0.0 and I want to use the cuda 11.8 version. Then I would add the following to the pyproject file:

[[tool.poetry.source]]
name = "torch-gpu"
url = "https://download.pytorch.org/whl/cu118"
priority = "explicit"

[tool.poetry.dependencies]
python = ">=3.10,<3.12"
torch = {version = "2.0.1+cu118", source = "torch-gpu"}

If the user wants to use pip package manager in his project he can also just manually install torch:
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

@araffin
Copy link
Member

araffin commented Sep 19, 2023

Just to make sure we're on the same page, the result of the discussion in #545 still stands, in the sense that poetry does not seem to be necessary for SB3, although nothing prevents you from setting it up yourself (as you do in this PR).

@HadiSDev
Copy link
Author

@araffin okay :( Poetry did help finding some version mismatch between the packages, so I think it is useful but this is not my repo so I respect your decision. I will keep my code saved in case you change your mind so we don't have to redo it, just in case :)

@HadiSDev HadiSDev closed this Sep 20, 2023
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.

3 participants