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 dest_dir into pythonpath before loading modules #2692

Merged
merged 13 commits into from
Sep 23, 2024

Conversation

arbaobao
Copy link
Contributor

Tracking issue

Why are the changes needed?

According to issue#2673, it seems better to add dest_dir before loading the modules.

What changes were proposed in this pull request?

This change will add dest_dir before loading the modules.

How was this patch tested?

Run workflow with --destination-dir=/xxx.
For example, pyflyte run --remote --destination-dir=/tmp flytekit-example/hello_world.py hello_world_wf

Setup process

Screenshots

截圖 2024-08-20 凌晨12 13 30 截圖 2024-08-20 凌晨12 12 21

Check all the applicable boxes

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

Related PRs

issue#2673

Docs link

Copy link

codecov bot commented Aug 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.40%. Comparing base (7f54171) to head (7a90b32).
Report is 3 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##            master    #2692       +/-   ##
============================================
- Coverage   100.00%   74.40%   -25.60%     
============================================
  Files            5      194      +189     
  Lines          122    19726    +19604     
  Branches         0     2865     +2865     
============================================
+ Hits           122    14677    +14555     
- Misses           0     4312     +4312     
- Partials         0      737      +737     

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

@@ -376,6 +377,8 @@ def _execute_task(
dynamic_addl_distro,
dynamic_dest_dir,
) as ctx:
if all(os.path.realpath(path) != dynamic_dest_dir for path in sys.path):
sys.path.append(dynamic_dest_dir)
Copy link
Member

Choose a reason for hiding this comment

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

I think we should add dest_dir to PYTHONPATH instead of dynamic_dest_dir

@arbaobao
Copy link
Contributor Author

I think it's better to add dest_dir to pythonpath before create subprocess.

@@ -549,7 +549,13 @@ def fast_execute_task_cmd(additional_distribution: str, dest_dir: str, task_exec

# Use the commandline to run the task execute command rather than calling it directly in python code
# since the current runtime bytecode references the older user code, rather than the downloaded distribution.
p = subprocess.Popen(cmd)
env = os.environ.copy()
if all(os.path.realpath(path) != dest_dir for path in sys.path) and dest_dir is not None:
Copy link
Member

Choose a reason for hiding this comment

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

The new process may have a different sys.path that is not connected to the current process.

I think it's okay to just check for dest_dir is not None.

flytekit/bin/entrypoint.py Outdated Show resolved Hide resolved
Signed-off-by: Nelson Chen <[email protected]>
pingsutw
pingsutw previously approved these changes Aug 25, 2024
Copy link
Member

@pingsutw pingsutw left a comment

Choose a reason for hiding this comment

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

Could you also add --destination-dir to this test?

Signed-off-by: Nelson Chen <[email protected]>
Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

@arbaobao Can you sync up your PR with master? I think this is good to go!

@arbaobao
Copy link
Contributor Author

@thomasjpfan I have synced this PR.

Copy link
Member

@pingsutw pingsutw left a comment

Choose a reason for hiding this comment

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

lgtm

@pingsutw pingsutw merged commit 15dee95 into flyteorg:master Sep 23, 2024
103 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.

3 participants