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

feat: upload setup.sh to the remote dev #5016

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/bentoml/_internal/cloud/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ def _init_deployment_files(
rel_path = os.path.relpath(full_path, bento_dir).replace(os.sep, "/")
if not bento_spec.includes(rel_path) and rel_path != "bentofile.yaml":
continue
if rel_path == REQUIREMENTS_TXT:
if rel_path in (REQUIREMENTS_TXT, "setup.sh"):
continue
file_content = open(full_path, "rb").read()
if (
Expand All @@ -769,6 +769,8 @@ def _init_deployment_files(
requirements_md5 = hashlib.md5(requirements_content).hexdigest()
if requirements_md5 != pod_files.get(REQUIREMENTS_TXT, ""):
upload_files.append((REQUIREMENTS_TXT, requirements_content))
setup_script = _build_setup_script(bento_dir, build_config)
upload_files.append(("setup.sh", setup_script))
self.upload_files(upload_files, console=console)
return requirements_md5

Expand Down Expand Up @@ -1395,3 +1397,15 @@ def _build_requirements_txt(bento_dir: str, config: BentoBuildConfig) -> bytes:
bentoml_requirement = f"-e ./{EDITABLE_BENTOML_DIR}"
content += f"{bentoml_requirement}\n".encode("utf8")
return content


def _build_setup_script(bento_dir: str, config: BentoBuildConfig) -> bytes:
content = b""
if config.docker.system_packages:
content += f'apt-get update && apt-get install -y {" ".join(config.docker.system_packages)} || exit 1\n'.encode()
if config.docker.setup_script and os.path.exists(
fullpath := os.path.join(bento_dir, config.docker.setup_script)
):
with open(fullpath, "rb") as f:
content += f.read()
return content