Skip to content

Commit

Permalink
feat: upload setup.sh to the remote dev (#5016)
Browse files Browse the repository at this point in the history
* feat: upload setup.sh to the remote dev

Signed-off-by: Frost Ming <me@frostming.com>

* fix: upload setup sh anyway

Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming authored Oct 10, 2024
1 parent 949ff38 commit 24951d4
Showing 1 changed file with 15 additions and 1 deletion.
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

0 comments on commit 24951d4

Please sign in to comment.