-
Notifications
You must be signed in to change notification settings - Fork 298
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
[BUG] Consider each site_package #2920
base: master
Are you sure you want to change the base?
Conversation
Thank you for opening this pull request! 🙌 These tips will help get your PR across the finish line:
|
Signed-off-by: Bennett <[email protected]>
a6b6894
to
e48f56c
Compare
any chance you can think of a simple unit test for this? |
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.
@BennettRand I think the simplest unit test is to monkeypatch site.getsitepackages
and check that list_imported_modules_as_files
does the right thing.
Signed-off-by: Bennett <[email protected]>
@thomasjpfan @wild-endeavor Just added it. |
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 test! LGTM
Signed-off-by: Bennett <[email protected]>
0e09c79
|
||
def test_list_imported_modules_as_files(): | ||
|
||
source_path = "/home/username/project" |
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.
For windows CI to pass, I think we'll either need to use os.path.join
or pathlib.Path
to define the paths.
(Windows uses \
instead of /
)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2920 +/- ##
==========================================
+ Coverage 46.91% 51.11% +4.19%
==========================================
Files 199 200 +1
Lines 20840 20839 -1
Branches 2681 2688 +7
==========================================
+ Hits 9778 10651 +873
+ Misses 10582 9693 -889
- Partials 480 495 +15 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Signed-off-by: Bennett <[email protected]>
20538ea
to
ecea07d
Compare
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.
@BennettRand The failing windows test looks related to this PR.
@thomasjpfan Yeah, I believe my unit test is showing that list_imported_modules_as_files is not behaving as expected in Windows. I'm working on launching a Windows VM to debug it properly. |
…tement Signed-off-by: Bennett <[email protected]>
|
Signed-off-by: Bennett <[email protected]>
root_dir = Path("C:\\") if platform.system() == "Windows" else Path("/") | ||
source_path = root_dir / "home" / "username" / "project" |
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.
To keep this simple, can we have the source_path
be Path.cwd()
?
for m, p in zip(modules, module_paths): | ||
m.__file__ = p |
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.
Depending on two list being aligned feels a little brittle. Can have the modules be a list of tuples? Something like this:
local_modules = [
(ModuleType("local_module_1"), str(source_path / "package_a" / "module_1.py")),
...
]
all_modules = local_modules + flyte_modules + ...
for mod, mod_path in all_modules:
mod.__file__ = mod_path
# to be passed in later
modules = [mod for mod, _ in all_modules]
with mock.patch("site.getsitepackages", new=lambda: site_packages):
file_list = list_imported_modules_as_files(str(source_path), modules)
local_module_paths = [path for _, path in local_modules]
assert sorted(file_list) == sorted(local_module_paths)
Signed-off-by: Bennett <[email protected]>
Why are the changes needed?
site.getsitepackages()
was returningwhich when run through
os.path.commonpath
isThis makes it so that any
mod_file
compared to the site packages set, will never be a string in the site packages set, thus being included in the list of filed to be packaged for fast serialization.What changes were proposed in this pull request?
Compare the common path of the module file to each site package in the site package set to see if the mosule file should be skipped.
How was this patch tested?
No tests added, all tests passed in Python 3.12.7
Manually inspected the file tree generated by a
pyflyte -v run --remote ...
command and the contents of the resulting.tar.gz
file.Setup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link