Skip to content

refactor: decompose _do_run_file into compiler, state, and exception handlers - #181

Open
bhagathkrishnacdac wants to merge 1 commit into
omec-project:mainfrom
bhagathkrishnacdac:bess-refactor-commands-complexity
Open

refactor: decompose _do_run_file into compiler, state, and exception handlers#181
bhagathkrishnacdac wants to merge 1 commit into
omec-project:mainfrom
bhagathkrishnacdac:bess-refactor-commands-complexity

Conversation

@bhagathkrishnacdac

Copy link
Copy Markdown

Description
This PR refactors _do_run_file to address cognitive complexity and improve code readability. The original monolithic configuration loader, which handled file reading, syntax translation, warning prompts, global namespace preparation, execution, and verbose traceback formatting in a single nested block, has been broken down into single-responsibility helpers.

Key Changes

  • Decoupled File Processing:
    • _process_config_file handles syntax transformation and compilation via sugar.
    • _handle_syntax_error manages the specific formatting of compilation errors.
  • Isolated Pipeline Gates: _prepare_pipeline_state orchestrates safety checks, pausing worker threads and prompting on non-empty pipeline resets.
  • Declarative Environment Setup: _setup_execution_globals isolates the instantiation of global variables and dynamic module creators required for executing scripts securely.
  • Cleaned Exception Handling: _handle_execution_exception separates python traceback-frame extraction and formatting to keep the execution pathway clean.

…handlers

Signed-off-by: bhagathkrishnacdac <bhagath.krishna@cdac.in>
@bhagathkrishnacdac
bhagathkrishnacdac requested a review from a team August 2, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant