-
Notifications
You must be signed in to change notification settings - Fork 301
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
feat: implement force push functionality in ImageSpec #2234
feat: implement force push functionality in ImageSpec #2234
Conversation
…ngine classes - Add a new attribute `is_force_push` to the `ImageSpec` class - Add a new method `force_push` to the `ImageSpec` class - Update the logic in the `ImageBuildEngine` class to handle `is_force_push` attribute in `ImageSpec` instances Signed-off-by: jason.lai <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2234 +/- ##
==========================================
- Coverage 83.81% 83.36% -0.45%
==========================================
Files 332 309 -23
Lines 25093 24021 -1072
Branches 3690 3480 -210
==========================================
- Hits 21032 20026 -1006
+ Misses 3441 3375 -66
Partials 620 620 ☔ View full report in Codecov by Sentry. |
- Add a `force_push` method to the `image_spec` class - Assert that `is_force_push` is True in the test function Signed-off-by: jason.lai <[email protected]>
- Add a default value for `is_force_push` in the `ImageSpec` class - Change the message when force pushing an image in the `ImageBuildEngine` class Signed-off-by: jason.lai <[email protected]>
- Update the default image tag in `ic_result_4` variable Signed-off-by: jason.lai <[email protected]>
…ildEngine classes - Change `is_force_push` attribute to `_is_force_push` in the `ImageSpec` class - Remove the `is_force_push` parameter from the `force_push` method in the `ImageSpec` class - Update references to `is_force_push` to `_is_force_push` in the `ImageBuildEngine` class Signed-off-by: jason.lai <[email protected]>
- Add a method to enable force push in `ImageSpec` class - Update image tags in test cases in `test_run.py` - Assert that `_is_force_push` is False in `test_image_spec.py` Signed-off-by: jason.lai <[email protected]>
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.
@jasonlai1218
Can you help me test the case with force push?
For example
image = ImageSpec(
name="test-flyte",
packages=["flytekit"],
registry="futureoutlier",
)
and add the flag in the ImageSpec
@Future-Outlier |
@Future-Outlier like this?
|
Yes, and please provide screenshot with overwrite message on terminal, thank you |
I mean the example of using |
I think the interface should be simple, we add 1 more flag in |
@pingsutw Do you have any thoughts on this? Do I need to add flag to ImageSpec interface? |
- Change the variable `is_force_push` to `_is_force_push` Signed-off-by: jason.lai <[email protected]>
we don't need a flag. just use |
- Remove the `_is_force_push` attribute from `ImageSpec` class Signed-off-by: jason.lai <[email protected]>
- Refactor the `ImageBuildEngine` class to improve readability and maintainability - Update the logic for handling image building and registration - Fix formatting and messaging inconsistencies in the code Signed-off-by: jason.lai <[email protected]>
7471785
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 agree with #2234 (comment) around adding flag to ImageSpec
instead of a method. The two use cases I see for force pushing is:
- Debugging
- User did not pin their dependencies and want to rebuild the image with newer versions.
In both cases, I'll want to enable and then disable force pushing. In either cases, I think a common pattern is to configure it through the environment. Here is what the API looks like for both designs
# Option 1: __init__
spec = ImageSpec(...,
force_push=os.environ.get("FORCE_PUSH_IMAGE", "1") == "1"
)
# Option 2: `force_push ` method
spec = ImageSpec(...)
if os.environ.get("FORCE_PUSH_IMAGE", "1") == "1":
spec = spec.force_push()
I prefer option 1.
flytekit/image_spec/image_spec.py
Outdated
@@ -67,6 +67,7 @@ class ImageSpec: | |||
|
|||
def __post_init__(self): | |||
self.name = self.name.lower() | |||
self._is_force_push = False # False by default |
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.
Do we need to update:
flytekit/flytekit/image_spec/image_spec.py
Line 248 in 632b2c2
def calculate_hash_from_image_spec(image_spec: ImageSpec): |
such that the force_push
field is not a part of the hash?
- Add a new test for building an existing image with force push Signed-off-by: jason.lai <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Thank you very much @thomasjpfan for your advice.
|
LGTM, I'm comfortable with the result. |
Signed-off-by: jason.lai <[email protected]> Signed-off-by: Kevin Su <[email protected]> Co-authored-by: Kevin Su <[email protected]>
Signed-off-by: jason.lai <[email protected]> Signed-off-by: Kevin Su <[email protected]> Co-authored-by: Kevin Su <[email protected]> Signed-off-by: Jan Fiedler <[email protected]>
Tracking issue
https://github.com/flyteorg/flyte/issues/
Why are the changes needed?
So that we can easily override an image with the same name.
What changes were proposed in this pull request?
_is_force_push
to the__post_init__
force_push
to theImageSpec
classImageBuildEngine
class to handle_is_force_push
attribute inImageSpec
instancesHow was this patch tested?
Setup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link
flyteorg/flyte#5030