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

Imgspec/copy auto #2731

Merged
merged 12 commits into from
Sep 10, 2024
Merged

Imgspec/copy auto #2731

merged 12 commits into from
Sep 10, 2024

Conversation

wild-endeavor
Copy link
Contributor

@wild-endeavor wild-endeavor commented Sep 5, 2024

Why are the changes needed?

We introduced a new switch, --copy, to the pyflyte command recently to help standardize control of the fast register experience. This switch also changed the behavior slightly for discovering and copying the files into the fast register tar file. This PR changes the ImageSpec build process to also rely on that new file discovery and copying behavior, and updates the default behavior to copy only loaded Python modules rather than all files. This make all file finding/copying the same across flytekit.

What changes were proposed in this pull request?

  • Added a new option called copy to the ImageSpec object to mirror the option on the switches. This is the first time ImageSpec has a non-primitive option but I think this is okay.
  • Moved the enum that back this option to its own package - because it's used by by both the tools and core side it was causing too many circular imports.
  • Behavior of ImageSpec when copying is needed is now to copy 'auto' (only loaded Python modules). Before it was copying all files.
  • Move shared logic in containertask/pythonautocontainertask into a helper function.

Couple notes:

  • The tag and id properties of ImageSpec rely on the fields source_root and now copy to compute the tag and id correctly. This is fine but because these values are mutated by the update_image_spec_copy_handling (this was happening before this pr also), this means that when a user calls these properties will affect their return values. We can make update_image_spec_copy_handling not mutate, but that doesn't work since tag/id need the correct values for source_root and copy in order to correctly compute their values. Basically the question is how to make sure serialization settings has been taken into account before these two properties are called.
  • Noticed in multiple places that deref_symlinks and any ignore settings are not piped all the way through. We should clean this up as a follow-up.

How was this patch tested?

Unit tests, tested locally with sandbox, confirmed behavior before and after. Tested both default and envd builders. ls files inside image, ran a test workflow, etc.

Setup process

Screenshots

Check all the applicable boxes

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

Related PRs

Docs link

Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
Copy link

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 33.96226% with 35 lines in your changes missing coverage. Please review.

Project coverage is 49.75%. Comparing base (a9c9c46) to head (3dd1b32).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
flytekit/core/python_auto_container.py 14.28% 11 Missing and 1 partial ⚠️
flytekit/image_spec/default_builder.py 16.66% 10 Missing ⚠️
flytekit/image_spec/image_spec.py 27.27% 8 Missing ⚠️
flytekit/tools/script_mode.py 25.00% 3 Missing ⚠️
flytekit/core/container_task.py 33.33% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (a9c9c46) and HEAD (3dd1b32). Click for more details.

HEAD has 7 uploads less than BASE
Flag BASE (a9c9c46) HEAD (3dd1b32)
9 2
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2731       +/-   ##
===========================================
- Coverage   78.57%   49.75%   -28.83%     
===========================================
  Files         193      194        +1     
  Lines       19672    19718       +46     
  Branches     4100     4109        +9     
===========================================
- Hits        15458     9811     -5647     
- Misses       3492     9379     +5887     
+ Partials      722      528      -194     

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

Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
flytekit/core/python_auto_container.py Show resolved Hide resolved
flytekit/image_spec/default_builder.py Outdated Show resolved Hide resolved
flytekit/image_spec/image_spec.py Outdated Show resolved Hide resolved
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
"""

name: str = "flytekit"
python_version: str = None # Use default python in the base image if None.
builder: Optional[str] = None
source_root: Optional[str] = None
source_root: Optional[str] = None # a.txt:auto
Copy link
Member

Choose a reason for hiding this comment

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

a.txt:auto. is there a plan to support this?
it looks nicer honestly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

separate pr?

Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
@wild-endeavor wild-endeavor merged commit 26559fa into master Sep 10, 2024
102 of 104 checks passed
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.

2 participants