-
Notifications
You must be signed in to change notification settings - Fork 313
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 image builder user defined #3180
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Nelson Chen <[email protected]>
…builder_user_defined
Signed-off-by: Nelson Chen <[email protected]>
Code Review Agent Run #4675f8Actionable Suggestions - 2
Review Details
|
Changelist by BitoThis pull request implements the following key changes.
|
FROM $UV_IMAGE as uv | ||
FROM $MICROMAMBA_IMAGE as micromamba |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider defining the default values for UV_IMAGE
and MICROMAMBA_IMAGE
variables to maintain backward compatibility. Currently, these variables are used in the Dockerfile template but their default values are not defined, which might cause issues if they're not provided when the template is rendered.
Code suggestion
Check the AI-generated fix before applying
FROM $UV_IMAGE as uv | |
FROM $MICROMAMBA_IMAGE as micromamba | |
# Default to the previously hardcoded versions if not specified | |
FROM ${UV_IMAGE:-ghcr.io/astral-sh/uv:0.5.1} as uv | |
FROM ${MICROMAMBA_IMAGE:-mambaorg/micromamba:2.0.3-debian12-slim} as micromamba |
Code Review Run #4675f8
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
flytekit/configuration/__init__.py
Outdated
@@ -651,6 +670,8 @@ class DataConfig(object): | |||
gcs: GCSConfig = GCSConfig() | |||
azure: AzureBlobStorageConfig = AzureBlobStorageConfig() | |||
generic: GenericPersistenceConfig = GenericPersistenceConfig() | |||
image_builder: ImageBuilderConfig = ImageBuilderConfig() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value for image_builder
in DataConfig
is a function call to ImageBuilderConfig()
. Function calls in dataclass defaults can lead to unexpected behavior as they are evaluated only once at definition time.
Code suggestion
Check the AI-generated fix before applying
image_builder: ImageBuilderConfig = ImageBuilderConfig() | |
image_builder: ImageBuilderConfig = field(default_factory=ImageBuilderConfig) |
Code Review Run #4675f8
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
Signed-off-by: Nelson Chen <[email protected]>
flytekit/configuration/__init__.py
Outdated
@dataclass(init=True, repr=True, eq=True, frozen=True) | ||
class ImageBuilderConfig(object): | ||
""" | ||
Any GCS specific configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any GCS specific configuration. | |
Any image builder configuration. |
flytekit/configuration/__init__.py
Outdated
micromamba_image: str = "mambaorg/micromamba:2.0.3-debian12-slim" | ||
|
||
@classmethod | ||
def auto(cls, config_file: typing.Union[str, ConfigFile] = None) -> GCSConfig: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def auto(cls, config_file: typing.Union[str, ConfigFile] = None) -> GCSConfig: | |
def auto(cls, config_file: typing.Union[str, ConfigFile] = None) -> ImageBuilderConfig: |
flytekit/configuration/__init__.py
Outdated
@@ -651,6 +670,8 @@ class DataConfig(object): | |||
gcs: GCSConfig = GCSConfig() | |||
azure: AzureBlobStorageConfig = AzureBlobStorageConfig() | |||
generic: GenericPersistenceConfig = GenericPersistenceConfig() | |||
image_builder: ImageBuilderConfig = ImageBuilderConfig() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we put it in the DataConfig?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I can make it independent.
Signed-off-by: Nelson Chen <[email protected]>
Signed-off-by: Nelson Chen <[email protected]>
Signed-off-by: Nelson Chen <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3180 +/- ##
==========================================
- Coverage 83.58% 77.22% -6.37%
==========================================
Files 3 213 +210
Lines 195 22275 +22080
Branches 0 2901 +2901
==========================================
+ Hits 163 17201 +17038
- Misses 32 4227 +4195
- Partials 0 847 +847 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Code Review Agent Run #df86abActionable Suggestions - 1
Review Details
|
Any image builder specific configuration. | ||
""" | ||
|
||
default: DefaultConfig = DefaultConfig() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dataclass field default
is using a function call DefaultConfig()
as a default value, which can lead to unexpected behavior. Consider using field(default_factory=DefaultConfig)
instead.
Code suggestion
Check the AI-generated fix before applying
default: DefaultConfig = DefaultConfig() | |
default: DefaultConfig = field(default_factory=DefaultConfig) |
Code Review Run #df86ab
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR @arbaobao !
I prefer to have these configuration options in ImageSpec
itself (or a way to for ImageSpec to pass in builder specific configuration, like a task_config
but for image builders)
Design-wise, when two people running the same image spec, it should produce the same image. If we depend on an external config file for building, then it'll make it harder to debug and reason about.
The options I see are:
builder_config
ImageSpec(builder_config={"uv_image": "..."})
- Add another kwarg
ImageSpec(uv_image="...")
@thomasjpfan I see your point, but if users want to use the UV image from a private registry, they must update every image spec |
or we can probably show the builder config in the error message, will that be helpful for debugging |
I think it is reasonable for users to change all their |
@pingsutw @thomasjpfan Is there anything still need to discuss? |
Tracking issue
Why are the changes needed?
In some situations, there isn't internet to build image from pulling uv and micromamba images from the net.
What changes were proposed in this pull request?
I add an
ImageBuilderConfig
to detect if there is user defined image_builder in config.yaml.How was this patch tested?
This patch can be tested by adding
image_builder
to~/.flyte/config.yaml
if we don't specify the image, the default images are
ghcr.io/astral-sh/uv:0.5.1
andmambaorg/micromamba:2.0.3-debian12-slim
.Setup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link
Summary by Bito
This PR adds support for user-defined image builder configuration to enhance flexibility in offline or air-gapped environments. It refactors configuration classes to better separate default from user-defined settings, replacing legacy configuration with new classes including ImageBuilderConfig and updated DataConfig. Docker file templates are revised to allow users to override default images through configuration files.Unit tests added: False
Estimated effort to review (1-5, lower is better): 2