Skip to content

Commit f0c421e

Browse files
author
Varun Shenoy
authoredAug 28, 2023
only copy data if it exists (#622)
1 parent 29c82ee commit f0c421e

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed
 

‎truss/contexts/image_builder/serving_image_builder.py

+5
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,13 @@ def create_tgi_build_dir(config: TrussConfig, build_dir: Path, truss_dir: Path):
206206
dockerfile_template = read_template_from_fs(
207207
TEMPLATES_DIR, "tgi/tgi.Dockerfile.jinja"
208208
)
209+
210+
data_dir = build_dir / "data"
209211
dockerfile_content = dockerfile_template.render(
210212
hf_access_token=hf_access_token,
211213
models=model_files,
212214
hf_cache=config.hf_cache,
215+
data_dir_exists=Path(data_dir).exists(),
213216
)
214217
dockerfile_filepath = build_dir / "Dockerfile"
215218
dockerfile_filepath.write_text(dockerfile_content)
@@ -252,11 +255,13 @@ def create_vllm_build_dir(config: TrussConfig, build_dir: Path, truss_dir: Path)
252255
)
253256
nginx_template = read_template_from_fs(TEMPLATES_DIR, "vllm/proxy.conf.jinja")
254257

258+
data_dir = build_dir / "data"
255259
dockerfile_content = dockerfile_template.render(
256260
hf_access_token=hf_access_token,
257261
models=model_files,
258262
should_install_server_requirements=True,
259263
hf_cache=config.hf_cache,
264+
data_dir_exists=data_dir.exists(),
260265
)
261266
dockerfile_filepath = build_dir / "Dockerfile"
262267
dockerfile_filepath.write_text(dockerfile_content)

‎truss/templates/server.Dockerfile.jinja

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ COPY ./{{config.data_dir}} /app/data
5353
{%- endif %}
5454

5555
{%- if config.hf_cache != None %}
56+
RUN mkdir /app
5657
RUN curl -s https://baseten-public.s3.us-west-2.amazonaws.com/bin/b10cp-5fe8dc7da-linux-amd64 -o /app/b10cp; chmod +x /app/b10cp
5758
ENV B10CP_PATH_TRUSS /app/b10cp
5859
COPY ./cache_requirements.txt /app/cache_requirements.txt

‎truss/templates/tgi/tgi.Dockerfile.jinja

+3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ ENV HUGGING_FACE_HUB_TOKEN {{hf_access_token}}
1212

1313

1414
{%- if hf_cache %}
15+
RUN mkdir /app
16+
{%- if data_dir_exists %}
1517
COPY ./data /app/data
18+
{%- endif %}
1619
RUN curl -s https://baseten-public.s3.us-west-2.amazonaws.com/bin/b10cp-5fe8dc7da-linux-amd64 -o /app/b10cp; chmod +x /app/b10cp
1720
ENV B10CP_PATH_TRUSS /app/b10cp
1821
COPY ./cache_requirements.txt /app/cache_requirements.txt

‎truss/templates/vllm/vllm.Dockerfile.jinja

+3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ ENV HUGGING_FACE_HUB_TOKEN {{hf_access_token}}
1313

1414

1515
{%- if hf_cache %}
16+
RUN mkdir /app
17+
{%- if data_dir_exists %}
1618
COPY ./data /app/data
19+
{%- endif %}
1720
RUN curl -s https://baseten-public.s3.us-west-2.amazonaws.com/bin/b10cp-5fe8dc7da-linux-amd64 -o /app/b10cp; chmod +x /app/b10cp
1821
ENV B10CP_PATH_TRUSS /app/b10cp
1922
COPY ./cache_requirements.txt /app/cache_requirements.txt

0 commit comments

Comments
 (0)
Please sign in to comment.