-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 for build variants/profiles #2613
Comments
Anything on this? I always have to create a separate script to install PyTorch because of this. |
I am not familiar with that topic, but if I understood right these discussions might be related:
[My impression is that it is not something that poetry can/should tackle on its own. I feel like there is some background work that should be done in the larger Python packaging community beforehand: standardizations, and so on.] |
A very trivial kind of "support" would be to (optionally?) not reinstall a package by
|
After spending a couple of hours on this issue, I found a "solution" by combining Poetry and pip just for PyTorch. You don't need to specify the wheel URLs directly and thus remain cross-platform. I'm using Poe The Poet, a nice task runner for Poetry that allows to run any arbitrary command.
You can run:
and then:
Hope it helps. |
Reminder that you should always call the executable modules |
@sinoroc I'm not sure it's really needed here as everything runs into Poetry virtual env but one can never be too careful! Thanks for sharing. I edited the comment. |
Absolutely, it should not be needed. But I find it is a good habit to take. Especially since in this case it is in a file, so you type the long form just once. The shorter script wrappers are good for interactive command line sessions (less characters to type). |
Relevant discussion on Python.org: |
At least within [[tool.poetry.dependencies.torch]]
python = "^3.8"
markers = "platform_system == 'Linux'"
url = "https://download.pytorch.org/whl/lts/1.8/cpu/torch-1.8.1%2Bcpu-cp38-cp38-linux_x86_64.whl" However, the version comes across as SolverProblemError
Because torchvision (0.9.1+cpu) depends on torch (1.8.1)
and librephotos depends on torch (1.8.1+cpu), torchvision is forbidden.
So, because librephotos depends on torchvision (0.9.1+cpu), version solving failed. Any concerns with Alternatively, dropping I'm happy to do the implementation if you don't have spare cycles to do it. |
Hello, any update on this issue? I am facing the same issue. According to PEP 440, poetry should be ignoring these local versions: https://www.python.org/dev/peps/pep-0440/#local-version-identifiers |
@kaustubhharapanahalli Support for neural net packages is one of many unresolved issues waiting in the ticket queue for poetry at the moment. If we want any of them to progress we might need to investigate volunteering as poetry maintainers. |
@danmackinlay I see, thanks for the update. |
@kaustubhharapanahalli regarding the pull-request backlog, see #4595 |
@danmackinlay looks like the resolving of this issue might take some time if my understanding is right 😅 Actually there is a fix that was developed and PR was raised (#4221). So not really sure how long it might take as well. But I do support the governance ticket :) |
NB the hack from March to use pip to install a desired package over the poetry version still works. It has various side effects that are undesirable (e.g. it must be run each time poetry "resolves" dependencies), so I find it easier to ditch poetry entirely in favor of a virtualenv in this case, but if there are some other features of poetry that you need this might be of interest. |
this used to work on preview release, but now it stopped working |
Why doesn't poetry support something akin to Right now, Poetry just defaults to installing the nvidia dependencies for PyTorch regardless if your hardware requires them. |
Feature Request
For some Python packages, there are different wheel variants with identical package names, which are distinguished only based on PEP-440 local version labels (the
label
in1.2.3+label
). E.g. for PyTorch or mxnet, this is used to deliver different variants that use CPU or one of several CUDA versions. This is independent of system or hardware platform and Python version - PyTorch have a wheel for almost every combination of these.For example, for PyTorch 1.5.1 with Python 3.8 on Linux there are versions
pytorch-1.5.1
(for CUDA 10.2),pytorch-1.5.1+cu101
(for CUDA 10.1),pytorch-1.5.1+cu92
(for CUDA 9.2) andpytorch-1.5.1+cpu
(for CPU).As far as I know, the only way Poetry supports for switching between these variants on a given platform is to modify the pyproject.toml file, which obviously is not so optimal. Markers are not a solution here because it is not possible switch between different variants on the same machine. Neither are optional dependencies and extras, because the package names are identical for the different variants.
In the Java world, Maven offers build profiles, which allow for specifying different sets of dependencies, build plugins etc.. Maven profiles can be activated and deactivated on a per-build basis (or using triggers similar to markers, but that is not interesting for this use case) and independently of each other.
Maven profiles are a bit complex, but I think picking and modifying some of its ideas for this specific use case could be useful for Poetry.
I'd suggest the following syntax in pyproject.toml:
There could be one lock file per profile/combination of profiles (which I think would be easier to understand and maintain, and probably also to implement) or one global lockfile which combines several profiles/profile combinations.
The profiles could be activated using a CLI switch --profile/-p for poetry update/lock/install/add/etc.;
E.g.
poetry lock -p cpu-backend
would only lock the versions for the CPU variant, andpoetry install -p cpu-backend
would install the global packages and those defined in thecpu-backend
lockfile.Another variant would be profile groups where one of several alternatives must be active, and one of them may be active by default:
For the profile group variant the syntax could be "-p backend=cpu" etc.
An alternative solutions might be allowing to specify constraints under extras, but I don't think that's the point of extras.
The text was updated successfully, but these errors were encountered: