Skip to content

[Arch] Add runtime image build CI & clean up runtime build using jinja2 template#3055

Merged
xingyaoww merged 29 commits into
mainfrom
xw/runtime-build-jinja2
Jul 24, 2024
Merged

[Arch] Add runtime image build CI & clean up runtime build using jinja2 template#3055
xingyaoww merged 29 commits into
mainfrom
xw/runtime-build-jinja2

Conversation

@xingyaoww

@xingyaoww xingyaoww commented Jul 21, 2024

Copy link
Copy Markdown
Contributor

What is the problem that this fixes or functionality that this introduces? Does it fix any open issues?

Need to merge this first: #3051


Give a summary of what the PR does, explaining any non-trivial design decisions

  • Refactor the Python-based dockerfile writing into a Jinja2 template, hopefully making it more readable.
  • Add GHCR workflow for runtime images, named od_runtime:od_v{od_release_version}_image_{base_image_name}_tag_{base_image_tag}.
  • Move test_runtime.py into ghcr-runtime workflow, similar to existing ghcr workflow.

Other references

@xingyaoww
xingyaoww marked this pull request as ready for review July 21, 2024 18:35
@xingyaoww
xingyaoww marked this pull request as draft July 21, 2024 18:39
@xingyaoww xingyaoww changed the title [Arch] Clean up runtime build using jinja2 template [Arch] Add runtime image build CI & clean up runtime build using jinja2 template Jul 22, 2024
@xingyaoww
xingyaoww marked this pull request as ready for review July 22, 2024 19:00
@xingyaoww
xingyaoww requested review from li-boxuan and tobitege and removed request for tobitege July 22, 2024 19:00
# Print the full name of the image
echo "Loaded Docker image: $image_name"

SANDBOX_CONTAINER_IMAGE=$image_name TEST_IN_CI=true poetry run pytest --cov=agenthub --cov=opendevin --cov-report=xml -s ./tests/unit/test_runtime.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SANDBOX_CONTAINER_IMAGE=$image_name - this puzzles me. Is runtime image a special type of sandbox image? If so, why do we need a separate yaml file? Is it because the integration of runtime image hasn't finished yet?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YES. Runtime to some extend is a type of Sandbox (not the SSHBox type of Sandbox class, but conceptually sandbox). And i kinda hope to make the transition relatively smooth so we can re-use these configs without introducing new stuff.

The idea is once this has been extensively test to work, we simply remove all the old Sandbox classes, ServerRuntime, and test_sandbox.py so we ended up with only one workflow for build and test runtime.

@xingyaoww
xingyaoww requested a review from yufansong July 23, 2024 19:50

import docker
import toml
from jinja2 import Environment, FileSystemLoader

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any benifit that introduce jinja2?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it makes manipulating the Dockerfile a bit more straightforward, so this seems OK to me? Also, we already use jinja2 in OD, so it's not an extra dependency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep! that's exactly the motivation - basically get rid of our existing string concatenation that makes creating dockerfile too complex and hard to maintain.

@neubig neubig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! Just a few comments.


import docker
import toml
from jinja2 import Environment, FileSystemLoader

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it makes manipulating the Dockerfile a bit more straightforward, so this seems OK to me? Also, we already use jinja2 in OD, so it's not an extra dependency.

Comment on lines +194 to +199
if base_image == new_image_name:
logger.info(
f'Using existing od_runtime image [{base_image}]. Will NOT build a new image.'
)
else:
logger.info(f'New image name: {new_image_name}')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just confirming, will this cause any issues? For instance, is there a possibility that the OpenDevin code gets updated, but the image name stays the same so it doesn't build a new image?

@xingyaoww xingyaoww Jul 24, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - it might be for the developer. I haven't thought of a good way to do versioning easily for this (e.g., people could modify code on top of the same commit, so commit hash is not useful either). Currently when developing, we ask people to set their env var to force update the code.

https://github.com/OpenDevin/OpenDevin/blob/547c510848d0b4782ec2d023375469f734f64a6c/opendevin/runtime/client/client.py#L9

But it should not cause issues for user in production, bc the sandbox image is already pre-build and code is not changed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good enough solution for now, happy to merge.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

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.

5 participants