Yicong-Huang opened a new issue, #4684:
URL: https://github.com/apache/texera/issues/4684

   ## Task Summary
   
   \`amber/src/main/python/core/runnables/data_processor.py\` repeats the same 
per-call setup three times across \`process_internal_marker\`, 
\`process_state\`, and \`process_tuple\`:
   
   \`\`\`python
   try:
       executor = self._context.executor_manager.executor
       port_id = self._context.tuple_processing_manager.get_input_port_id()
       with replace_print(self._context.worker_id,
                          self._context.console_message_manager.print_buf):
           ...  # body
   except Exception as err:
       logger.exception(err)
       exc_info = sys.exc_info()
       self._context.exception_manager.set_exception_info(exc_info)
       self._report_exception(exc_info)
   finally:
       self._switch_context()
   \`\`\`
   
   The body is a one- or two-liner; the boilerplate is ~10 lines each. 
\`_pre_loop_checks\` and \`_post_switch_context_checks\` are also one-line 
wrappers that just call \`_check_and_process_debug_command\`.
   
   ## Proposed Next Step
   
   - Extract the repeated setup into a single \`_executor_session\` 
\`@contextmanager\` that yields \`(executor, port_id)\` and owns the 
print-capture, exception routing, and trailing \`_switch_context()\`. Each 
\`process_*\` method then becomes a few lines.
   - Inline \`_pre_loop_checks\` / \`_post_switch_context_checks\` into their 
single callers.
   
   No behavior change; \`core/runnables/test_main_loop.py\` should continue to 
pass unchanged.
   
   ## Priority
   P3 – Low (refactor / readability)
   
   ## Task Type
   - [x] Refactor / Cleanup


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