Re: [PR] [#19711] Fix missing step_id in Python SDK worker logs during DoFn setup [beam]

2026-04-15 Thread via GitHub


github-actions[bot] commented on PR #37413:
URL: https://github.com/apache/beam/pull/37413#issuecomment-4252158120

   This pull request has been marked as stale due to 60 days of inactivity. It 
will be closed in 1 week if no further activity occurs. If you think that’s 
incorrect or this pull request requires a review, please simply write any 
comment. If closed, you can revive the PR at any time and @mention a reviewer 
or discuss it on the [email protected] list. Thank you for your 
contributions.


-- 
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]



Re: [PR] [#19711] Fix missing step_id in Python SDK worker logs during DoFn setup [beam]

2026-02-13 Thread via GitHub


tvalentyn commented on PR #37413:
URL: https://github.com/apache/beam/pull/37413#issuecomment-3899963058

   waiting on author


-- 
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]



Re: [PR] [#19711] Fix missing step_id in Python SDK worker logs during DoFn setup [beam]

2026-02-12 Thread via GitHub


github-actions[bot] commented on PR #37413:
URL: https://github.com/apache/beam/pull/37413#issuecomment-3890664148

   Reminder, please take a look at this pr: @tvalentyn 


-- 
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]



Re: [PR] [#19711] Fix missing step_id in Python SDK worker logs during DoFn setup [beam]

2026-02-04 Thread via GitHub


gemini-code-assist[bot] commented on code in PR #37413:
URL: https://github.com/apache/beam/pull/37413#discussion_r2765276107


##
sdks/python/apache_beam/runners/worker/log_handler.py:
##
@@ -134,9 +134,12 @@ def emit(self, record: logging.LogRecord) -> None:
 log_entry.timestamp.nanos = int(nanoseconds)
 if record.exc_info:
   log_entry.trace = ''.join(traceback.format_exception(*record.exc_info))
-instruction_id = statesampler.get_current_instruction_id()
-if instruction_id:
-  log_entry.instruction_id = instruction_id
+if hasattr(record, 'instruction_id'):
+  log_entry.instruction_id = record.instruction_id
+if not log_entry.instruction_id:
+  instruction_id = statesampler.get_current_instruction_id()
+  if instruction_id:
+log_entry.instruction_id = instruction_id

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   This logic for setting `instruction_id` can be simplified to be more concise 
and readable by using `getattr` and consolidating the checks.
   
   ```python
   instruction_id = getattr(record, 'instruction_id', None)
   if not instruction_id:
 instruction_id = statesampler.get_current_instruction_id()
   if instruction_id:
 log_entry.instruction_id = instruction_id
   ```



##
sdks/python/apache_beam/runners/worker/bundle_processor.py:
##
@@ -1159,8 +1160,13 @@ def __init__(
 from apache_beam.runners.worker.sdk_worker_main import 
terminate_sdk_harness
 terminate_sdk_harness()
 
-for op in reversed(self.ops.values()):
-  op.setup(self.data_sampler)
+  if instruction_id:
+with statesampler.instruction_id(instruction_id):
+  for op in reversed(self.ops.values()):
+op.setup(self.data_sampler)
+  else:
+for op in reversed(self.ops.values()):
+  op.setup(self.data_sampler)

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   The loop for setting up operations is duplicated in both the `if` and `else` 
blocks. This can be refactored to avoid code repetition and improve 
maintainability. A common pattern for this is to use a conditional context 
manager.



-- 
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]



Re: [PR] [#19711] Fix missing step_id in Python SDK worker logs during DoFn setup [beam]

2026-02-04 Thread via GitHub


claudevdm commented on code in PR #37413:
URL: https://github.com/apache/beam/pull/37413#discussion_r2765256700


##
sdks/python/apache_beam/runners/worker/log_handler.py:
##
@@ -134,9 +134,12 @@ def emit(self, record: logging.LogRecord) -> None:
 log_entry.timestamp.nanos = int(nanoseconds)
 if record.exc_info:
   log_entry.trace = ''.join(traceback.format_exception(*record.exc_info))
-instruction_id = statesampler.get_current_instruction_id()
-if instruction_id:
-  log_entry.instruction_id = instruction_id
+if hasattr(record, 'instruction_id'):

Review Comment:
   Can simplify/optimize by avoid hasattr then acces?
   ```
   instruction_id = getattr(record, 'instruction_id', None) or 
statesampler.get_current_instruction_id()
   if instruction_id:
   log_entry.instruction_id = instruction_id
   ```



##
sdks/python/apache_beam/runners/worker/bundle_processor.py:
##
@@ -1091,6 +1091,7 @@ def __init__(
   state_handler: sdk_worker.CachingStateHandler,
   data_channel_factory: data_plane.DataChannelFactory,
   data_sampler: Optional[data_sampler.DataSampler] = None,
+  instruction_id: Optional[str] = None,

Review Comment:
   Should this be optional, or should we rather make it required?



-- 
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]



Re: [PR] [#19711] Fix missing step_id in Python SDK worker logs during DoFn setup [beam]

2026-02-04 Thread via GitHub


claudevdm commented on PR #37413:
URL: https://github.com/apache/beam/pull/37413#issuecomment-384353

   /gemini review


-- 
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]



Re: [PR] [#19711] Fix missing step_id in Python SDK worker logs during DoFn setup [beam]

2026-02-04 Thread via GitHub


github-actions[bot] commented on PR #37413:
URL: https://github.com/apache/beam/pull/37413#issuecomment-3847142206

   Assigning new set of reviewers because Pr has gone too long without review. 
If you would like to opt out of this review, comment `assign to next reviewer`:
   
   R: @tvalentyn for label python.
   
   Available commands:
   - `stop reviewer notifications` - opt out of the automated review tooling
   - `remind me after tests pass` - tag the comment author after tests pass
   - `waiting on author` - shift the attention set back to the author (any 
comment or push by the author will return the attention set to the reviewers)


-- 
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]



Re: [PR] [#19711] Fix missing step_id in Python SDK worker logs during DoFn setup [beam]

2026-02-01 Thread via GitHub


github-actions[bot] commented on PR #37413:
URL: https://github.com/apache/beam/pull/37413#issuecomment-3830969860

   Reminder, please take a look at this pr: @claudevdm 


-- 
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]



Re: [PR] [#19711] Fix missing step_id in Python SDK worker logs during DoFn setup [beam]

2026-01-24 Thread via GitHub


github-actions[bot] commented on PR #37413:
URL: https://github.com/apache/beam/pull/37413#issuecomment-3796027585

   Assigning reviewers:
   
   R: @claudevdm for label python.
   
   
   Note: If you would like to opt out of this review, comment `assign to next 
reviewer`.
   
   Available commands:
   - `stop reviewer notifications` - opt out of the automated review tooling
   - `remind me after tests pass` - tag the comment author after tests pass
   - `waiting on author` - shift the attention set back to the author (any 
comment or push by the author will return the attention set to the reviewers)
   
   The PR bot will only process comments in the main thread (not review 
comments).


-- 
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]



Re: [PR] [#19711] Fix missing step_id in Python SDK worker logs during DoFn setup [beam]

2026-01-24 Thread via GitHub


gemini-code-assist[bot] commented on PR #37413:
URL: https://github.com/apache/beam/pull/37413#issuecomment-3795964760

   ## Summary of Changes
   
   Hello @Tanishq1030, I'm Gemini Code Assist[^1]! I'm currently reviewing this 
pull request and will post my feedback shortly. In the meantime, here's a 
summary to help you and other reviewers quickly get up to speed!
   
   This pull request resolves a critical logging issue in the Python SDK worker 
where `step_id` metadata was missing from logs emitted during the 
`DoFn.setup()` phase. By ensuring the `instruction_id` is correctly propagated 
and made available to the logging context during this early lifecycle method, 
the change significantly improves the debuggability and traceability of Beam 
pipelines, allowing developers to better understand the context of 
setup-related issues.
   
   ### Highlights
   
   * **Problem Resolution**: Fixed an issue where the `step_id` (instruction 
ID) was consistently missing or empty in worker logs generated during the 
`DoFn.setup()` lifecycle method.
   * **Root Cause Addressed**: The `FnApiLogRecordHandler` previously failed to 
populate `instruction_id` because `DoFn.setup()` was executed before the 
`statesampler` thread-local context was fully initialized for the instruction.
   * **BundleProcessor Enhancement**: The `BundleProcessor` now accepts the 
active `instruction_id` during its creation and explicitly injects it into the 
`statesampler` context when calling `op.setup()`.
   * **Log Handler Priority**: The `FnApiLogRecordHandler`'s `emit()` method 
has been updated to prioritize an explicitly provided `instruction_id` on the 
log record before attempting to retrieve it from thread-local storage.
   * **Verification**: The fix was confirmed locally using a reproduction 
script, showing correct `instruction_id` in `setup()` logs post-fix.
   
   🧠 **New Feature in Public Preview:** You can now enable **Memory** to help 
**Gemini Code Assist** learn from your team's feedback. This makes future code 
reviews more consistent and personalized to your project's style. **Click 
[here](https://codeassist.google/code-review/login) to enable Memory in your 
admin console.**
   
   
   
   
   
   
   
   
   Using Gemini Code Assist
   
   
   The full guide for Gemini Code Assist can be found on our [documentation 
page](https://developers.google.com/gemini-code-assist/docs/review-github-code),
 here are some quick tips.
   
   Invoking Gemini
   
   You can request assistance from Gemini at any point by creating a comment 
using either `/gemini ` or `@gemini-code-assist `. Below is a 
summary of the supported commands on the current page.
   
   Feature | Command | Description
   --- | --- | ---
   Code Review | `/gemini review` | Performs a code review for the current pull 
request in its current state.
   Pull Request Summary | `/gemini summary` | Provides a summary of the current 
pull request in its current state.
   Comment | @gemini-code-assist | Responds in comments when explicitly tagged, 
both in pull request comments and review comments.
   Help | `/gemini help` | Displays a list of available commands.
   
   Customization
   
   To customize Gemini Code Assist for GitHub experience, repository 
maintainers can create a configuration file and/or provide a custom code review 
style guide (such as PEP-8 for Python) by creating and adding files to a 
`.gemini/` folder in the base of the repository. Detailed instructions can be 
found 
[here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
   
   Limitations & Feedback
   
   Gemini Code Assist may make mistakes. Please leave feedback on any instances 
where its feedback is incorrect or counter productive. You can react with 
:thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're 
interested in giving your feedback about your experience with Gemini Code 
Assist for Github and other Google products, sign up 
[here](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG).
   
   You can also get AI-powered code generation, chat, as well as code 
reviews directly in the IDE at no cost with the [Gemini Code Assist IDE 
Extension](https://cloud.google.com/products/gemini/code-assist).
   
   
   
   
   
   [^1]: Review the [Privacy Notices](https://policies.google.com/privacy), 
[Generative AI Prohibited Use 
Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of 
Service](https://policies.google.com/terms), and learn how to configure Gemini 
Code Assist in GitHub 
[here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
 Gemini can make mistakes, so double check it and [use code with 
caution](https://support.google.com/legal/answer/13505487).
   


-- 
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