damccorm commented on code in PR #41159:
URL: https://github.com/apache/beam/pull/41159#discussion_r4528398538


##########
sdks/python/apache_beam/runners/common.py:
##########
@@ -1000,10 +1005,11 @@ def _invoke_process_per_window(
       else:
         window = GlobalWindow()
       side_inputs = [si[window] for si in self.side_inputs]
-      side_inputs.extend(additional_args)
+      if additional_args:
+        side_inputs.extend(additional_args)
       args_for_process, kwargs_for_process = util.insert_values_in_args(
           self.args_for_process, self.kwargs_for_process, side_inputs)
-      if not self.recalculate_window_args:
+      if not self.recalculate_window_args and not additional_args:

Review Comment:
   Note on `and not additional_args` here:
   - On the standard `DoFnRunner.process` / 
`DoFnRunner.process_with_sized_restriction` execution path, `additional_args` 
is always `None` (or `[]` for SDFs), so `not additional_args` is always `True` 
and caching behavior is unchanged.
   - When non-empty `additional_args` are passed (e.g., 
`SDFProcessElementInvoker.invoke_process_element` in `sdf_direct_runner.py`, 
where `ProcessFn` creates `self.sdf_invoker` with `side_inputs=()` and forwards 
resolved per-window side inputs via `additional_args=args`), 
`util.insert_values_in_args` replaces the `ArgumentPlaceholder` entries in 
`self.args_for_process` with `side_inputs + additional_args`. Guarding the 
cache read/write with `not additional_args` prevents the first call's 
`additional_args` from overwriting `self.args_for_process` and being reused on 
subsequent calls with different `additional_args`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to