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

Add pip_extra_args #3081

Merged
merged 2 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions flytekit/image_spec/default_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ def prepare_python_install(image_spec: ImageSpec, tmp_dir: Path) -> str:
extra_urls = [f"--extra-index-url {url}" for url in image_spec.pip_extra_index_url]
pip_install_args.extend(extra_urls)

if image_spec.pip_extra_args:
pip_install_args.append(image_spec.pip_extra_args)
amitani marked this conversation as resolved.
Show resolved Hide resolved

requirements = []
if image_spec.requirements:
requirement_basename = os.path.basename(image_spec.requirements)
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 @@ -48,6 +48,7 @@ class ImageSpec:
platform: Specify the target platforms for the build output (for example, windows/amd64 or linux/amd64,darwin/arm64
pip_index: Specify the custom pip index url
pip_extra_index_url: Specify one or more pip index urls as a list
pip_extra_args: Specify one or more extra pip install arguments as a space-delimited string
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
Expand Down Expand Up @@ -82,6 +83,7 @@ class ImageSpec:
platform: str = "linux/amd64"
pip_index: Optional[str] = None
pip_extra_index_url: Optional[List[str]] = None
pip_extra_args: Optional[str] = None
registry_config: Optional[str] = None
entrypoint: Optional[List[str]] = None
commands: Optional[List[str]] = None
Expand Down
7 changes: 5 additions & 2 deletions tests/flytekit/unit/core/image_spec/test_default_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def test_create_docker_context_uv_lock(tmp_path):
requirements=os.fspath(uv_lock_file),
pip_index="https://url.com",
pip_extra_index_url=["https://extra-url.com"],
pip_extra_args="--no-install-package library-to-skip",
)

warning_msg = "uv.lock support is experimental"
Expand All @@ -247,7 +248,8 @@ def test_create_docker_context_uv_lock(tmp_path):

assert (
"uv sync --index-url https://url.com --extra-index-url "
"https://extra-url.com --locked --no-dev --no-install-project"
"https://extra-url.com --no-install-package library-to-skip "
"--locked --no-dev --no-install-project"
) in dockerfile_content


Expand Down Expand Up @@ -309,6 +311,7 @@ def test_create_poetry_lock(tmp_path):
name="FLYTEKIT",
python_version="3.12",
requirements=os.fspath(poetry_lock),
pip_extra_args="--no-directory",
)

create_docker_context(image_spec, docker_context_path)
Expand All @@ -317,7 +320,7 @@ def test_create_poetry_lock(tmp_path):
assert dockerfile_path.exists()
dockerfile_content = dockerfile_path.read_text()

assert "poetry install --no-root" in dockerfile_content
assert "poetry install --no-directory --no-root" in dockerfile_content


def test_python_exec(tmp_path):
Expand Down
Loading