replicate / cog

Containers for machine learning
https://cog.run
Apache License 2.0
7.79k stars 546 forks source link

Support poetry-style Python requirements #1385

Open nirga opened 9 months ago

nirga commented 9 months ago

Right now, cog requires either specifying all dependencies in the cog.yaml file, or importing them from requirements.txt. Many Python apps manage their dependencies with Poetry (us included) and I think being able to specify dependencies directly in a pyproject.toml Poetry-style would be super useful.

Haven't looked into cog code yet, but I might be open to contributing that.

mattt commented 9 months ago

@nirga Thanks for checking out Cog! This is something I've also been thinking about.

https://github.com/replicate/cog/issues/1081 and https://github.com/replicate/cog/issues/1082 discuss what this might look like. These are framed by pip-compile & project.dependencies, but the same should apply for tool.poetry.dependencies.

One theory is that Cog should compose with tools like pip-compile / poetry somewhat agnostically:

  1. Take dependency constraints in cog.yaml or pyproject.toml
  2. Refine those constraints according to CUDA / PyTorch version resolution
  3. Hand off those refined constraints to another tool to do the full resolution from there.

Does that track? Or do you see a more direct way to integrate with Poetry and similar tools?

nirga commented 9 months ago

Yes exactly! @mattt Poetry is useful IMO in 2 places here:

  1. Resolving versions and dependencies (so I don't need to specify an exact version for torch but can rely on Poetry to find the right version w.r.t other pacakges.
  2. Run a model locally (i.e. outside of docker). Right now with cog I'm forced to build a docker image every time I want to test out my code.
bzikst commented 1 month ago

Hi! Just checking out is there any updates?