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
Show file tree
Hide file tree
Changes from 2 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
9 changes: 9 additions & 0 deletions flytekit/image_spec/default_builder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os
import shutil
import subprocess
Expand Down Expand Up @@ -73,6 +74,8 @@
ENV PATH="$$PATH:/usr/local/nvidia/bin:/usr/local/cuda/bin" \
LD_LIBRARY_PATH="/usr/local/nvidia/lib64:$$LD_LIBRARY_PATH"

ENTRYPOINT $ENTRYPOINT

$COPY_COMMAND_RUNTIME
RUN $RUN_COMMANDS

Expand Down Expand Up @@ -191,6 +194,11 @@ 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:
entrypoint = ""

if image_spec.commands:
run_commands = " && ".join(image_spec.commands)
else:
Expand All @@ -206,6 +214,7 @@ def create_docker_context(image_spec: ImageSpec, tmp_dir: Path):
BASE_IMAGE=base_image,
ENV=env,
COPY_COMMAND_RUNTIME=copy_command_runtime,
ENTRYPOINT=entrypoint,
RUN_COMMANDS=run_commands,
)

Expand Down
2 changes: 2 additions & 0 deletions flytekit/image_spec/image_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ImageSpec:
pip_index: Specify the custom pip index url
pip_extra_index_url: Specify one or more pip index urls as a list
registry_config: Specify the path to a JSON registry config file
entrypoint: List of strings to overwrite the entrypoint of the base image with, set to [] to remove the entrypoint.
commands: Command to run during the building process
tag_format: Custom string format for image tag. The ImageSpec hash passed in as `spec_hash`. For example,
to add a "dev" suffix to the image tag, set `tag_format="{spec_hash}-dev"`
Expand All @@ -68,6 +69,7 @@ class ImageSpec:
pip_index: Optional[str] = None
pip_extra_index_url: Optional[List[str]] = None
registry_config: Optional[str] = None
entrypoint: Optional[List[str]] = None
commands: Optional[List[str]] = None
tag_format: Optional[str] = None

Expand Down
325 changes: 325 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
#
# This file is autogenerated by pip-compile with Python 3.10
pryce-turner marked this conversation as resolved.
Show resolved Hide resolved
# by the following command:
#
# pip-compile requirements.in
#
-e file:.#egg=flytekit
# via -r requirements.in
adlfs==2023.9.0
# via flytekit
aiobotocore==2.5.4
# via s3fs
aiohttp==3.9.1
# via
# adlfs
# aiobotocore
# gcsfs
# s3fs
aioitertools==0.11.0
# via aiobotocore
aiosignal==1.3.1
# via aiohttp
anyio==4.2.0
# via azure-core
arrow==1.3.0
# via cookiecutter
async-timeout==4.0.3
# via aiohttp
attrs==20.3.0
# via
# -r requirements.in
# aiohttp
azure-core==1.29.6
# via
# adlfs
# azure-identity
# azure-storage-blob
azure-datalake-store==0.0.53
# via adlfs
azure-identity==1.15.0
# via adlfs
azure-storage-blob==12.19.0
# via adlfs
binaryornot==0.4.4
# via cookiecutter
botocore==1.31.17
# via aiobotocore
cachetools==5.3.2
# via google-auth
certifi==2023.11.17
# via
# kubernetes
# requests
cffi==1.16.0
# via
# azure-datalake-store
# cryptography
chardet==5.2.0
# via binaryornot
charset-normalizer==3.3.2
# via requests
click==8.1.7
# via
# cookiecutter
# flytekit
# rich-click
cloudpickle==3.0.0
# via flytekit
cookiecutter==2.5.0
# via flytekit
croniter==2.0.1
# via flytekit
cryptography==41.0.7
# via
# azure-identity
# azure-storage-blob
# msal
# pyjwt
dataclasses-json==0.5.9
# via flytekit
decorator==5.1.1
# via gcsfs
diskcache==5.6.3
# via flytekit
docker==6.1.3
# via flytekit
docstring-parser==0.15
# via flytekit
exceptiongroup==1.2.0
# via anyio
flyteidl==1.10.6
# via flytekit
frozenlist==1.4.1
# via
# aiohttp
# aiosignal
fsspec==2023.9.2
# via
# adlfs
# flytekit
# gcsfs
# s3fs
gcsfs==2023.9.2
# via flytekit
google-api-core==2.15.0
# via
# google-cloud-core
# google-cloud-storage
google-auth==2.26.2
# via
# gcsfs
# google-api-core
# google-auth-oauthlib
# google-cloud-core
# google-cloud-storage
# kubernetes
google-auth-oauthlib==1.2.0
# via gcsfs
google-cloud-core==2.4.1
# via google-cloud-storage
google-cloud-storage==2.14.0
# via gcsfs
google-crc32c==1.5.0
# via
# google-cloud-storage
# google-resumable-media
google-resumable-media==2.7.0
# via google-cloud-storage
googleapis-common-protos==1.62.0
# via
# flyteidl
# flytekit
# google-api-core
# grpcio-status
grpcio==1.60.0
# via
# flytekit
# grpcio-status
grpcio-status==1.60.0
# via flytekit
idna==3.6
# via
# anyio
# requests
# yarl
importlib-metadata==7.0.1
# via
# flytekit
# keyring
isodate==0.6.1
# via azure-storage-blob
jaraco-classes==3.3.0
# via keyring
jinja2==3.1.3
# via cookiecutter
jmespath==1.0.1
# via botocore
joblib==1.3.2
# via flytekit
jsonpickle==3.0.2
# via flytekit
keyring==24.3.0
# via flytekit
kubernetes==29.0.0
# via flytekit
markdown-it-py==3.0.0
# via rich
markupsafe==2.1.3
# via jinja2
marshmallow==3.20.2
# via
# dataclasses-json
# marshmallow-enum
# marshmallow-jsonschema
marshmallow-enum==1.5.1
# via
# dataclasses-json
# flytekit
marshmallow-jsonschema==0.13.0
# via flytekit
mashumaro==3.11
# via flytekit
mdurl==0.1.2
# via markdown-it-py
more-itertools==10.2.0
# via jaraco-classes
msal==1.26.0
# via
# azure-datalake-store
# azure-identity
# msal-extensions
msal-extensions==1.1.0
# via azure-identity
multidict==6.0.4
# via
# aiohttp
# yarl
mypy-extensions==1.0.0
# via typing-inspect
numpy==1.26.3
# via pyarrow
oauthlib==3.2.2
# via
# kubernetes
# requests-oauthlib
packaging==23.2
# via
# docker
# marshmallow
# msal-extensions
portalocker==2.8.2
# via msal-extensions
protobuf==4.24.4
# via
# flyteidl
# flytekit
# google-api-core
# googleapis-common-protos
# grpcio-status
# protoc-gen-swagger
protoc-gen-swagger==0.1.0
# via flyteidl
pyarrow==14.0.2
# via flytekit
pyasn1==0.5.1
# via
# pyasn1-modules
# rsa
pyasn1-modules==0.3.0
# via google-auth
pycparser==2.21
# via cffi
pygments==2.17.2
# via rich
pyjwt[crypto]==2.8.0
# via msal
python-dateutil==2.8.2
# via
# arrow
# botocore
# croniter
# kubernetes
python-json-logger==2.0.7
# via flytekit
python-slugify==8.0.1
# via cookiecutter
pytimeparse==1.1.8
# via flytekit
pytz==2023.3.post1
# via croniter
pyyaml==6.0.1
# via
# cookiecutter
# flytekit
# kubernetes
requests==2.31.0
# via
# azure-core
# azure-datalake-store
# cookiecutter
# docker
# flytekit
# gcsfs
# google-api-core
# google-cloud-storage
# kubernetes
# msal
# requests-oauthlib
requests-oauthlib==1.3.1
# via
# google-auth-oauthlib
# kubernetes
rich==13.7.0
# via
# cookiecutter
# flytekit
# rich-click
rich-click==1.7.3
# via flytekit
rsa==4.9
# via google-auth
s3fs==2023.9.2
# via flytekit
six==1.16.0
# via
# azure-core
# isodate
# kubernetes
# python-dateutil
sniffio==1.3.0
# via anyio
statsd==3.3.0
# via flytekit
text-unidecode==1.3
# via python-slugify
types-python-dateutil==2.8.19.20240106
# via arrow
typing-extensions==4.9.0
# via
# anyio
# azure-core
# azure-storage-blob
# flytekit
# mashumaro
# rich-click
# typing-inspect
typing-inspect==0.9.0
# via dataclasses-json
urllib3==1.26.18
# via
# botocore
# docker
# flytekit
# kubernetes
# requests
websocket-client==1.7.0
# via
# docker
# kubernetes
wrapt==1.16.0
# via aiobotocore
yarl==1.9.4
# via aiohttp
zipp==3.17.0
# via importlib-metadata
2 changes: 2 additions & 0 deletions tests/flytekit/unit/core/image_spec/test_default_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_create_docker_context(tmp_path):
requirements=os.fspath(other_requirements_path),
source_root=os.fspath(source_root),
commands=["mkdir my_dir"],
entrypoint=["/bin/bash"],
pingsutw marked this conversation as resolved.
Show resolved Hide resolved
)

create_docker_context(image_spec, docker_context_path)
Expand All @@ -42,6 +43,7 @@ def test_create_docker_context(tmp_path):
assert "--requirement requirements_uv.txt" in dockerfile_content
assert "COPY --chown=flytekit ./src /root" in dockerfile_content
assert "RUN mkdir my_dir" in dockerfile_content
assert "ENTRYPOINT [\"/bin/bash\"]" in dockerfile_content

requirements_path = docker_context_path / "requirements_uv.txt"
assert requirements_path.exists()
Expand Down
Loading
Loading