This repository was archived by the owner on Sep 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
This repository was archived by the owner on Sep 13, 2023. It is now read-only.
No clear way to overwrite requirements inferred by MLEM #689
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestfeedbackUser's feedbackUser's feedbackrequirementsFinding requirements and dependencies needed to properly serialize objectsFinding requirements and dependencies needed to properly serialize objects
Description
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
requirementsattributes that I can overwrite, but others (DockerModelDirectory, Server) have aget_requirements()method instead. So I’d have to replace a method which is dirtier. - But if I only replace the
docker_model_directoryrequirements with those inferred by Pants, I am missing the serving requirements (fastapi, mlem, uvicorn,...). - If I replace the
MlemModelrequirements by the correct requirements,and letDockerModelDirectoryaggregate 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
DockerModelDirectorymyself instead of using the higher levelDockerImageBuilder. This allows me to first calldocker_model_directory.write_distribution()and thendocker_model_directory.write_requirements_file(correct_requirements)to overwrite therequirements.txtfile. - 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
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestfeedbackUser's feedbackUser's feedbackrequirementsFinding requirements and dependencies needed to properly serialize objectsFinding requirements and dependencies needed to properly serialize objects