Repository: pantsbuild/pants

Issue:
allow a single Get to convert to ExecuteProcessRequest and execute the process
See the [fixme](https://github.com/pantsbuild/pants/pull/5703/files#diff-7f3f0b29ef16b071ae652a0ef434bd4fR73) left in #5703. A brief description of what this change would entail:

```python
@rule(Concatted, [Select(CatExecutionRequest)])
def cat_files_process_result_concatted(cat_exe_req):
  # this is what we're doing now:
  cat_proc_req = yield Get(ExecuteProcessRequest, CatExecutionRequest, cat_exe_req)
  cat_process_result = yield Get(ExecuteProcessResult, ExecuteProcessRequest, cat_proc_req)
  # this is what we'd like to be able to do instead:
  cat_process_result = yield Get(ExecuteProcessResult, CatExecutionRequest, cat_exe_req)
  yield Concatted(value=cat_process_result.stdout)
```

However, the below fails because [`Select#gen_nodes()` calls `ExecuteProcess::lift()` in `nodes.rs`](https://github.com/cosmicexplorer/pants/blob/7b7f557ff19eec80845a1842834da3b67c33b65f/src/rust/engine/src/nodes.rs#L315), which tries to interpret our `CatExecutionRequest` as an `ExecuteProcessRequest` (which fails when it tries to access fields such as `"env"`).

I made [a branch which attempts to fix this](https://github.com/cosmicexplorer/pants/tree/single-get-for-process-execution) after reading @stuhood's [comment on the PR](https://github.com/pantsbuild/pants/pull/5703#issuecomment-381507758), but currently it ends up executing `execute_process_noop` when I try to do a single `Get(ExecuteProcessResult, CatExecutionRequest, cat_exe_req)`, which throws.

This doesn't seem like it should be a difficult change to make, I'm just finding it difficult to make progress on it so dumping it here for now.


Discussion:

Resolving patch:
diff --git a/src/python/pants/engine/fs.py b/src/python/pants/engine/fs.py
--- a/src/python/pants/engine/fs.py
+++ b/src/python/pants/engine/fs.py
@@ -9,8 +9,7 @@
 from os.path import join
 
 from pants.base.project_tree import Dir, File
-from pants.engine.rules import RootRule, rule
-from pants.engine.selectors import Select
+from pants.engine.rules import RootRule
 from pants.util.objects import Collection, datatype
 
 
@@ -102,20 +101,8 @@ def __str__(self):
 )
 
 
-@rule(Snapshot, [Select(PathGlobs)])
-def snapshot_noop(*args):
-  raise Exception('This task is replaced intrinsically, and should never run.')
-
-
-@rule(FilesContent, [Select(Snapshot)])
-def files_content_noop(*args):
-  raise Exception('This task is replaced intrinsically, and should never run.')
-
-
 def create_fs_rules():
   """Creates rules that consume the intrinsic filesystem types."""
   return [
-    files_content_noop,
-    snapshot_noop,
     RootRule(PathGlobs),
   ]
diff --git a/src/python/pants/engine/isolated_process.py b/src/python/pants/engine/isolated_process.py
--- a/src/python/pants/engine/isolated_process.py
+++ b/src/python/pants/engine/isolated_process.py
@@ -8,8 +8,7 @@
 import logging
 
 from pants.engine.fs import EMPTY_SNAPSHOT
-from pants.engine.rules import RootRule, rule
-from pants.engine.selectors import Select
+from pants.engine.rules import RootRule
 from pants.util.objects import datatype
 
 
@@ -61,9 +60,6 @@ class ExecuteProcessResult(datatype(['stdout', 'stderr', 'exit_code'])):
 
 def create_process_rules():
   """Intrinsically replaced on the rust side."""
-  return [execute_process_noop, RootRule(ExecuteProcessRequest)]
-
-
-@rule(ExecuteProcessResult, [Select(ExecuteProcessRequest)])
-def execute_process_noop(*args):
-  raise Exception('This task is replaced intrinsically, and should never run.')
+  return [
+      RootRule(ExecuteProcessRequest),
+    ]


Test patch:
diff --git a/tests/python/pants_test/engine/test_isolated_process.py b/tests/python/pants_test/engine/test_isolated_process.py
--- a/tests/python/pants_test/engine/test_isolated_process.py
+++ b/tests/python/pants_test/engine/test_isolated_process.py
@@ -77,12 +77,7 @@ def cat_files_process_request_input_snapshot(cat_exe_req):
 
 @rule(Concatted, [Select(CatExecutionRequest)])
 def cat_files_process_result_concatted(cat_exe_req):
-  # FIXME(cosmicexplorer): we should only have to run Get once here. this: yield
-  # Get(ExecuteProcessResult, CatExecutionRequest, cat_exe_req) fails because
-  # ExecuteProcessRequest is a RootRule (which shouldn't be true), but there's
-  # probably some work required in isolated_process.py to fix this (see #5718).
-  cat_proc_req = yield Get(ExecuteProcessRequest, CatExecutionRequest, cat_exe_req)
-  cat_process_result = yield Get(ExecuteProcessResult, ExecuteProcessRequest, cat_proc_req)
+  cat_process_result = yield Get(ExecuteProcessResult, CatExecutionRequest, cat_exe_req)
   yield Concatted(str(cat_process_result.stdout))