Skip to content

Image spec builder options#3233

Merged
mhotan merged 3 commits into
masterfrom
mhotan/image_spec_builder_options
Apr 22, 2025
Merged

Image spec builder options#3233
mhotan merged 3 commits into
masterfrom
mhotan/image_spec_builder_options

Conversation

@mhotan
Copy link
Copy Markdown
Contributor

@mhotan mhotan commented Apr 18, 2025

Why are the changes needed?

This PR provides the ability to specify image builder specific options to Image Spec.

from flytekit import ImageSpec, task

image = ImageSpec(
    base_image="localhost:30000/flytekit:0.1.5", 
    builder_options={"option": "custom_build_option"}
)

@task(container_image=image)
def main() -> int:
    return 10

In a more realistic example, Union image builder is looking the ability to configure and set registry credentials through this attribute.

from flytekit import ImageSpec, task

# Assume we uploaded credentials
# union create secret --type imagepullsecrets --value-file /path/to/credentials.json  my-custom-credentials

image = ImageSpec(
    base_image="myprivateregistry.com/flytekit:0.1.5", 
    builder_options={"imagepull_secret_name": "my-custom-credentials"}
)

@task(container_image=image, secret_requests=[Secret(key="my-custom-credentials""))
def main() -> int:
    return 10

What changes were proposed in this pull request?

This PR adds:

  • The ability to specify 'builder_options` dictionary to image spec
  • A imagespec.with_builder_options to additively accumulate builder_options

How was this patch tested?

Additional unit tests

Summary by Bito

This PR enhances ImageSpec functionality by enabling dictionary-based builder-specific options with type validation and clearer error messages. It improves error handling in image_spec.py and updates docstring formatting to meet pydoclint standards, reducing discrepancies between documented and actual attributes. New test cases verify proper handling of invalid builder_options inputs, strengthening the robustness, reliability and clarity of the image specification API.

Unit tests added: True

Estimated effort to review (1-5, lower is better): 1

@welcome
Copy link
Copy Markdown

welcome Bot commented Apr 18, 2025

Thank you for opening this pull request! 🙌

These tips will help get your PR across the finish line:

  • Most of the repos have a PR template; if not, fill it out to the best of your knowledge.
  • Sign off your commits (Reference: DCO Guide).

@flyte-bot
Copy link
Copy Markdown
Contributor

flyte-bot commented Apr 18, 2025

Code Review Agent Run #83541f

Actionable Suggestions - 1
  • flytekit/image_spec/image_spec.py - 1
    • Missing validation for new builder_options parameter · Line 106-106
Additional Suggestions - 7
Review Details
  • Files reviewed - 3 · Commit Range: 2b8f16d..2b8f16d
    • flytekit/image_spec/image_spec.py
    • pydoclint-errors-baseline.txt
    • tests/flytekit/unit/core/image_spec/test_image_spec.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

Refer to the documentation for additional commands.

Configuration

This repository uses code_review_bito You can customize the agent settings here or contact your Bito workspace admin at haytham@union.ai.

Documentation & Help

AI Code Review powered by Bito Logo

@mhotan mhotan force-pushed the mhotan/image_spec_builder_options branch from 2b8f16d to e84b0dc Compare April 18, 2025 20:37
@flyte-bot
Copy link
Copy Markdown
Contributor

flyte-bot commented Apr 18, 2025

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Feature Improvement - Enhanced Image Specification

image_spec.py - Added support for builder_options with type validation, improved error handling, and comprehensive docstring updates to better describe class attributes.

test_image_spec.py - Introduced new tests covering both positive and negative scenarios for the builder_options functionality, ensuring robust behavior.

Documentation - Updated Documentation for Compliance

pydoclint-errors-baseline.txt - Revised and aligned class and method documentation to meet pydoclint standards, addressing discrepancies in documented attributes.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 18, 2025

Codecov Report

Attention: Patch coverage is 57.14286% with 9 lines in your changes missing coverage. Please review.

Project coverage is 79.19%. Comparing base (9b100f0) to head (3efb7de).

Files with missing lines Patch % Lines
flytekit/image_spec/image_spec.py 57.14% 4 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #3233       +/-   ##
===========================================
+ Coverage   52.32%   79.19%   +26.87%     
===========================================
  Files         215      215               
  Lines       22391    22408       +17     
  Branches     2927     2934        +7     
===========================================
+ Hits        11716    17747     +6031     
+ Misses       9988     3817     -6171     
- Partials      687      844      +157     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mhotan mhotan force-pushed the mhotan/image_spec_builder_options branch from 24ce8ae to 7dc2335 Compare April 18, 2025 20:55
pip_index: Specify the custom pip index url
pip_extra_index_url: Specify one or more pip index urls as a list
pip_secret_mounts: Specify a list of tuples to mount secret for pip install. Each tuple should contain the path to
Attributes:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated all this Doc to fix linter

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @ppiegaze - your upcoming flytekit PR renders these changes moot right? Along with the monodocs build? I've been out of the loop on the doc building stuff for a while, do you know what the plan for that is? or maybe @cosmicBboy?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context, I was doing my best here to get tests passing under the assumption that I was upholding the current standards. I am not aware of ongoing changes and potential CICD inconsistencies.

thomasjpfan
thomasjpfan previously approved these changes Apr 18, 2025
Copy link
Copy Markdown
Contributor

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments, otherwise LGTM

Comment thread flytekit/image_spec/image_spec.py Outdated
Comment thread tests/flytekit/unit/core/image_spec/test_image_spec.py
@flyte-bot
Copy link
Copy Markdown
Contributor

flyte-bot commented Apr 18, 2025

Code Review Agent Run #413df0

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: 2b8f16d..7dc2335
    • flytekit/image_spec/image_spec.py
    • pydoclint-errors-baseline.txt
    • tests/flytekit/unit/core/image_spec/test_image_spec.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

Refer to the documentation for additional commands.

Configuration

This repository uses code_review_bito You can customize the agent settings here or contact your Bito workspace admin at haytham@union.ai.

Documentation & Help

AI Code Review powered by Bito Logo

@mhotan mhotan force-pushed the mhotan/image_spec_builder_options branch from 17157d2 to 3efb7de Compare April 18, 2025 21:45
@kumare3
Copy link
Copy Markdown
Contributor

kumare3 commented Apr 18, 2025

LGTM

@flyte-bot
Copy link
Copy Markdown
Contributor

flyte-bot commented Apr 18, 2025

Code Review Agent Run #30b4ef

Actionable Suggestions - 0
Additional Suggestions - 1
  • flytekit/image_spec/image_spec.py - 1
Review Details
  • Files reviewed - 3 · Commit Range: 7dc2335..3efb7de
    • flytekit/image_spec/image_spec.py
    • pydoclint-errors-baseline.txt
    • tests/flytekit/unit/core/image_spec/test_image_spec.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

Refer to the documentation for additional commands.

Configuration

This repository uses code_review_bito You can customize the agent settings here or contact your Bito workspace admin at haytham@union.ai.

Documentation & Help

AI Code Review powered by Bito Logo

@flyteorg flyteorg deleted a comment from flyte-bot Apr 19, 2025
Copy link
Copy Markdown
Contributor

@wild-endeavor wild-endeavor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a couple questions. This will not be used at all by the default builder correct?

pip_index: Specify the custom pip index url
pip_extra_index_url: Specify one or more pip index urls as a list
pip_secret_mounts: Specify a list of tuples to mount secret for pip install. Each tuple should contain the path to
Attributes:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @ppiegaze - your upcoming flytekit PR renders these changes moot right? Along with the monodocs build? I've been out of the loop on the doc building stuff for a while, do you know what the plan for that is? or maybe @cosmicBboy?

return None

def _update_attribute(self, attr_name: str, values: Union[str, List[str]]) -> "ImageSpec":
def _update_attribute(self, attr_name: str, values: Union[str, List[str], Dict[str, Any]]) -> "ImageSpec":
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the type hint here (and in the class definition) really be dict[str, Any] rather than just dict[str, str]? What are the other types users might add?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see a future, however don't have a specific example, where int and potentially List[str] be used but it seems builder dependent. Happy to constrain to Dict[str, str] and we could later decide to move toward Dict[str, Any] if we find compelling future cases.

@mhotan
Copy link
Copy Markdown
Contributor Author

mhotan commented Apr 21, 2025

just a couple questions. This will not be used at all by the default builder correct?

Correct, not be used by the default builder. That being said, it is not currently restricted for future use at this time

mhotan added 3 commits April 22, 2025 08:39
Provide the ability to specify image `builder` specific options per
Image Spec.

Signed-off-by: Mike Hotan <mike@union.ai>
Signed-off-by: Mike Hotan <mike@union.ai>
Signed-off-by: Mike Hotan <mike@union.ai>
@mhotan mhotan force-pushed the mhotan/image_spec_builder_options branch from 3efb7de to d6b6494 Compare April 21, 2025 22:39
@flyte-bot
Copy link
Copy Markdown
Contributor

flyte-bot commented Apr 21, 2025

Code Review Agent Run #c907a9

Actionable Suggestions - 0
Additional Suggestions - 1
  • flytekit/image_spec/image_spec.py - 1
Review Details
  • Files reviewed - 3 · Commit Range: 3efb7de..d6b6494
    • flytekit/image_spec/image_spec.py
    • pydoclint-errors-baseline.txt
    • tests/flytekit/unit/core/image_spec/test_image_spec.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

Refer to the documentation for additional commands.

Configuration

This repository uses code_review_bito You can customize the agent settings here or contact your Bito workspace admin at haytham@union.ai.

Documentation & Help

AI Code Review powered by Bito Logo

@mhotan mhotan merged commit bba955f into master Apr 22, 2025
115 of 116 checks passed
@welcome
Copy link
Copy Markdown

welcome Bot commented Apr 22, 2025

Congrats on merging your first pull request! 🎉

mhotan added a commit that referenced this pull request Apr 22, 2025
* Image spec builder options

Provide the ability to specify image `builder` specific options per
Image Spec.

Signed-off-by: Mike Hotan <mike@union.ai>

* Add builder_options validation

Signed-off-by: Mike Hotan <mike@union.ai>

* updates

Signed-off-by: Mike Hotan <mike@union.ai>

---------

Signed-off-by: Mike Hotan <mike@union.ai>
wild-endeavor pushed a commit that referenced this pull request Apr 22, 2025
* Image spec builder options

Provide the ability to specify image `builder` specific options per
Image Spec.

Signed-off-by: Mike Hotan <mike@union.ai>

* Add builder_options validation

Signed-off-by: Mike Hotan <mike@union.ai>

* updates

Signed-off-by: Mike Hotan <mike@union.ai>

---------

Signed-off-by: Mike Hotan <mike@union.ai>
mhotan added a commit that referenced this pull request Apr 22, 2025
* Adds ImageSpec.with_runtime_packages (#3231)

* Adds ImageSpec.with_dev_dependencies

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Fix

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Add tests for noop builder

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Use runtime_packages

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Add docs abount how to use runtime packages

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Less diffs

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Fix formatting

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Fix docstring

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Dix docstring

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Let pip default to user by itself to be more compatible

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

---------

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Image spec builder options (#3233)

* Image spec builder options

Provide the ability to specify image `builder` specific options per
Image Spec.

Signed-off-by: Mike Hotan <mike@union.ai>

* Add builder_options validation

Signed-off-by: Mike Hotan <mike@union.ai>

* updates

Signed-off-by: Mike Hotan <mike@union.ai>

---------

Signed-off-by: Mike Hotan <mike@union.ai>

---------

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
Signed-off-by: Mike Hotan <mike@union.ai>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Atharva1723 pushed a commit to Atharva1723/flytekit that referenced this pull request Oct 5, 2025
* Image spec builder options

Provide the ability to specify image `builder` specific options per
Image Spec.

Signed-off-by: Mike Hotan <mike@union.ai>

* Add builder_options validation

Signed-off-by: Mike Hotan <mike@union.ai>

* updates

Signed-off-by: Mike Hotan <mike@union.ai>

---------

Signed-off-by: Mike Hotan <mike@union.ai>
Signed-off-by: Atharva <atharvakulkarni172003@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants