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 ImageConfig to the serialization context for dynamic task #2456

Merged
merged 25 commits into from
Jun 4, 2024

Conversation

pingsutw
Copy link
Member

@pingsutw pingsutw commented Jun 3, 2024

Tracking issue

NA

Why are the changes needed?

Dynamic task tries to build the ImageSpec at runtime.

What changes were proposed in this pull request?

  • Build the ImageSpec for the task entities that are inside the dynamic task
  • Add ImageConfig to the serialization context for dynamic tasks at compile time.
  • At runtime, the dynamic task will look up the image URL in the ImageConfig instead of rebuilding the image spec.

How was this patch tested?

remote cluster

Setup process

from click.testing import CliRunner

from flytekit import ImageSpec, task, dynamic, workflow
from flytekit.clis.sdk_in_container import pyflyte


new_flytekit = "git+https://github.com/flyteorg/flytekit.git@28d4da3a49c98a9f8dc93fef0945e22ca3cd208a"

repro_img = ImageSpec(
    builder="envd",
    packages=["mypy", new_flytekit],
    apt_packages=["git"],
    registry="pingsutw",
    source_root="."
)

image_foo = repro_img.with_apt_packages(["curl"])
image_d1 = repro_img.with_apt_packages(["wget"])
image_bar = repro_img.with_apt_packages(["vim"])


# hello
@task(container_image=image_foo)
def foo():
    print("foo")


@task(container_image=image_bar)
def bar():
    print("bar")


@dynamic(container_image=image_d1)
def d1():
    bar()


@workflow
def wf():
    foo()
    d1()

Screenshots

Screenshot 2024-06-02 at 7 39 43 PM

Also tested it on serverless

Screenshot 2024-06-02 at 7 55 44 PM

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

NA

Docs link

NA

pingsutw added 10 commits June 2, 2024 15:36
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
pingsutw added 2 commits June 2, 2024 19:58
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Copy link

codecov bot commented Jun 3, 2024

Codecov Report

Attention: Patch coverage is 21.05263% with 15 lines in your changes missing coverage. Please review.

Project coverage is 41.91%. Comparing base (6d40413) to head (375db5c).
Report is 3 commits behind head on master.

Current head 375db5c differs from pull request most recent head 6095194

Please upload reports for the commit 6095194 to get more accurate results.

Files Patch % Lines
flytekit/core/python_auto_container.py 12.50% 7 Missing ⚠️
flytekit/tools/translator.py 33.33% 6 Missing ⚠️
flytekit/core/container_task.py 0.00% 1 Missing ⚠️
flytekit/core/python_customized_container_task.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2456       +/-   ##
===========================================
- Coverage   76.07%   41.91%   -34.17%     
===========================================
  Files         182      182               
  Lines       18473    18484       +11     
  Branches     3825     3614      -211     
===========================================
- Hits        14053     7747     -6306     
- Misses       3809    10644     +6835     
+ Partials      611       93      -518     

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

@pingsutw
Copy link
Member Author

pingsutw commented Jun 3, 2024

cc @kumare3 @EngHabu

EngHabu
EngHabu previously approved these changes Jun 3, 2024
@pingsutw pingsutw marked this pull request as draft June 3, 2024 22:47
pingsutw added 4 commits June 3, 2024 16:47
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
pingsutw added 3 commits June 3, 2024 18:03
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
wild-endeavor
wild-endeavor previously approved these changes Jun 4, 2024
Copy link
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.

deduped

Signed-off-by: Kevin Su <[email protected]>
@pingsutw pingsutw marked this pull request as ready for review June 4, 2024 01:24
@pingsutw pingsutw merged commit db2ff9e into master Jun 4, 2024
39 of 45 checks passed
fiedlerNr9 pushed a commit that referenced this pull request Jul 25, 2024
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.

3 participants