-
Notifications
You must be signed in to change notification settings - Fork 302
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
Run command in pyflyte-fast-execute in the same process #3029
base: master
Are you sure you want to change the base?
Run command in pyflyte-fast-execute in the same process #3029
Conversation
Signed-off-by: Thomas J. Fan <[email protected]>
Code Review Agent Run #ff52b8Actionable Suggestions - 3
Review Details
|
Changelist by BitoThis pull request implements the following key changes.
|
|
||
command(args) | ||
|
||
|
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.
Consider adding error handling around subprocess.Popen()
call to catch potential OSError
or ValueError
exceptions that could occur during process creation.
Code suggestion
Check the AI-generated fix before applying
try: | |
p = subprocess.Popen(cmd, env=env) | |
except (OSError, ValueError) as e: | |
logger.error(f"Failed to start subprocess: {e}") | |
exit(1) |
Code Review Run #ff52b8
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
@@ -742,24 +773,16 @@ def fast_execute_task_cmd(additional_distribution: str, dest_dir: str, task_exec | |||
cmd.extend(["--dynamic-addl-distro", additional_distribution, "--dynamic-dest-dir", dest_dir]) | |||
cmd.append(arg) | |||
|
|||
commands_to_run_in_process = {cmd.name: cmd for cmd in [map_execute_task_cmd, execute_task_cmd]} |
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.
Consider moving the commands_to_run_in_process
dictionary definition outside the function to avoid recreating it on every call. This dictionary is static and could be defined at module level.
Code suggestion
Check the AI-generated fix before applying
@@ -1,1 +1,3 @@
+_commands_to_run_in_process = {cmd.name: cmd for cmd in [map_execute_task_cmd, execute_task_cmd]}
+
def fast_execute_task_cmd(additional_distribution: str, dest_dir: str, task_execute_cmd: List[str]):
@@ -776,1 +778,0 @@
- commands_to_run_in_process = {cmd.name: cmd for cmd in [map_execute_task_cmd, execute_task_cmd]}
Code Review Run #ff52b8
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3029 +/- ##
===========================================
+ Coverage 51.28% 79.01% +27.72%
===========================================
Files 201 220 +19
Lines 21281 22215 +934
Branches 2734 2734
===========================================
+ Hits 10915 17554 +6639
+ Misses 9767 3923 -5844
- Partials 599 738 +139 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Thomas J. Fan <[email protected]>
Code Review Agent Run #33c19cActionable Suggestions - 1
Review Details
|
@@ -23,6 +23,9 @@ | |||
# Set this environment variable to true to force the task to return non-zero exit code on failure. | |||
FLYTE_FAIL_ON_ERROR = "FLYTE_FAIL_ON_ERROR" | |||
|
|||
# Set this environment variable to true to force pyflyte-fast-execute to run task-execute-cmd in a separate process | |||
FLYTE_FAST_EXECUTE_CMD_IN_NEW_PROCESS = "FLYTE_FAST_EXECUTE_CMD_IN_NEW_PROCESS" | |||
|
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.
Could we run a workflow in the integration tests with FLYTE_FAST_EXECUTE_CMD_IN_NEW_PROCESS
enabled? Just want to make sure the old behavior is still working.
def test_remote_run(): |
…r_flyte_fast_execute Signed-off-by: Thomas J. Fan <[email protected]>
Signed-off-by: Thomas J. Fan <[email protected]>
Signed-off-by: Thomas J. Fan <[email protected]>
Code Review Agent Run #cfcbeeActionable Suggestions - 0Additional Suggestions - 10
Review Details
|
Signed-off-by: Thomas J. Fan <[email protected]>
Code Review Agent Run #53b9a2Actionable Suggestions - 1
Review Details
|
Why are the changes needed?
With this PR,
pyflyte-fast-execute
does not run the command in another process, which saves ~7 seconds.What changes were proposed in this pull request?
With this PR,
pyflyte-fast-execute
will runpyflyte-map-execute
andpyflyte-execute
in the same process, which improves startup time. There is aFLYTE_FAST_EXECUTE_CMD_IN_NEW_PROCESS
env var that triggers the previous behavior.How was this patch tested?
I ran:
With
pyflyte run --remote wf.py hello --name flyte
, it took 8s:With
pyflyte run --remote --env FLYTE_FAST_EXECUTE_CMD_IN_NEW_PROCESS=1 wf.py hello --name flyte
, which took 15 s:Summary by Bito
This PR combines multiple enhancements: (1) pyflyte-fast-execute optimization with in-process command execution for ~7 second startup time gains (with FLYTE_FAST_EXECUTE_CMD_IN_NEW_PROCESS flag for legacy behavior), (2) new Environment class for task configurations, (3) VLLM integration and Optuna plugin for model serving and hyperparameter optimization, and (4) improved package management with uv.lock and poetry.lock supportUnit tests added: True
Estimated effort to review (1-5, lower is better): 5