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
Support optionally restarting interactive processes when input files change #13178
Support optionally restarting interactive processes when input files change #13178
Conversation
c847d4c
to
0b12c42
Compare
The commits are somewhat useful to review independently, but the second and third overlap one another quite a bit. |
52a9915
to
f5c289b
Compare
src/python/pants/engine/rules.py
Outdated
) | ||
if signature is not None: | ||
product_str, subject_str, effect = signature | ||
get = AwaitableConstraints( |
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.
Are get
/gets
still appropriate var names here? (and in validate_requirements()?) One might also be an effect
, no?
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.
There is going to be a long tail of updates required, for sure. I'm not really sure what the best abstract name for the new concept is (used Awaitable
in selectors
, but mostly because that was what it was used for in that file). But I'll change the local variable names nearby Awaitable*
at least.
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.
Cool stuff.
Think there's only a few outstanding nits and bits for error feedback, could be done as follow up too..
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.
🤘
|
||
|
||
@ensure_daemon | ||
def test_run_then_edit(use_pantsd: bool) -> None: |
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.
Sweet!
@@ -490,7 +491,7 @@ async def run_tests( | |||
OpenFiles, OpenFilesRequest(coverage_report_files, error_if_open_not_found=False) | |||
) | |||
for process in open_files.processes: | |||
interactive_runner.run(process) | |||
_ = await Effect(InteractiveProcessResult, InteractiveProcess, 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.
No need for _ =
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.
When discarding something, I like to make it clear that it's intentional.
[ci skip-rust] [ci skip-build-wheels]
… support configuring whether to restart. [ci skip-build-wheels] # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust]
[ci skip-build-wheels]
# Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
f5c289b
to
1e82cda
Compare
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
"If your application can safely be restarted while it is running, you can pass " | ||
"`restartable=True` on your binary target (for supported types), and the `run` goal " |
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.
Imo pass
=> CLI arg, set
=> change a BUILD file.
"If your application can safely be restarted while it is running, you can pass " | |
"`restartable=True` on your binary target (for supported types), and the `run` goal " | |
"If your application can safely be restarted while it is running, you can set " | |
"`restartable=True` on your binary target (for supported types), and the `run` goal " |
"If your application can safely be restarted while it is running, you can pass " | ||
"`restartable=True` on your binary target (for supported types), and the `run` goal " | ||
"will automatically restart them as all relevant files change. This can be particularly " | ||
"useful for server applications." |
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.
like Django and Flask.
…t spurious restarts. (#13385) Unlike `run_rule_with_mocks`, `RuleRunner.run_goal_rule` does actually run a `Goal` via the engine, and is thus subject to being restarted when its inputs have changed (see #13178). Consequently, the `Console` and `Workspace` types _do_ need to track side-effects in that context, in order to prevent the `@rule` from being restarted after its first side-effect. This was exhibiting as test flakiness for a goal that re-writes files in the workspace (see #13383), because after writing the updated lockfile to disk, the `@rule` has changed its own inputs and is subject to restart: if the restart arrived before any `Console` output was written, the second attempt to run the rule would not find anything to do, and would thus not render any `Console` output. Fixes #13383. [ci skip-rust] [ci skip-build-wheels]
f"A `@rule` that was not a @goal_rule ({func_id}) has a `SideEffecting` parameter: {ty}" | ||
) | ||
if not cacheable: | ||
return |
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.
Just realized now, that this early return cancels all the Effect
checks further down for @goal_rule
s. cc @stuhood
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.
Thanks! #14069.
#13178 added additional validation of use of `Effect`s in `@goal_rules` but it was accidentally unreachable. [ci skip-rust] [ci skip-build-wheels]
Adds
pex_binary(.., restartable=True)
andrepl --restartable
to optionally allow user processes to be restarted when files change. Seerun_integration_test.py
for an example.InteractiveProcess
is used for any process that needs to run in the foreground, including those forrun
, andrepl
. To support restarting those processes, we make invoking anInteractiveProcess
async, which allows it to (optionally) be restarted when files change.To make
InteractiveProcess
async, we convert it into a rust-sideIntrinsic
, and introduce a newEffect
awaitable type, which is used in place ofGet
when a type isSideEffecting
. This also prepares the otherSideEffecting
param types to be converted toEffect
s as well (in order to accomplish #10542).Fixes #9462.