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

Added entrypoint to imagespec and default builder #2553

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Fixed falsey behavior of empty list, moved ENTRYPOINT directive into …
…optional str to avoid entrypoint reset behavior

Signed-off-by: pryce-turner <[email protected]>
pryce-turner committed Jul 3, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
juliusknorr Julius Knorr
commit bd1a2179b76c45c797b008b3c874d8e1fcdc8c4a
8 changes: 4 additions & 4 deletions flytekit/image_spec/default_builder.py
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@
ENV PATH="$$PATH:/usr/local/nvidia/bin:/usr/local/cuda/bin" \
LD_LIBRARY_PATH="/usr/local/nvidia/lib64:$$LD_LIBRARY_PATH"
ENTRYPOINT $ENTRYPOINT
$ENTRYPOINT
$COPY_COMMAND_RUNTIME
RUN $RUN_COMMANDS
@@ -194,10 +194,10 @@ def create_docker_context(image_spec: ImageSpec, tmp_dir: Path):
else:
python_version = f"{sys.version_info.major}.{sys.version_info.minor}"

if image_spec.entrypoint:
entrypoint = json.dumps(image_spec.entrypoint)
else:
if image_spec.entrypoint is None:
entrypoint = ""
else:
entrypoint = f"ENTRYPOINT {json.dumps(image_spec.entrypoint)}"

if image_spec.commands:
run_commands = " && ".join(image_spec.commands)
18 changes: 18 additions & 0 deletions tests/flytekit/unit/core/image_spec/test_default_builder.py
Original file line number Diff line number Diff line change
@@ -81,6 +81,24 @@ def test_create_docker_context_with_git_subfolder(tmp_path):
assert requirements_path.exists()


def test_create_docker_context_with_null_entrypoint(tmp_path):
docker_context_path = tmp_path / "builder_root"
docker_context_path.mkdir()

image_spec = ImageSpec(
name="FLYTEKIT",
python_version="3.12",
entrypoint=[],
)

create_docker_context(image_spec, docker_context_path)

dockerfile_path = docker_context_path / "Dockerfile"
assert dockerfile_path.exists()
dockerfile_content = dockerfile_path.read_text()
assert "ENTRYPOINT []" in dockerfile_content


def test_create_docker_context_cuda(tmp_path):
docker_context_path = tmp_path / "builder_root"
docker_context_path.mkdir()