Skip to content
This repository was archived by the owner on Sep 13, 2023. It is now read-only.
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

@aguschin

Description

@aguschin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfeedbackUser's feedbackrequirementsFinding requirements and dependencies needed to properly serialize objects

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions