Skip to content
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

fix resolve pack method #1533

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

GemmaTuron
Copy link
Member

@GemmaTuron GemmaTuron commented Feb 4, 2025

Thank you for taking your time to contribute to Ersilia, just a few checks before we proceed

  • Have you followed the guidelines in our Contribution Guide
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Description

The resolve pack method for Docker images was not working as the history had several versions some of which contained nginx, which is what was defined to decide between bentoml or fastapi

Changes to be made

I have added an if statement to check only in the latest version

Status

Completed. I have tried to use it with FastAPI packed models that were originally packed with BentoML (eos3b5e) and
models that have been packed with BentoML (eos9f6t) for example. Works in both situations.

To do

None

Is this pull request related to any open issue? If yes, replace issueID below with the issue ID

Related to #1509

@GemmaTuron GemmaTuron requested a review from Abellegese February 4, 2025 12:37
@GemmaTuron
Copy link
Member Author

GemmaTuron commented Feb 4, 2025

mmm maybe we need more thinking:

Model eos9f6t to my understanding is not packed with FastAPI (in principle?) but the current fix determines it is. Am I understanding that the "nginx" bit will appear in the history somewhere but not necessarily in the actual "CreatedBy" tagged as "latest"? How these histories are created is a bit confusing to me.

This is what I see tagged as latest for the following models:

  • eos3b5e:

{'Comment': 'buildkit.dockerfile.v0', 'Created': 1710253156, 'CreatedBy': 'ENTRYPOINT ["sh" "docker-entrypoint.sh"]', 'Id': 'sha256:b1f9672384fa3e2e5a2a75b8746ccdbdd03e368403380e6e4d74dcfa06de66cb', 'Size': 0, 'Tags': ['ersiliaos/eos3b5e:latest']}

  • eos9f6t
    {'Comment': 'buildkit.dockerfile.v0', 'Created': 1713876497, 'CreatedBy': 'RUN |1 MODEL=eos9f6t /bin/sh -c ersilia -v fetch $MODEL # buildkit', 'Id': 'sha256:98315e5dbcca94e6f01e490c2191f9493a7a93e5e34b864fe7af773d7ac93eff', 'Size': 6731738954, 'Tags': ['ersiliaos/eos9f6t:latest']}

  • eos2gw4:
    {'Comment': 'buildkit.dockerfile.v0', 'Created': 1712733635, 'CreatedBy': 'ENTRYPOINT ["sh" "docker-entrypoint.sh"]', 'Id': 'sha256:6c64f81fc6a4d37999e5e60104b059799c931680c657266a746e8c2319515df3', 'Size': 0, 'Tags': ['ersiliaos/eos2gw4:latest']}

  • eos9gg2:
    {'Comment': 'buildkit.dockerfile.v0', 'Created': 1731174690, 'CreatedBy': 'RUN |1 MODEL=eos9gg2 /bin/sh -c mkdir /root/bundles && ersilia_model_pack --repo_path $MODEL --bundles_repo_path /root/bundles && rm -rf /root/$MODEL && rm -rf /root/.cache && cp /root/bundles/$MODEL/*/information.json /root/information.json && cp /root/bundles/$MODEL/*/api_schema.json /root/api_schema.json && cp /root/bundles/$MODEL/*/status.json /root/status.json # buildkit', 'Id': 'sha256:6f844ab14f6ea2674dc3a865553a3687e3240a56940e8ed52e249610e2e02d37', 'Size': 829165978, 'Tags': ['ersiliaos/eos9gg2:latest']}

  • eos8a4x:
    {'Comment': 'buildkit.dockerfile.v0', 'Created': 1737037679, 'CreatedBy': 'RUN |1 MODEL=eos8a4x /bin/sh -c apt-get update && apt-get install -y git && mkdir /root/bundles && ersilia_model_pack --repo_path $MODEL --bundles_repo_path /root/bundles && apt-get remove --purge -y git && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* && rm -rf /root/$MODEL && rm -rf /root/.cache && cp /root/bundles/$MODEL/*/information.json /root/information.json && cp /root/bundles/$MODEL/*/api_schema.json /root/api_schema.json && cp /root/bundles/$MODEL/*/status.json /root/status.json && mkdir -p /root/model/framework/examples && cp /root/bundles/$MODEL/*/model/framework/examples/output.csv /root/model/framework/examples/output.csv && cp /root/bundles/$MODEL/*/model/framework/examples/input.csv /root/model/framework/examples/input.csv # buildkit', 'Id': 'sha256:8359783b0d801614eba6f9e24059dc3478c119277541a3e49d466e2f10ade9a6', 'Size': 201130569, 'Tags': ['ersiliaos/eos8a4x:latest']}

I do not see a consistency that allows us to determine the packaging manner from this. But I am sure the current "nginx" method is giving problems. Are we sure the eos3b5e is actually well packaged with FastAPI? For the type of information I am seeing it looks more like it is a bentoML model, but it fails. Moreover, this error should be reproducible for everyone but it does not seem the case?

I am maybe missing the point on how FastAPI packaged vs BentoML packaged models work. What is the difference on the CREATED BY: ENTRYPOINT and CREATED BY: RUN ?

@GemmaTuron
Copy link
Member Author

GemmaTuron commented Feb 4, 2025

Okay definitely looking into this history is no good way of picking the packaging method

I tried in another computer and I got an absolute different output for the history of eos3b5e, which does not contain the "nginx" string anywhere not even in the not "latest" images. I am guessing cache plays a role here.

This is the history of eos3b5e:

(ersilia) gturon@pujarnol:~$ docker history ersiliaos/eos3b5e
IMAGE          CREATED        CREATED BY                                      SIZE      COMMENT
4ebb984d4747   4 months ago   RUN |1 MODEL=eos3b5e /bin/sh -c mkdir /root/…   196MB     buildkit.dockerfile.v0
<missing>      4 months ago   COPY ./eos3b5e /root/eos3b5e # buildkit         144kB     buildkit.dockerfile.v0
<missing>      4 months ago   WORKDIR /root                                   0B        buildkit.dockerfile.v0
<missing>      4 months ago   ENV MODEL=eos3b5e                               0B        buildkit.dockerfile.v0
<missing>      4 months ago   ARG MODEL=eos3b5e                               0B        buildkit.dockerfile.v0
<missing>      4 months ago   ENTRYPOINT ["sh" "/root/docker-entrypoint.sh…   0B        buildkit.dockerfile.v0
<missing>      4 months ago   EXPOSE map[80/tcp:{}]                           0B        buildkit.dockerfile.v0
<missing>      4 months ago   RUN /bin/sh -c apt-get clean && apt-get auto…   49.7MB    buildkit.dockerfile.v0
<missing>      4 months ago   COPY . /ersilia-pack # buildkit                 48.4kB    buildkit.dockerfile.v0
<missing>      4 months ago   WORKDIR /root                                   0B        buildkit.dockerfile.v0
<missing>      4 months ago   CMD ["python3"]                                 0B        buildkit.dockerfile.v0
<missing>      4 months ago   RUN /bin/sh -c set -eux;  for src in idle3 p…   36B       buildkit.dockerfile.v0
<missing>      4 months ago   RUN /bin/sh -c set -eux;   savedAptMark="$(a…   40.6MB    buildkit.dockerfile.v0
<missing>      4 months ago   ENV PYTHON_VERSION=3.10.15                      0B        buildkit.dockerfile.v0
<missing>      4 months ago   ENV GPG_KEY=A035C8C19219BA821ECEA86B64E628F8…   0B        buildkit.dockerfile.v0
<missing>      4 months ago   RUN /bin/sh -c set -eux;  apt-get update;  a…   3.11MB    buildkit.dockerfile.v0
<missing>      4 months ago   ENV LANG=C.UTF-8                                0B        buildkit.dockerfile.v0
<missing>      4 months ago   ENV PATH=/usr/local/bin:/usr/local/sbin:/usr…   0B        buildkit.dockerfile.v0
<missing>      4 months ago   /bin/sh -c #(nop)  CMD ["bash"]                 0B        
<missing>      4 months ago   /bin/sh -c #(nop) ADD file:270cda9833ffe6dfb…   80.6MB 

So the history that appears when I print the hist in the function resolve_pack_method_docker is not the same, as elements like this one appear:

{'Comment': 'buildkit.dockerfile.v0', 'Created': 1710253156, 'CreatedBy': 'COPY /root/nginx.conf /etc/nginx/sites-available/default # buildkit', 'Id': '<missing>', 'Size': 245, 'Tags': None}

@GemmaTuron
Copy link
Member Author

GemmaTuron commented Feb 4, 2025

okay definitely according to GPT the history of an image might differ between the python API and the CLI. Why the behavior is different between computers is a mistery and probably is due to a cached file that does not get removed

@Abellegese don't merge the PR as this will not fix the issue system wide probably

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant