Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

No clear way to overwrite requirements inferred by MLEM #689

Open
aguschin opened this issue Jul 11, 2023 · 0 comments
Open

No clear way to overwrite requirements inferred by MLEM #689

aguschin opened this issue Jul 11, 2023 · 0 comments
Labels
enhancement New feature or request feedback User's feedback requirements Finding requirements and dependencies needed to properly serialize objects

Comments

@aguschin
Copy link
Contributor

I have a lockfile, and I use https://www.pantsbuild.org/ as a build system. So I can get the exact 3rd party dependencies. But I have not found a clean way to override the requirements inferred by MLEM:

  • Afaict, there is no planned way to override requirements in the Python API
  • Some objects (like MlemModel) have a requirements attributes that I can overwrite, but others (DockerModelDirectory, Server) have a get_requirements() method instead. So I’d have to replace a method which is dirtier.
  • But if I only replace the docker_model_directory requirements with those inferred by Pants, I am missing the serving requirements (fastapi, mlem, uvicorn,...).
  • If I replace the MlemModel requirements by the correct requirements,and let DockerModelDirectory aggregate the model requirements with the server requirements, I get a version mismatch because of errors in MLEM inference of the middleware requirements.
  • I had to create a script taking the requirements inferred by pants + the requirements MLEM inferred for the server, and correct the version of the server requirements with the version found in my lockfiles.
  • And to get this into the docker context, my solution was to create a DockerModelDirectory myself instead of using the higher level DockerImageBuilder. This allows me to first call docker_model_directory.write_distribution() and then docker_model_directory.write_requirements_file(correct_requirements) to overwrite the requirements.txt file.
  • All of this negates the advantages of automatic dependencies inference. I found it easier to create a small script creating a FastAPI app serving the model, and get pants to infer its dependencies (which, this time, include fastapi and uvicorn, because the script is using them to serve the model).

reported in Discord

@aguschin aguschin added enhancement New feature or request requirements Finding requirements and dependencies needed to properly serialize objects feedback User's feedback labels Jul 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request feedback User's feedback requirements Finding requirements and dependencies needed to properly serialize objects
Projects
None yet
Development

No branches or pull requests

1 participant