Skip to content

Commit 502da71

Browse files
ykchong45junpuf
andauthored
DLC Buildx engine full migration (#5209)
* Remove legacy builder to use buildx * Build autogluon * Build pytorch * Build vllm * Build base * Recover toml --------- Co-authored-by: Junpu Fan <junpu@amazon.com>
1 parent 97be92c commit 502da71

File tree

1 file changed

+0
-112
lines changed

1 file changed

+0
-112
lines changed

src/image.py

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -201,45 +201,6 @@ def build(self):
201201
return self.build_status
202202

203203
def docker_build(self, context_path, custom_context=False):
204-
"""
205-
Uses Docker Buildx for vLLM images, falls back to legacy Docker API for others
206-
207-
:param context_path: str, Path to build context
208-
:param custom_context: bool, Whether to use custom context from stdin (default: False)
209-
:return: int, Build status
210-
"""
211-
if self._is_vllm_image() or self._is_pytorch_training_image():
212-
LOGGER.info(
213-
f"Using Buildx for vLLM and PyTorch Training image: {self.repository}:{self.tag}"
214-
)
215-
return self._buildx_build(context_path, custom_context)
216-
else:
217-
LOGGER.info(
218-
f"Using legacy Docker API for non-vLLM and non-PyTorch Training image: {self.repository}:{self.tag}"
219-
)
220-
return self._legacy_docker_build(context_path, custom_context)
221-
222-
def _is_vllm_image(self):
223-
"""
224-
Determine if current image is a vLLM image
225-
226-
:return: bool, True if this is a vLLM image
227-
"""
228-
return (
229-
self.info.get("framework") == "vllm"
230-
or "vllm" in self.repository.lower()
231-
or "vllm" in str(self.info.get("name", "")).lower()
232-
)
233-
234-
def _is_pytorch_training_image(self):
235-
"""
236-
Determine if current image is a PyTorch Training image
237-
238-
:return: bool, True if this is a PyTorch Training image
239-
"""
240-
return self.info.get("framework") == "pytorch" and self.info.get("image_type") == "training"
241-
242-
def _buildx_build(self, context_path, custom_context=False):
243204
"""
244205
Uses Docker Buildx CLI for building with real-time streaming and advanced caching.
245206
@@ -330,79 +291,6 @@ def _buildx_build(self, context_path, custom_context=False):
330291
self.log.append(response)
331292
return self.build_status
332293

333-
def _legacy_docker_build(self, context_path, custom_context=False):
334-
"""
335-
Uses legacy Docker API Client to build the image (for non-vLLM images).
336-
337-
:param context_path: str, Path to build context
338-
:param custom_context: bool, Whether to use custom context from stdin (default: False)
339-
:return: int, Build Status
340-
"""
341-
response = [f"Starting Legacy Docker Build Process for {self.repository}:{self.tag}"]
342-
LOGGER.info(f"Starting Legacy Docker Build Process for {self.repository}:{self.tag}")
343-
344-
# Open context tarball for legacy API
345-
fileobj = open(context_path, "rb") if custom_context else None
346-
347-
line_counter = 0
348-
line_interval = 50
349-
350-
try:
351-
for line in self.client.build(
352-
fileobj=fileobj,
353-
path=self.dockerfile if not custom_context else None,
354-
custom_context=custom_context,
355-
rm=True,
356-
decode=True,
357-
tag=self.ecr_url,
358-
buildargs=self.build_args,
359-
labels=self.labels,
360-
target=self.target,
361-
):
362-
# print the log line during build for every line_interval lines
363-
if line_counter % line_interval == 0:
364-
LOGGER.info(line)
365-
line_counter += 1
366-
367-
if line.get("error") is not None:
368-
response.append(line["error"])
369-
self.log.append(response)
370-
self.build_status = constants.FAIL
371-
self.summary["status"] = constants.STATUS_MESSAGE[self.build_status]
372-
self.summary["end_time"] = datetime.now()
373-
374-
LOGGER.info(f"Docker Build Logs: \n {self.get_tail_logs_in_pretty_format(100)}")
375-
LOGGER.error("ERROR during Docker BUILD")
376-
LOGGER.error(
377-
f"Error message received for {self.dockerfile} while docker build: {line}"
378-
)
379-
380-
return self.build_status
381-
382-
if line.get("stream") is not None:
383-
response.append(line["stream"])
384-
elif line.get("status") is not None:
385-
response.append(line["status"])
386-
else:
387-
response.append(str(line))
388-
389-
self.log.append(response)
390-
391-
LOGGER.info(f"DOCKER BUILD LOGS: \n{self.get_tail_logs_in_pretty_format()}")
392-
LOGGER.info(f"Completed Legacy Build for {self.repository}:{self.tag}")
393-
394-
self.build_status = constants.SUCCESS
395-
return self.build_status
396-
397-
except Exception as e:
398-
response.append(f"Legacy Docker build error: {str(e)}")
399-
self.build_status = constants.FAIL
400-
LOGGER.error(f"Legacy Docker build exception: {str(e)}")
401-
return self.build_status
402-
finally:
403-
if fileobj:
404-
fileobj.close()
405-
406294
def image_size_check(self):
407295
"""
408296
Checks if the size of the image is not greater than the baseline.

0 commit comments

Comments
 (0)